I'd like to know if there is a way to detect a peak of current in a stepper motor ? I use this shield I'd like my motor to go backward if it's blocked by an obstacle... Do you think this would be easily realisable ? thx
If you like Adafruit stuff then get one of their current sensor modules and put it in the power wires going to the motor shield. You can do the same with a resistor too. Connect up to an analog input and then you will know what current the motor is using.
However a stepper uses almost exactly the same current when it's moving to when it's stationary. I'm not sure if you could really detect an obstruction that way. Can you put a switch on the thing-which-is-moving to detect when it hits something?
Have a look at stepper motor basics.
With a specialised stepper motor driver the driver controls the maximum current in the coil and it will be the same whether the motor is moving or stationary and would not form a basis for detecting an obstacle. The motor shield is not as good for driving a stepper but it may have the effect of showing increased current when the motor is blocked. However the Arduino would lose track of the position of the motor if it was prevented from executing the correct number of steps - and if that does not matter there would not seem any need for a stepper motor.
The usual way to deal with that problem is to add a rotary encoder to the stepper motor and count the steps using the encoder. If that number differs from the number of steps commanded by the Arduino you know there is a problem. And the encoder allows the Arduino to keep track of position even if the motor is blocked. However the programming of this is not simple.
As @MorganS has said, some form of detector switch would be much easier.
MorganS: Can you put a switch on the thing-which-is-moving to detect when it hits something?
No, Ican not... I explain (excuse my english, I'm french) I'm going to do a dog feeder. I use a endless screw (?), in a pipe, dry food for dogs comes from the top by a kind of entonnoire (?)... I do 3 turns forward and half on backward for the food not to be wedged but it's not enought...sometimes it does.... If I could detect the motor lock, I could make it go at the other direction... I hope you can understand what I tried to explain !!! :) So, any solution ?
Add a magnet and hall sensor to check for rotation? Stall detection with a stepper is complex and tricky compared to a DC motor.
phil77560: I do 3 turns forward and half on backward for the food not to be wedged but it's not enought...sometimes it does....
That sounds to me like a situation where the simple solution is a more powerful motor which just crushes the food if there is a blockage.
Or maybe just a DC motor (for which a stall is more easily detected) plus a magnet and hall sensor to allow you to count revolutions.
Thanks for your help. I'm gonna look for a mechanical way, mays be a different kind of feeder... The magnet is a very good idea.... I'll do this if I don't find something else Have a nice day
phil77560: entonnoire (?)...
Perhaps you could prevent jamming with a bit of vibration. For example go 10 steps forward then go forwards and backwards 5 steps for a while before going forward 10 steps again.
ooops... yes.... I know a new word !!! I tried what you said... it help but it's not perfect ... I guess I should use an optical sensor