1 Controlservice: Pseudo-Code For The Controlservice Module
1 Controlservice: Pseudo-Code For The Controlservice Module
1 Controlservice: Pseudo-Code For The Controlservice Module
************************************************************************************
Pseudo-code for the ControlService module
This is a service to implement a control law on yaw rate for the thrust fans, as
well as respond to digital bit commands in the control byte from the controller.
It responds to a brake command and a peripheral command.
InitControlService
Takes a priority number, returns true
PostControlService
Create PostControlService
RunControlService
The parameter it takes in will be ThisEvent and the parameter field of
ThisEvent will be the time that the event occurred. Returns ES_NO_Event.
InitThrustPeriodicTimer
Initializes the periodic timer used for the control law on yaw rate, which updates
the duty cycles for the thrust fans upon every expiration.
1
// Make sure that timer A is disabled
// Set it up in 32bit wide( individ, not concatenated)
// Set up timer A in periodic mode
// Set timeout to SAMPLE_TIME
// Dont enable a local timeout interrupt yet
// Enable timer A wide timer 2 in NVIC (bit2 of EN3, corresponds to bit 98 overall)
// Set priority of interrupt as 1, which is lower than the automatic 0 priority of
other interrupts
// Make sure interrupts are enabled globally
// Kick timer off
End of InitThrustPeriodicTimer
Thunderbolt
Sets the color of the LED ribbons so as to simulate Pikachu shocking the other
pokemon with a lightning attack
ThrustPeriodicTimerISR
Responds to the thrust fan periodic timers expiration by setting the thrust fan
duty cycle based on the FwdReverseByte and LeftRightByte from the controllers
last control message as well as the current yaw rate.
End of ControlService