PIC Mapping for : ************************ Hurdy = midi channel 9 (offset 0) ----------------------------------- Version 1.1 - 19.06.2004 Version 1.2 - 28.06.2004... Version 2.0 - 02.2007, PIC4 added. Version 2.1 - 01.11.2007 [to do] Problemen-logboek: Version 1.0 log: 1. PIC1: werkt in grote lijnen, maar regelmatig geeft ie het op en reageert niet meer op midi inputs. (Probleem met cirkulaire buffer in PIC kode???) 2. PIC2: lampjes kode werkt o.k. Motor besturing: verliest om de haverklap de PWM output. Alleen wanneer ik heel vaak alsmaar dezelfde volume kontroller doorstuur, werkt het. Ook de switches verliezen hun logische status, en gaan zelfs in Hi-Z toestand. De PWM loopt geinverteerd! Ook de switches lijken geinverteerd te werken (als ze werken). Motor mag niet reageren op note ON/Note offs. Wel op all notes off. 3. PIC3: dit loopt helemaal niet. Er komt geen PWM uit. Soms -waarom?- wel enkele ON/OFF's, daarna steevast niks meer. Ook hier moet de PWM geinverteerd worden. Key pressure moet ook geimplementeerd zijn! Version 2.0 log: 4. PIC4 tone generator for electromagnetic string activation PIC TYPE: PIC30F3010-I/SP added feature on Hurdy february 2007. ************************************************************ updated 14.03.2007: flageolet implementation debug session 30.10.2007 updated 31.10.2007 - new dampers implemented in hardware. (see webpage) 30.10.2007: BUGS to be solved: [... Johannes] [ PIC4] the transposition mechanism is faulty! When we send higher values for ctrl 20, the pitch goes down! same bug for ctrl 21. Probably we forgot that the transposition, most of the time is a negative value! The normal tuning for the low string is 33, and for the high string 50. Thus the transposition for the low string is in this case -7 and for the high string -14. As it implemented now we get the correct tuning for the low string only by sending: ctrl 20 to 35, leading to the production of note 33 at reception of a note-on command for note 40. It should be: ctrl 20 to 33, leading to the production of note 33 at the reception of note-on for note 40 For the high string, the behaviour is: ctrl 21 to 66, leads to the production of note 50 for the reception of a note-on for note 64 It should be: ctrl 21 to 50, leading to the production of note 50 for the reception of a note-on for note 64. Other improvements: (allowing combined e-drive with the bow mechanism) controller 5: when 0, ctrl 3 is used to set the level of the low string drive. when 1, the velo byte with a note on controls the level of the low string drive when 2, velo controls the pushers as well as the e-drive controller 6: when 0, ctrl 4 is used to set the level of the high string drive when 1, the velo byte with a note on controls the level of the high string drive when 2, velo controls the pushers as well as the e-drive [note: the default must be 0 for these controllers. They also should be implemented on the bow solenoid driver PIC (PIC3), such that when these controllers are set to 1, the bow pushing mechanism for the corresponding string is disabled. With value 2, we can combine both mechanisms. This change makes the use easier for sequencer users. Since ctrl's higher than 64 are normally used as switches, we choose to implement controllers 5 and 6 for this purpose. Changes urgently required in the other PIC's: - PIC1: lookup tables for the note/tangent combinations (for e-drive, it is best to use only a single tangent to cut off the string!) Since we added a felt damper, activation of more than a single tangent is likely no longer required. The lookup tables should be selectable with program change commands. - PIC3: - add appropriate commands for the dampers. (see website) The low string damper is connected to PIC3 pin 2 (RA1) The high string damper is connected to PIC3 pin 3 (RA2) proposed format: [lookups for fingerings] note: 40 0000 0000 0000 0000 0000 0000 41 1000 0000 0000 0000 0000 0000 42 0100 0000 0000 0000 0000 0000 43 0010 0000 0000 0000 0000 0000 etc up to 63 0000 0000 0000 0000 0000 0001 and for the high string latches: 64 0000 0000 0000 0000 0000 0000 0 65 1000 0000 0000 0000 0000 0000 0 etc up to 87 0000 0000 0000 0000 0000 0001 0 88 0000 0000 0000 0000 0000 0000 1 Note that the high string has an extra bit. Practically when have enough with 2 times 3 bytes, since the lookup for the notes 40 and 64 will always be 0. This corresponds to the way the hardware was designed. (3 8-bit latches for each string) Overview: is controlled by 4 PIC controllers: =========================================================================== ==== P I C 1 ============================================================= =========================================================================== PIC1 is used for the tangent solenoids: - 1 data byte (RB0 to RB7, bits flipped), 6 note latch adresses: RA0 to RA5 let n = midi number of lowest note (openstring low string) [40] This pic should behave as follows: on reception of NOTE ON command: ' first string n set bit 0 in latch 0, reset all other bits in latch 0,1,2 (no solenoid connected) n+1 set bit 1 in latch 0, reset all other bits in latch 0,1,2 (solenoid 1 ON) n+2 set bit 2 in latch 0, reset all other bits in latch 0,1,2 (solenoid 2 ON) n+3 set bit 3 in latch 0, reset all other bits in latch 0,1,2 (solenoid 3 ON) n+4 set bit 4 in latch 0, reset all other bits in latch 0,1,2 (solenoid 4 ON) n+5 set bit 5 in latch 0, reset all other bits in latch 0,1,2 (solenoid 5 ON) n+6 set bit 6 in latch 0, reset all other bits in latch 0,1,2 (solenoid 6 ON) n+7 set bit 7 in latch 0, reset all other bits in latch 0,1,2 (solenoid 7 ON) n+8 set bit 0 in latch 1, reset all other bits in latch 0,1,2 (solenoid 8 ON) n+9 set bit 1 in latch 1, reset all other bits in latch 0,1,2 (solenoid 9 ON) n+10 set bit 2 in latch 1, reset all other bits in latch 0,1,2 (solenoid 10 ON) n+11 set bit 3 in latch 1, reset all other bits in latch 0,1,2 (solenoid 11 ON) n+12 set bit 4 in latch 1, reset all other bits in latch 0,1,2 (solenoid 12 ON) n+13 set bit 5 latch 1, bit 1,latch 0, reset other bits in latch 0,1,2 (solenoid 1 & 13 ON) n+14 set bit 6 latch 1, bit 2,latch 0, reset other bits in latch 0,1,2 (solenoid 2 & 14 ON) n+15 set bit 7 latch 1, bit 3,latch 0, reset other bits in latch 0,1,2 (solenoid 3 & 15 ON) n+16 set bit 0 latch 2, bit 4,latch 0, reset other bits in latch 0,1,2 (solenoid 4 & 16 ON) n+17 set bit 1 latch 2, bit 5,latch 0, reset other bits in latch 0,1,2 (solenoid 5 & 17 ON) n+18 set bit 2 latch 2, bit 6,latch 0, reset other bits in latch 0,1,2 (solenoid 6 & 18 ON) n+19 set bit 3 latch 2, bit 7,latch 0, reset other bits in latch 0,1,2 (solenoid 7 & 19 ON) n+20 set bit 4 latch 2, bit 0,latch 1, reset other bits in latch 0,1,2 (solenoid 8 & 20 ON) n+21 set bit 5 latch 2, bit 1,latch 1, reset other bits in latch 0,1,2 (solenoid 9 & 21 ON) n+22 set bit 6 latch 2, bit 2,latch 1, reset other bits in latch 0,1,2 (solenoid 10 & 22 ON) n+23 set bit 7 latch 2, bit 3,latch 1, reset other bits in latch 0,1,2 (solenoid 11 & 23 ON) ' second string: [64-] n+24 set nothing (open string), reset bits in latches 3,4,5 n+25 set bit 0 latch 3, reset other bits in latch 3,4,5 (solenoid 1 ON) n+26 set bit 1 latch 3, reset other bits in latch 3,4,5 (solenoid 2 ON) n+27 set bit 2 latch 3, reset other bits in latch 3,4,5 (solenoid 3 ON) n+28 set bit 3 latch 3, reset other bits in latch 3,4,5 (solenoid 4 ON) n+29 set bit 4 latch 3, reset other bits in latch 3,4,5 (solenoid 5 ON) n+30 set bit 5 latch 3, reset other bits in latch 3,4,5 (solenoid 6 ON) n+31 set bit 6 latch 3, reset other bits in latch 3,4,5 (solenoid 7 ON) n+32 set bit 7 latch 3, reset other bits in latch 3,4,5 (solenoid 8 ON) n+33 set bit 0 latch 4, reset other bits in latch 3,4,5 (solenoid 9 ON) n+34 set bit 1 latch 4, reset other bits in latch 3,4,5 (solenoid 10 ON) n+35 set bit 2 latch 4, reset other bits in latch 3,4,5 (solenoid 11 ON) n+36 set bit 3 latch 4, reset other bits in latch 3,4,5 (solenoid 12 ON) n+37 set bit 4 latch 4, bit 0,latch 3, reset other bits in latch 3,4,5 (solenoid 1 & 13 ON) n+38 set bit 5 latch 4, bit 1,latch 3, reset other bits in latch 3,4,5 (solenoid 2 & 14 ON) n+39 set bit 6 latch 4, bit 2,latch 3, reset other bits in latch 3,4,5 (solenoid 3 & 15 ON) n+40 set bit 7 latch 4, bit 3,latch 3, reset other bits in latch 3,4,5 (solenoid 4 & 16 ON) n+41 set bit 0 latch 5, bit 4,latch 3, reset other bits in latch 3,4,5 (solenoid 5 & 17 ON) n+42 set bit 1 latch 5, bit 5,latch 3, reset other bits in latch 3,4,5 (solenoid 6 & 18 ON) n+43 set bit 2 latch 5, bit 6,latch 3, reset other bits in latch 3,4,5 (solenoid 7 & 19 ON) n+44 set bit 3 latch 5, bit 7,latch 3, reset other bits in latch 3,4,5 (solenoid 8 & 20 ON) n+45 set bit 4 latch 5, bit 0,latch 4, reset other bits in latch 3,4,5 (solenoid 9 & 21 ON) n+46 set bit 5 latch 5, bit 1,latch 4, reset other bits in latch 3,4,5 (solenoid 10 & 22 ON) n+47 set bit 6 latch 5, bit 2,latch 4, reset other bits in latch 3,4,5 (solenoid 11 & 23 ON) n+48 set bit 7 latch 5, bit 3,latch 4, reset other bits in latch 3,4,5 (solenoid 12 & 24 ON) On reception of a note OFF command, nothing should happen in PIC1's code. On reception of all notes OFF, however, all bits should be cleared. take n = 40. [hurdy is a transposing instrument] data-port: RB0-RB7 Port B van de PIC, alle bits geflipt: RB7 ==> D0 pic pin 28 RB6 ==> D1 pic pin 27 RB5 ==> D2 pic pin 26 RB4 ==> D3 pic pin 25 RB3 ==> D4 pic pin 24 RB2 ==> D5 pic pin 23 RB1 ==> D6 pic pin 22 RB0 ==> D7 pic pin 21 =========================================================================== ==== P I C 2 ============================================================= =========================================================================== PIC2 is used for bow motor control (3 output bits, 1 PWM for analog voltage) - 0-10V speed control for Siemens Micromaster 410 on reception of volume controller data: 176+9, 7, data PIC pin 13 The mapping should be such that we have 0-50% PWM for midi-in values 0-100, whereas the 50% to 100% range should be mapped on 101-127. CHANGE IN VERSION 1.2: PWM has to be inverted in the PIC code !!! - start/stop bow motor on reception of 176+9, 66, data (data = 0 or >0) on reception of note-on commands, unless 176+9, 66, 0 was received before. on reception of all notes off, the bit should be reset. PIC pin 2 - RA0 CHANGE IN VERSION 1.2: Bit has to be inverted in PIC code. - CW/CWW direction of bow rotation on reception of 176+9, 67, data (data = 0 or >0) PIC pin 3 - RA1 A change of direction should be preceded by a motor stop command. - new for version 1.2: on reception of 176+9, 68, data (data = 0 or >0) PIC pin 4 - RA2 should be set reset. Also here, the bit has to be inverted on the PIC code level. Following can be removed in version 1.2: - Ack. send on reception of reset: clears error condition on reception of 176+9, 123, 0 (all notes off) PIC pin 4 - RA2 for extra features (lights): - PIC pin 28 - RB7 set/reset bit on reception of Note ON/OFF for note 0 (left frontlight) - PIC pin 27 - RB6 set/reset bit on reception of note ON/OFF for note 1 (right frontlight) - PIC pin 26 - RB5 set/reset bit on reception of 176+9, 92, 0/1 =========================================================================== ==== P I C 3 ============================================================= =========================================================================== PIC3 is used for the bow pusher softshift solenoids (2 PWM outputs) this PIC also steers the felt dampers on both strings. - PIC pin 12 (RC1) - PWM output 0-100% The PWM value should correspond to the velocity byte in the note on command for the note range n to n+23 Note OFF command for this note range should reset the output to 0. - PIC pin 13 (RC2) - PWM output 0-100% The PWM value should correspond to the velocity byte in the note on command for the note range n+24 to n+48 Note OFF command for this note range should reset the output to 0. Keypressure command should be implemented as well, so that we can change bow pressure during a note (midi command sequence 160 + k, note, value). For notes n to n+23, value should be output to PWM1, for notes n+24 to n+48, to PWM2. All-notes-off should reset both PWM outputs. If controller 5 is 1, the pwm for the low string should be disabled If controller 6 is 1, the pwm for the high string should be disabled For extra features: - PIC port RB (8 bit port) To be implemented. data-port: RB0-RB7 Port B van de PIC, alle bits geflipt: RB7 ==> D0 pic pin 28 RB6 ==> D1 pic pin 27 RB5 ==> D2 pic pin 26 RB4 ==> D3 pic pin 25 RB3 ==> D4 pic pin 24 RB2 ==> D5 pic pin 23 RB1 ==> D6 pic pin 22 RB0 ==> D7 pic pin 21 PIC pins used for felt string dampers: - PIC pin 2, port RA0 = low string damper - PIC pin 3, port RA1 = high string damper Behaviour of this damper on reception of note-on's: 40 low string damper OFF 41-51 low string damper ON 52 low string damper OFF 53-63 low string damper ON 64 high string damper OFF 65-75 high string damper ON 76 high string damper OFF 77-87 high string damper ON 88 high string damper OFF Behaviour of these dampers on reception of note-off's: If the sustain pedal controller (ctr64) is False then: 40-63: damper low string on on reception of a note off 64-88: damper high string on, on reception of a note off else no damping on note-off's (so release dampers always!) endif =========================================================================== ==== P I C 4 ============================================================= =========================================================================== This PIC controls the e-drive for both strings. Note ON (144+9), note, velo the velo byte is to be disregarded, unless it is %False, in which case it obviously means a note off. [note: velo byte controls the bow pressure and thus we use different controllers for the duty cycle of the e-drive]. CHANGE REQUEST 31.10.2007: if ctrl 5 or 6 is 0, velo should controll the PWM for the softshift magnets if ctrl 5 or 6 are 1, velo should control the amplitude of the e-drives this requires a modification in the firmware for PIC3 if ctrl 5 or 6 are 2, velo should control both softshift pwm and e-drive The note range 40-63 controls a first note generator (pic pin 24, low string), the note range 64-88 (?127) the second note generator. (pic pin 26, high string). [ new wish 30.10.2007: see at the end] Note OFF On reception of a note-off in the range 40-63, pic pin 24 should go high. On reception of a note-off in the range 64-127, pic pin 26 should go high. This should also happen when a note on with velo=0 is received. CHANGE REQUEST 31.10.2007: if the note off velo byte is non zero, note off should activate the felt damper note range 40-63: low string damper note range 64-120: high string damper Controller 3, byte: byte = pulse width value for the e-drive activation of the low string Controller 4, byte: byte = pulse width value for the e-drive activation of the high string Controller 20, byte. byte = real pitch whereto the low string is tuned if byte = 40, there is no transposition lowtransposition = byte - 40 ( negative = lower, positive = higher). So, on reception of a note, the frequency to be generated should be found in the lookup as note + lowtransposition. Controller 21, byte: byte = real pitch whereto the high string is tuned if byte = 64, there is no transposition hightransposition = byte - 64 ( negative = lower, positive = higher). So, on reception of a note, the frequency to be generated should be found in the lookup as note + hightransposition The transposition value should default to 40 and 64 on startup. It should not be reset on an all notes off command. Controller 22, byte: 1 to 32 - multiplier for the output frequency on low string byte = 0 must be the same as byte = 1 When byte = 2, the output will be an octave higher when byte = 3, the output will be an octave and a fifth higher etc... Controller 23, byte: 1 to 32 - multiplier for the output frequency on high string Controller 69: ON/OFF disable/enable the low string e-driver (pin 24 high) Controller 70: ON/OFF disable/enable the high string e-driver (pin 26 high) frequency lookup table: http://www.logosfoundation.org/kursus/1083.html required precision: 0.05% minimum. Specific lookup for Hurdy Pic4 application: http://www.logosfoundation.org/instrum-gwr/hurdy/hurdy_flut.txt note range (taking into account transposition shifts): notes 14 - 127 The pic pins used for the frequency generation (pin 24 and 26) should as a default always be at a high level (the ICL7667 mosfet driver inverts the signal). On any note off command it should be high also. Otherwize, the BUZ345 will conduct and send unlimited DC to the coils, leading to a guaranteed melt down. A yellow LED is connected to the third PWM output (pin22). It can be used for debugging and fault visualisation.