The control software is written in C++ using the Arduino compiler on a MAC.
In manual mode it reads the 3 channels from the radio control for speed, direction and mode and drives the PWM for motor speed and direction control as well as switching the directional lights.
In automatic mode, which can be selected by channel 5 on the radio control (default when the R/C transmitter is switched off), the software reads the distance information from the RADAR module, processes it and adjusts the motor controller PWM to slow the loco or bring it to a complete stop depending on the distance to the detected object.
There is also an emergency fail-safe triggered by a button on the front buffer which will bring the loco to an immediate stop if the RADAR fails to detect something.
After an emergency stop the loco will flash its directional lights and will then have to be reset either manually by pressing the red button in the cab or remotely by toggling the mode switch on the radio control transmitter.
|