Difference between revisions of "ECUs Emergency"
(→SHR7 Decoder/Transmitter) |
(→SHR7 Decoder/Transmitter) |
||
Line 22: | Line 22: | ||
* Power consumption: 6,4mA | * Power consumption: 6,4mA | ||
− | For more Information read [[File: | + | For more Information read [[File:Shr7.pdf|this documentation (PDF)]] |
=== Software Component === | === Software Component === |
Revision as of 09:10, 23 April 2010
The Emergency Break Board gives a chance to remote stop the car. It is mostly independent from the other parts. Also its electric circuit is not connected to the main power supply system, so it will still work, when the other systems don't work any more. The Emergency Signal is given by an extra radio transmitter, sending on a frequency other then the main control unit.
Contents
Usage
Pushing any of the 3 Buttons on the emergency remote control sets the car in a stop mode. Changes on the main remote control do not affect the cars state. Only if all 3 Buttons are pushed on the emergency remote control, the car will leave the stop mode and reset to running mode. At
How the Emergency Board works
The Emergency Board sits between the acceleration and the steering control boards, and the active parts (motor and steering). If an emergency signal arrives, the signals that come from the control boards are being replaced with stop signals generated from the emergency board itself. The replacement is done by simply switching a multiplexer.
The signal transmitting part works with a SHR7 decoder board and a fully assembled transmitter unit. The decoder board receives the signal from the transmitter and generates a code that contains information on the sending device and on which buttons on the 3-button-control were pushed.
Electrical Information
Emergency Board
SHR7 Decoder/Transmitter
The SHR-7 Decoder receives signals via the 433,920 MHz band and decodes them to a digital signal.
Technical Data:
- Sending via 433,920 MHz
- Bandwidth: 20 Hz to 2kHz
- Current: 7 to 14 V DC
- Power consumption: 6,4mA
For more Information read File:Shr7.pdf
Software Component
The main task of the software running on the Atmega88 is to decode the signals from the shr7 decoder and decide whether to switch the running/stop state.
The hole process is split into three main parts:
- Analyze signals arriving from the shr7 decoder
- Prove signals arrive in correct order and decode signals
- Switch the state of the car (run - stop)
Analyze signals arriving from the shr7 decoder
The signals arriving from the shr7 decoder can be split to 4 different codes, as shown in the next Figure:
- Synchronization (S)
- The signal is lead by a synchronization preamble. Before each signal, there is a high-signal period of at least two long signal-time-periods.
- -, +, 0
- Each of the other signals - in the further text, referred to as characters - are represented by the times between 4 signal rise and falls.
The decoding is done by a interrupt service routine, that is called every time, a change of the incoming signal from the shr7 decoder occurs. The service routine measures the time between each call. After measuring enough times (9 or 4), the routine can decide whether a synchronization, a plus, a minus or a zero character has been sent. The received characters are then written to the State Machine input tape (discussed later on).
Prove correct order and validity of received characters through State Machine and decode
Each packet from the shr7 decoder can be split up into 5 parts:
- One character Start Synchronization
- Nine characters Identification of the transmitter (8 chars ID + 1 syn)
- Four characters Middle Synchronization
- Three characters each representing the
- Two characters end synchronization
These parts can be represented by states in a state machine:
In the source code, the input tape is represented by a ring buffer "inputTape". Due to the definite higher frequency of the main loop, this buffer can be very small. But you must be sure, to never get stuck in a state, that does no reading from the buffer.
State: INIT
Initialization State resets all values. Its only transition is to the STARTSYNC State via an empty input (eps).
State: STARTSYNC
The Startsynchronization State waits (no active waiting) until the character 'S' (for Synchronization) was sent to the tape. After receiving 'S', state will be changed to GETID.
State: GETID
After Synchronization was sent, GETID awaits 9 characters to be sent. For characters 1 to 5 and 7 to 9 values '+','-' and '0' are valid, for character 6 only '-' will lead to success. If this State was passed successfully, the state will switch to MIDSYNC. If an error occured, state will switch to ERROR State.
State: MIDSYNC
MIDSYNC State awaits for signals for middle synchronization. Three times '0' and the last character is '-'. If an error occurs, in the case of an invalid character, state will switch to ERROR; else to the next State GETBFLAG.
State: GETBFLAG
This State waits until three characters '0','+' or '-' are received. These three characters represent the buttons that are pushed on the transmitter. These characters are saved to a variable, because they are needed in state CHANGE_CAR_STATE.
State is switched to ENDSYNC if nothing bad happened; or to ERROR if so.
State: ENDSYNC
The last receiving state waits until "00" is sent via the tape. If successfull, switch to CHANGE_CAR_STATE, otherwise switch to ERROR.
State: CHANGE_CAR_STATE
In this state, we decide whether to set the car to start, or to stop mode. This is further described in the next section. This states only transition is to INIT with no input.
State: ERROR
In this state errors and invalid inputs can be catched. At the moment, this state simply gives a short signal to the EmergencyLED. After that, state is again switched to INIT.
Switch the cars running state
In SM state "CHANGE_CAR_STATE" we decide whether to start or stop the car, depending on the number of buttons pushed at the time and on the current state of the car (you don't need to set the car stop mode multiple times). If switching from run to stop mode, the incoming control signal from the control boards, are being replaced by the boards own stop signal (corresponding PWM signal described in earlier section). Therefore the pin, connected to the control signal MUX is set to Vcc (1). If switching from stop to run mode, this procedure is simply repeated reverse (Set MUX pin to Gnd (0)). The mode switching is done via two self describing functions setStartMode() and setStopMode().