I've made an arduino shield where I mounted an L293D to drive two motors and a gyroscope, for a small robotic vehicle.
It works as expected, except the fact that whenever i turn the arduino on, the motor on one of the sides (the same one every time) spins "twice" towards a specific direction.
Particularly, it spins for a small amount of time (less than 0.5 second) then gets released and then again, towards the same direction for a similar amount of time after which it stops and then everything works fine. I can film a video if someone hasn't understood.
Now, this doesn't affect the general functionality of the shield, however it is annoying, as everything else works fine.
Does anyone have any idea on why this is happening? It is always the same motor, the same direction and regardless of whether i try the shield with an Arduino Uno or with a Mega.
I am attaching pictures of the connection schema, as well as the PCB board. If anyone wants to see the source files, i will gladly share them. (it's an open source project)
On the schema, it's the 1Y and 2Y pins of the L293D that control the motor with the weird behavior. The other one does not seem to be affected.
I haven't looked at the schematics but I'd think pull down resistor on the enable pins would be a good idea. I think pulling motor controller pins to the "off" state is a pretty common way to prevent this sort of glitch.
OldSteve:
Is it happening on the output corresponding to the "2A" input of the L293D?
Yes indeed. Input 2A corresponds to Arduino's D13 and 1A to D12.
Whenever I have D12 and D13 HIGH, the motor spins backwards (depending on the respective EN signal of course).
Remember, that this behavior is exhibited both on the Uno and the Mega. Any clues?
DuaneDegn:
This only happens on startup right?
I haven't looked at the schematics but I'd think pull down resistor on the enable pins would be a good idea. I think pulling motor controller pins to the "off" state is a pretty common way to prevent this sort of glitch.
Yeap, on startup only.
Aha, so your suggestion is to add a pull down resistance to the EN pins. Hmmm, it makes sense. So regardless of any other weird input signals, if i have made sure that EN is grounded at that moment, the motor(s) shouldn't spin. Is that your point?
kuruki:
Aha, so your suggestion is to add a pull down resistance to the EN pins. Hmmm, it makes sense. So regardless of any other weird input signals, if i have made sure that EN is grounded at that moment, the motor(s) shouldn't spin. Is that your point?
The I/O pins start out as inputs so they're floating during bootup. I think the use pull-down resistors for this sort of thing is very common.
OldSteve:
That's the pin with an internal LED. It's resistor is most likely causing the problem, during startup before the chip makes the pin an output.
That also makes sense! It explains why the problem is experienced only on one of the motors. I used that pin mostly so to leave pin 7 and downwards available for the user. Never realized there could be complications.
Anyway, I would like to thank you both for the remarks, I will fix this by adding those pull downs in the next iteration of the shield. It always helps to get a look on things from a different perspective!