hi guys,
is here someone that can give me a hand with the code to command a motor to turn 90 degrees clockwise and command it to turn back again? im building an arcade cabinet and im trying to emulate this design. Rotating MAME Monitor - YouTube
any help would be appreciated
What microcontroller are you using for commanding the motor? What type of motor do you have?
You will need something to measure the 90 degree turn.
Multiple choices here:
- Integrated motor encoder
- Potentiometer - only goes 270 degrees
- Older red Quadrature encoder
- Gyroscope sensor
You then want to figure out how many ticks or potentiometer reading means 90 degrees. Or the gyro reads 90 degrees. Then you need some code to get you to your target effectively and not over or undershoot. You want your motor to slow down and glide into 90 degrees. Otherwise momentum will carry you further than you want.
Start with this P controller. You want a turn versus arm height but the concept is exactly the same. Once you master this, you can decide if you want to get fancier.
https://vexforum.com/t/simple-p-controller-for-arm-position/23699/1
Limit switches would work, just mount one at the stopping point. I would use a limit switch and an encoder, the limit switch would set the encoder to zero.
Thanks everybody for replying. i have
2 wire motor 393
2 limit switches
motor controller 29
this is what im building
Hmmm. You look like Arduino is you thing. Not sure where the motor is on this thing and what kinds of options you have for detecting the position.
A gyro may be your best bet. but they are expensive.
https://www.sparkfun.com/pages/accel_gyro_guide?_ga=1.135409145.996206786.1473788968
I did it in PROS using the compas.