PIC Mapping for : 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 adressing strobe signals for the latches: Port C van de PIC: RC0 = Timer 1 output. Test LED op PIC board (zoals op het board) LED via 1k2 naar GND. pic pin 11 RC1 = nc ? PWM output pic pin 12 RC2 = PWM output - connected to mosfet gate for PWM. pic pin 13 RC3 = nc pic pin 14 RC4 = A0, latch 0 note board 1 pic pin 15 RC5 = A1, latch 1 note board 1 pic pin 16 RC6 = cannot be used pic pin 17 RC7 = serial input for MIDI data pic pin 18 (zoals op het board) Port A van de PIC: RA0 = A2, latch 2 note board 1 pic pin 2 RA1 = A4, latch 4 note board 2 pic pin 3 RA2 = A5, latch 5 note board 2 pic pin 4 RA3 = A3, latch 3 note board 2 pic pin 5 RA4 = nc, pull up 4k7 pic pin 6 RA5 = nc pic pin 7 GROUND: pic pin 19 pic pin 8 POSITIVE SUPPLY: pic pin 20 Note: in the first design we had RA3 N.C. and RA0 connected to A3, latch 3. This appeared to be impossible for the PIC's configuration, so we changed it to the scheme given above. [ 23.02.2004] Note: as it appeared impossible to use RC6 as output, we modified the circuit such as to make RA0 (pin2) the bit to controll latch 2 [ 28.04.2004] Software implementation: Channel = 15 (&H0F) Note range: (note-on & note-off implemented): 32 to 79 (48 notes) notes out of the range should be rejected in the PIC software. The software should have a six byte array to store the contents of the latches: la(0) to la(5) On reception of a NOTE ON command: i = ((note - 32) \ 8) ' integer divide to obtain the latch in index FlipByte la(i) ' swap D0,D7, D1,D6, D2,D5, D3,D4 la(i) = la(i) OR (note MOD 8) ' set the corresponding bit, preserving existing contents FlipByte la(i) ' swap again OUT RB, la(i) ' send to data port JMP Strobing On reception of a NOTE OFF command: i = ((note - 32) \ 8) ' integer divide to obtain the latch in index FlipByte la(i) ' swap D0,D7, D1,D6, D2,D5, D3,D4 la(i) = BIT RESET la(i),note MOD 8 ' reset the corresponding bit, preserving existing contents FlipByte la(i) ' swap again OUT RB, la(i) ' send to data port JMP Strobing Strobing: ' strobe high: ' select case i case 0,1,2 OUT RC, &Bx111xxxx ' bits 4,5,6 high, x = preserve bits case 3,4,5 OUT RA, &Bxxxxx111 ' bits 0,1,2 high end select ' strobe low: ' strobe should stay low for at least 1 microsecond! select case i case 0 OUT RC, &Bx110xxxx ' bit 4 low x= preserve existing bits case 1 OUT RC, &Bx101xxxx ' bit 5 low case 2 OUT RC, &Bx011xxxx ' bit 6 low case 3 OUT RA, &Bxxxxx110 ' bit 0 low case 4 OUT RA, &Bxxxxx101 ' bit 1 low case 5 OUT RA, &Bxxxxx011 ' bit 2 low end select ' wait 1 microsecond... ' strobe high again: select case i case 0,1,2 OUT RC, &Bx111xxxx ' bits 4,5,6 high case 3,4,5 OUT RA, &Bxxxxx111 ' bits 0,1,2 high end select On init, all strobe bits should be high and all notes switched to OFF. The note latches should be cleared. This should also happen on reception of an all-notes off command: AllOff: FOR i = 0 to 5 la(i) = 0 JMP Strobing NEXT Volume controller: controller nr. 7 channel 15 The received value for this controller should be output as a repeated PWM signal on pin 13 (RC2) of the PIC. For parameter value 0, the RC2 pin should be 0. (no PWM) For parameter value 127 ,RC2 should be 1. (no PWM)