Slide Whistle 2
Roland PC-200 MIDI Keyboard 3
MIDI Port 4
Digital Signal Processor/Peripheral Interface Controller – dsPIC 30F4013 4
Misc. Chips 4
MCG Brushless Motor- I2383092NC-Z3 5
Motor Power Circuit- Driver 6
Brushless Motor- Encoder 7
Motor Power Circuit- Logic 8
dsPIC Program 10
PID Feedback Control 12
Possible Future Improvements 13
The main purpose of this project was to create a slide whistle which would take in inputs from a MIDI keyboard and the whistle would play said note through a control system. Currently, the system is only using a MIDI keyboard as the user interface, but the goal is to eventually make the slide whistle compatible with the Continuum. The slide whistle will be able to perform most musical effects (Such as vibrato) once the move to Continuum is complete.
The slide whistle is taken from the Fall 2006 project of the same name by Yang Li. While the slide itself was not touched, the original stepper motor was switched out because a stronger, faster motor was desired for better effect. The control signals for the motor, which has three phases, will come from a dsPIC. The dsPIC will refer to hard-coded value locations for finding a note on the slide whistle when a key is pressed on the keyboard. As there is only one slide whistle available at the moment, the program will only recognize the first key pressed if multiple keys are pressed. Given the hard code value, the slide would move to the specified location, which should have been manually set up so that the note at the location matches the key played from the MIDI keyboard.
The whistle itself takes in air from a pressure tube at around 100PSI to create sound. The tube has a valve control that will only open when a key has been pressed on the keyboard. The valve will also respond to the velocity (force) with which the key is pressed, opening the orifice at different sizes to create different levels of volume.
The final product will be a slide whistle that can be played using the continuum, with full range of octaves and musical effects.
(Reference: Timing Belt Feed Axis LEZ1)
The slide whistle was bought in its entirety. This component received no additional changes. The motor and coupling are mounted on the side, with an additional foothold for the whistle also on the side, as shown in Figure 1.
Figure 1 – Side View of Slide Whistle
Originally, because the motor in use was a stepper motor, the coupling was a small one as the output power from the motor would not cause an issue with slipping. After the motor was changed out for a much stronger one, the coupling had to be changed to ensure that slipping won’t occur unless the system was run at higher voltages.
Figure 2 – Close Up View of coupling
Roland PC-200 MIDI Keyboard
This is a basic MIDI keyboard. The keyboard’s output will be received by the dsPIC and through software be converted into a hard-coded value that corresponds to a location on the slide whistle.
This component connects the MIDI keyboard and feed the output to the dsPIC for processing. The circuit is presented in figure 3.
Figure 3 – MIDI Port Circuitry
Digital Signal Processor/Peripheral Interface Controller – dsPIC 30F4013
(Reference: dsPIC30F Family Reference Manual, dsPIC30F/33F Programmer’s Reference Manual, dsPIC30F3014/4013 Data Sheet)
A hybrid between a PIC and a DSP, the dsPIC offers easy interfacing options, a familiar instruction set, and essential DSP functionalities. The 30F4013 is a 16-bit fixed-point dsPIC capable of up to 30 MIPS operation, with 2 KB on-chip RAM, two 40-bit accumulators, single cycle multipliers and barrel shifters, three timer modules, two UART modules, and 13-channel 12-bit A/D capable of up to 200 ks/s conversion rate. It is used in this project to process the MIDI keyboard inputs, and to interface with the computer.
7.3728MHz crystal oscillator for the dsPIC.
Two 7486N for the BLDC logic circuit
Two 7408N for the BLDC logic circuit
One 74HC00N for the BLDC logic circuit
Six TIP142 for the BLDC driver circuit
Six TIP147 for the BLDC driver circuit
MCG Brushless Motor- I2383092NC-Z3
(Reference: I2383092NC Wiring Diagram, Z-Series Commutation Encoder)
The I2380 series NEMA 23 motors is a medium inertia motor capable of high speed operation.
Capable of low buss voltage applications
Voltage rating up to 170 Vdc for offline drives
Precision servo and power transmission gearing
Figure 4 – Complete Motor Power Circuit
Motor Power Circuit- Driver
(Reference: AN885 Brushless DC (BLDC) Motor Fundamentals, AN1130 INTRODUCTION TO SENSORLESS BRUSHLESS DC MOTOR DRIVE APPLICATIONS WITH THE ST72141, AN42004 Using the ML4425/ML4426 BLDC Motor Controllers, EMS Ch.12 Brushless DC Motors)
The BLDC driver, in figure 6, is made of three half bridges, named A, B, and C from left to right, respectively. The phases are shown in figure 5 below.
Figure 5 – Motor Coil Windings
The half bridge design is made of 12 transistors pairings, with every two pairs corresponding to a coil. The half bridge design is required because to be able to drive each coil in its different modes (Forward, Backward, Off), a design that can turn the transistors on or off for each corresponding coil is necessary.
Transistors Q7 and Q2 would correspond to the high-side gate for coil A.
Transistors Q9 and Q1 would correspond to the high-side gate for coil B.
Transistors Q12 and Q3 would correspond to the high-side gate for coil C.
Transistors Q4 and Q8 would correspond to the low-side gate for coil A.
Transistors Q5 and Q10 would correspond to the low-side gate for coil B.
Transistors Q6 and Q11 would correspond to the low-side gate for coil C.
Therefore, based on figure 6, if a current is to be driven from A to B, while disconnecting C, A-high (Q7 and Q2) and B-low (Q5 and Q10) would need to be turned on, while all other transistors should be turned off.
Figure 6 – BLDC Driver Circuit
The design required a transistor pairing per gate is because dsPIC cannot provide/sink as much current as this specific design requires, thus we allow the outer transistor to be driven by the sink current from the dsPIC, which would in turn output a larger current to drive the inner transistor.
Brushless Motor- Encoder
The following figure shows the output for each of the phases. The output U, V, W corresponds to the referred variables A, B, C, respectively. With information from the encoder, the current fed through the BLDC driver circuit will change accordingly so the motor can move in the correct manner.
Figure 7 – Brushless Motor Encoder Output waveforms
Motor Power Circuit- Logic
The circuit will match the following states for correct operation.
Figure 8 – Motor States progression
Based on the sensor input, the current entry and output will be from different phases. The following is a table of the conversion from the left of the chart to the right.
Ch = CA’
Cl = AC’
Bh = BC’
Bl = CB’
Ah = AB’
Al = BA’
The software program would be based on the above information to generate the correct current flow to move the motor in the desired direction.
Figure 9 is the circuit of the above logic.
Figure 9 – BLDC Logic Circuit
The dsPIC is used to precisely position the BLDC motor and control the solenoid valve. Inputs from the MIDI keyboard, specifically, KeyOn, KeyOff, Volume, and PitchBend MIDI messages, are intercepted by the dsPIC through its UART2 module. A position on the slide is generated according to the currently pressed key, and the amount of pitch bend applied to it. That position is set as the reference, or destination, to the PID controller implemented on the same dsPIC. Concurrently, the dsPIC monitors the feedback from the incremental encoder attached to the motor; its reading is used by the PID controller as the current position, or feedback. The PID controller samples every 1/2000 of a second, and updates the driving voltage based on the current error between destination and feedback, as well as the same error from the previous sample. This controller regulates the slide to be positioned within ±0.06mm.
Meanwhile, depending on the states of the key presses, the dsPIC also outputs an on/off control to a solenoid valve. When it is opened, the slide whistle is blown.
The dsPIC also receives input from the PC through its UART1 module. This is primarily used during tuning. The PC can specify a slide position in 16-bit fractional representation, and send it through the serial port; this will override the destination in the dsPIC, and cause the slide to move to the corresponding position. Also, if -1 is passed through the interface, the valve will be forced to toggle its state. In this way, one can manually position the slide and blow the whistle; then, using human intonation or pitch-detection software, he can determine the correct positions for different notes.
Figure 10: Flow Charts of the dsPIC Program
PID Feedback Control
For theories of PID control, refer to the references found in the “PID Controller” page in Wikipedia (http://en.wikipedia.org/wiki/PID_controller). The PID controller used here is of the ideal form, with coefficients:
Kp = 64
Ki = 62.5
Kd = 0.128
The coefficients are set as such partly in order to simplify computation. The feedback is sampled at 2 KHz, and the integral and derivative are generated using discrete approximations:
So in code, the first difference of the error is to be first multiplied by 2000, and then multiplied by 0.128 to form the derivative term in the controller; this results in a net multiplication by 256, which is accomplished by a simple left shift by 8. Similarly, the sum of all error is to be first divided by 2000, and then multiplied by 62.5 to form the integral term in the controller; this results in a net division by 32, which is equivalent to a right shift by 5. This way, the controller is implemented without any multiply-accumulate needed.
Additional encoder on other side of slide whistle – Current design only has one encode on the side of the motor for determining the location of the slide explicitly. This configuration means that slipping due to the coupling between the motor and slide is not taken into account, and if driven at too high of a voltage, will cause the whistle to become out-of-tune. The solution is to add an encoder to the slide, so that the tracking is of the actual slide location, rather than location based on the amount of movement caused by the motor.
New valve – Current valve’s orifice is too small to allow for good range of volume when taking into account key velocity. Trying to play a soft note will result in too little air being released, resulting in unclear notes. We will still need to look up a suitable replacement for the current one.
Fix tone – Current whistle does not have a wide range of octaves, and at higher notes the sound is extremely airy. The current whistle will either need to be worked on, or a new whistle will be needed.