I stumble upon this idea about creating an open source Electric Speed Controller using Arduino that normally use on typical RC Car either for Crawling or Speedrun activities.
I've already built some prototypes and I'm using the following electronics:
BTS7960 (For High power motor driver 43A 6-24v)
Arduino Nano
DC Buck converter
DumboRC Transmitter and Receiver (Generally use by hobbyist in RC Car world)
Generic servo
550 Brushed Motor
So my question is does anyone tried to create similar prokect like this? I want to know the logic and how did you program the speed controller interface that has:
Forward, Reverse and Brake
Min-Max Speed/Throttle Acceleration
Min-Max Startup Acceleration
Min-Max Drag Brake (When your in a downhill it automatically creates drag brake for you even you are in neutral)
Min-Max Brake force (I get confuse by this how to implement it in the code while getting full throttle and hit reverse immediately it should brake smoothly but instead i get this huge brake and mess up with my gears and tumble my car lol)
Any suggestion and help will be really appreciate!
Photos and some of my prototype codes get from the internet
If you slow the motor on a controlled deceleration curve, you may tune it to never lose traction or flip (losing traction 100%).
There two kinds of friction here; static and sliding which is way lower than static, the difference is never close... the change is sudden and complete.
A rolling wheel keeping up with the road has static friction.
Lock the brakes on the car and push till it slides on the track, that is how much force your slowing down should never reach. F = M x A
You want an acceleration curve, it's probably the decel curve run backwards. You won't waste power and traction if your wheels never slide, it's good for steering too.
Do you write non-blocking code?
If not, the journey starts with you getting started on that and simple state machines at the beginner level. The lessons are short but you have to play around with the ideas to really grasp the implications.
And you can arrive at code to do one thing that runs along with codes to do other things so that one big code doesn't have to coordinate them with if-else's inside of if-else's.
And then look at coding the car and where to find motor and other code on this forum or the main Arduino site (link in forum here, upper left says ARDUINO.CC) Playground or out on the web but avoiding any blocking code that would need fixing to use.
You have a major project, the kind that people make a living doing.
Nick gives real world examples before he gives code with every line explained.
It doesn't take long to read except for stopping to think and reading again later.
This teaches how to make things happen on time, step 1 that includes what is blocking.
When you add time to your code, it gets deeper.
Everyone writing non-blocking code runs into a problem with contact switches (buttons) because the code is so fast, you press the button once and it looks like twelve times! That is called bounce and everyone who gets so far writes their own debounce or so it seemed 10 years ago. Hello Real World!
The INH either connects or disconnects the OUT pin.
The IN determines if the OUT pin is connected to HIGH (+VS) or LOW (GND).
You need TWO BTS7960 drivers to control motor direction. The OUT of one goes to Motor+ and the OUT of the other goes to Motor-. Lets call their respective ve IN pins "IN1" and "IN2"
When INH is LOW, the motor coasts.
When INH is HIGH:
When IN1 and IN2 are both HIGH or both LOW, the motor is braking (the motor terminals are shorted together and the Back EMF is slowing the motor).
When IN1 is HIGH, connecting Motor+ to VS, and IN2 is LOW connecting Motor- to GND, the motor runs forward.
When IN1 is LOW, connecting Motor+ to GND, and IN2 is HIGH connecting Motor- to VS, the motor runs backward.
You can use PWM on the shared INH pin to control both the speed and degree of braking. You don't need PWM on the IN pins.
Note: If you want to control the SPEED of the motor and not just the average power applied to the motor, you need a way to measure the speed.
Note: If the motor is driving wheels through a differential, you may want to put speed sensors on each wheel separately so you can detect spinning (motor is going the same speed but one wheel is stopped and the other is going twice as fast.)
Got the idea and its nice and possible to do. But the problem is I only have one spare. Maybe i can try to order one again but it may took 2 weeks to arrive. Is this possible to do in just one Motor driver?
Are you sure your motor control module doesn't have two driver chips? There isn't much call for Half-H-Bridge modules.
It might be possible to use half an H-Bridge if you center-tap the battery and connect the tap to one side of the motor. Let's say you have a 4S 14.8V battery with a tap at 7.4V.
When OUT is connected to the 14.8V end the motor will get +7.4V and when OUT is connected to the 0V (GND) end, the motor will see -7.4V. Of course since you will probably be moving mostly forward, the forward half of the battery will drain faster than the backward half. You will DEFINITELY need a balancing charger or two batteries in series that you charge separately.