SMC02B not switching directions

Hey,

So I have a while loop running that does the following:

while ()
 Ask Question
 Prompt for Answer
 Answer Entered:  
        motor.sendByte(0x80);     //prefix
        motor.sendByte(0x00);     //activate motor controller
        motor.sendByte(0x02);     //motor 2 reverse .. 0|000010|0
        motor.sendByte(0x5A);     //speed @ 90
        CPU.delay(20000);         // WAIT 2 SECOND

        motor.sendByte(0x80);     //prefix
        motor.sendByte(0x00);     //activate motor controller
        motor.sendByte(0x02);     //motor 2 reverse .. 0|000010|0
        motor.sendByte(0x00);     //speed @ 0
        CPU.delay(1000);          // WAIT 100ms

 Ask Question 2
 Prompt for Answer 2
 Answer 2 Entered:  
        motor.sendByte(0x80);     //prefix
        motor.sendByte(0x00);     //activate motor controller
        motor.sendByte(0x05);     //motor 2 forward.. 0|000010|1
        motor.sendByte(0x5A);     //speed @ 90
        CPU.delay(20000);         // WAIT 2 SECOND

        motor.sendByte(0x80);     //prefix
        motor.sendByte(0x00);     //activate motor controller
        motor.sendByte(0x05);     //motor 2 forward.. 0|000010|1
        motor.sendByte(0x00);     //speed @ 0
        CPU.delay(1000);          // WAIT 100ms 

End While

My problem is this: The first part spins the motor no problems, but the second part doesn’t move the motor at all, even though it should spin in the opposite direction just like the first part.

Once the second part “runs”, and it goes back to the first part, the motor spins again.

It seems like the controller gets the code to go reverse, then ignores the code to go forward.

Any body got any ideas?

Thanks

Hello.

You seem to have a mistake in the bytes you’re sending the controller. 0x02 in binary is 00000010, so the line:

motor.sendByte(0x02); //motor 1 (not 2) reverse … 0|000001|0 (not 0|000010|0)

is really commanding motor number 1 to move in reverse.

In your second section, you use the command:

motor.sendByte(0x05); //motor 2 forward… 0|000010|1

Here your binary representation matches the hex and requests that motor number 2 move forward. If commands to motor 1 move the desired motor and commands to motor 2 have no effect, you should change this second command to:

motor.sendByte(0x03); //motor 1 forward… 0|000001|1

- Ben

Great, thanks for catching that.

I’m pretty sure I burnt some chips out though now.

I have 3 controllers hooked up through though the same pin and each controller has its own number.

They all used to work fine, but then I attempted to program a fourth controller and I think it messed up everything. Now only the first controller works and the rest of them don’t.

Is there some way to tell if they are still functioning correctly or if they are dead?

Thanks.

Hello,

You should try sending commands to the global motor number (0) in case you inadvertently changed the motor numbers.

Does anything smell burned out?

- Jan

no nothing smelled burned … I’ll try sending to motor 0 soon

I’ll keep you posted.

Thanks.

Ok so, I got them all working again, I mistakenly reprogrammed them, but now they work.

Back to the original problem, So it still doesn’t switch directions properly.

It will move in “reverse” at the speed it needs to, but then when switching direction to “forward”, it will move for a half second, just kinda sputters … but then when moving back to the “reverse” direction, it will move normally.

Any new ideas?

Can you try a lighter load? Perhaps your motor draws more power in one direction, or one direction of the motor driver is slightly better than the other. It would also be interesting to know what happens when you swap the leads on your motor. Also, what motor are you using?

- Jan