have main board which has motor control circuit and has row and column to control the row and column of the vending machine.

I have made changes in motor in two ways:

A. I have attached an image for circuit diagram enter image description here

In this design I have some pros and cons

PROS: 1. It stops at its home position after one rotation 2. It detects row and column of the machine

CONS: 1. Sometime it does not stop at its home position or take more than 1 rotation

B. I have attached an image of other diagram

enter image description here In this design also I have some pros and cons

PROS: 1. It stops perfectly at its home position after one rotation.

CONS: 1. It does not detect ROW

Please suggest What should I follow and what should I made changes in the circuit.

Here is the video



  • 1
    it rotates extra because it is programmed to do so – jsotola Aug 3 '19 at 17:51
  • 1
    You've programmed 3.1 sec delays but your comments suggest you intended 2 second delays. Are you seeing ~50% extra rotation? – JRobert Aug 4 '19 at 15:07
  • I have tested it with different time delays. Forgot to clear the comment. – sugandha sharma Aug 4 '19 at 15:12
  • 1
    what are the NO and NC pins used for? – jsotola Aug 4 '19 at 23:06
  • 1
    find out ... use an ohmmeter to find out when the limit switch closes or opens – jsotola Aug 5 '19 at 22:07

"It rotates little bit forward like 10% extra with 3.1 sec delay,"

"I just want to rotate the motor from the home location to the home location when I give signal one time. But i do not know what time delay should I use?"

More than 2.0 and less than 3.1! If 3.1 sec gives 110% rotation, then you need (100/110)*3.1 = 2.818sec to get 100%.

I realize that your 10% extra is an estimate and not accurate to 3 decimals, but I'd use 2.82 as a starting point and tweak it up or down until you get the amount of rotation you want.

Remember that timing a motor to get distance will inherently be inaccurate due to inconsistencies in the motor acceleration rate and rotation speeds, due to variations in its temperature and the power supply voltage, and load, but this should get you started. For long term accuracy, i.e., if you need it to always come back to a fixed position, you'll need some position feedback, which may be as simple as flag on the motor shaft interrupting a photocell. And even that will have some degree of inconsistency due to coasting speed when you shut the power off, but at least those error won't accumulate.


2.82, My motor rotates 10% less every time and change its location in every rotation

Right - 2.82 was a first approximation. If that is too small, try splitting the difference between 2.81 and 3.1. If that ends up too small, then split the difference between it and 3.1; or if it was too big, try splitting the difference between 2.1 and it. Do that a few more times until you have an acceptably close value.

Then read what I said about accumulating errors. The Arduino doesn't ever know what the motor position is so it can't correct for any overshoot or undershoot. If you need accuracy and repeatability, you'll have to add some kind of position sensing, or switch to using a stepper motor and drive the number of steps that makes one full rotation (and it would still have to be started from a known position).

| improve this answer | |
  • What position feedback? Motor has limit switch but I could not control the limit switch. Can you help me in this? – sugandha sharma Aug 4 '19 at 16:09
  • With 2.82, My motor rotates 10% less every time and change its location in every rotation – sugandha sharma Aug 4 '19 at 16:18
  • @sugandhasharma Probably, controlling the motor the way you try only works more or less properly for multiple rotations. Due to the number of coils/magnets the motor has stable positions at specific angles. Stopping at positions between those angles might not work – Sim Son Aug 4 '19 at 16:50
  • @Sim Son If you know about it please let me know. I have attached the circuit block diagram and video too. drive.google.com/open?id=15CmMVI410zq1Vc2Wl7yseq9n4T8Q1rMm – sugandha sharma Aug 4 '19 at 17:23
  • I feel you might be building a solution that will only work for a short period of time. The time you calculate will work for the environmental conditions you have right now. As temperature and humidity and age of the motor change, friction will change, this will likely have an impact on the amount of time that the motor needs to be active to get.to a desired position. You should seriously consider an approach that says "I'm here" when the motor reaches the desired position. This is mentioned @jrobert answer as "position feedback" you should investigate(search) it. – GMc Aug 4 '19 at 22:24

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