Pages: [1]   Go Down
Author Topic: 360 degree rotating dome with limit switches  (Read 369 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Any advice is very much appreciated.

Gary.
(Dalek Dexter)
Logged

Offline Offline
Jr. Member
**
Karma: 1
Posts: 56
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
Logged

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9675
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Offline Offline
Jr. Member
**
Karma: 0
Posts: 94
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

or get it to do one rotation cw and one ccw and stop in middle if 200 step per rotation 200 cw, 200ccw then goto 100 cw
Logged

Pages: [1]   Go Up
Jump to: