Include third party libraries to program the baby orangutan via Arduino IDE?

Hello,

I’m embarking on a project that will require controlling 4 DC brushed motors remotely using a hobby grade RC receiver. I have found several write-ups on the web about how to sample the PWM signal from the RC receiver and then output that to the motors. However, as far as I can tell the method I would like to use (Pin Change Interrupts) is not supported in the Pololu arduino IDE libraries. I have many questions, but the first and most basic is whether or not I can use the Arduino IDE and other third party libraries to write a program (aka sketch) and the upload it to the baby-o?

For example, I would like to use this library:

is this possible?

Thanks

Hello.

The Pololu AVR library, which can be used with the Arduino IDE, supports pin change interrupts. You can find more details about it under the “Orangutan Pulse/PWM Inputs” section in the Pololu AVR Library Command Reference guide.

You can use the Arduino IDE to program your Baby Orangutan, however, not all existing Arduino library code and other third party libraries are guaranteed to work with the Baby Orangutan. Please see the note under the “Arduino Libraries for the Orangutan and 3pi Robot” section of the Programming Orangutans and the 3pi Robot from the Arduino Environment guide for more details. You probably would need to test those libraries for yourself.

According to the Wiki page for the EnableInterrupt library, which can be found under the “More Information” section on its GitHub page (that you linked), the library supports ATmega328P-based boards. Since the Baby Orangutan uses an AVR ATmega328P, you might be able to use that library with the Baby Orangutan. Again, you would need to test the library for yourself.

By the way, you mentioned wanting to control four brushed DC motors from the Baby Orangutan. The Baby Orangutan uses the TB6612FNG motor driver, which can only achieve independent control of two motors. If you tell me more about your motors (like their operating voltage and stall current), and how you plan to use them (e.g. how much load is on them and do you need independent control of each one?), I might be able to tell you if the Baby Orangutan is appropriate or recommend another driver.

- Amanda

Well I’ve made much progress and I have been able to use the EnableInterrupt library successfully to monitor an incoming PWM signal from my RC receiver which then triggers an ISR and which I can then use to trigger some routines to evaluate joystick positions and forward the signal on to the OrangutanMotors functions.

What I did not make clear in my original post is that I am using two Baby Orangutans (one for left side motors and the other for right side motors). Based on the motor specs and the Baby Orangutan specs the current limits should be fine.

My code requires that different code be sent to the left and right wheels depending on the joystick position. I would like to write code that can run on both Baby Orangutans, but uses some serial number or other unique identifier of the Baby Orangutan to determine wether it should assign the LEFT or RIGHT variable. Are there any unique strings available?

Cheers.

Cool! That’s good to know the EnableInterrupt library works on the Baby Orangutan.

We do not program any unique identifiers into the Baby Orangutan’s ATmega328P. You could try writing a unique byte (or ID) to EEPROM for one Baby Orangutan and a different ID for the other. Then have the main program read that unique ID from EEPROM and use it to determine which side (left or right) it is.

- Amanda

OK. That was a good idea. I used avrdude to write my LEFT and RIGHT variables to EEPROM.

avrdude -v -v -p m328p -c avrisp2 -P /dev/tty.usbmodem00149931 -U eeprom:r:eeprom.bin:r

Then use a hex editor of some sort to put “L” into address 0

write to EEPROM:

avrdude -v -v -p m328p -c avrisp2 -P /dev/tty.usbmodem00149931 -U eeprom:w:eeprom.bin:r

However, everytime I wrote a new sketch to the baby orangutan the EEPROM got overwritten . Turns out there is a fuse that needs to get changed in order to preserve EEPROM when flash is overwritten. The EESAVE fuse should be on or 1

I found this fuse calculator is very helpful for determining the correct fuse settings. http://www.engbedded.com/fusecalc

I want hfuse to have the following HEX value 0xD1

avrdude -v -v -p m328p -c avrisp2 -P /dev/tty.usbmodem00149931 -U hfuse:w:0xd1:m

after that my EEPROM remained intact after uploading new sketches.

1 Like