Main Site Documentation

PWM and restart on Domino with a twist


#1

Ok, I have a strange one here. Got a new pololu 5-28v dual motor controller and testing. Have two PWM pins hooked up to test 1 motor. 1 pwm pin for each direction (per motor). When I have Both 12V and 5V-usb hooked up, it works. The motor goes forward, sleeps, then backward as expected.

However, the problem comes in when I remove the 5V-usb. If just connected to 12V, the program starts. But after sleep, it seems to restart and do forward again, and again, and again. This smells like similar issue posted here before, but this a bit different. Any thoughts?

I am sourcing 12V to BB rail. Sourcing Fez via 12V rail to VIN. Source motor controller via 12V rail. All common gnd to BB. Why would having 5v-usb let this work?

static PWM pwm9;
        static PWM pwm10;
        public static void Main()
        {
            
            pwm9 = new PWM((PWM.Pin)FEZ_Pin.PWM.Di9);
            pwm10 = new PWM((PWM.Pin)FEZ_Pin.PWM.Di10);
            Debug.Print("Setting pwm 9");
            pwm9.Set(true);
            Thread.Sleep(4000);
            pwm9.Set(false);

            // Seems to restart here if USB not connected.

            // reverse
            Debug.Print("Reverse");
            pwm10.Set(true);
            Thread.Sleep(4000);
            pwm10.Set(false);

            Debug.Print("Dispose.");
            pwm9.Dispose();
            pwm10.Dispose();
        }

#2

I think I found it. It seems to be the increase power draw between forward and full reverse causing v drop that restarts fez in a loop. Adding a sleep removes/side-steps the issue.

So how to solve this in production without the sleep workaround? Not sure I can use seperate power and logic supplies/batteries. Can the motor-controller power be completely seperate from the logic? If a wall-wart can’t handle the power needs, can battery(s)?

static PWM pwm9;
static PWM pwm10;
public static void Main()
{      
    pwm9 = new PWM((PWM.Pin)FEZ_Pin.PWM.Di9);
    pwm10 = new PWM((PWM.Pin)FEZ_Pin.PWM.Di10);
    Debug.Print("Setting pwm 9");
    pwm9.Set(true);
    Thread.Sleep(4000);
    pwm9.Set(false);

    Thread.Sleep(500); // Comment out to have restart.

    // reverse
    Debug.Print("Reverse");
    pwm10.Set(true);
    Thread.Sleep(4000);
    pwm10.Set(false);

    Debug.Print("Dispose.");
    pwm9.Dispose();
    pwm10.Dispose();
}

#3

We had similar problem on the robot we have. This is normal. The fix was to ramp up or down the speed instead of instantly change it.


#4

If it really

then you can add a big capacitor near FEZ.

I think it can be a noise kind of problem, not only current draw.
You can make your motors make less noise.
First link from google http://www.superdroidrobots.com/product_info/motor_wiring.htm It has a good picture.
Basically what you can do is twist the wires to the motor and solder 3 non-polarized capacitor to motor. One directly to both pins. Other two as follows: one c pin to motor pin, the other c pin to motor corpus.

And abit ramp to motor control in software (as Gus said).

Hope, this helps

Edit: hope, fixed the link


#5

Going from reverse to forward draws a lot of current.
I do not know if your pololu controller does the same like mine, but mine “brakes” the motor. Electric brakes literally eat current :smiley:


#6

Thanks to both. I will add some caps per suggestion.

FWIW, here is the driver http://www.pololu.com/catalog/product/1213
I like it so far. Did have to spend time figuring out how to hook it up as directions on site not that clear (at least for me).


#7

@ rimvis. FYI, that link is broke.


#8

Just need to remove trailing dot

http://www.superdroidrobots.com/product_info/motor_wiring.htm


#9

To separate the fez power supply, you simply put a diode in series and a large enough cap in parallel to source the fez for let’s say 1second. The diode ensures the motors can’t draw current from your cap.


#10

@ wouter. Like below? tia


#11

Exactly