0
$\begingroup$

I'm working on a project where using a gear motor with an encoder and an Arduino Uno. I have not done Arduino in a long time and am struggling getting it to do what I want. If you look at the wiring guide for the motor below here is what I have currently wired up:

1 - M1 (-) wired to the ground of the voltage source, 2-GND Encoder wired to the GND pin on the Arduino, 3-Encoder A phase wired to Pin9, 4-Encoder B phase wired to Pin10, 5-3V3 Encoder + wired to 3V3 pin on the Arduino, 6-M1 motor (+) wired to the hot voltage source.

When I supply a voltage source the motor begins to spin. I want the motor to start not moving even when the power is supplied. Then I want to be able to set the angle that the position of the motor will turn to that spot and have it stop moving. I will then turn off the power supply and the motor will stay in that position until power is supplied again a new position is programed into the code. This motor can rotate in both directions. Please help even suggestions what commands to use will be great. enter image description here

$\endgroup$
1
  • $\begingroup$ I also have an h bridge, but am not sure how to wire it with the motor and arduino $\endgroup$ – kiera Apr 7 at 18:44
0
$\begingroup$

The motor should not be connected directly to your power source since this will not allow it to be controlled by the Arduino. The encoder is a passive add-on to the motor (mechanical coupling only). There is no electrical connection between the encoder and the motor to allow for control of motor motion. You'll need to use the H-Bridge to allow the Arduino's DIO pins to control the motor and the encoder to provide rotation feedback to the Arduino through DIO pins so you can decide when to turn on and off the motor. This motor/encoder combination does not provide accurate rotational position, i.e. you won't be able to "tell" the motor to go to a specific angle with any reasonable accuracy.

Here is a generic application of the H-Bridge... You should find a datasheet for your specific H-Bridge for a more detailed idea of the proper application of the circuit. enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.