Hi Everyone,
I am trying to improve my coding skill. Here is my scenario:
I have four ports which connected to four DC motor. The default state of the ports is set to '0'. I change the ports state to '1' for turning on all the motors. When I disconnect one of the Motors from their port, one motor will be off because I disconnect it. But the other three are still running. How do I know if my ports is connected to any device such as DC motors? Can anyone show a sample code?
Thanks!
Regards, Sharil
You monitor the motion with another pin?
People either just want to know if motors are running. Then they often add some current sensors - this allows them to see if the motor draws current and also to shut down the motor if there is a short.
Or people want to know how far the motor axis is rotating. So they then add sensors that picks up the axis rotation. So you might have a tick/turn. Or if positional precision is important, you would have a quadrature encoder with lots of pulses/turn and the ability to tell forward or backward rotation.
Sometimes, people just have end-stop sensors. So they turn on the motor and count time - if the end stop sensor doesn't get trigged within the expected time then something is assumed wrong and the motor is stopped anyway.
But this feedback is separate from any pin to turn on power to the motor. And it's your task to figure out how you want to figure out how to detect motor presence/rotations and how to implement code to make decisions based on this feedback.
This site really is broken.
I get a timeout when I post the first time. Trying to press post a second time, the site claims I have already posted.
So I keep the text and wait for almost two hours. Do a reload of the thread and my post isn't visible. I then repost and now both the original post and the repost becomes visible. So Keil seems to sometimes fail to perform the full database update when receiving posts and then doesn't repair the thread until a new post arrives.