I recently purchased the APM 1280 + IMU shield to fly my electric glider. I ultimately want to reprogram it to be able to find thermals autonomously.However im starting to think iv thrown myself in the deep end. I need to get a solid understanding of the arduino language first. Im starting with the extreme basic tutorials that come with the arduino software. I have programmed a little in VB.net & C# in the past so i should be able to pick it up quickly. Theres alot of information available about the APM board, but i need more basic information that what i have been able to find.I have a couple of questions:- Within the arduino program you can select the board you are working with. There is an ATmega1280 choice in there. Will this be compatible with my board? Or is there some way to import a APM 1280 board setting or something?-What are the basic "handles" i can use to tell the LEDs, inputs & outputs what to do? for example what would be the line of code i would type to switch on one of the LEDs or change an output?I know how to use the logic (if, then statements, arrays etc), but i dont know how to connect the logic to hardware. I think that once i get this basic information i will be able to start playing around and build from there.I know this is a noob question. Hopefully that means its also an easy one!
You need to be a member of diydrones to add comments!
I understand the schematic now. I assumed that the outputs were coming straight out of the ATMega1280 unit, I was getting very confused.
Iv never been so happy to see flashing lights in my life! I tried hooking up some servos to the outputs, that doesnt work. I guess im going to have to learn about digital signals and pulse technology.
I think ill start by making a ballistic launcher that can calculate the appropriate angle and power to throw an object a certain distance. Should be a fun project to learn on. The maths is easy, I just have to learn the hardware and the language : ) I think ill head down to the local electronics shop and get some basic bits and peices i can control with my APM.
To find what output is what pin you need to use Eagle and the eagle files. Trace it back and you have the pin number.
Using the APM code you the figure out what is happening and when. If you intend to fiddle with Arduino get an Arduino, APM use many techniques of Arduino programming including direct port manipulation and a pretty big step up from flashing an LED and a big step in money.
Hi Chris, thanks for that information. I was looking for something like that schematic. I had a look at the spreadsheet too. I still cant quite work out how the arduino pin numbers relate to what i can see on the board though.
The APM unit has inputs 1-8 and outputs 1-8, each with +, - and ground pins. Im trying to figure out the corrosponding arduino numbers. The information might be buried in that schematic somehow, but iv been trying to work it out for an hour and im not having any luck.
This is the code im trying to run:
/* Blink Turns on an LED on for one second, then off for one second, repeatedly. */
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(1000); // wait for a second
}
So im trying to figure out the pin numbers for the LEDs on my board. I have no blinking lights when i upload this code, so pin 13 must not be an LED on the APM board. I thought if i cant find the LED pin numbers, maybe i can find output pin numbers instead. Iv been making guesses based on that schematic. I have my multimeter hooked up to an output and im trying to get the high/low voltage change each second.
Maybe i will have to buy one of those basic boards to learn this : ( I was hoping i could use this board as a mini computer with inputs and outputs that i can run basic code on, like whats above. If i just work the appropriate way to receive a signal from the inputs, and push a signal to the outputs, there's a hell of a lot i could do just with that.
Yes, you can program APM in Arduino as an Arduino Mega (ATmega1280). But note that it's a custom board, so many of the I/O pins are doing something other than what a standard Arduino dev board does.
You can read basic Arduino programming tutorials on the Arduino.cc site, but the way you turn on a LED is by setting that digital pin high. You need to study the APM schematic and pin mapping to know what pin does what (there are a lot of them!) but you can start in the manual here: http://code.google.com/p/ardupilot-mega/wiki/Hardware
I would suggest that you start with a basic Arduino Uno dev board kit and learn basic Arduino programming there. Then you'll feel more comfortable modifying the APM code. Here's a good starter kit for Arduino: http://www.adafruit.com/products/68&zenid=6461c74f0dc6ab2c76861...
Replies
which line should i look at so it state the pin number? i'm not sure which one is the digital output pin or analog output pin of the APM board... :(
Woohoo, iv finally got outputs & LEDs going.
I understand the schematic now. I assumed that the outputs were coming straight out of the ATMega1280 unit, I was getting very confused.
Iv never been so happy to see flashing lights in my life! I tried hooking up some servos to the outputs, that doesnt work. I guess im going to have to learn about digital signals and pulse technology.
I think ill start by making a ballistic launcher that can calculate the appropriate angle and power to throw an object a certain distance. Should be a fun project to learn on. The maths is easy, I just have to learn the hardware and the language : ) I think ill head down to the local electronics shop and get some basic bits and peices i can control with my APM.
Thanks for the help!
Using the APM code you the figure out what is happening and when. If you intend to fiddle with Arduino get an Arduino, APM use many techniques of Arduino programming including direct port manipulation and a pretty big step up from flashing an LED and a big step in money.
Hi Chris, thanks for that information. I was looking for something like that schematic. I had a look at the spreadsheet too. I still cant quite work out how the arduino pin numbers relate to what i can see on the board though.
The APM unit has inputs 1-8 and outputs 1-8, each with +, - and ground pins. Im trying to figure out the corrosponding arduino numbers. The information might be buried in that schematic somehow, but iv been trying to work it out for an hour and im not having any luck.
This is the code im trying to run:
/* Blink Turns on an LED on for one second, then off for one second, repeatedly. */
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(1000); // wait for a second
}
So im trying to figure out the pin numbers for the LEDs on my board. I have no blinking lights when i upload this code, so pin 13 must not be an LED on the APM board. I thought if i cant find the LED pin numbers, maybe i can find output pin numbers instead. Iv been making guesses based on that schematic. I have my multimeter hooked up to an output and im trying to get the high/low voltage change each second.
Maybe i will have to buy one of those basic boards to learn this : ( I was hoping i could use this board as a mini computer with inputs and outputs that i can run basic code on, like whats above. If i just work the appropriate way to receive a signal from the inputs, and push a signal to the outputs, there's a hell of a lot i could do just with that.
You can read basic Arduino programming tutorials on the Arduino.cc site, but the way you turn on a LED is by setting that digital pin high. You need to study the APM schematic and pin mapping to know what pin does what (there are a lot of them!) but you can start in the manual here:
http://code.google.com/p/ardupilot-mega/wiki/Hardware
I would suggest that you start with a basic Arduino Uno dev board kit and learn basic Arduino programming there. Then you'll feel more comfortable modifying the APM code. Here's a good starter kit for Arduino:
http://www.adafruit.com/products/68&zenid=6461c74f0dc6ab2c76861...