orangutanModel.h

Hi Team
Have a nice day
Please delete this post if it is illegal’s question
The following codes are sourced from the <orangutanModel.h> library within the libpololu-arduino library. Upon inspection, it does not reference the Atmega328p microcontroller, despite the library being used for the 3pi robot, which employs the Atmega328p microcontroller. We are currently investigating how to adapt this library for use with the Arduino Mega which will be help us to get rid of pin limitation of Arduino Uno


#undef _ORANGUTAN_X2   // Orangutan X2
#undef _ORANGUTAN_SVP  // Orangutan SVP-324 or 1284
#undef _ORANGUTAN_XX4  // Either the X2, SVP-324, or SVP-1284.

#if defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(_X2_1284)
 #define _ORANGUTAN_X2
#elif defined(__AVR_ATmega324P__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega1284PA__)
 #define _ORANGUTAN_SVP
#endif

#if defined(_ORANGUTAN_SVP) || defined(_ORANGUTAN_X2)
  #define _ORANGUTAN_XX4
#endif

Hello.

I moved your post to a more appropriate category.

The header file you copied here just defines some preprocessor macros that are used by the rest of the Pololu AVR Library. Basically, for an ATmega48/168/328, none of those macros will be defined, while some of them will be defined for the other processor types. You can see how those macros control the compilation of the other parts of the library in OrangutanMotors.cpp, for example.

- Patrick

Hi Patrick
Thanks for the reply

This define for ORANGUTAN_SVP

#ifdef _ORANGUTAN_SVP

#define PWM2A	IO_D7
#define PWM2B	IO_D6
#define DIRA	IO_C7
#define	DIRB	IO_C6

This define for I think Arduino ATmega48/168/328 which pin configuration for OCR0A / OCR0B / OCR2A / OCR2B identical for all three models

#else

#define PWM0A	IO_D6
#define	PWM0B	IO_D5
#define PWM2A	IO_B3
#define PWM2B	IO_D3

#endif

But Atmega 2560 pin configuration is deferent

#define PWM0A IO_B7
#define PWM0B IO_G5
#define PWM2A IO_B4
#define PWM2B IO_H6

I’d like to confirm if the following method will work for the Mega 2560.

#ifdef _ORANGUTAN_SVP

#define PWM2A IO_D7
#define PWM2B IO_D6
#define DIRA  IO_C7
#define DIRB  IO_C6

#ifdef _pololu_MEGA

#define PWM0A IO_B7
#define PWM0B IO_G5
#define PWM2A IO_B4
#define PWM2B IO_H6

#else

#define PWM0A IO_D6
#define PWM0B IO_D5
#define PWM2A IO_B3
#define PWM2B IO_D3

#endif

At a glance, your proposed modification looks okay. However, please keep in mind that the Pololu AVR Library was not written with the ATmega2560 in mind (it was written for our now mostly discontinued Orangutan robot controllers). So, there is no guarantee that the code will work without more significant changes, and helping to modify our library to that extent is beyond the scope of our technical support.

Based on your other thread, my impression is you might be trying to use our AVR library because it has a lot of the functionality that you are looking for (control motor drivers, control buzzer, read QTR sensors, etc.), but since it does not support the ATmega2560, I suspect it would be easier to use separate libraries (ones that are more directly intended for use with your microcontroller) for each of those tasks. For example, you might consider these libraries for the QTR sensors and buzzer:

And if you post information about the specific motor drivers you are using, we might be able to offer a recommendation for code to control those.

- Patrick