Motor control with light sensor
Posted: 24 Nov 2012, 20:02
Hi again,
I would like to know your thoughts on the best way to control a motor with a a light sensor. What I am trying to do is run a motor at full power and when an event occurs a light sensor will read a hight value, at this point I want to stop the motor dead. I have tried a few techniques, one being to run the motor and monitor the sensor in a loop then switch it off, the issue with this is I always overrun as the Off command does not stop the motor straight away. I have tried a smiler approach using 2 tasks one watching the sensor and telling the other when it's time to stop. I have also tried moving the motor a little then checking the state of the sensor but this is very slow and jerky. I have tried applying a reverse when see the point to stop the movement but this is hard to calculate and often overruns then back up I really need to stop the movement dead.
so any ideas?
I would like to know your thoughts on the best way to control a motor with a a light sensor. What I am trying to do is run a motor at full power and when an event occurs a light sensor will read a hight value, at this point I want to stop the motor dead. I have tried a few techniques, one being to run the motor and monitor the sensor in a loop then switch it off, the issue with this is I always overrun as the Off command does not stop the motor straight away. I have tried a smiler approach using 2 tasks one watching the sensor and telling the other when it's time to stop. I have also tried moving the motor a little then checking the state of the sensor but this is very slow and jerky. I have tried applying a reverse when see the point to stop the movement but this is hard to calculate and often overruns then back up I really need to stop the movement dead.
so any ideas?