Improving the parent guided remote in a childs ride on electric car

Hi Geniuses,

I am in the process of learning the arduino basics to enable me to use an arduino with an rc controller to control a childs electric car. The desired outcome is that the child in the car can control the car (child guided) using the normal in car controls, and whilst the child is learning to use the car, or before they are able to use the car properly, I can drive the child around (parent guided) using an rc transmitter.

The in-car controls, perhaps unsurprisingly are:

  • Steering wheel (connected mechanically to the steering rack, but also has a servo motor on the rack to steer with a motor).
  • Throttle pedal (currently only on or off, but would like to make this proportional)
  • Gear stick - This has 3 positions, forwards, neutral, reverse

I would like to be able to have three modes of operation.

  • Ability to have full parent guided control over the car regardless of what the child does with the controls
  • Child to guide the car, and the parent to be able to override the steering or throttle if required
  • Complete child guidance with no need for the rc transmitter to be turned on

These modes should be controlled via a switch in the car.

I have a fair bit of experience with RC gear having flown rc aircraft for about 10 years. I have a good working understanding of channels and PWM outputs.

I have already made some headway, and already successfully made the car "parent guided/remote control) by implementing a rc receiver in the car, using a standard brushed speed controller for the drive, and a H-bridge connected to a potentiometer for steering.

A bit more on the steering, I have used a servo (with servo motor removed) to determine the position of the steering. I have connected the wires that would normally go the servo motor to a H-bridge to drive a large motor to control the steering. This works well.

The Throttle is fairly straightforward and works out of the box as its a standard rc setup.

OK, here are my questions/assumptions.

Inputs

  • RC Steering control signal
  • RC throttle Signal
  • In car steering control signal
  • In car throttle Signal
  • In car driving mode switch (to select child guided or parent guided)
  • In car gear stick (To determine neutral, forward, reverse).

I have already written some code in Arduino to do something similar but it doesn’t work as i’d expect

Before I show the code - this is what is supposed to happen:

I have a potentiometer on A0 - When the potentiometer is providing a value of less than 1000, then LEDS should light up dependant on the position of the steering wheel signal

If the potentiometer on A0 is providing a value greater than 1000pwm, then do nothing.

I am guessing this is how i’d structure the code for the entier thing. Three big if statements, one for each driving mode:

  • parent guided
  • child guided (with parent over ride)
  • child guided

Question 1 - Can someone please let me know if I am heading in the right direction…

Here is the code with just one mode for now…

/*
This sketch uses a single RC input - RC Steering input on Pin 6 turns LEDs on and off depending on the steering wheel position.

There is a Potentiometer on input A0 that determines whether the below behavior is invoked or not.

If the Potentiometer value is less than or = 1000, run the below code:

If the steering is neutral, where the RC input is PWM between 1400 and 1500 - The Yellow LED should light up
If the steering is full left, where the RC input is PWM less than 1400 - The Green LED should light up
If the steering is full right, where the RC input is PWM greater than 1500 - the Red LED should light up

If the Potentiometer value is greater than 1000 = turn all LEDS off an do nothing. 
 */


int rcsteering;
int rcthrottle;
int rcdrivemode;

int sensorValue = 0;

int RedLedPin = 13;
int YellowLedPin = 12;
int GreenLedPin = 8;

void setup() {     // put your setup code here, to run once:

  // Initialize RC inputs
  pinMode(3, INPUT); // RC Throttle input
  pinMode(6, INPUT); // RC Steering input
  pinMode(5, INPUT); // RC Driving Mode input

  //Initialize Manual inputs
  pinMode(A0, INPUT);

  // Initialize LED Outputs
  pinMode(RedLedPin, OUTPUT); // Red
  pinMode(YellowLedPin, OUTPUT); // Yellow
  pinMode(GreenLedPin, OUTPUT); // Green

  Serial.begin(9600);
  Serial.println("Initialise");
}

void loop() {
  // put your main code here, to run repeatedly:
  rcsteering = pulseIn(6, HIGH, 25000);
  sensorValue = analogRead(A0);
  /*Serial.print("Steering");
    Serial.print(rcsteering);
    Serial.println("  ");*/
  rcdrivemode = pulseIn(5, HIGH, 25000);
  /*Serial.println(rcdrivemode);*/
  Serial.println(sensorValue);

  if (sensorValue <= 1000)
  {
    if (rcsteering <= 1400)
    {
      digitalWrite(GreenLedPin, HIGH);
      digitalWrite(YellowLedPin, LOW);
      digitalWrite(RedLedPin, LOW);
    };

    if (rcsteering >= 1400 && rcsteering <= 1500)
    {
      digitalWrite(YellowLedPin, HIGH);
      digitalWrite(GreenLedPin, LOW);
      digitalWrite(RedLedPin, LOW);
    };

    if (rcsteering >= 1500)
    {
      digitalWrite(RedLedPin, HIGH);
      digitalWrite(GreenLedPin, LOW);
      digitalWrite(YellowLedPin, LOW);

    }
    else
    {
      digitalWrite(YellowLedPin, LOW);
      digitalWrite(GreenLedPin, LOW);
      digitalWrite(RedLedPin, LOW);
    };
  }



}

When printing out the values of the PWM signal in the Serial window, every few seconds the pwm values seem to get lost - Should i be doing something clever with the pwm inputs when reading them in?

If anyone could point me in the general direction i’d be very grateful… And if I have not obeyed forum etiquette, please let me know, and i’ll do better next time!

Thanks in advance guys (and girls)!

rich

So your planning to put a child in a remote control car, that you, or possibly anyone else, will be able to control ?

I have only flown RC aircraft for around 30 years, and its does not seem to matter how much care and experience you put into the electronics, things do go wrong and planes crash, but then planes are easy to replace.

Thanks for the helpful comment.

I should be clear. The car is designed for children aged three to eight years old. Is already remote controlled, and goes 1.5mph.

The remote control that come with these cars are unreliable, and not proportional. And run on 27mhz.

They also do not have an override function. They are either child guided or parent guided.

I see nothing wrong with this post.

Bob.

Me neither, sounds interesting. I’ve fixed my granddaughters electric car and that motor is tiny. It runs on 6v and although it has gear reduction to get it going. Not sure how it would do at a slower speed.

Conversion from the "as built" unit would depend a lot on just what that 27mhz unit actually does now.

Speed via a brushed esc. plenty on Ebay etc for a few dollars.

R/c steering over-ride might be a problem as a child, even a youngster , could apply quite an adverse force to your rack servo and simply stall or over-ride it.

Gear change same thing unless concealed.

2.4 gig radios themselves are as cheap as and hardly worth the bother of building your own if reliability is a concern.

There are a couple of sites that run drones etc. from Arduino, so if you must then have a peek at one here..... Part of a series on a quad build... https://www.youtube.com/watch?v=_ekFXTn3GhE

This was what I found in mine

It stalls easily

Train of gears in there a mile long should have plenty of torque at a few rpm on the output drive socket. Even considering some loss due to the wheel size.

Used to find these style of motor (makita 7v2 battery drills) would lose their grunt after a few years work. New motor brought it back to original.

If you disconnect the steering wheel from the rack and pinion and sense the steering wheel then you can choose which input steers the car. If there is nothing from the remote then the kid steers it. I would sense the steering wheel with a rotary switch so that the wheel has change position but not position data -- so when parent control ends, the steering wheel points forward as far as the controller is concerned otherwise it'd turn to where position data tells it, maybe a hard turn. The steering wheel would need to turn freely (no stops) to do this.

Then disconnect the shifter, "gas" pedal and brakes though those.... what happens if the shifter is in reverse when the remote had it in forward before letting control go back?

I'd pitch the remote and get the kid to learn by doing.

Hi All,

Thanks very much for the responses, all really helpful. These cars already exist today, they can be purchased for around £100, they are quite popular, they are also already remote control. There are shortcomings with existing designs (plus the second hand one i bought doesn't work!)

These Shortcomings with existing models,to name a few

  • When on parent guided mode, the car can move with radio interference
  • When the throttle is pushed it does jolt a bit
  • The steering is either full lock or centered, not proportional

I intend on improving this functionality to add the following benefits:

  • Proportional throttle
  • Proportional Steering
  • Parent Override

I also appreciate that kids driving around in electric cars should compliment a healthy active lifestyle! I also appreciate that these vehicles should only be used in safe environments, e.g. a flat garden!

Can I reiterate what I have already done, I have the car functioning well on a FS-GT5 2.5ghz remote control.

I also already have steering servo motor fitted to steering shaft, this is already in the car.

I also have a dual brushed speed controller in the car connected to both drive motors, this is controlled via a pwm signal from the RC Receiver.

What I want to do is enable the arduino unit to determine which inputs to listen to.

@GoForSmoke - I do intend on disconnecting the steering wheel from the steering shaft and using mechanical end points and a servo potentiometer to send a "desired steering position" to the arduino. This should then activate the H-bridge which drives the steering motor and sets the steering position. In order for the servo to know when the desired steering position is reached, the steering position is connected to the servo potentiometer via a pushrod. This will stop the steering servo from turning the wheels once the desired steering position is reached.

I have added a picture of the Current car electronics, which does not currently include an arduino, I have also added a schematic of the inputs and outputs in the car and how it all connects to the Arduino.

I don't have any programming knowledge, apart from doing Arduino tutorials. And I was wondering if anyone had any thoughts as to the overall structure of the code.

The car will work on 3 modes - selectable via a switch parent guided child guided with parent over ride child guided

Would that mean that the code is structured in three big if statements?

E.g

if driving mode is set to child guided - listen to child steering input and child throttle input and child gear selector

if driving mode is set to child guided with parent over ride, listen to child inputs, but if an input is detected from the parent remote then use the parent remote input

if driving mode is set to parent guided, use all parent inputs and ignore all child inputs

In my original piece of code above, I tried to mimic this using a potentiometer on A0 as the driving mode switch. obviously this should be changed to a 3 position switch for the 3 modes. But I don't have a 3 position switch at the moment.

Hopefully I have added some more context to my original post, I'd like to invite any comments on the code in my original post...If this isnt the place to do that, I'll move it to a different forum section!

Cheers, All,

Stay Safe.

richie967: I have the car functioning well on a FS-GT5 2.5ghz remote control.

Small correction - it is 2.4GHz

You say you have the car functioning well. Does that mean that you already have a working Arduino program and you need help to make some changes to it?

If so, please post the program and tell us in detail what it actually does and what you want it to do that is different. It will make it much easier to focus on the parts you need help with rather than wasting time on things that you can do.

...R

richie967: @GoForSmoke - I do intend on disconnecting the steering wheel from the steering shaft and using mechanical end points and a servo potentiometer to send a "desired steering position" to the arduino. This should then activate the H-bridge which drives the steering motor and sets the steering position. In order for the servo to know when the desired steering position is reached, the steering position is connected to the servo potentiometer via a pushrod. This will stop the steering servo from turning the wheels once the desired steering position is reached.

So while the remote controls the steering, the wheel gets turned to the left stop. What happens when control is passed back to the kid?

Does the car immediately make a hard left? If not then how can the car make a left turn? You need to logically model more than just the make it work part unless you want to debug after building?

This is why I say the wheel should turn freely and be sensed by a rotary encoder that returns clicks to left or right. That way it can pick up where the remote left off as if the kid steered correctly the whole time.

And still, what if the kid moves the shift lever to reverse and the remote was in forward when it handed control over?

Go pedal, stop pedal, maybe not problems being out of synch.

Hi Robin / GoForSmoke,

Thanks very much for your responses. Sorry my frequency was meant to say 2.4ghz! Typing with my gloves on again!

Thanks for the thoughts, and also thanks for thinking of some of the eventualities that could happen, I was only really thinking of how to make it work, as opposed to thinking of some of the potentially problematic scenarios.

Sorry, when i say functioning well, I have the mechanics of the steering and throttle functioning well from the 2.4ghz receiver. I don’t have an Arduino program written the does this. I also do not possess any coding or programming knowledge apart from the tutorials I have done on the Arduino website.

Regarding the steering - I have removed the broken original control unit that controls the steering, and the steering is now controlled via a modified standard RC Servo. As opposed to using the standard RC servo motor for the steering, I have connected the two wires that normally go the the rc servo motor to a H-bridge, which enables me to drive a bigger motor for steering. The Steering column is connected to the potentiometer in the servo via a pushrod so that the current steering position can be determined.

I think i understand your point about having a continuously rotating steering wheel, so that when parent mode is stopped, the position of the steering wheel is maintained by the childs mode.

RE: throttle, my thoughts are that if the parent remote is commanding reverse, and the child unit is commanding forwards, when control is relinquished back to the car, the motors would stop for a second.

Regarding the throttle, this is currently only controlled via the RC receiver as well. Basically the same setup as it would be on a small RC car.

At the moment I am trying to write a program that does something very simple.
Based on the value of a potentiometer, the RC channel should be listened to or not. Comments in the code below for desired behavior:

/*
  This sketch uses a single RC input into pwm pin 6.

  This program should run in two modes

  Mode 1 - Steering LEDs light up when rc remote steering wheel is centered, or turns left and right
  Mode 2 - LEDS Disabled, No LEDs light up when steering wheel is turned

  There is a Potentiometer on input A0 that should mimic the driving mode switch that is in the car.

  If the Potentiometer value is less than or equal to 1000, this should invoke Mode 1 -
  This mimics the driving mode switch being set to rc mode

  Mode 1 function
  If the steering is neutral, where the RC input is PWM between 1400 and 1500 - The Yellow LED should light up
  If the steering is full left, where the RC input is PWM less than 1400 - The Green LED should light up
  If the steering is full right, where the RC input is PWM greater than 1500 - the Red LED should light up


  If the Potentiometer value is greater than 1000, this should invoke Mode 2 -
  This mimics the driving mode switch in the car being set to child guided mode

  Mode 2 function
  No LEDS should turn on

  NOTE: No Override mode is currently in place.
*/


int rcsteering;
int rcthrottle;
int rcdrivemode;

int sensorValue = 0;

int RedLedPin = 13;
int YellowLedPin = 12;
int GreenLedPin = 8;

void setup() {     // put your setup code here, to run once:

  // Initialize RC inputs
  // pinMode(3, INPUT); // RC Throttle input
  pinMode(6, INPUT); // RC Steering input
  pinMode(5, INPUT); // RC Driving Mode input

  //Initialize Manual inputs
  pinMode(A0, INPUT);

  // Initialize LED Outputs
  pinMode(RedLedPin, OUTPUT); // Red
  pinMode(YellowLedPin, OUTPUT); // Yellow
  pinMode(GreenLedPin, OUTPUT); // Green

  Serial.begin(9600);
  Serial.println("Initialise");
}

void loop() {
  // put your main code here, to run repeatedly:
  rcsteering = pulseIn(6, HIGH, 25000);
  sensorValue = analogRead(A0);
  rcdrivemode = pulseIn(5, HIGH, 25000); // controlled by Potentiometer, but will be a switch in future.
  Serial.println(sensorValue);

  if (sensorValue <= 1000) // Mode 1 - LEDS should light up when steering is turned right and left
  {
    if (rcsteering <= 1400)
    {
      digitalWrite(GreenLedPin, HIGH);
      digitalWrite(YellowLedPin, LOW);
      digitalWrite(RedLedPin, LOW);
    };

    if (rcsteering >= 1400 && rcsteering <= 1500)
    {
      digitalWrite(YellowLedPin, HIGH);
      digitalWrite(GreenLedPin, LOW);
      digitalWrite(RedLedPin, LOW);
    };

    if (rcsteering >= 1500)
    {
      digitalWrite(RedLedPin, HIGH);
      digitalWrite(GreenLedPin, LOW);
      digitalWrite(YellowLedPin, LOW);

    }
  }
  else // Mode 2 - No LEDS should light up
  {
    digitalWrite(YellowLedPin, LOW);
    digitalWrite(GreenLedPin, LOW);
    digitalWrite(RedLedPin, LOW);
  };
}

When on Mode 1 - The lights behave as expected.
When on Mode 2 - the lights periodically flash, even though they should be disabled.

Any idea why the lights are flashing when they should be all set to LOW?

I realise this is a far cry away from the program that I will eventually write, but I figured i’d get this basic logic working first?

Cheers, rich

A pot returns an absolute position value. A rotary encoder tells you clicks to the left or right. Which one would not have to be physically realigned to stay on-course when control is passed to the steering wheel?

I’m working on similar circuit currently... you need a potentiometer on the steering mechanism for feedback to your steering motor. What keeps it from oscillating?

GoForSmoke: A pot returns an absolute position value. A rotary encoder tells you clicks to the left or right. Which one would not have to be physically realigned to stay on-course when control is passed to the steering wheel?

Hi, apologies for the confusion.

I am currently not that far yet. I am trying to test something really basic, basically using a pot to mimic a switch, if the value of the pot is less than a certain value, let the rc gear take over, if the value is above a certain value then do nothing.

I get the fact a rotary encoder would need to be on the steering wheel itself to determine that kind of stuff, i'm probably a way off that yet. I am in the process just trying to get the high level bit done where the rc input is respected or not.

I hope that makes sense!

Cheers, Rich

wolframore: I’m working on similar circuit currently... you need a potentiometer on the steering mechanism for feedback to your steering motor. What keeps it from oscillating?

Hi Wolframore,

Yes that's already in place, I have a potentiometer on the steering mechanism that gives feedback to the servo to stop the servo from going past the max steering limit.

There's a bit of jittering on it but it seems to work ok. I will introduce a dead band to stop jittering in future. But thats out of my league at the moment!

That’s one way of doing it not great for responsiveness but it would make it a little better

Have you tried using analogRead() to get the pot sense as a value from 0 to 1023?

That can map as 0 to 180 degrees in fractions of a degree.

The value may dither +/- 1 or 2 when near an ADC step edge. You can clean that up in code, it won't be fall-over easy.

richie967: Sorry, when i say functioning well, I have the mechanics of the steering and throttle functioning well from the 2.4ghz receiver. I don't have an Arduino program written the does this.

Where does the program you have included in Reply #12 fit in.

If you want an Arduino system that can choose between inputs from different sources then that system must be able to receive all of the inputs and put the appropriate ones to use. Among other things that means that all the outputs from the RC receiver must be channelled through the Arduino (presumably using pulseIn() to detect them).

I think if this was my project I would dispense with the RC transmitter and receiver and build my own simple TX using a pair of nRF24L01+ transceivers for the wireless part. It would avoid the need for pulseIn() but it would require an Arduino as part of the TX. If you wanted to you could remove the electronics from the existing hand-controller and replace them with an Arduino nano and an nRF24.

Other people seem to be covering the complexities of switching between the different control systems

...R Simple nRF24L01+ Tutorial