Requirements for APS State Machine
State Machine should have its own task in freertos
- Listen for critical inputs
- check current state and data
- determine whether to change state or remain in current state
Current states:
- Sleep
- Wake
- Safe
- Armed
Sub-functions in State Task will perform internal tasks
APS must have different states
Sleep Mode
- Wake Mode
- Safe Mode
- Armed Mode
Sleep Mode
- Powered off
- Able to be powered up by remote signal
- Very low current draw on battery
Wake Mode
- Powered up
- Check of systems, environment
- Initializations
Safe Mode
- Initialization complete
- External system communication normal
- Ready for armed state
- Physically locked out of armed state by ground pin or other device
Armed Mode
- Ready for launch
- Crew safety top priority
- Keep safety margins
- All work should be remote
Testing Algorithm for APS State Machine
Pseudocode for rough draft of APS state machine
enum aps_state //easier to use real names when referring to states
- sleep = 0
- wake
- safe
- armed
variable rocket_mode = sleep //could init into other state if desired
task apssm_task
get data from environment checklist
change state depending on data //for demo, use buttons
if button 1 triggered
switch rocket_mode
case sleep: rocket_mode++, output new mode to serial
case wake: rocket_mode++, output new mode to serial
case safe: rocket_mode++, output new mode to serial
case armed: rocket_mode = sleep, output new mode to serial
end switch
if button 2 triggered
rocket_mode = sleep //simulate reset sequence
output 'reset event' and new mode to serial
keep looping apssm_task
Error Handling
- Error levels
- Error levels are implemented as a prefix of the error message.
- Error Logs
- The error log is held as a global-scope array of plain text, accessible by all tasks
- Error messages
- Error messages are in the format [prefix][message][unique detail]
- Error messages are the responsibility of the function observing the error.
- Functions must report error messages in the correct format
- Functions must report error messages 127 characters or less, and end with a string terminator (null byte)
Serial console
- Request error logs
- Listens to incoming traffic on UART, on receipt of keyword "errors" responds with a dump of error log
- Checking registers
- Stub code in place for this and additional UART command functionality
Battery Management
- Read battery voltages and currents
- Pack voltage
- Cell voltage
- Charge counting into capture timer (charge, calculate amps = charge/delta_T)
- Never turned off unless disconnected
Umbilical
- Monitor shore power
- Rocket Ready signal, SAFETY CRITICAL
- Relays will prevent launch if there are problems
- Any node can give the Scrub Launch signal
Over current monitoring and “circuit breaker” functionality
- All sensors, power supplies (pyro, sps, etc.), communication checks needed before cleared for launch