Integrating APM 2.6 with Motor Shield

hi friends…

i want to use the APM 2.6 board to control 4 DC motors with the Monster Motor Shield from Sparkfun… ( https://www.sparkfun.com/products/10182 )

i have been searching everywhere… to find a solution… please help me with it!!

You could be a bit more specific on your problem. What type of problems you have, how much you know electronics, how much you know about programming and so on.

In generally using that type H-Bridge drivers is rather straight forward thing. Connect MCU output pins to driver board input pins and then program your MCU board.

I don’t remember out from my head how many pins that monster board needs but usually it’s 2 pins / motor eg Enable and Direction.

Even thou APM2.6 is autopilot, it is also a “normal” arduino so you can use some of it’s exposed pins freely. There is load of analog pins that can be turned as IO pins exposed and also all PWM pins are exposed thou they have small buffer resistor.

I just happen to have diagram of APM RC output pins in front of me as just made PPM Encoder testing setup for my company use (jDrones) and we are using some old broken APM boards to run test systems. Broken as in way that maybe gyro, compass or baro fails on QC tests. So they are really good boards for other type things :slight_smile:

RC outs as follows in Arduino IDE:

RC1 = 12
RC2 = 11
RC3 = 8
RC4 = 7
RC5 = 6
RC6 = 3
RC7 = 2
RC8 = 5

So basically if I remember correctly eg. 2 pins per motor control, those 8 pins should be enough to run all your 4 motors (4 * 2 pins = 8 pins)

There are ABC leds too on APM board that you can use to do info tricks but just don’t remember their IO pin numbers. I will send those later.

Led A = digital out 27
Led B = digital out 26
Led C = digital out 25

Theres a small sample Arduino sketch to blink LED A

// APM25 board LED blinker test
// Author: Jani Hirvinen / jDrones
// Version: 1.0
// Date: 12-06-2016
//
// Usage: change PIN code to either 27, 26, 25 to blink ABC leds on APM2.5/2.6 boards
// Setup: Arduino IDE, Arduino MEGA 2560 board

#define PIN 27

void setup() {
  pinMode(PIN, OUTPUT);
}

void loop() {
  digitalWrite(PIN, HIGH);
  delay(500);
  digitalWrite(PIN, LOW);
  delay(500);
}

hey hi…

thank you very much for the reply.

actually i have basic information about programming and good knowledge about electronics.

i had built a rover using a Arduino UNO + L293D H Bridge + RC receiver and it worked perfectly fine.

i am now totally confused on how to integrate the APM 2.6 as it has its own set of software and output variables. the pin out reference you gave was perfect but don’t understand how to interface it with an motor shield which drive set of DC motors.

being more precise i am using https://www.sparkfun.com/products/10182 motor driver.

i thank you for very much for the help you have offered.

No APM does NOT have it’s own set of software if you just plan to do basic things. You can program it as a normal Arduino MEGA board. WIth a limitations that many of the GPIO pins have been taken out to control other devices such gyro, barometer, flash memory and so on but there are still plenty of GPIO pins available for normal use.

  • A0-A8 (+A9, A11) Analog pins are all there free to use.
  • Those PWM capable GPIO pins are all there, ok they have small buffer resistor but can easily be used as normal GPIO pins.
  • All UARTS are available
  • I2C is available
  • Several info LEDs are available

Along that there are several extra hardware available such as HMC5883 compass, you can use normal compass library to access that. MPU6000 Gyro/Accel packet is there that can be used via SPI and so on.

Ok sure if you want to access all those components from software like our made ArduCopter/ArduPlane, then you need to install our software libraries and you just make library calls. This way you don’t need to worry about creating component drivers, timing and many other issues.

Like said, without our libraries, it’s just a “normal” Arduino MEGA board.

For reading RC controller there is PPM Encoder on board that can be seen on PIN 48 (ICP5). To read PPM, there are many reference codes lying around internet.

Here is one example code sniplet that will give all needed channels:

Just change:

  • #define channumber 6 to be 8.
  • Replace pinMode(4,… and pulseIn(4, … with GPIO 48

Then connect RC to RC-input pins. If your RC can output PPM code directly, you can either bypass PPM Encoder with a jumper and then just connect PPM signal cable to one of the RC-Inputs OR you can solder PPM input directly to bottom solder pad that leads to main MCU (remember to cut trace between <-ppm and >-ppm pads at bottom)

Easiest way is to use PPM Encoder bypass. Here are instructions for it:
http://ardupilot.org/copter/docs/common-connecting-the-radio-receiver-apm2.html

Thanks for the assist Jani, much appreciated.
Regards,
Tom C AVD

thank you very much for this Jani.

i was wondering if anyone has ever done such kind of integration before.

basically DC motors controller like this -> ( https://www.sparkfun.com/products/10182 ) are very economical compared to their ESC type brothers.

and using it for something like a Rover project sounds good so why would it not be easy to APM boards to have some sort of interface which can directly give their I/O to such boards.

or maybe people are not too interested in getting their hands dirty with all this Mix&Match :slight_smile:

anyways i am trying to make sense of what you have said as it will take sometime for me to understand it, reason: i lack intelligence :wink: :slight_smile:

thanking you again for help.

Well I don’t see any problems on using old APM boards to control that driver. On SparkFUN page they even provide a sample code for you. Use it and just change few IO Pin numbers and off you go. And naturally connect H-bridge to correct pins.

/* VNH2SP30 pin definitions xxx[0] controls '1' outputs xxx[1] controls '2' outputs */ int inApin[2] = {7, 4}; // INA: Clockwise input int inBpin[2] = {8, 9}; // INB: Counter-clockwise input int pwmpin[2] = {5, 6}; // PWM input int cspin[2] = {2, 3}; // CS: Current sense ANALOG input int enpin[2] = {0, 1}; // EN: Status of switches output (Analog pin)

There is their code sniplet that you need to change those PINs. On earlier posts here I posted RC1-8 output pins and their corresponding IO Pin numbers in Arduino IDE. Use those pins.

Analog pins are just analog pins in APM board. Check which you want to use and change pins on code too.