Working (:-) ) samples for Orangutan X2

Can some one point me to all the program samples that work correctly on Orangutan X2 controller. I found many of the existing programs and Orangutan-lib does not work correctly on X2. One simple example is the motor test.

I would like to get to some working sample code to control the motors on the X2 controller board.

Many thanks in advance.

Cheers,

The only motor control demo code for the X2 comes as part of the test demo (the code that comes pre-loaded). The test demo gives user instructions via the LCD, so it might not seem so user-friendly to you. If you load the test demo program and push button 4, you get to the motor test. In this mode, the X2 attempts to drive its motors at a speed and direction determined by the position of the user potentiometer. When the potentiometer is all the way to one side, the motors are driven full-speed forward; when the potentiometer is all the way to the other side, the motors are driven full-speed reverse. The middle potentiometer position gives the motors a speed of zero.

The motor direction LEDs are physically tied to the motor driver’s outputs, so if you see them lit, the board is attempting to drive the motors. If your motors do not move while connected to the motor driver’s outputs, it’s either because the PWM duty cycle (speed) you are commanding them to move at is too low to get them started, or because your power supply cannot supply enough current to drive them. Do you know how much current your motors are trying to draw and how much current your power supply can output?

As a first step, I recommend you observe the effect of turning the user potentiometer from side to side on the motor direction LEDs (both color and intensity). Then, with the potentiometer turned all the way to one side, connect a motor and see if it starts spinning.

It would be very easy for you to write your own short and simple motor control demo since the SPI.c has functions that command the motors to move at a speed you specify. For example:

#include <avr/io.h>
#include "SPI.h"

int main()
{
    SPIInit();    // initialize SPI hardware module for communication with auxiliary mega168
    setMotor1(255);   // set motor 1 forward at full speed (from SPI.h)
    setMotor2(-255);    // set motor 2 reverse at full speed
    while (1)    // loop here forever to avoid running off the end of the program
        ;
    return 0;
}

This code sets motor 1 running full-speed forward (you should see M1’s green LED on brightly) and motor 2 running full-speed in reverse (you should see M2’s red LED on brightly). It compiles, but I haven’t actually tested it. Don’t forget to add SPI.c to your AVR Studio project.

- Ben

Ben,

Thanks for the sample code.

I compiled and programmed the board with this simple program.
Neither the motor direction LEDs nor the motors fire up.

I have 6V alkaline battery pack connected to Vin and Gnd. Motors are connected to the M1 and M2 set of terminals on the motor controller board.

I’ll continue to run some tests tomorrow. I sincerely appreciate your continuous help today.

Cheers,

I’ll test my program on an X2 when I get to work tomorrow to make sure I didn’t mess something up. If you run this test program without motors connected do the LEDs light up? What happens when you run the test demo and turn the user potentiometer? Make sure that you reset the controller after you program it because the auxiliary microcontroller will not respond to commands while it’s in programming mode.

Also, there’s some motor control demo code in this thread that you might want to try:

- Ben

"If you run this test program without motors connected do the LEDs light up? "

No, the Motor direction LEDs do not light up with the test program you suggested.

"What happens when you run the test demo and turn the user potentiometer? "

Nothing. Motors do not come on. With the test demo I notice the Motor direction
LEDs are on.

“Make sure that you reset the controller after you program it because the auxiliary microcontroller will not respond to commands while it’s in programming mode.”

Yup I did that. Also, I power cycled the entire board as well, just to be sure.

Cheers,

I’m really very confused at this point. I tested out my short motor program here and it worked as expected. I don’t understand why the motor LEDs would light when you run the test demo but not when you run the motor test program I posted earlier in this thread. I created this HEX file from my motor test code; could you please load the hex file onto your Orangutan X2 and tell me if the motor LEDs light up?

As I said in another post, the motor LEDs are physically tied to the motor driver’s output. If they light up as expected but the motors aren’t going anywhere, I think the fault is most likely with your power supply. How much current are your motors trying to draw? Do your motors run just fine if you connect them directly to your power supply? Can you describe to me how you are connecting the motors to your X2 (or, even better, take a picture of your connections and post it here)?

- Ben

Ben,

Thanks for sending the HEX file. Both the motors worked fine.

Now to summarize and clear the mystery:

I started with a power supply that behaved weird. It is a 12V lab power supply capable of delivering 2A. But when I connected it to X2 the voltage dropped to around 6V. When I connected my motors rated for 12 V, it appeared that motor test program did not fire up my motors.

Later I switched to a 6V battery pack and connected different set of motors that works at 6V. Now the motor test that ships with X2 works just fine.

One thing I noticed is that since the board is rated for 6V and above, when I ran the motor test with a mere 6V battery pack, one of the motors did not kick in occasionally. I think it is understandable.

All is well. Big thanks to Ben to help me through this.

Cheers,

I’m glad to hear that you got everything working!

- Ben