' ******************************************************************** ' * PIC firmware for * ' * Hub board * ' * coded by dr.Godfried-Willem Raes * ' * http://www.logosfoundation.org/instrum_gwr/hunt/picworks * ' * source code development directory: * ' * Hunt_Hub.bas * ' * Version 1.0 * ' * Proton Compiler version 3.6.2.7 11/2018 * ' ******************************************************************** '------------------------------------------------------------------------------ ' 21.09.2019: Start coding for , compiler version 3.6.2.7 ' mapping adapted to hardware - compiles o.k. ' Merely functions as a parsed midibuffer/filter and lights controll ' We could also implement a polyphony limiter on this level. ' 24.09.2019: tested on LED board and found ok. ' 26.09.2019: Controllers adapted to whats implemented on the other boards. ' 26.11.2019: lights mapping changed. ' 08.12.2019: This code still uses the loopcount version. Timing is more precise ' with the new counter0 version as used on the beater and damper boards. ' However, its not really important here as timing is only used for flashing lights... '------------------------------------------------------------------------------- ' 19.01.2020: Starting from Tubo code, rewrite for ' to be implemented here: valves working on 12V, without pulse (5 solenoids) ' delayed midi-out for sound generator board ok ' PWM for lip-controller, softshift solenoid ok ' implement counter0 version as we should avoid jitter here. ok ' Add Bb valve to hub board? ' first tests: the parser delay is 1ms ' the delayed midi is now 18ms (constant value = 750) ' 20.01.2020: delay measurements: with constant 250 we get a 7.5ms midi-delay ' note that the loopspeed (ca.9us) is much faster than the timer0 resolution.(ca.25us) ' no delay on repeated notes now. ' key-hold time is now 1.5 seconds. ' 22.01.2020: We could implement fingered vibrato here, using timer3 and a valve lookup table ' 27.01.2020: First tests on the robot. ' 28.01.2020: bugs in the parser solved: we did not pass pitchbend and confused lsb msb order! ' 29.01.2020: note range extended to note 105 ' 30.01.2020: Bug: windklep moet altijd dicht voor noten 48-59. Coding for controller #2 rewritten. ' default controllers for synth board implemented on start-up ' 02.02.2020: all prog.changes now passed to synth board. ' 03.02.2020: pitch bend delayed if played note is not yet set but waiting in the buffer. ' 05.02.2020: pass thru for CC15 added. ' 12.03.2020: thinning for pitchbend implemented. LSB's will be disregarded. ' 01.04.2020: note-off implementation changed for overlapping notes in legato's. ' 09.04.2020: Firmware upload. ' **************************************************************************************************** ' 13.11.2020: Code ported to , hub board. ' This code is a lot less complicated than the code for . ' 19.11.2020: First tentative version ready. Firmware upload and test passed. ' 21.11.2020: Keypressure implemented for lights. ' 22.11.2020: Very first tests on the robot passed. ' To do: make sure we pass all controllers to the other boards!!! ' We may need prog change as well for natural overtone series selection. ' 29.11.2020: Controllers adapted to just intonation modes. ' 10.12.2020: Continued work on ' 17.01.2020: debug taken up again. Include "18F2620.inc" 'version for the Hunt hub board. (40MHz) 'Include "18F2520.inc" 'also possible. (40MHz) Clear ' Mapping defines for midi-events on pin outputs and inputs: ' Power-on relay: $define Power_Relay PORTA.4 ' 5V ' Mosfet outputs: $define Red1_lite PORTA.5 $define Red2_lite PORTC.0 $define Gun PORTC.1 ' HPWM 2 $define Free1 PORTC.2 ' can pwm HPWM 1 $define Free2 PORTC.3 $define White1_lite PORTC.4 $define White2_lite PORTC.5 ' inputs: $define sensor1 PORTA.0 ' not used here. $define sensor2 PORTA.1 ' LED's: $define GreenLed PORTB.2 ' on/off $define Debug_Led PORTB.5 ' for testing - red led - watchdog Declare All_Digital = True ' makes all analog pins, digital for I/O Clear SSPCON1.5 ' make sure RC3 is free for use. ' configure the input and output pins: TRISA = %11000011 'bits set to 0 are output, 1 = input - bits 6 and 7 are the clock! TRISB = %11100000 'bits 6 and 7 are for the ICP, bit 5 is the red LED TRISC = %11000000 'RC6 en RC7 zijn USART I/O and must be set to input Input sensor1 'not used for Input sensor2 'constant definitions: Symbol fPwm = 21000 ' PWMminF Symbol Hunt_low_note = 41 Symbol Hunt_high_note = 91 Symbol Lite1 = 120 ' Tungsten lites on motor board Symbol Lite2 = 121 ' id. Symbol Gunshot = 107 ' on this board! Symbol RedLite1_note = 122 Symbol RedLite2_note = 123 Symbol WhiteLite1_note = 124 Symbol WhiteLite2_note = 125 Symbol Free1_note = 126 Symbol Free2_note = 127 ' place for 6 lites on hub board + 1 gunshot. ' constants: Symbol True = 1 Symbol False = 0 'initialisations for the midi input parser: Symbol Midichannel = 2 ' Hunt channel Symbol NoteOff_Status = 128 + Midichannel ' 2 bytes follow Symbol NoteOn_Status = 144 + Midichannel Symbol Keypres_Status = 160 + Midichannel Symbol Control_Status = 176 + Midichannel Symbol ProgChange_Status = 192 + Midichannel ' 1 byte message Symbol Aftertouch_Status = 208 + Midichannel ' 1 byte follows Symbol Pitchbend_Status = 224 + Midichannel ' lsb msb follow Symbol Hold_Time = 65535 ' houdtijd voor de kleppen - this is 1.5 seconds ' timeunits are 22.8us here Symbol KlepDelay_time = 250 ' measured: 7.5ms delay.(20.01.2020) ' used for delayed midi out to synth board on note-on's ' with changing fingerings. Symbol NrTasks = 3 Symbol LastTask = NrTasks - 1 Symbol CC107_default = 255 ' default controller settings: 'Symbol CC4 = 94 ' vibrato speed 'Symbol CC3 = 8 ' vibrato depth 'Symbol CC6 = 20 ' tremolo speed 'Symbol CC5 = 8 ' tremolo depth ' Setup the USART Declare Hserial_Baud = 31250 ' Set baud rate for the USART to MIDI specs. 'Hserial1_ChangeBaud 31250, 1 Declare Hserial_TXSTA = 0x24 ' instead of the normal 0x20 - ?? 0x24 ' Declare Hserial_Clear = On ' should clear on errors. Bytes get lost of course... ' Create variables: Dim Cnt As Dword System '32 bit counter Dim CntHw As Cnt.Word1 ' Word System 'used in the timer0 interrupt, where it is incremented Dim CntLw As TMR0L.Word 'this is the trick to read both TMR0L and TMR0H ' Dim time As Cnt ' alias Dim Tim3 As TMR3L.Word ' same trick for timer3 Dim Bytein As Byte System ' midi byte read from buffer Dim StBit As Bytein.7 ' highest bit of ByteIn Dim i As Byte System ' general purpose counter ' midi variables Dim statusbyte As Byte System Dim noteUit As Byte System ' note off + release value Dim release As Byte System Dim noteAan As Byte System ' note on + release value Dim velo As Byte System Dim notePres As Byte System ' note pressure + pressure value Dim pres As Byte System Dim Ctrl As Byte System ' continuous controller + value Dim value As Byte System Dim prog As Byte System ' program change + program-byte Dim aft As Byte System ' channel aftertouch Dim pblsb As Byte System ' pitch bend lsb Dim pbmsb As Byte System ' pitch bend msb ' Dim Velflags As Byte System ' so we can have only 8 tasks Dim CC66 As Byte System ' global on/off switch Dim PowerOn As CC66.0 ' handled on the hub board. ' Dim notes As Byte System ' used for flashing lites and note repeats ' Dim CC30 As Byte System ' repeat freq. controller ' Dim pres0 As Byte System ' Dim pres1 As Byte System ' Dim pres2 As Byte System ' Dim pres3 As Byte System ' Dim pres4 As Byte System ' Dim pres5 As Byte System ' Dim pres6 As Byte System ' Dim pres7 As Byte System ' Dim klep As Byte System ' 6 bits used. Dim RedSpeed As Byte Dim WhiteSpeed As Byte Dim maxtim As Cnt.31 ' overflow bit, will cause timer reset after 1h45 Dim TimVals[NrTasks] As Dword ' lijst met timer waarden - de kleinste is eerst aan de beurt Dim Nxt As Dword System ' waarde voor de eerstvolgende timer Dim idx As Byte System ' index voor de eerstvolgende timer '----------------------------------------------------------------------------------------- ' Load the USART Interrupt handler and buffer read subroutines into memory Dim Ringbuffer[256] As Byte ' Array for holding received midi bytes Include "Hunt_Hub_Irq.inc" ' for UART,Timer0, Timer3 Interrupt ' velocity lookup table Dim Vels[128] As Word ' for Laukhuff solenoid Dim Dur[128] As Word ' duration lookup for repetitions Dim Dur5[128] As Word ' duration lookup for lite flashing repetitions 'Dim Kleppen[128] As Byte ' lookup for the fingerings Dim Outbuffer[256] As Byte ' midi-outputbuffer for delay! Dim OutIdxIn As Byte System ' write idx pointer Dim OutIdxOut As Byte System ' read idx pointer Dim playing_note As Byte Dim old_note As Byte ' previous note Dim delaystatus As Byte ' new for delayed pitchbend Dim old_PB As Byte ' new for PB thinning - we disregard PB lsb's Dim CC107 As Byte ' 8-bit pwm value for the gunshot. ' Main program starts here: MAIN: High Debug_Led DelayMS 10 ' wait for stability Low Debug_Led Low Power_Relay Low GreenLed Low Red1_lite Low Red2_lite Low Gun Low Free1 Low Free2 Low White1_lite Low White2_lite Set TimVals ' no timers running on startup Clear CC66 ' power off Clear Outbuffer Clear OutIdxIn Clear OutIdxOut Set old_PB Set idx CC107 = CC107_default Init_Usart_Interrupt ' Initiate the USART serial buffer interrupt ' this procedure is in the include file Clear_Serial_Buffer ' Clear the serial buffer and reset its pointers ' in the include as well ' TIMER0: Configure Timer0 for: ' Clear TMR0L and TMR0H registers ' Interrupt on Timer0 overflow ' 16-bit operation ' Internal clock source 40MHz ' 1:256 Prescaler : thus 40MHz / 256 = 156.250kHz ' 6.4 us per clock-tick Clear T1CON Clear IntConBits_T0IF ' clear interrupt flag Set INTCONBITS_T0IE ' enable interrupt on overflow T0CON = %10000111 ' bit 7 = enable/disable ' bit 6 = 1=8 bit, 0=16 bit ' bit 5 = 1 pin input, 0= Internal Clk0 ' bit 4 = HL or LH transition when bit5 =1 ' bit 3 = 1= bypass prescaler, 0= input from prescaler ' bit 2-0 = prescaler select: 111= 1:256 ' Setup the High priorities for the interrupts ' TIMER1: ? in conflict with UART ' Configure Timer1 for: ' Clear TMR1L and TMR1H registers ' Interrupt on Timer1 overflow ' 16-bit read/write mode ' Internal clock source ' 1:8 Prescaler ' OpenTimer1(TIMER_INT_ON & T1_16BIT_RW & T1_SOURCE_INT & T1_PS_1_8) ' dit kompileert o.k. ' TIMER2: if enabled, the UART stops working... ' Opentimer2 (Timer_Int_On & T2_POST_1_16 & T2_PS_1_16) ' dit lukt... maar de timer is nodig voor de UART... ' TIMER3: ' Configure Timer3 for: ' Interrupt on Timer3 overflow ' 16-bit read/write mode ' Internal clock source ' 1:8 Prescaler ' Dont sync external clock input ' doing it this way seems to work: Clear T3CON Clear PIR2BITS_TMR3IF ' clear IRQ flag Set PIE2BITS_TMR3IE ' irq on Clear Tim3 ' Clear TMR3L And TMR3H registers Set RCONbits_IPEN ' Enable priority interrupts Clear IPR2bits_TMR3IP ' Set Timer3 as a low priority interrupt source ' we can also set T3Con in one instruction as: T3CON = %10110001 ' oef, now it works... ' bit 7 = 16 bit mode ' bit 6,3 = 0, 0 ' bit 5,4 = 1:8 prescale ' bit 2 = 0 ' bit 1 = 0 Internal clock = Fosc/4 ' bit 0 : 1= enable timer 3, 0= disable ' maximum count = 52.42ms, 1 tick =0.8uS, freq.=19Hz ' Set up priority interrupts. ' IPR1bits_TMR1IP = 0 ' Set Timer1 as a low priority interrupt source ' INTCONbits_PEIE = 1 ' Enable peripheral interrupts ' INTCONbits_GIE = 1 ' Enable global interrupts GoSub Dur_Lookup GoSub Vels_Lookup ' start the main program loop: 'Hoofdlus: ' Create an infinite loop Do Cnt.Word0 = CntLw ' read timer 0 = time (defined as alias for Cnt) GetMidiIn () ' we cannot create functions in Proton... Bytein = MidiIn ' this function is defined in Hunt_Hub_irq.inc ' Start the midi parser. Midi_Parse: If Bytein > Pitchbend_Status Then ' here higher statusses are not implemented. (was Control_Status!!!) ' this was the bug causing pitchbend not to work... If Bytein > 253 Then '254 = midiclock, 255= reset 'midiclock can interrupt all other msg's... '255 had to be intercepted since thats what we 'get when no new byte flows in. Else Clear statusbyte 'reset the status byte End If GoTo Check_Timers 'throw away... EndIf If StBit =1 Then 'should be faster than If Bytein > 127 Then 'status byte received, bit 7 is set Clear statusbyte 'if on another channel, the statusbyte needs a reset Select Bytein 'eqv to Select case ByteIn Case NoteOff_Status statusbyte = Bytein Set noteUit 'reset value. Cannot be 0 !!! Set release '0 is a valid midi note! Case NoteOn_Status statusbyte = Bytein Set noteAan Set velo Case Keypres_Status statusbyte = Bytein Set notePres Set pres Case Control_Status ' controllers and switches statusbyte = Bytein Set Ctrl Set value Case ProgChange_Status ' be used for different lookup tables statusbyte = Bytein Set prog Case Aftertouch_Status ' for repetition speed statusbyte = Bytein Set aft Case Pitchbend_Status statusbyte = Bytein Set pblsb Set pbmsb EndSelect Else 'midi byte is 7 bits Select statusbyte Case 0 'not a message for this channel GoTo Check_Timers 'disregard Case NoteOff_Status If noteUit = 255 Then noteUit = Bytein Else release = Bytein 'message complete, so we can do the action... Select noteUit Case playing_note HRSOut NoteOff_Status, noteUit, release ' so, if we have overlaps, the synth board will disregard. Clear playing_note Set old_PB ' make it 255 Case Lite1 HRSOut NoteOff_Status, Lite1, 0 ' for motor board Case Lite2 HRSOut NoteOff_Status, Lite2, 0 Case Gunshot ' Clear Gun or: HPWM 2,0, fPwm Set TimVals[2] Case RedLite1_note Clear Red1_lite Set TimVals[0] Case RedLite2_note Clear Red2_lite Set TimVals[0] Case WhiteLite1_note Clear White1_lite Set TimVals[1] Case WhiteLite2_note Clear White2_lite Set TimVals[1] Case Free1_note Clear Free1 Case Free2_note Clear Free2 Case Else GoTo Check_Timers EndSelect Set noteUit 'reset GoTo resort EndIf GoTo Check_Timers Case NoteOn_Status If noteAan = 255 Then noteAan = Bytein Else velo = Bytein If velo = 0 Then ' note off via velo=0 Select noteAan Case playing_note ' 41 To 91 HRSOut NoteOn_Status, noteAan, 0 ' no delay! Clear playing_note ' start timer! ' TimVals[0] = Cnt + Hold_Time ' old_note = noteAan Set old_PB Case Lite1 HRSOut NoteOff_Status, Lite1, 0 Case Lite2 HRSOut NoteOff_Status, Lite2, 0 Case Gunshot ' note 107 'Clear Gun HPWM 2,0,fPwm Set TimVals[2] Case RedLite1_note Clear Red1_lite Set TimVals[0] Case RedLite2_note Clear Red2_lite Set TimVals[0] Case WhiteLite1_note Clear White1_lite Set TimVals[1] Case WhiteLite2_note Clear White2_lite Set TimVals[1] Case Free1_note Clear Free1 Case Free2_note Clear Free2 Case Else GoTo Check_Timers ' disregard the note-off EndSelect GoTo resort Else If PowerOn = 1 Then ' dont do things if power is off Select noteAan Case Hunt_low_note To Hunt_high_note HRSOut NoteOn_Status, noteAan, velo playing_note = noteAan Case Lite1 To Lite2 HRSOut NoteOn_Status, noteAan, velo Case Gunshot ' here we have to decide on how to implement ' velocity versus PWM value... ' they are interdependent... If CC107 > 0 Then HPWM 2, CC107, fPwm TimVals[2] = Cnt + Vels[velo] Else ' disregard command. Set TimVals[2] HPWM 2, 0,fPwm EndIf Case RedLite1_note RedSpeed = velo If RedSpeed = 127 Then Set Red1_lite Set TimVals[0] Else Set Red1_lite Clear Red2_lite TimVals[0] = Cnt + Dur5[RedSpeed] EndIf Case RedLite2_note RedSpeed = velo If RedSpeed = 127 Then Set Red2_lite Set TimVals[0] Else Set Red2_lite Clear Red1_lite TimVals[0] = Cnt + Dur5[RedSpeed] EndIf Case WhiteLite1_note WhiteSpeed = velo If WhiteSpeed = 127 Then Set White1_lite Set TimVals[1] Else Set White1_lite Clear White2_lite TimVals[1] = Cnt + Dur5[WhiteSpeed] EndIf Case WhiteLite2_note WhiteSpeed = velo If WhiteSpeed = 127 Then Set White2_lite Set TimVals[1] Else Set White2_lite Clear White1_lite TimVals[1] = Cnt + Dur5[WhiteSpeed] EndIf Case Free1_note Set Free1 Case Free2_note Set Free2 Case Else Set noteAan GoTo Check_Timers EndSelect EndIf Set noteAan GoTo resort EndIf EndIf GoTo Check_Timers Case Keypres_Status If notePres = 255 Then notePres = Bytein Else pres = Bytein GoSub KeyPres ' midi out in the sub 'GoTo resort ' changing repetition rates requires timers! EndIf GoTo Check_Timers Case Control_Status 'this is where the action takes place for controllers If Ctrl = 255 Then Ctrl = Bytein Else value = Bytein GoSub Controller EndIf GoTo Check_Timers Case ProgChange_Status If prog = 255 Then 'single byte message prog = Bytein HRSOut ProgChange_Status, prog ' all prog changes passed for synth board undelayed! ' used for switching to just-overtone series based on note 41 Set prog EndIf GoTo Check_Timers Case Aftertouch_Status ' not used here If aft = 255 Then aft = Bytein GoSub Aftertouch EndIf GoTo Check_Timers Case Pitchbend_Status If pblsb = 255 Then pblsb = Bytein Else pbmsb = Bytein GoSub Pitchbend ' thinning happens there EndIf GoTo Check_Timers EndSelect EndIf resort: GoSub SortTimers ' so we resort only if an incoming midi command changed something Check_Timers: If idx < NrTasks Then ' we moeten alleen checken wanneer er een timer loopt If Cnt >= Nxt Then ' nagaan of de eerstvolgende timer afgelopen is... ' in dit geval is de eerste timer afgelopen en moeten we de juiste aktie ondernemen: Set Nxt.31 ' timer reset, is immers afgelopen ' aan de hand van idx weten we welke timer dit is Select idx Case 0 ' can be used for flashing the two red lights in alternation Toggle Red1_lite Toggle Red2_lite TimVals[0] = Cnt + Dur5[RedSpeed] Case 1 Toggle White1_lite Toggle White2_lite TimVals[1] = Cnt + Dur5[WhiteSpeed] Case 2 'Clear Gun HPWM 2, 0, fPwm Set TimVals[2] 'Case Else ' ' in dit geval is idx geset ' GoTo jumpout EndSelect GoSub SortTimers ' find a new nxt and idx EndIf ' beveiliging tegen overflow crashes... If maxtim = 1 Then Clear Cnt Set TimVals EndIf Else ' idx > 1, no timers running, so to avoid overflows, we can reset the loop timer If maxtim = 1 Then Clear Cnt EndIf Btg PORTB.0 ' 19.11.2020: 128kHz, with 3 timers. Loop SortTimers: ' look up the next smallest timer value in the Timvals array ' zoek de de volgende kleinste timer waarde: Set idx Set Nxt.31 ' nxt is set on entry. - for speed, we just set the highest bit For i = 0 To LastTask ' = NrTasks -1 If TimVals[i] < Nxt Then Nxt = TimVals[i] ' 3 dword comparisons idx = i EndIf Next i Return KeyPres: Select notePres Case Hunt_low_note To Hunt_high_note HRSOut Keypres_Status, notePres, pres ' do we use this on Hunt? ' check implementation on synth board... Case RedLite1_note To RedLite2_note RedSpeed = pres Case WhiteLite1_note To WhiteLite2_note WhiteSpeed = pres EndSelect ' we do not need to resort here Set notePres Return ProgChange: ' done in midi parser Set prog 'this is not realy required Return Pitchbend: ' should be delayed if the note is still waiting in the buffer!!! ' here we also thin pitchbend messages by not passing them through if the msb has not changed since the previous call If playing_note >= Hunt_low_note Then ' in fact it should also be < 92... If pbmsb <> old_PB Then HRSOut Pitchbend_Status, pblsb, pbmsb old_PB = pbmsb EndIf EndIf Set pblsb Return Aftertouch: ' this is the channel aftertouch, affecting any playing note ' not implemented here. ' could be used for fingered vibrato... Set aft ' reset Return Controller: ' checked with synth implementation Select Ctrl Case 1 ' wind noise controller HRSOut Control_Status, 1, value ' Case 2 not implemented on Hunt. Case 3 To 7 ' vibrato, tremolo and volume HRSOut Control_Status, Ctrl, value Case 15 To 19 HRSOut Control_Status, Ctrl, value ' adsr ctrl's Case 20 Select value Case 41 HRSOut Control_Status,20, 41 ' just-overtones mode for F horn Case 48 To 59 HRSOut Control_Status, 20, value ' just intonation scales Case 61 To 67 HRSOut Control_Status, 20, value ' other tunings are not implemented. Case 72 To 83 HRSOut Control_Status, 20, value ' just intonation, second series (01.12.2020) EndSelect Case 22 HRSOut Control_Status, 22, value ' horn motor ' Case 30 ' ' can be used for global repeat frequency ' ' do we need to forward this? ' ' no, only used for the lights controlled by this board Case 40 To 43 ' used for debug: selection of excitation waveforms If value < 7 Then ' acceptable values are 0-6 only HRSOut Control_Status, Ctrl, value EndIf Case 66 'on/off for the robot ' this should also go to all other boards! HRSOut Control_Status, 66, value If value = 0 Then Clear PowerOn 'CC66.0 =0 GoSub PowerDown Else High Power_Relay Set GreenLed Set PowerOn 'CC66.0 =1 CC107 = CC107_default ' send default controllers to synth board: - now implemented on the synth board. EndIf Case 69 HRSOut Control_Status, 69, value ' automatic lites controller, for motor board. ' if we implement this on this board, we have to add code here... Case 80 HRSOut Control_Status, 80, value ' 05.02.2020 used to change dynamic scales. -20dB, -30dB, -40dB, -50dB, -60dB Case 107 ' gunshot solenoid voltage for PWM. If value = 0 Then CC107 = 0 ' this disables the gunshot alltogether. Else CC107 = value + value + 1 ' 3 - 255 EndIf Case 123 ' all notes off - no controller resets HRSOut Control_Status, 123, 0 Clear Red1_lite Clear Red2_lite Clear Free2 Clear White1_lite Clear White2_lite Clear Free1 HPWM 2, 0, fPwm ' gunshot Set TimVals[2] Clear old_note Clear old_PB EndSelect Set Ctrl 'mandatory reset Return PowerDown: Low Power_Relay Clear GreenLed Clear Red1_lite Clear Red2_lite Clear White1_lite Clear White2_lite HPWM 2, 0, fPwm 'Gun Clear Free2 Clear Free1 Clear CC66 Clear old_note Clear old_PB CC107 = CC107_default Set TimVals Return Dur_Lookup: 'lookup for repeat frequencies Set Dur[0] ' used for lights Dur[1]= 23674 ' freq= 2.11202162710146 Dur[2]= 22917 ' freq= 2.18178644674259 Dur[3]= 22548 ' freq= 2.21749157353202 Dur[4]= 22185 ' freq= 2.25377507324769 Dur[5]= 21827 ' freq= 2.29074082558299 Dur[6]= 21475 ' freq= 2.32828870779977 Dur[7]= 21129 ' freq= 2.36641582658905 Dur[8]= 20789 ' freq= 2.40511809129828 Dur[9]= 20454 ' freq= 2.44450963136795 Dur[10]= 20124 ' freq= 2.48459550785132 Dur[11]= 19800 ' freq= 2.52525252525252 Dur[12]= 19481 ' freq= 2.56660335711719 Dur[13]= 19167 ' freq= 2.60865028434288 Dur[14]= 18858 ' freq= 2.65139463357726 Dur[15]= 18554 ' freq= 2.69483669289641 Dur[16]= 18255 ' freq= 2.73897562311695 Dur[17]= 17961 ' freq= 2.7838093647347 Dur[18]= 17672 ' freq= 2.82933454051607 Dur[19]= 17387 ' freq= 2.87571173865532 Dur[20]= 17107 ' freq= 2.92278014847723 Dur[21]= 16831 ' freq= 2.97070881112233 Dur[22]= 16560 ' freq= 3.01932367149758 Dur[23]= 16293 ' freq= 3.06880255324372 Dur[24]= 16030 ' freq= 3.11915159076731 Dur[25]= 15772 ' freq= 3.17017499365965 Dur[26]= 15518 ' freq= 3.22206469905916 Dur[27]= 15268 ' freq= 3.27482315954938 Dur[28]= 15022 ' freq= 3.32845160431367 Dur[29]= 14780 ' freq= 3.382949932341 Dur[30]= 14542 ' freq= 3.43831660019254 Dur[31]= 14307 ' freq= 3.4947927587894 Dur[32]= 14077 ' freq= 3.55189315905378 Dur[33]= 13850 ' freq= 3.6101083032491 Dur[34]= 13627 ' freq= 3.66918617450649 Dur[35]= 13407 ' freq= 3.72939509211606 Dur[36]= 13191 ' freq= 3.79046319460238 Dur[37]= 12978 ' freq= 3.85267375558638 Dur[38]= 12769 ' freq= 3.91573341686898 Dur[39]= 12564 ' freq= 3.97962432346386 Dur[40]= 12361 ' freq= 4.04498017959712 Dur[41]= 12162 ' freq= 4.1111659266568 Dur[42]= 11966 ' freq= 4.17850576633796 Dur[43]= 11773 ' freq= 4.24700586086809 Dur[44]= 11583 ' freq= 4.31667098333765 Dur[45]= 11397 ' freq= 4.38711941739054 Dur[46]= 11213 ' freq= 4.45910996165165 Dur[47]= 11032 ' freq= 4.53226976069616 Dur[48]= 10855 ' freq= 4.60617227084293 Dur[49]= 10680 ' freq= 4.6816479400749 Dur[50]= 10508 ' freq= 4.75827940616673 Dur[51]= 10338 ' freq= 4.83652544012381 Dur[52]= 10172 ' freq= 4.91545418796697 Dur[53]= 10008 ' freq= 4.99600319744204 Dur[54]= 9846 ' freq= 5.07820434694292 Dur[55]= 9688 ' freq= 5.16102394715111 Dur[56]= 9532 ' freq= 5.24548887956357 Dur[57]= 9378 ' freq= 5.33162721262529 Dur[58]= 9227 ' freq= 5.4188793757451 Dur[59]= 9078 ' freq= 5.50782110597048 Dur[60]= 8932 ' freq= 5.59785042543663 Dur[61]= 8788 ' freq= 5.68957669549385 Dur[62]= 8646 ' freq= 5.78302105019662 Dur[63]= 8507 ' freq= 5.87751263665217 Dur[64]= 8370 ' freq= 5.973715651135 Dur[65]= 8235 ' freq= 6.07164541590771 Dur[66]= 8102 ' freq= 6.17131572451246 Dur[67]= 7972 ' freq= 6.27195183140993 Dur[68]= 7843 ' freq= 6.37511156445238 Dur[69]= 7717 ' freq= 6.47920176234288 Dur[70]= 7593 ' freq= 6.58501251152377 Dur[71]= 7470 ' freq= 6.69344042838019 Dur[72]= 7350 ' freq= 6.80272108843537 Dur[73]= 7231 ' freq= 6.91467293597013 Dur[74]= 7115 ' freq= 7.02740688685875 Dur[75]= 7000 ' freq= 7.14285714285714 Dur[76]= 6888 ' freq= 7.25900116144018 Dur[77]= 6777 ' freq= 7.37789582411096 Dur[78]= 6667 ' freq= 7.49962501874906 Dur[79]= 6560 ' freq= 7.62195121951219 Dur[80]= 6454 ' freq= 7.74713356058258 Dur[81]= 6350 ' freq= 7.8740157480315 Dur[82]= 6248 ' freq= 8.00256081946223 Dur[83]= 6147 ' freq= 8.13404912965674 Dur[84]= 6048 ' freq= 8.26719576719577 Dur[85]= 5951 ' freq= 8.40194925222652 Dur[86]= 5855 ' freq= 8.5397096498719 Dur[87]= 5760 ' freq= 8.68055555555555 Dur[88]= 5668 ' freq= 8.82145377558222 Dur[89]= 5576 ' freq= 8.96700143472023 Dur[90]= 5486 ' freq= 9.11410864017499 Dur[91]= 5398 ' freq= 9.26268988514264 Dur[92]= 5311 ' freq= 9.41442289587648 Dur[93]= 5225 ' freq= 9.56937799043062 Dur[94]= 5141 ' freq= 9.72573429293912 Dur[95]= 5058 ' freq= 9.88533017002768 Dur[96]= 4977 ' freq= 10.0462125778581 Dur[97]= 4897 ' freq= 10.2103328568511 Dur[98]= 4818 ' freq= 10.3777501037775 Dur[99]= 4740 ' freq= 10.548523206751 Dur[100]= 4664 ' freq= 10.7204116638079 Dur[101]= 4589 ' freq= 10.8956199607758 Dur[102]= 4515 ' freq= 11.0741971207087 Dur[103]= 4442 ' freq= 11.2561909049977 Dur[104]= 4370 ' freq= 11.441647597254 Dur[105]= 4300 ' freq= 11.6279069767442 Dur[106]= 4231 ' freq= 11.8175372252422 Dur[107]= 4162 ' freq= 12.013455069678 Dur[108]= 4095 ' freq= 12.2100122100122 Dur[109]= 4029 ' freq= 12.4100273020601 Dur[110]= 3964 ' freq= 12.6135216952573 Dur[111]= 3901 ' freq= 12.8172263522174 Dur[112]= 3838 ' freq= 13.0276185513288 Dur[113]= 3776 ' freq= 13.2415254237288 Dur[114]= 3715 ' freq= 13.4589502018842 Dur[115]= 3655 ' freq= 13.6798905608755 Dur[116]= 3596 ' freq= 13.9043381535039 Dur[117]= 3538 ' freq= 14.1322781232335 Dur[118]= 3481 ' freq= 14.3636885952312 Dur[119]= 3425 ' freq= 14.5985401459854 Dur[120]= 3370 ' freq= 14.8367952522255 Dur[121]= 3316 ' freq= 15.0784077201448 Dur[122]= 3262 ' freq= 15.3280196198651 Dur[123]= 3210 ' freq= 15.5763239875389 Dur[124]= 3158 ' freq= 15.8328055731476 Dur[125]= 3107 ' freq= 16.0926939169617 Dur[126]= 3057 ' freq= 16.3559044815178 Dur[127]= 3008 ' freq= 16.6223404255319 'lookup for flashing lights: Set Dur5[0] ' not used Dur5[1]= 41667 ' freq= .999992000063999 Dur5[2]= 39494 ' freq= 1.0550125757499 Dur5[3]= 38450 ' freq= 1.08365843086259 Dur5[4]= 37434 ' freq= 1.11307011451265 Dur5[5]= 36445 ' freq= 1.14327525495038 Dur5[6]= 35482 ' freq= 1.17430434210774 Dur5[7]= 34544 ' freq= 1.20619113787247 Dur5[8]= 33631 ' freq= 1.23893629885126 Dur5[9]= 32743 ' freq= 1.27253662360403 Dur5[10]= 31877 ' freq= 1.30710752789367 Dur5[11]= 31035 ' freq= 1.34257021642232 Dur5[12]= 30215 ' freq= 1.37900601246621 Dur5[13]= 29416 ' freq= 1.41646269603844 Dur5[14]= 28639 ' freq= 1.45489251254117 Dur5[15]= 27882 ' freq= 1.49439303732396 Dur5[16]= 27146 ' freq= 1.53490999287802 Dur5[17]= 26428 ' freq= 1.57661066545583 Dur5[18]= 25730 ' freq= 1.61938074880166 Dur5[19]= 25050 ' freq= 1.66333998669328 Dur5[20]= 24388 ' freq= 1.70849051446066 Dur5[21]= 23743 ' freq= 1.75490319953951 Dur5[22]= 23116 ' freq= 1.8025033166061 Dur5[23]= 22505 ' freq= 1.85144042064726 Dur5[24]= 21910 ' freq= 1.90171915411532 Dur5[25]= 21331 ' freq= 1.95333864641445 Dur5[26]= 20768 ' freq= 2.006291730868 Dur5[27]= 20219 ' freq= 2.06076792455941 Dur5[28]= 19685 ' freq= 2.11667090000847 Dur5[29]= 19164 ' freq= 2.17421554303207 Dur5[30]= 18658 ' freq= 2.23317969057062 Dur5[31]= 18165 ' freq= 2.29378842095605 Dur5[32]= 17685 ' freq= 2.35604561304307 Dur5[33]= 17218 ' freq= 2.41994811631239 Dur5[34]= 16763 ' freq= 2.48563304102289 Dur5[35]= 16320 ' freq= 2.5531045751634 Dur5[36]= 15888 ' freq= 2.62252433702585 Dur5[37]= 15469 ' freq= 2.69355916133342 Dur5[38]= 15060 ' freq= 2.76671093404161 Dur5[39]= 14662 ' freq= 2.84181330423316 Dur5[40]= 14274 ' freq= 2.91906029610948 Dur5[41]= 13897 ' freq= 2.99824902257082 Dur5[42]= 13530 ' freq= 3.07957625030796 Dur5[43]= 13172 ' freq= 3.16327563518575 Dur5[44]= 12824 ' freq= 3.24911624038262 Dur5[45]= 12485 ' freq= 3.33733813910025 Dur5[46]= 12155 ' freq= 3.42794460441519 Dur5[47]= 11834 ' freq= 3.52092839840009 Dur5[48]= 11522 ' freq= 3.61627032343922 Dur5[49]= 11217 ' freq= 3.71459986330272 Dur5[50]= 10921 ' freq= 3.81527943106553 Dur5[51]= 10632 ' freq= 3.91898670679709 Dur5[52]= 10351 ' freq= 4.02537597011561 Dur5[53]= 10078 ' freq= 4.13441820467024 Dur5[54]= 9811 ' freq= 4.24693371385859 Dur5[55]= 9552 ' freq= 4.36208821887214 Dur5[56]= 9300 ' freq= 4.48028673835125 Dur5[57]= 9054 ' freq= 4.60201752448273 Dur5[58]= 8815 ' freq= 4.72679145396105 Dur5[59]= 8582 ' freq= 4.85512312592247 Dur5[60]= 8355 ' freq= 4.9870337123479 Dur5[61]= 8134 ' freq= 5.12253094008688 Dur5[62]= 7919 ' freq= 5.26160710527423 Dur5[63]= 7710 ' freq= 5.40423692174665 Dur5[64]= 7506 ' freq= 5.5511146638245 Dur5[65]= 7308 ' freq= 5.70151432220398 Dur5[66]= 7115 ' freq= 5.85617240571562 Dur5[67]= 6927 ' freq= 6.01510995621 Dur5[68]= 6744 ' freq= 6.1783313562673 Dur5[69]= 6565 ' freq= 6.34678852500635 Dur5[70]= 6392 ' freq= 6.51856487275761 Dur5[71]= 6223 ' freq= 6.69559162247576 Dur5[72]= 6059 ' freq= 6.87682235792485 Dur5[73]= 5898 ' freq= 7.06454165253758 Dur5[74]= 5743 ' freq= 7.25520924023449 Dur5[75]= 5591 ' freq= 7.45245334764204 Dur5[76]= 5443 ' freq= 7.65509216730969 Dur5[77]= 5299 ' freq= 7.86311882745172 Dur5[78]= 5159 ' freq= 8.07650061381405 Dur5[79]= 5023 ' freq= 8.29517552591413 Dur5[80]= 4890 ' freq= 8.52079072937969 Dur5[81]= 4761 ' freq= 8.75166281593503 Dur5[82]= 4635 ' freq= 8.98957209636821 Dur5[83]= 4513 ' freq= 9.23258734027624 Dur5[84]= 4393 ' freq= 9.48478640261021 Dur5[85]= 4277 ' freq= 9.74203101862676 Dur5[86]= 4164 ' freq= 10.0064040986231 Dur5[87]= 4054 ' freq= 10.277914816642 Dur5[88]= 3947 ' freq= 10.5565408326999 Dur5[89]= 3843 ' freq= 10.842223956978 Dur5[90]= 3741 ' freq= 11.1378419317473 Dur5[91]= 3642 ' freq= 11.4406004027091 Dur5[92]= 3546 ' freq= 11.7503290092122 Dur5[93]= 3452 ' freq= 12.0702974121282 Dur5[94]= 3361 ' freq= 12.3971040364971 Dur5[95]= 3272 ' freq= 12.7343113284434 Dur5[96]= 3186 ' freq= 13.0780498012136 Dur5[97]= 3102 ' freq= 13.4321942832581 Dur5[98]= 3020 ' freq= 13.7969094922737 Dur5[99]= 2940 ' freq= 14.172335600907 Dur5[100]= 2862 ' freq= 14.5585837409737 Dur5[101]= 2787 ' freq= 14.9503647889008 Dur5[102]= 2713 ' freq= 15.3581521071385 Dur5[103]= 2641 ' freq= 15.7768522024486 Dur5[104]= 2571 ' freq= 16.2064047711656 Dur5[105]= 2504 ' freq= 16.640042598509 Dur5[106]= 2437 ' freq= 17.0975242784845 Dur5[107]= 2373 ' freq= 17.5586458772299 Dur5[108]= 2310 ' freq= 18.037518037518 Dur5[109]= 2249 ' freq= 18.5267526307989 Dur5[110]= 2190 ' freq= 19.0258751902588 Dur5[111]= 2132 ' freq= 19.5434646654159 Dur5[112]= 2076 ' freq= 20.0706486833654 Dur5[113]= 2021 ' freq= 20.616856341745 Dur5[114]= 1967 ' freq= 21.182850364345 Dur5[115]= 1915 ' freq= 21.7580504786771 Dur5[116]= 1865 ' freq= 22.3413762287757 Dur5[117]= 1815 ' freq= 22.9568411386593 Dur5[118]= 1767 ' freq= 23.5804565176382 Dur5[119]= 1721 ' freq= 24.2107301956227 Dur5[120]= 1675 ' freq= 24.8756218905473 Dur5[121]= 1631 ' freq= 25.5466993664418 Dur5[122]= 1588 ' freq= 26.2384550797649 Dur5[123]= 1546 ' freq= 26.9512721000431 Dur5[124]= 1505 ' freq= 27.6854928017719 Dur5[125]= 1465 ' freq= 28.4414106939704 Dur5[126]= 1427 ' freq= 29.1987853305302 Dur5[127]= 1389 ' freq= 29.9976001919846 Return Vels_Lookup: ' velo lookup scale for Laukhuff solenoid. Logarithmic ' Vels_Lookup_Laukhuff: ' used in Flex for the beaters ' in used for the gunshot. ' the values were too long for the gunshot, so there is a ' rescaling at the end of the lookup-data... Vels[1]= 1160 ' duur= .0116 Vels[2]= 1190 ' duur= .0119 Vels[3]= 1206 ' duur= .01206 Vels[4]= 1222 ' duur= .01222 Vels[5]= 1238 ' duur= .01238 Vels[6]= 1254 ' duur= .01254 Vels[7]= 1270 ' duur= .0127 Vels[8]= 1287 ' duur= .01287 Vels[9]= 1303 ' duur= .01303 Vels[10]= 1320 ' duur= .0132 Vels[11]= 1337 ' duur= .01337 Vels[12]= 1355 ' duur= .01355 Vels[13]= 1373 ' duur= .01373 Vels[14]= 1390 ' duur= .0139 Vels[15]= 1408 ' duur= .01408 Vels[16]= 1427 ' duur= .01427 Vels[17]= 1445 ' duur= .01445 Vels[18]= 1464 ' duur= .01464 Vels[19]= 1483 ' duur= .01483 Vels[20]= 1503 ' duur= .01503 Vels[21]= 1522 ' duur= .01522 Vels[22]= 1542 ' duur= .01542 Vels[23]= 1562 ' duur= .01562 Vels[24]= 1582 ' duur= .01582 Vels[25]= 1603 ' duur= .01603 Vels[26]= 1624 ' duur= .01624 Vels[27]= 1645 ' duur= .01645 Vels[28]= 1667 ' duur= .01667 Vels[29]= 1688 ' duur= .01688 Vels[30]= 1710 ' duur= .0171 Vels[31]= 1732 ' duur= .01732 Vels[32]= 1755 ' duur= .01755 Vels[33]= 1778 ' duur= .01778 Vels[34]= 1801 ' duur= .01801 Vels[35]= 1825 ' duur= .01825 Vels[36]= 1848 ' duur= .01848 Vels[37]= 1872 ' duur= .01872 Vels[38]= 1897 ' duur= .01897 Vels[39]= 1921 ' duur= .01921 Vels[40]= 1946 ' duur= .01946 Vels[41]= 1972 ' duur= .01972 Vels[42]= 1997 ' duur= .01997 Vels[43]= 2023 ' duur= .02023 Vels[44]= 2050 ' duur= .0205 Vels[45]= 2077 ' duur= .02077 Vels[46]= 2104 ' duur= .02104 Vels[47]= 2131 ' duur= .02131 Vels[48]= 2159 ' duur= .02159 Vels[49]= 2187 ' duur= .02187 Vels[50]= 2215 ' duur= .02215 Vels[51]= 2244 ' duur= .02244 Vels[52]= 2273 ' duur= .02273 Vels[53]= 2303 ' duur= .02303 Vels[54]= 2333 ' duur= .02333 Vels[55]= 2363 ' duur= .02363 Vels[56]= 2394 ' duur= .02394 Vels[57]= 2425 ' duur= .02425 Vels[58]= 2457 ' duur= .02457 Vels[59]= 2489 ' duur= .02489 Vels[60]= 2521 ' duur= .02521 Vels[61]= 2554 ' duur= .02554 Vels[62]= 2587 ' duur= .02587 Vels[63]= 2621 ' duur= .02621 Vels[64]= 2655 ' duur= .02655 Vels[65]= 2690 ' duur= .0269 Vels[66]= 2725 ' duur= .02725 Vels[67]= 2760 ' duur= .0276 Vels[68]= 2796 ' duur= .02796 Vels[69]= 2833 ' duur= .02833 Vels[70]= 2870 ' duur= .0287 Vels[71]= 2907 ' duur= .02907 Vels[72]= 2945 ' duur= .02945 Vels[73]= 2983 ' duur= .02983 Vels[74]= 3022 ' duur= .03022 Vels[75]= 3061 ' duur= .03061 Vels[76]= 3101 ' duur= .03101 Vels[77]= 3142 ' duur= .03142 Vels[78]= 3183 ' duur= .03183 Vels[79]= 3224 ' duur= .03224 Vels[80]= 3266 ' duur= .03266 Vels[81]= 3309 ' duur= .03309 Vels[82]= 3352 ' duur= .03352 Vels[83]= 3395 ' duur= .03395 Vels[84]= 3440 ' duur= .0344 Vels[85]= 3484 ' duur= .03484 Vels[86]= 3530 ' duur= .0353 Vels[87]= 3576 ' duur= .03576 Vels[88]= 3622 ' duur= .03622 Vels[89]= 3669 ' duur= .03669 Vels[90]= 3717 ' duur= .03717 Vels[91]= 3766 ' duur= .03766 Vels[92]= 3815 ' duur= .03815 Vels[93]= 3864 ' duur= .03864 Vels[94]= 3915 ' duur= .03915 Vels[95]= 3966 ' duur= .03966 Vels[96]= 4017 ' duur= .04017 Vels[97]= 4070 ' duur= .0407 Vels[98]= 4123 ' duur= .04123 Vels[99]= 4176 ' duur= .04176 Vels[100]= 4231 ' duur= .04231 Vels[101]= 4286 ' duur= .04286 Vels[102]= 4342 ' duur= .04342 Vels[103]= 4398 ' duur= .04398 Vels[104]= 4456 ' duur= .04456 Vels[105]= 4514 ' duur= .04514 Vels[106]= 4572 ' duur= .04572 Vels[107]= 4632 ' duur= .04632 Vels[108]= 4692 ' duur= .04692 Vels[109]= 4753 ' duur= .04753 Vels[110]= 4815 ' duur= .04815 Vels[111]= 4878 ' duur= .04878 Vels[112]= 4941 ' duur= .04941 Vels[113]= 5006 ' duur= .05006 Vels[114]= 5071 ' duur= .05071 Vels[115]= 5137 ' duur= .05137 Vels[116]= 5204 ' duur= .05204 Vels[117]= 5272 ' duur= .05272 Vels[118]= 5340 ' duur= .0534 Vels[119]= 5410 ' duur= .0541 Vels[120]= 5480 ' duur= .0548 Vels[121]= 5552 ' duur= .05552 Vels[122]= 5624 ' duur= .05624 Vels[123]= 5697 ' duur= .05697 Vels[124]= 5772 ' duur= .05772 Vels[125]= 5847 ' duur= .05847 Vels[126]= 5923 ' duur= .05923 Vels[127]= 6000 ' duur= .06 For i = 1 To 127 Vels[i] = Vels[i] >> 1 ' divide by 2, for gunshot. Next i Return '[EOF]