Skip to content

Power up sequence

Tim Long edited this page Jan 22, 2021 · 1 revision

Power-up Sequence

Recommended Sequence

The recommended power-up sequence is:

  1. Power up the rotator module
  2. Wait 20-30 seconds
  3. Power up the shutter module

Explanation

When the firmware starts up, it must configure teh XBee radio and negotiate a two-way connection with the other module. This process takes a little time and is non-trivial. The firmware is designed to automatically recover from loss of communications and to retry until a connection is established. The XBee state machine prints out the name of each state as it is entered, in the form XB->state-name. This is a useful diagnostic and also allows a client application to detect and display the connection state.

What follows is a simplified description of the firmware and XBee start-up process.

Rotator and Shutter

  1. Wait for the XBee to fully reset (~ 2 seconds) XB->Start
  2. Connect to the XBee and send a series of configuration commands (~ 5 seconds) XB->WaitAT, XB->Config

The process then continues differently in each unit. The rotator assumes the role of "coordinator" node while the shutter becomes a "slave" node.

Rotator

  1. Wait for the XBee to perform a Clear Channel Scan and select a coordinator channel (~ 15 to 20 seconds).
  2. Listen for a shutter "hello" message and learn its unique address (up to 30 seconds). XB->Detect
  3. Send an acknowledgement message XB->Online

Shutter:

  1. Instruct the XBee to scan for coordinators (rotators) and select the strongest signal (~ 15 to 20 seconds) XB->WaitAssociate
  2. Wait for an association notification and learn the coordinator's unique address XB->Associated. If none found, reset and start from step 2, otherwise send a "hello" message
  3. Wait for an acknowledgement XB->Online. If none received, reset and go to step 2.

Thereafter, the two units communicate directly using unique addresses, rather than using broadcasts. The "Hello"/Acknowledge handshake repeats about every 8 seconds and the firmware will report XB->Online when it completes successfully. A client application is able to monitor this output and detect the connection state. If the rotator does not receive a "Hello" message for 2 cycles (~ 16 seconds), then it resets the XBee and starts from step 2. If the shutter does not receive an acknowledgement within a short time of sending "Hello", then it resets the XBee and starts from step 2.

The fastest possible start-up will be achieved if the shutter is powered up just after the rotator has selected its channel, which is about 21 seconds after power-up. The shutter will still take about 15 seconds to associate with the rotator.

The worst-case startup time will occur if the shutter times out in step 3 just before the rotator selects its channel, or if the shutter successfully binds to the coordinator but then the coordinator moves to a different channel. The recovery time is a little difficult to predict because it depends on where the two units were in their cycle and whether they are "in phase". The state machines in each unit have deliberately different timings to stop them getting exactly out-of-sync with each other and never being able to associate. In the worst case, it is possible for the recovery to take 2 to 3 cycles of 20 - 40 seconds, so about 1 to 2 minutes.

Therefore, the shortest possible start-up time is about 35 seconds, while the longest is at least 2 minutes.