how to make brakes for RC car ? [SOLVED]

Think what this piece of your code does

void setMotor(int speed, boolean reverse)
{
analogWrite(enablePin, speed);
digitalWrite(in1Pin, ! reverse);
digitalWrite(in2Pin, reverse);
}

The direction depends on whether 'reverse' is true or false and the motor will move at the speed determined by 'speed'.

First you need to know what your motor does when forward direction and 0 speed is selected. I assume you started this Topic because the motor keeps turning due to the momentum of the car - but if you have not yet built the car you will have to wait and see. Anyway, assume the car keeps moving and slowing, but not as quickly as you would like. What do you think would happen if you applied a small reverse current to the motor? Again you will have to do some experiments to see what actually happens. Do you think the smoke might escape somewhere if you apply a large reverse current? I don't know.

How would you get this electric brake to work while the car is moving backwards?

...R

Robin2:
Think what this piece of your code does

void setMotor(int speed, boolean reverse)

{
analogWrite(enablePin, speed);
digitalWrite(in1Pin, ! reverse);
digitalWrite(in2Pin, reverse);
}




The direction depends on whether 'reverse' is true or false and the motor will move at the speed determined by 'speed'.

First you need to know what your motor does when forward direction and 0 speed is selected. I assume you started this Topic because the motor keeps turning due to the momentum of the car - but if you have not yet built the car you will have to wait and see. Anyway, assume the car keeps moving and slowing, but not as quickly as you would like. What do you think would happen if you applied a small reverse current to the motor? Again you will have to do some experiments to see what actually happens. Do you think the smoke might escape somewhere if you apply a large reverse current? I don't know.

How would you get this electric brake to work while the car is moving backwards?

...R

i guess i must make both directions on but on with same current to make it stop completely ?

Hopefully it is not possible to have both directions ON at the same time - that almost certainly would let the smoke out.

Surely it is sufficient, once the car is no longer moving, to stop all power to the motor? Don't look for complicated solutions.

Also, it seems to me that you are mentally skipping past the problem of slowing the car to the separate question of whether a parking brake is needed. Make sure you fully understand the slowing process before you bother with a parking brake. And you will need to do some experiments to figure out what works best.

If you really do need a parking brake why not mount a small servo so it's arm presses on one of the tyres.

...R

Robin2:
Hopefully it is not possible to have both directions ON at the same time - that almost certainly would let the smoke out.

Surely it is sufficient, once the car is no longer moving, to stop all power to the motor? Don't look for complicated solutions.

Also, it seems to me that you are mentally skipping past the problem of slowing the car to the separate question of whether a parking brake is needed. Make sure you fully understand the slowing process before you bother with a parking brake. And you will need to do some experiments to figure out what works best.

If you really do need a parking brake why not mount a small servo so it's arm presses on one of the tyres.

...R

aha the last part you said, mechanical brake, i was actully thinking about making a small mechanism for that but i found out it won't work !!
but you are suggesting to make the servo's arm directly press on the tyre well wouldn't that damage the arm or the tyre ?

and about the first part of your post yes your right i will get the answer when i make experiments and if not then i will ask about the problem i get into.

I fear you and I are thinking on very different wavelengths and I worry that what I say may be seriously misinterpreted.

I don't understand, based on what I said earlier, how you can think that a servo arm pressing on a stationary tyre with just sufficient force to stop the wheel moving could damage either the tyre or the servo.

I think it would be helpful if you explain your thinking in case you are having similar misunderstandings about other things I have said.

...R

Robin2:
I fear you and I are thinking on very different wavelengths and I worry that what I say may be seriously misinterpreted.

I don't understand, based on what I said earlier, how you can think that a servo arm pressing on a stationary tyre with just sufficient force to stop the wheel moving could damage either the tyre or the servo.

I think it would be helpful if you explain your thinking in case you are having similar misunderstandings about other things I have said.

...R

ah ok well i understood that your idea is to put a servo with its arm close to the tyre and when hitting the brake the servo will turn and make a pressure on the rotating wheel and act like a brake to make it stop ?

No, that is NOT what I said, and that's why I wanted you to explain what you thought I was saying.

I only suggested using the servo as a parking brake - meaning it would only be used AFTER the wheel had stopped turning (just to stop the car rolling down a hill).

I think it would be useful to read all the previous posts very carefully to make sure you have not made any similar erroneous assumptions. If you are unsure of anything please ask.

...R

Robin2:
No, that is NOT what I said, and that's why I wanted you to explain what you thought I was saying.

I only suggested using the servo as a parking brake - meaning it would only be used AFTER the wheel had stopped turning (just to stop the car rolling down a hill).

I think it would be useful to read all the previous posts very carefully to make sure you have not made any similar erroneous assumptions. If you are unsure of anything please ask.

...R

ohh i am sorry for my misunderstanding :S
but thanks for that idea it can be used in other applications but not in this one :slight_smile: because i don't need to make a park button, what i need is : a reverse button, a burnout button, neutral and a speed limiter, all is solved except the reverse one which i know how to do but still waiting for the IC to be in my hands (the suppliers fault :frowning: ), so the reverse must be clicked on so when i hit the throttle, the car will go backward and when i hit the brakes it should be braking probably like a real car (that's my goal to make it function similarly to a real car but electrically ),
if you know any good tutorials about something similar on the braking issue it would be great :slight_smile: ?

I have already described how I would try to make braking work if it were my car. I can't think of anything else to add.

...R

Robin2:
I have already described how I would try to make braking work if it were my car. I can't think of anything else to add.

...R

ok thanks a lot will read it again and again to make it works :slight_smile:

It would help if you could give a picture of the car setup.

Personally I would code the brake to remove throttle up to the point in which the brake is mor than the throttle, then actuated a servo with some form of friction device on the driven axle. That way limiting the amount of additional components required.

Presume you're using some form of pot for the accelerator and brake... So if throttle is on full, apply half brake arduino supplies half throttle, simple really. If throttle is on half, apply full brake, servo actuated to ram on the friction. Simple really.

i guess it should be the same because the throttle and brake are pots so it would work in reverse, full thottle and full brake car will stop, ... same as u said

And to make sure, just programme the full throttle range to 90% of its sweep, then when arduino sees full throttle, it's only 90% in reality, so when 100% brake is applied, it will ALWAYS be a high value than throttle regardless, thus slamming on the brakes.

ahh so you suggest i put instead of 255, about 240 for example ?! but i guess i loose power here for the dc motor :S

Nope. Put 240 on the pot as max, and when the pot hits 240 upwards arduino supplies max power to the motor, but limits the reading to 240, even if its 249. The brake pot is read as is, so 241 on the brake pot would kill power to DC motors completely.

So, 50 on boths pots = zero power to DC motors.

240 on accelerator, 120 on brake = 50% power to motors (remember 240 = 100% power)

That way anything where brake > accelerator applies power to servo assisted brake.

Nice and simple and involves less components :wink:

well i must experiment this to understand what you really mean because it's been a while i made my program and forgot the logic lol, nevertheless i am a beginner :slight_smile: i managed to make a full program with a gearbox like, but the brakes still didn't work with because still didn't get the chip

but the servo i can't use it because the structure of the car i have it wouldn't allow that !! you can check the pictures up in the starting of the topic and if it's not clear i will upload new ones soon :slight_smile:

hello,
finally i got my L293D chip
i started to work with it here are the codes i am using :

/*
Adafruit Arduino - Lesson 15. Bi-directional Motor
*/
int enablePin = 11;
int in1Pin = 10;
int in2Pin = 9;
int switchPin = 7;
int potPin = 0;

void setup()
{
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(enablePin, OUTPUT);
  pinMode(switchPin, INPUT_PULLUP);
}

void loop()
{
  int speed = analogRead(potPin) / 4;
  boolean reverse = digitalRead(switchPin);
  setMotor(speed, reverse);
}

void setMotor(int speed, boolean reverse)
{
  analogWrite(enablePin, speed);
  digitalWrite(in1Pin, ! reverse);
  digitalWrite(in2Pin, reverse);
}

so now i need to do the throttle and brake system,
what do i have to do ? where do i have to connect the brake pot ? is it on the enable pin of the chip ? which means brake and throttle are both connected to the pin 1 on the IC ?

Going reverse like everyone suggested here is one solution.. I've used the L293D chip, but never needed a break system.. So I didn't really think about it then.. You can look at how the arduino team did it with their motor shield (L298P)(http://arduino.cc/en/Main/ArduinoMotorShieldR3).. Pins 9 and 8 are coupled to some breaking function for motors A and B.. Looking at the schematic, sending a high or low to the break pin is the same as putting the direction pins on the chip to the same state (both high or low).. You can also look at the logic table for the chip on page 6/13 in the datasheet (http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/CD00000240.pdf)..

Good luck

//Basel

Thanks for all i solved it :
here are the codes in case someone needs it :

int enablePin = 11;
int in1Pin = 10;
int in2Pin = 9;
//int switchPin = 7;
int potPin1 = A0;
int potPin2 = A1;

void setup()
{
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(enablePin, OUTPUT);
  //pinMode(switchPin, INPUT_PULLUP);
}

void loop()
{
  int throttle = analogRead(potPin1);
  throttle = map(throttle, 0, 1023, 255, 0);
  
  int brake = analogRead(potPin2);
  brake = map(brake, 0, 1023, 10, 0);
  
  //boolean reverse = digitalRead(switchPin);
  setMotor(throttle, brake);
}

void setMotor(int throttle, int brake)
{
  int pedal ;
  if(throttle){
    pedal = throttle;
    analogWrite(enablePin, throttle);
  }else if (brake){
    pedal = brake;
    analogWrite(enablePin, brake);
  }
  
  digitalWrite(in1Pin, throttle);
  digitalWrite(in2Pin, brake);
}