I`m building a lawnmower robot and have run into a problem.
I use digital pins to control the 350w electric wheel (from hoverboard) speed.
Arduino UNO powered from a laptop USB
with this code:
analogWrite(3, 65); //slow 1.27V - left wheel
analogWrite(5, 65); //slow 1.28V - right wheel
got different Voltage for different pins (with the same value of 65), and because of that getting different wheel speed. Could you advise me on how to get the same voltage with the same values sent to analogwrite.
The problem may be with the speed controller. If you swap the connections to pins 3 and 5 what happens ?
Having said that, does an output voltage difference of 0.01 volts really matter ? There is also the strong possibility that the motors are not matched for power either
Hello valiokaz
Check the hardware how the PWM voltage is converted to the control voltage for the motor drive.
The deviations in the components used for the low pass lead to the different output voltages.
You can install a gyroscope to stay on the track.
Have a nice day and enjoy programming in C++ and learning.
MIND THE GAP
The voltages on these pins are always 0V or 5V, not a voltage between. The function name analogWrite() is confusing, it does not cause the pins on Uno to output a voltage between 0V and 5V. What it does is output a square wave signal where the duty cycle can be adjusted.
A multimeter cannot accurately measure that square wave. If you are lucky, you might see a voltage that approximately represents the duty cycle, but it will not be perfectly actuate. If you are not lucky, you might see a voltage that fluctuates continuously and wildly.
If your lawn mower doesn't travel straight, it's not because of the 0.01 V difference! You need a rotation encoder on each axis to get the wheels rotate at exact the same RPM. And even then it won't be a straight line, due to differences in tyres and most of all, the terrain.
If your lawn mower doesn't travel straight, it's not because of the 0.01 V difference! You need a rotation encoder on each axis to get the wheels rotate at exact the same RPM. And even then it won't be a straight line, due to differences in tyres and most of all, the terrain.
I just noticed, that when I restart Arduino UNO, it happens randomly, one time right wheel runs faster, than left one, after restart they can change sides and left going faster.
I`m using these 2 controllers to control hoverboards wheel
After switching 3 and 5 I noticed, that doesnt matter, it actually matters when Arduino sends voltage to start motors, Im not experienced in electronics, but it looks like Voltage/Amperage is not stable and because of wheel runs at different speed
Restarting Arduino randomly runs one wheel faster or another.
I just find out that every time when I connect and disconnect voltage to the throttle, every time it runs at a different speed, so it looks like it have 3 different speeds Need more digging
In the picture I see Hall, and I see motor phase. Is it so that this unit controls the brushless motor? The motor doesn't control itself? In that case the Hall signal probably works as a perfect speed control. Read its signal with Arduino and adjust the PWM duty cycle so that the Hall signal frequency is exactly the same on both wheels.