Shop OBEX P1 Docs P2 Docs Learn Events
Automatic braking on RC car — Parallax Forums

Automatic braking on RC car

IlidanxDIlidanxD Posts: 7
edited 2012-08-09 11:00 in Learn with BlocklyProp
Hello! I'm working in my final school project, the idea is to make an RC car stop automatically when there's an obstacle in front of it, even if someone is still speeding up. For this, I'm using a ping sensor to detect the objects and the propeller chip to decide when stop the vehicle.
My problem is, since I connected the car's circuit to the propeller, the car have ceased moving, I'm sure it's a software problem but I don't know how to fix it, can you tell me if there's something wrong in my code? or another way to code this?
here is my code, and the code I use to control the ping sensor
Ping.spin S.P.A.T beta.spin

Thanks in advance, and sorry for my bad English.

Comments

  • T3rr0rByte13T3rr0rByte13 Posts: 29
    edited 2012-07-28 02:12
    The trick is not to stop the car, but rather limit the forward motion of the car.

    dont tell the car to go forward for 3 seconds then send a command to stop the car, tell the car to go forward 0.2 seconds, and forward for 0.2 seconds. Stop sending the command to go forward for 0.2 seconds when you want it to stop... and hazza! it stops.

    "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." -Einstein
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-07-28 11:47
    Will the car get drive forward when controlled by the Propeller? It's a good idea to test each of the parts of a program before adding the parts together.

    How are the motors controlled? What's connected to "MTAD_Pin"? Is it some sort of H-bridge?
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-07-30 07:12
    It would actually help if the H-bridge that controls the car has braking included in its feature.

    Here is a full-featured DIY H-bridge that claims to have braking. It works even better if you electric motor is geared.

    http://www.solarbotics.net/library/circuits/driver_robinson.html
  • ercoerco Posts: 20,256
    edited 2012-07-30 10:14
    If this is a brushed DC motor, the simplest solution is just to add a single SPDT relay at the motor wired in order to:

    1) break one motor connection to the existing H-bridge circuit, and
    2) connect that same motor connection to the other motor connection

    That is, when the relay is activated by your sensor, the two motor leads are disconnected from the controller and shorted together to achieve dynamic braking. That will stop the car in a hurry until the object is removed. Kind of a pain, though, since the car is stuck, you can't back up either. You could get tricky and add a diode so that the relay drops out when reverse is applied so you can back away after stopping.

    There are numerous ways to put the brakes on, but your bigger problem is sensing the obstacle reliably. Sonar/ultrasonic won't work reliably above a certain airspeed (motion and wind will affect), and your car will have a minimum braking distance, so I suspect you will spend some time limiting its top speed so as to not overdrive the car into an obstacle. Likely on the slow side, given the limits of sensor function, detection reliabilty, and vehicle stopping ability.
  • IlidanxDIlidanxD Posts: 7
    edited 2012-08-01 16:12
    thanks for your answers :smile:. now I want to answer you some things... first, yes the "MTAD_Pin" and the "MTAT_Pin" are connected to an H-bridge but it doesn't has the braking included.
    well the problem I mentioned is solved, I realized that the backwards ping was not correctly connected :blank:, and the car was moving just when the ping detect something, I mean if there was nothing in 3 m. the wasn't moving, I fixed that in the program, changing the case statement "16..300: outa[MTAD_Pin] := 1" for "other : outa[MTAD_Pin] := 1" but now my problem is the speed, as closer is the object as faster goes the car, and when the object is close enough, the motor stops but the inertia makes the car crash any way. If I want to make the speed stable do I have to use pwm?
  • ercoerco Posts: 20,256
    edited 2012-08-02 08:20
    Repeating:
    erco wrote: »
    There are numerous ways to put the brakes on, but your bigger problem is sensing the obstacle reliably. Sonar/ultrasonic won't work reliably above a certain airspeed (motion and wind will affect), and your car will have a minimum braking distance, so I suspect you will spend some time limiting its top speed so as to not overdrive the car into an obstacle. Likely on the slow side, given the limits of sensor function, detection reliabilty, and vehicle stopping ability.

    If it isn't obvious, you're going way too fast for your sensors. Slow down. WAY down.

    Are you braking to stop, or just removing power and coasting into the crash?
  • IlidanxDIlidanxD Posts: 7
    edited 2012-08-02 11:03
    erco wrote: »

    Are you braking to stop, or just removing power and coasting into the crash?
    actually I'm just removing power, I'm still thinking on the brake system
  • ercoerco Posts: 20,256
    edited 2012-08-02 14:27
    Brushed or brushless motor?
  • IlidanxDIlidanxD Posts: 7
    edited 2012-08-02 16:14
    It's a brushed motor
  • ercoerco Posts: 20,256
    edited 2012-08-02 16:48
    So just short your motor leads together to brake.

    Yes, disconnect them from the power first. That's why I suggested a SPDT relay earlier.

    http://www.youtube.com/watch?v=hGQEzz8CNIQ

    and

    http://www.youtube.com/watch?v=zFkJ29xuRFY (no braking)

    http://www.youtube.com/watch?v=1EKlAOUXZ8U (with braking)
  • ercoerco Posts: 20,256
    edited 2012-08-02 19:11
    What object sensors are you using?
  • IlidanxDIlidanxD Posts: 7
    edited 2012-08-03 09:59
    thanks, I will use the relay. And I'm using the Ping demo object
  • ercoerco Posts: 20,256
    edited 2012-08-03 10:45
    PING doesn't work reliably at any speed or in wind. Your options are to go painfully slow with a PING or try going faster using a different sensor like a laser rangefinder.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-08-03 12:05
    erco wrote: »
    PING doesn't work reliably at any speed or in wind. Your options are to go painfully slow with a PING or try going faster using a different sensor like a laser rangefinder.

    erco, have you observed problems with ultrasound sensors in windy environments?

    When I played around with a Ping, one of the things I tried was to blow hot air from a heat gun at various angles in front of the sensor. I never observed any problems during these short tests. I haven't tried having the sensor move instead of using blowing air, but from my experience I don't see the vehicle speed (of RC cars) being a issue with the Ping.

    Parallax's Laser Range Finder has a pretty slow refresh rate and doesn't work well outside in bright sunlight.

    I agree about going slow enough to have time to stop but I'm not sure if switching to a LRF would help much.
  • ercoerco Posts: 20,256
    edited 2012-08-03 19:39
    No personal experience, but I've read many recommendations from smarter folks than me here in the forum that any airspeed is likely to cause erroneous results. I'm assuming the the OP is talking about an typical hobby RC car with reasonable speed potential. Even modest R/C speeds will probably result in outdriving a PING's detection capabilities, and any airspeed-related inaccuracies is likely to make a bad situation worse.

    I'm gonna go out on a limb here and throw out a number like 1 foot per second might be a reasonable speed to expect a single PING to function properly to detect large objects and walls and give a car/robot time to stop. Even 2 ft/sec may be possible with lots of chassis and sensor tweaking, but the 10 ft/sec speeds that even inexpensive cars can hit are "right out".

    OK, the race is on. Who will be first to post results or find a Youtube video which proves erco doesn't know stuff from Shinola? :)
  • IlidanxDIlidanxD Posts: 7
    edited 2012-08-04 16:50
    so... do I have to use pwm to slow down the speed, and be sure it's stable?
  • ercoerco Posts: 20,256
    edited 2012-08-04 19:04
    First you need to limit your top speed. What kind of motor/speed controller are you using?
  • IlidanxDIlidanxD Posts: 7
    edited 2012-08-06 17:50
    I'm just using the propeller and the H-Bridge to control the motor and its speed.
    Well I made some changes in my code that solve most of my problems and I want to share it with you.
    Thank you very much for your help :cool:.
    S.P.A.T beta 2.spin
  • ercoerco Posts: 20,256
    edited 2012-08-08 14:23
    erco wrote: »
    Who will be first to post results or find a Youtube video which proves erco doesn't know stuff from Shinola? :)

    No one bit, so I'll have to take myself down with this nifty page on robotic vehicles that navigate around a room using ultrasonics. Looks to be somewhere in the ballpark of my predicted 2-3 ft/sec speed. Check the two videos, pretty cool stuff!

    http://letsmakerobots.com/node/696#robot_em_video
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-08-08 14:37
    erco wrote: »
    No one bit,

    None of my bots travel 10 ft/sec. I started making a Lego vehicle to add an ultrasound to but I've just got too much other stuff going on to spend much time on it.

    An ultrasound echo from a forward facing sensor will return to the sensor a little sooner (<2%) than from a stationary vehicle. The frequency would also shift a little bit, but I don't think 10 ft/s is enough to cause the sensor trouble. A side facing sensor might have trouble since the robot might not be in the right place to detect the echo.

    Since I'm working on quadcopter stuff right now, I might use one to test ultrasound sensors a higher speeds. I don't think a quadcopter will have trouble flying 10 ft/s.

    I think we need some sort of wager to make this more interesting.

    Sorry IllidanxD for hijacking the thread (but it's mostly erco's fault).
  • ercoerco Posts: 20,256
    edited 2012-08-09 01:53
    Duane Degn wrote: »
    Since I'm working on quadcopter stuff right now, I might use one to test ultrasound sensors a higher speeds. I don't think a quadcopter will have trouble flying 10 ft/s.

    Welcome to Tangent City! AFAIK, all the propwash/downdraft/swirling eddies under a quadcopter is REALLY looking for a bloody nose using ultrasonic sensors calibrated for still air! :) Further apologies to the OP for hijacking, but now it's fully Duane's fault for bringing quadrotors into a thread about cars.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-08-09 06:23
    erco wrote: »
    AFAIK, all the propwash/downdraft/swirling eddies under a quadcopter is REALLY looking for a bloody nose using ultrasonic sensors calibrated for still air!

    Propwash? Hogwash!

    I blasted my Ping with both room temperature air and hot air from my heatgun while using the Ping to take measurements. The Ping didn't give a hoot about having air blow at it or across it. I will admit there was only a few inches of moving air the ultrasound waves had to pass through but the air was moving pretty fast. I don't think 10 ft/s movement nor propwash is going to present a significant problem for ultrasound sensors.

    My little $100 HobbyKing quadcopter could lift a couple of ultrasound sensors, so I'll be testing this out relatively soon. I'll also add some ultrasound sensors to my new Elev-8 once I get it built. I'll post my results in a new thread before this one ends up in Cuba.
  • ercoerco Posts: 20,256
    edited 2012-08-09 08:32
    Duane Degn wrote: »
    Propwash? Hogwash!

    The Force is strong with this one! Duane, I love good strong convictions and a firm challenge. My past learnings include PhiPi making a believer out of me in encoders for differential drive to go straight, then I got fiesty and dug in when someone said a BS2 couldn't track a quad encoder at high speed. You have empirical tests, I only have accumulated the comments of the forumistas. Perhaps there's more to your passionate claims than meets the eye!
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-08-09 09:34
    erco wrote: »
    I love good strong convictions and a firm challenge.

    I find strong convictions also give crow a much stronger taste whenever I have to eat it.

    I recently learned the board that comes with the Elev-8 can use ultrasound to aid in it's altitude control.

    I'm adding connectors for ultrasound to my Propeller powered quadcopter daughter board to use with my $100 quadcopter right now. The original purpose of the Prop board was to control some LEDs. Now it will also monitor some ultrasound sensors. I'll probably use the LEDs (RGB) to display altitude and distance information.

    Are we in Cuba yet?
  • ercoerco Posts: 20,256
    edited 2012-08-09 11:00
    Duane Degn wrote: »
    Are we in Cuba yet?

    A funny thing happened on our way to Chaco Canyon: Cuba, New Mexico! I just happened to have a T-shirt from my Cuban buddy's restaurant.
    653 x 490 - 66K
Sign In or Register to comment.