Xiaohan-Alyssa-Zhang / Data-Weight-Arduino-Project

0 stars 0 forks source link

How to make the motor shaft stop spinning without using delay and step(0)? #17

Open Xiaohan-Alyssa-Zhang opened 2 years ago

Xiaohan-Alyssa-Zhang commented 2 years ago

Hi Matthew @mhamilt , I got a new question this time about how to let the motor stop spinning when there is nothing change on each side of the scale like what I do before:

if(L_R_old[0] == L_R_new[0] and L_R_old[1] == L_R_new[1]){ myStepper.step(0); }else{ myStepper.step(rotation*angle); } }

However, I find that the motor shaft can still be twisted using my hand even if I ask the motor stepper to spine zero steps ( eg. https://github.com/Xiaohan-Alyssa-Zhang/Data-Weight-Arduino-Project/blob/5fae506f64cba660e17f307a222e315de30c7581/TB6600_Driver/TB6600_Driver.ino#L20 ) . And I just realize that when I delete all the code inside the loop but keep the power on, the motor can hardly be twisted this time because of its high torque, which is exactly what I want when there is no change on each side of the scale.(if it can be twisted, the lever cannot hold the item at the specific position because of long resisting arm)

So, I'm wondering how to replace the previous line of code ( myStepper.step(0); )to let the motor stop spinning so that it cannot be twisted when putting a heavier item on one side of the scale.

mhamilt commented 2 years ago

Do you have the documentation for the motor driver? I think there should be a brake pin you can use to make sure the motor itself doesn't move when stationary.

https://github.com/Xiaohan-Alyssa-Zhang/Data-Weight-Arduino-Project/blob/129d26bd60593cdf2a03e0db41f41f70d4cf5e06/Final_Version/Final_Version.ino#L55-L56

Although I'm not sure if those are automatically engaged. You could probably confirm with an LED or a multi-meter reading from those brake pins.