It was only a matter of time...
I merged my MIDI-playing code with my scooter-driving code and put them both on the new, rad-hardened 3ph v3.1 controller. A brief summary of what exactly is going on here:
- Laptop program parses a MIDI file and I choose three tracks that look interesting.
- XBee radio streams MIDI data wirelessly to the motor controller.
- Motor controller uses the frequency of the MIDI note as the PWM frequency.
- Each phase corresponds to one MIDI track. Three phases can play three tracks simultaneously.
For kicks, here's the code for both ends of the system.
Because the PWM frequency is independent of the motor speed, this all happens more-or-less in the background while the regular motor control algorithm runs in the foreground. Meaning, I can ride the scooter around at low speeds without noticing any difference in performance. At high speeds, when the note frequencies get close to the commutation frequencies, bad things would happen.
The real motivation for this was to demonstrate just how much extra processing power there is to be squandered in this motor control setup. The MIDI routine now dominates both the processor usage and the data bandwidth. The motor controller itself, which is full field-oriented sinusoidal control, runs in the leftover gaps, and is still fast enough to execute a 1kHz current/torque controller. Yay 32-bit processors.