Hi, firstly apologies if I have posted in the wrong place, this is my first post and fairly new to this.
I have been building a full size replica Dalek and now I am ready to fit the automation controls. I would like to make the dome rotate 360 degrees and react to some ultrasonic sensors to follow anyone coming close. The following bit I am ok with I think. The bit I need help with is this...
Using limit switches I would like to be able to have the dome spin and then find a 'centre point' with the eye stalk facing forward.
My theory is that you run some code to spin the motor left until it hits switch 1, then the motor spins right until it hits the second limit switch then somehow works out where the centre point is between those two switches and spins the motor to the centre. Now I guess a stepper motor will be best for this?
I hope I have described this clear enough. I have looked at PID encoders and this seems a bit complicated for me at this early stage.
You don't need a PID controller to center a rotating object via limit switches and a stepper motor.
If you are using a stepper motor and 2 limit switches and want to move to the middle of the two switches you could use the following sudo code:
steps = 0
while (switch one not pressed) {
Step right
}
while(switch two not pressed) {
Step left
steps += 1
}
steps = steps / 2
for (i = 0; i < steps; i++){
step right
}
that will have you within 1/2 a step of centered - to the accuracy of your stepper motor. You will need to address in your code the max speed that your stepper motor can turn, etc.
My theory is that you run some code to spin the motor left until it hits switch 1, then the motor spins right until it hits the second limit switch then somehow works out where the centre point is between those two switches and spins the motor to the centre.
Why not put a third limit switch or position sensor at the middle position?
Ive been doing some digging around and found some stuff about optical encoders. Based on your suggestions if I use the encoder to count the steps when sending the dome on a spin cw and ccw, counting each way, storing the value and then divide in two, then use that value to send it to the centre. I'd still like to use PID to control the position, so when a child hits the dome which they will when out on display, the dome will centre its self again. Im learning more about PID, (Slowly).
I'll give it a go on my next day off and post my findings. Thanks for your comments.