Firmware                                                                        Latest change 2017-09-16
 
In brief:
Some notes about the Arduino firmwares.
Download the firmware for the BobControl Unit  and/or  for the Power Unit.  See remarks about the  Development Environments  I used.

Bob Control.
Most of the work is done in an interrupt routine ISR(TIMER1_COMPA_vect) called at a 20 kHz rate.
In successive calls the 6 AD-channels are converted, so we have effectively a 3.33 kHz sample frequency. I use 8 bit A/D conversions here.
The values from the Hall sensors are not further processed, they go into the message as they are.
The Center signal is at half-scale when the Bob is far away. When the Bob approaches, the signal rises at first and goes down through the midscale level when the Bob is exactly over the Center Coil. While waiting for this to happen the peak value is measured and frozen until the message can be sent.
After the Center Pass has been detected the first message will contain the time of passing derived from the 32-bit CounterAbs, which just counts 20 kHz ticks. Also the CounterDrv is set to zero to start a new sequence for timing the Drive pulse, the Leds and the Camera trigger.

The Rim signal also rises when the Bob approaches, but it is at its peak value when the Bob is just over the Rim Coil. So after we see the signal rise a bit we wait until it is going down again. At that moment the Rim Pass time and amplitude are entered into the first next message.

The loop() function looks for incoming bytes. If the byte has a value of 1 then more bytes are expected, containing the settings for the several timings.
Every message is responded to, either by sending Hall values, CenterPass information or RimPass information.

There is a mechanism to check for communication time-out. The GUI sends messages in a 10 Hz rate. When for 1 second no messages have been seen the Drive pulsing is disabled and a status bit is set for the next outgoing message.

PowerMonitor.
Here the interrupt routine is running at a 100 Hz rate and doing 10-bit A/D conversions.
The message mechanism is much the same as with the BobControl firmware, but messages from the GUI contain only 1 byte. Value 0x80 means to switch off the mains power supply for battery testing. The A/D converted values are sent as such to the GUI. Calculations to get voltages and currents in Volts and Amperes are done in the GUI.

The Dallas 18B20 temperature sensors are read every 2 seconds. Note that I used 2 Arduino pins, one for pulling the line low by a BS170 fet, and the other for sensing the output of the sensor.
The ID's of the sensors are hard coded.