Project: Saving pulses

Thread Starter

AMB33412

Joined Oct 5, 2017
25
Hi

I want to control my car movement through the pulses generated when I press Forward, Reverse, Right and Left and then read them from the saved place and re-do it

What shall I read or look into for such a thing ?

Detail:

I have a small RC car, not a big one
I want to control it from an RC remote on any path
everytime I make a movement, it should generate a different pulse
I intend to save this information in arduino
I intend to make a button or something to change from program mode to run mode

In program mode, I drive it
In run mode, I select 1,2,3 (depending upon the number of saved pulses), i want to save different paths
And I want it to follow the path that was programmed.
 
Last edited:

Papabravo

Joined Feb 24, 2006
21,225
Are we talking about a full sized vehicle that you and a passenger are riding in? Maybe this is for an RC car being controlled by RC servos that use pulse position control? You need to post with greater clarity.
 

MrSoftware

Joined Oct 29, 2013
2,200
The arduino can control servos (PWM), so if the arduino is on-board the car then it can run the car and store the data. Just have it build an array and store every command. Maybe the simplest form would be a command paired with the time delay before the next command. You can store it to the eeprom in the arduino, or add some external storage if you want to store more.
 

Thread Starter

AMB33412

Joined Oct 5, 2017
25
The arduino can control servos (PWM), so if the arduino is on-board the car then it can run the car and store the data. Just have it build an array and store every command. Maybe the simplest form would be a command paired with the time delay before the next command. You can store it to the eeprom in the arduino, or add some external storage if you want to store more.
I like what you are saying but then again, servos require signal from an arduino right? to work,... how to translate the already made simple signal from RC remote to a signal that servo can understand?
Like, if i put servos in the car instead of the current DC motors, then the car's controller cannot make them run, i need to change the supply of motors too right?

Also... are servos good ? for such a thing? is stepper better?
servos normally don't rotate more than 180 right? and they are also slow? not sure i used a slow one before
 

MrSoftware

Joined Oct 29, 2013
2,200
Ohhh... you're referring to servos to rotate the wheels for counting how far the car went.. I thought you were talking about servos for turning the wheels left and right.. Ok got it..

For counting rotations you can use servos with encoders for feedback, but steppers might be better. Use stepper motors, and you can give them a specific number of steps. If they don't miss stepps then feedback isn't needed, especially for a proof of concept type thing, but if they start missing steps then you can use an encoder for feedback.

You can control steppers directly with an arduino, maybe use an H bridge to get more power, or you can use a stepper controller that you can control with the arduino, for example:

http://www.kr4.us/dual-l6470-stepper-motor-controller.html

There are links on that page to HowTo docs and example code.

So you can just give your commands as how many steps to take, and save those values to repeat the series of movements.
 

MrSoftware

Joined Oct 29, 2013
2,200
If you don't need to be very precise, you can use basic DC motors on the wheels, and use encoders to count how far the wheels rotated. Still give your commands in counts of how many times to rotate the wheels (or degrees, etc..) and just turn the DC motors on while using the encoders to count how far you went . Steppers are more precise, DC motors plus encoders can be cheaper and simpler.
 

Thread Starter

AMB33412

Joined Oct 5, 2017
25
Ohhh... you're referring to servos to rotate the wheels for counting how far the car went.. I thought you were talking about servos for turning the wheels left and right.. Ok got it..

For counting rotations you can use servos with encoders for feedback, but steppers might be better. Use stepper motors, and you can give them a specific number of steps. If they don't miss stepps then feedback isn't needed, especially for a proof of concept type thing, but if they start missing steps then you can use an encoder for feedback.

You can control steppers directly with an arduino, maybe use an H bridge to get more power, or you can use a stepper controller that you can control with the arduino, for example:

http://www.kr4.us/dual-l6470-stepper-motor-controller.html

There are links on that page to HowTo docs and example code.

So you can just give your commands as how many steps to take, and save those values to repeat the series of movements.
well, thats not something I asked but thanks for it, now there is that idea too ...

now heres the idea more in depth....

I have an RC car with 4 buttons on Remote Control,
Up , down, left , right

now every time I press one of the buttons, the car moves in one direction....
lets say I press up... now the motor in the back wheels of car has a specific polarity..... and it moves and car goes forward.....

So what I wanna do is, translate forward, reverse, left and right commands into commands

like lets say
let the 2 terminals of run motor be
R1 and R2
and
turning motor be
T1 and T2

so , lets say
Forward = R1 (5V) , R2(0V)
Reverse = R1 (0V) , R2(5V)

same goes for turn motors...

now I want to read these 2 signals simultaneously on arduino and save them and replicate them in a way that this signal alone (for command) can run those DC motors or servos or anything but if it runs servos then I need to make a new circuit for the car so that the remote control can control servos directly

I hope you understood
 

MrSoftware

Joined Oct 29, 2013
2,200
"Simultaneous" is relative. With the arduino you've only got a single core, so things are going to happen serially, but if you do it fast enough then for your case it will be "simultaneously".

One possible method; use an h-bridge for each motor, control each h-bridge with a pin from the arduino. Make the pin high to turn on the motor, low to turn it off. In code, give each pin a flag (on/off) and a duration that it has been in the current state (on/off). Maybe:

struct pinStaus{
bool bPinOn;
int iTicksWhenStateChanged;
}

When your program starts, for all motors set bPinOn to false and iTicksWhenStateChanged to millis(). In your main loop, every loop around check your radio inputs for each motor and when the state on any pin changes, store the pin state and the difference between millis() now and your stored iTicksWhenStateChanged. Toggle bPinOn and reset iTicksWhenStateChanged to millis(). Now you have a list of every state change, and how long each state lasted, for every motor. For servos, instead of a bool for on/off, just store the PWM value that you use to control the servo. At the bottom of your loop, set the pins for the motors according to the bPinOn flags.

I'm sure there are better solutions, but this is one that popped to mind.
 

Thread Starter

AMB33412

Joined Oct 5, 2017
25
"Simultaneous" is relative. With the arduino you've only got a single core, so things are going to happen serially, but if you do it fast enough then for your case it will be "simultaneously".

One possible method; use an h-bridge for each motor, control each h-bridge with a pin from the arduino. Make the pin high to turn on the motor, low to turn it off. In code, give each pin a flag (on/off) and a duration that it has been in the current state (on/off). Maybe:

struct pinStaus{
bool bPinOn;
int iTicksWhenStateChanged;
}

When your program starts, for all motors set bPinOn to false and iTicksWhenStateChanged to millis(). In your main loop, every loop around check your radio inputs for each motor and when the state on any pin changes, store the pin state and the difference between millis() now and your stored iTicksWhenStateChanged. Toggle bPinOn and reset iTicksWhenStateChanged to millis(). Now you have a list of every state change, and how long each state lasted, for every motor. For servos, instead of a bool for on/off, just store the PWM value that you use to control the servo. At the bottom of your loop, set the pins for the motors according to the bPinOn flags.

I'm sure there are better solutions, but this is one that popped to mind.
Now you are talking... this is what I need but only understood 30% of it as I am not familiar with those commands :p but yes, timing and flags and state save is what I need....

I have alot of questions but I don't want to bother you much so, can you give me a link where I can read about these things? when I am stuck I will ask again but for now I just require too much information on this....

but this is the answer I guess...
 
Top