Thursday, January 12, 2012

Traction Control Part 1.3 - Childs Play.

EDIT: This has turned out to be really cool. Its great being able to take a car along on a walk with the kids,  drive it flat out and then be able to hand the controls to my two year old or three year old. All I have to do is hold the brake for a few seconds and the car will discretely switch into 'Child Mode'. Read on for details ...

If your a dad its great when your kids show some interest in any of your hobbies, but when a three year old takes control of your race car it can be a short lived and expensive experience.

Can I Have A Go ?


This is an open source project, based on open source hardware, but here is a project pitch anyway -

Wouldn't it be great if you could set you car to a lower 'child' speed even if it was at the other end of the park ?

You can now put your car into 'Child Mode' or back to 'Dad Mode' anywhere within range of your transmitter.

Turn RC Day into family day and protect your investment from children, wives and learner drivers of all ages !


There is no need to modify any of your existing components, just plug your receiver throttle channel into the Arduino and likewise connect your ESC to the Arduino.

Features
  • Remotely toggle between restricted power 'Child Mode' and full power 'Dad Mode'
  • Uses standard RC Equipment
  • No Modification of existing equipment required
  • Plug and play self calibration for quick changes between different models
  • Independently adjustable forward and brake/reverse power settings
  • 'Child Mode' Restricts the power available while still retaining proportional control through the full range of your controller
  • No additional RC Equipment required, takes its power from the existing car battery.


    How does it work ?

    The radio control equipment that steers and powers your vehicle uses on/off pulses to control the power and direction of your car. In general a pulse that is 1500ms wide is the center or neutral point, full throttle is around 2000ms and full brake or reverse is around 1000ms. These pulses are sent a steady 40 or 50 times per second, only the pulse width varies, not the frequency.

    In standard 'Dad' mode, the Arduino reads the incoming signal and outputs a signal of the same pulse width to the ESC, the Adruino is effectively operating in straight through mode (blue line in chart below).



    In 'Child Mode', the Arduino reads the incoming signal but generates an output signal based a scaling factor anywhere from 20% to 100%. The scale factor is separately adjustable for forwards and reverse, allowing any combination for example 50% forward power with full 100%  brake/reverse power (red line in graph) or 20% power in both directions (green line in graph).


    Operation

    The software is designed to start up in 'Dad Mode', as the car is driven, the software will monitor the maximum and minimum pulse width received in order to determine the full throttle and full brake settings.

    How do you keep your paint as fresh as this ? Try 'Child Mode'
    When the system switches to child mode, it will deliver only a percentage of the power available. The percentage delivered is determined through two rotary adjusters one for forwards power and one for reverse/brake power.The power delivery is scaled so that full proportional control is retained, for example if the power is set to 50% the system will deliver 50% of the input signal at 100% input, 45% at 90% input, 25% at 50% input etc. This allows the user to build experience in the proportional control of a performance model. As the user becomes more proficient, so the available power can be increased through the built in rotary adjusters.

    To switch between 'child' and 'dad' mode, simply hold the brake for about 5 seconds and you will see the green child mode light indicating that the car is now in restricted mode. To return to standard mode, hold the brake again and wait for the light to go out.

    The Circuit

    The circuit is extremely simple using only the following components and Arduino PINs

    • Two LEDs with current limiting resistors as status indicators
    • Two variable resistors connected to two Arduino analogue inputs as the forward and reserve power adjusters
    • A single Arduino interrupt to read the incoming servo signal
    • A single Arduino PWM Pin to generate the outgoing servo signal
    • Power is from the LIPO battery in the car
    The PIN assignments can be read from the code comments, the assigments are created through #define statements and so can easily be changed to suite an alternative layout.


    Installed and road tested in my Tamiya M03 Race Car


    The Code

    The code is again very simple, whereever possible I have used meaningful names for variables and functions, its not that I like typing, I really dislike reading code, more typing now means less reading in the future.

    The three novel features are -

    1) EEPROM Error Log - I have a small 10 Byte area reserved in the EEPROM to record errors. Its round robin so will overwrite itself rather than overflow. On startup the software will send the 10 Bytes to serial to allow post run diagnostics if required, the log is cleared as it is sent so each run starts with a clear log.

    2) Confidence - During my bench testing I noticed that the input signal as measured by the Arduino wanders around by +- 4 or 8 ms. If I treat each of these as a new command to the ESC, I get a lot of jitter. To smooth this and reduce the number of calls to Servo.writeMicroseconds, I have a very simple algorithm which maintains a 'confidence' level that an incoming signal is meaningful - its not very complex and is only designed to filter out random wandering around the current value.

    3) Be bad, but not very bad - In early versions of the project the software would enter an error mode and put the car in neutral after receiving a single bad pulse. I have now introduced a bad pulse tolerance which allows the system to soak up noise that can't be avoided for example from crossing underground cables etc.
     

    Further Development

    For my purposes this project is a simple test of using the Arduino to interface between a hobby quality radio controlled car receiver and electronic speed controller or servo.

    The project proves that -

    1) It is feasible to read, process and output the throttle signal in realtime using the Arduino platform
    2) Electrical noise can be managed so that it is not an issue

    The next step for me is to implement 'active traction control' based on the wheel speed monitoring previously described in Part 1.1, however there are some potentially interesting further developments to this for example 'passive traction control'.

    Passive Traction Control Project Suggestion 1 - Mulitple Acceleration Profiles




    The existing code and circuit forms the basis for a passive traction control system. One simple project idea is to provide the car with different acceleration modes or profiles to suite different surfaces. The Arduino would read the desired throttle level from the receiver but would control the rate at which the output signal seeks the level of the input signal - on a dirt setting this rate of change would be low, on a tarmac setting a higher rate of change would be possible - this could be fine tuned in car using the existing circuit potentiometers.

    Passive Traction Control Project Suggestion 2 - Brake Pressure Profiling



    When a car is traveling at high speed, the brakes can be applied powerfully, however as the car slows down the brake pressure should be reduced to avoid the brakes locking up. This is a particular problem for RWD radio controlled cars which are prone to locking the rear wheels and spinning out under braking. In this project, the Arduino would monitor the input signal for maximum brake, it will initially output a maximum brake signal, but will begin to fade this signal for the duration of the brake command. The rate of fade and the target value - around 30% brake force for my M-04 could be adjusted in car using potentiometers. 

    These two passive projects will be less effective than an active solution which monitors wheel speed however they are developments of the existing project that provide an incremental challenge. I will skip these developments and continue with the active version but feel free to use my code to explore these approaches.

    The Hardware
    The project is currently running an on Arduino UNO, this is a USB programmable version of the Arduino that costs around 20 dollars. This is an easy to use development board, but now that the code is finalised it can be run on a PCB or strip board based Arduino that is smaller, lighter and best of all can be built from components that cost less than 10 dollars.

    Child Mode/Traction Control Circuit - Version 1

    Top left - decoupling capacitors
    Bottom left - mode and operational indicator LEDs
    Center - Forwards and Reverse Child Mode max power adjustment
    Right of center - connections for wheel speed sensors for all four wheels in traction control mode
    Bottom right - 3 Pin headers for ESC Input and Output.

    Child Mode/Traction Control Circuit - Version 2

    Top Left - Power to the Arduino comes from the 8.4V Lipo battery in the car, it passes through this circuit on its way and is decoupled by the .01 .1 1 and 47 uf capacitors in the top left of the picture.
    Top Left - Next to the decouplind capacitors are two strips of three pin PCB Headers, these are used to connect the throttle channel of the RC Car receiver to Arduino interrupt 0 and an Arduino output pin to the car ESC signal pin.
    Bottom Left - The two potentiometers are used to adjust the amount of power the Arduino will make available for forwards and reverse throttle in child mode.
    Top Center - Indicator LEDs, red for error, green for child mode and blue for a glitch or unexpected pulse that is within operating tolerance, its really an information signal telling me that the signal environment is dirty but not so much that we need to treat it as an error condition.
    On the right hand side are the connections for the four wheel speed sensors. These are not used in the child mode project but are used in the ongoing traction control project.


    No comments:

    Post a Comment