Software Design
Our initial design was to use the Handyboard for all aspects of sensing, feedback and control. To accomplish this end we would need only to condition the input signal from each sense coil to eliminate noise, and fall within the analog input range of 0-5VDC. As we tested a rough prototype with the software, we encountered a number of issues, that eventually caused us to shift our design to a totally analog feedback control system.
The original design
To control each fin, the Handyboard would calculate an error signal to supply to motor coils through one of the four full H-Bridge outputs. This signal is calculated based on the difference between a carrier signal, the desired position, and the integrated sense coil values, the actual fin position.
At boot, the Handyboard generates a lookup table of sinusoidal values which will become the carrier signal as the main control program iteratively steps through the table. These calculations are made before the actual control of the fin would occur to amortize the expensive floating point calculations of the system, and allow real-time processing using only integer arithmetic.
When running, the Handyboard would poll its analog inputs to integrate the sense coil positions. In parallel, it would also generate the carrier signal, by stepping through the lookup table. The phase shift of each subsequent fin is accomplished by using a fixed offset from the carrier signal being read by the error processing threads. For example: Fin 1 should be at position lookup[t], Fin 2 at position lookup[t+offset], Fin 3 at lookup[t+2*offset].
A set of error threads would constantly check the difference between the position values, and the current lookup position. This value is then supplied to the H-Bridges to make necessary corrections to the fins.
A flaw in the ointment
One of the first tests that we tried was to run a prototype fin with open loop control from the Handyboard. Unfortunately, we weren't able to emulate the smooth motion that could be achieved with open loop control based on a function generator. Given a true sine wave from a function generator (supplied directly to the motor coil of the fin), the fin would smoothly move back and forth. When we generated a sinusoidal output from the Handyboard, we saw the fin violently jerk back and forth from one stop to the other. What was being supplied from the Handyboard was a PWM signal, with a time-varying duty cycle, shooting between +/-12VDC, rather than a true time-varying voltage.
At first we were sidetracked by the availability of only 8 different power levels supplied by the standard interactive-c libraries. This produced a relatively jerky version of duty cycles. This however, was not a major obstacle, as a replacement library is available from the Handyboard web site that allows significantly more levels of quantization. With this new library, we were able to achieve slightly better results, but the fin still exhibited jerky motion.
Closing the loop
With the hope that some level of closed loop control might enable smoother motion, we made experiments with a closed loop control system. In our test setup, we chose to use an op-amp based integrator circuit to remove the burden of polling the sense loops from the Handyboard. With multiple concurrent processes running, we were uncertain how accurate a polling-based integrator might be. One of the first tests with closed-loop control was to see if the Handyboard could keep a fin in a specified position. This basically meant that our carrier signal values, i.e. our lookup table was at only one constant value: the fin should stay centered when positioned upright.
At first, the fin would remain upright, but as it would start to move in one direction, it then jerked back in the opposite as the handyboard moved to correct the fin's position. This continued until the fin rapidly slammed back and forth from one extreme to the other: The Handyboard could not correctly detect the fin position, and produce a correction fast enough such that it could retain control of the fin. Since one individual fin takes little force to move back and forth, it seemed as though the Handyboard could not make its corrections fast enough or subtle enough as to not cause the fin to oscillate out of control.
Part of this problem comes from the fact that the voltage applied to the motor coil, and the resulting torque on the fin is not constant. A small applied voltage when the fin is upright (balanced between antiparallel magnetic fields) causes a greater force than that of an angled fin (biased towards one field). This is because at center, the fin faces its greatest change in flux with a movement in either direction. As the fin moves closer to saturation in one field, the rotational motion of the fin yields a diminishing change in the change in flux.
When the fin is centered, the shortest imitable pulse of a motor, using interactive-c { motor(x,1); ao(); } causes the fin to shoot completely to one side. (The +/-12-volt output of the H-bridges provides too much power for the fin.) When the fin is far to one side, the same pulse has little effect on the fin. As best observed, a sin(x)^3 or of higher odd power carrier-signal function could be used to swing the fin in a smooth motion. The exponent on the sine wave narrows the peaks (when the fin is at its extremes) and flattens the troughs (when the fin is towards center). What this basically translates to is applying power to the fin only when the fin is at its extremes. When the fin is towards center it must be free-swinging.
The complexity of this control structure, coupled with the low torque achieved led us to abandon our efforts of digital feedback control and concentrate on an analog system that we knew would work.
The Black Ghosts