I need the Arduino code to control the rotation angle (setpoint or target angle) of a DC motor using encoder, Can you help me?

Thank you for the great advice Stefan, love to read it.
I have been assigned to develop motor controller which uses a close loop negative feedback to control the desire angle and I have to built robot car for demonstration as well. The motor can either be dc motor or stepper motor. I am trying to figure out about components' specification and how to get this thing works using theoretical and practical principles (electronics, programming, mechanics).

I am actually learning about electronic and programming basics, and sometimes I have no idea about the functionality of electronic devices because I am inexperience in electronics and programing. However, I am trying and pushing myself hard to learn and get used to them. Moreover, learning these things in English is quite difficult for me (it is my second language), so that is why I do need you guys advice.

Ps. I did not mean to steal some codes from someone and claim this is mine or want to use the easy path to accomplish the project, but the code that I have posted is just to make sure that I am on the right track because apparently, there are so many functions and ways to do that and I am not sure how can I do that properly, so I need someone to consult and hopefully, there is someone to guide me to complete this project. Not just giving me fish but I need a rod so that I can find fish by myself.

Kind regards,
Siratid

Sorry, that is my mistake. It is the 5V pin.

Fine.
You have code and I don't see any obvious mistakes in the schematics.
How is the situation? What happens when You run the project?

Hi,

Is this a school/college/university project?
Or is it a commercial project?

Can you please tell us your electronics, programming, arduino, hardware experience?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

A stepper-motor needs (almost) no negative-feedback-loop.
A stepper-motor just needs a reference-point this could be

  • a light-barrier
  • a microswitch
  • an induktive proximity sensor

the stepper-motor starts to rotate and as soon as the reference-point is "reached" the sensor gives a signal. Immidiately stop the motor and your code "knows" the position.
For any further rotating of the stepper-motor the position is exactly known because each step means a certain angle.

Of course there are closed-loop-stepper-motors too. This increases the perfomance because a momentary steploosing can be compensated through the closed-loop-feedback

Be the change you want to see in the world
best regards Stefan

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.