' ******************************************************************** ' * PIC firmware for Balsi * ' * Hub board * ' * coded by dr.Godfried-Willem Raes * ' * http://www.logosfoundation.org/instrum_gwr/balsi/picworks * ' * source code development directory: * ' * Balsi_Hub.bas * ' * Version 1.0 * ' * Proton Compiler version 3.6.2.7 11/2018 * ' ******************************************************************** ' hardware: single or double sided PCB 12.2018 - gwr ' the second board can be used for in 2019. ' 01.12.2018: Compiler version 3.5.8.1 ' 05.12.2018: start coding, starting base ' 8 mosfet outputs ' 1 on board 12V relay ' This board serves only the power on/off relay and 8 tungsten lights ' This board performs midi-filtering and has TTL parsed midi out. ' This approach will cause a 1 ms latency in the instrument. ' 18.12.2018: Compiler upgrade to version 3.6.2.7 ' serious revisions of the code were required... ' Balsi_Hub_Irq rewritten, using a procedure to retrieve midi-input ' note mappings for Balsi added ' 19.12.2018: new compiler seems to work with the old USB-key, so we have ' an extra key now. ' 31.12.2018: mapping finalised conform the actual wiring og the board. ' to do: add midiout for notes on motor boards! done. ' First electrical tests passed. ' 04.01.2019: This version flashed. ' 05.01.2019: First test run. Observations: ' rotating light motor works ok. ' rotating light bulb not working - when switched on, all other functions stop working ' pinker lights ok, but repeats not working ' blue light o.k. ' ctrl 66 on works, power off not working... ' horns working, as long as or. rot lights is off ' siren fails intermittent. Check midi through... ' 06.01.2019: Horns ok, pinkers o.k., blue ok ' PWM on orange rotating light removed. Now it works again. ' Even now, the mosfet gets pretty hot... ' 09.01.2019: Siren3 implemented for motorboard 2. ' bug noticed: relay falls of every so on... glitches? ' 10.01.2019: Light flashing implemented for orange motor light. ' ctrl.120 steers rotation speed. ' This version flashed as version 1.0 ' 13.01.2019: ctrl 48 added for lsb control of siren 1 on the first motorboard. Include "18F2620.inc" 'version for the Balsi hub board. (40MHz) 'Include "18F4620.inc" '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 ' 12V ' Mosfet outputs: $define BlueLite PORTC.3 ' blue police light $define OrLeft PORTC.4 $define OrRight PORTC.5 $define Horn1 PORTA.5 ' 12V black $define Horn2 PORTC.0 ' 12V black $define OrLite_pwm PORTC.1 ' pwm rotating light 55W $define OrMot_pwm PORTC.2 ' pwm rotating light motor 12V ' inputs: $define sensor1 PORTA.0 $define sensor2 PORTA.1 ' LED's: $define BlueLed 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 Input sensor2 'constant definitions: Symbol fPwm = 21000 ' PWMminF ' midi note mapping Symbol Horn1_note = 96 ' Balsi Symbol Horn2_note = 97 Symbol OrLite_note = 120 ' rotating light 55W, motor= ctrl 120 Symbol Blue_lite_note = 122 Symbol OrLeft_note = 123 Symbol OrRight_note = 124 Symbol siren_low_note = 42 ' Balsi 24V - mot.board 1 Symbol siren_high_note = 84 ' Balsi 24V - mot.board 1 Symbol siren2_note = 24 ' Balsi 220V dc - mot.board 2 Symbol siren3_note = 25 Symbol bell_note = 28 Symbol horn3_note = 98 Symbol horn4_note = 99 ' constants: Symbol True = 1 Symbol False = 0 'initialisations for the midi input parser: Symbol Midichannel = 15 ' Balsi 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 ' 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 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 MotSpeed As Byte System ' for ctrl 120, orange light motor speed. Dim time As Dword System ' 32-bit, incremented in loopcounter Dim maxtim As time.31 ' overflow bit, will cause timer reset after 1h45 Dim t As Byte System ' loopcounter, running at 4 times time-clock Dim tog As Byte System Dim tg As tog.0 ' divide by 4 bit Dim TimVals[7] 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 "Balsi_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 ' Main program starts here: MAIN: High Debug_Led DelayMS 10 ' wait for stability Low Debug_Led Low Power_Relay Low BlueLed Low Horn1 Low Horn2 Low OrLite_pwm Low OrMot_pwm Low BlueLite Low OrLeft Low OrRight Clear notes Clear Velflags Set TimVals ' no timers running on startup Clear CC66 ' power off MotSpeed = 127 ' default on start-up 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 bot, 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 Inc t ' byte If t.1 = tg Then Btg tg Inc time ' dword EndIf 'Bytein = GetMidiIn ' was: HRSIn ' Read data from the serial buffer, with no timeout GetMidiIn () ' wa cannot create functions in Proton... Bytein = MidiIn ' this function is defined in Balsi_Hub_irq.inc ' Start the midi parser. Midi_Parse: If Bytein > Control_Status Then ' here higher statusses are not implemented. 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 '= 255 Set velo '= 255 Case Keypres_Status statusbyte = Bytein Set notePres '= 255 Set pres Case Control_Status ' controllers and switches statusbyte = Bytein Set Ctrl Set value Case ProgChange_Status ' could be used for different lookup tables statusbyte = Bytein Set prog Case Aftertouch_Status ' not used on this board 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 siren2_note '24 HRSOut NoteOff_Status, siren2_note, release ' mot. board 2 Case siren3_note ' 25 HRSOut NoteOff_Status, siren3_note, release Case bell_note '28 HRSOut NoteOff_Status, noteUit, 0 ' mot. board 2 Case siren_low_note To siren_high_note HRSOut NoteOff_Status, noteUit, release ' mot.board 1 Case Horn1_note Clear Horn1 Clear Velflags.0 Clear notes.0 Set TimVals[0] Case Horn2_note Clear Horn2 Clear Velflags.1 Clear notes.1 Set TimVals[1] Case horn3_note, horn4_note HRSOut NoteOff_Status, noteUit, 0 'release ' mot. board 1,2 Case OrLite_note ' 120 - rotating light 'HPWM 2, 0, fPwm ' shouldn't we also turn motor off? Clear OrLite_pwm ' light off HPWM 1, 0, fPwm ' motor off Clear Velflags.3 ' stop flashing Set TimVals[3] Case Blue_lite_note ' 4 Clear BlueLite Case OrLeft_note ' 5 Clear OrLeft Clear Velflags.5 Clear notes.5 Set TimVals[5] Case OrRight_note ' 6 Clear OrRight Clear Velflags.6 Clear notes.6 Set TimVals[6] Case Else GoTo Check_Timers EndSelect Set noteUit '= 255 '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 siren2_note HRSOut NoteOn_Status, siren2_note, 0 Case siren3_note HRSOut NoteOn_Status, siren3_note, 0 Case bell_note HRSOut NoteOn_Status, noteAan, 0 Case siren_low_note To siren_high_note HRSOut NoteOn_Status, noteAan, 0 Case Horn1_note Clear Horn1 Clear Velflags.0 Clear notes.0 Set TimVals[0] Case Horn2_note Clear Horn2 Clear Velflags.1 Clear notes.1 Set TimVals[1] Case horn3_note, horn4_note HRSOut NoteOn_Status, noteAan, 0 Case OrLite_note Clear OrLite_pwm ' light off 'HPWM 2, 0, fPwm HPWM 1, 0, fPwm ' switch motor off: Clear Velflags.3 Set TimVals[3] Case Blue_lite_note Clear BlueLite Case OrLeft_note Clear OrLeft Clear Velflags.5 Clear notes.5 Set TimVals[5] Case OrRight_note Clear OrRight Clear Velflags.6 Clear notes.6 Set TimVals[6] Case Else GoTo Check_Timers EndSelect GoTo resort Else If PowerOn = 1 Then ' dont do things if power is off Select noteAan Case siren2_note HRSOut NoteOn_Status, siren2_note, velo Case siren3_note HRSOut NoteOn_Status, siren3_note, velo Case bell_note HRSOut NoteOn_Status, noteAan, velo Case siren_low_note To siren_high_note HRSOut NoteOn_Status, noteAan, velo Case Horn1_note pres0 = velo ' need to store velo for the repeats Set Horn1 ' aan If pres0 < 127 Then ' pres0 is altijd > 0 Set notes.0 ' steers repeats TimVals[0] = time + Dur5[pres0] Set Velflags.0 Else Clear notes.0 ' single stroke, no repeats Clear Velflags.0 Set TimVals[0] EndIf Case Horn2_note pres1 = velo Set Horn2 If pres1 < 127 Then Set notes.1 TimVals[1] = time + Dur5[pres1] Set Velflags.1 Else Clear notes.1 Clear Velflags.1 Set TimVals[1] EndIf Case horn3_note, horn4_note HRSOut NoteOn_Status, noteAan, velo Case OrLite_note '120 'HPWM 2, velo + velo, fPwm ' bulb Set OrLite_pwm HPWM 1, MotSpeed, fPwm ' motor - ctrl 120 pres3 = velo If pres3 < 127 Then Set notes.3 TimVals[3] = time + Dur[pres3] Set Velflags.3 Else Clear notes.3 Clear Velflags.3 Set TimVals[3] EndIf Case Blue_lite_note ' 122 Set BlueLite ' simply on / off Case OrLeft_note ' 123 pres5 = velo Set OrLeft If pres5 < 127 Then Set notes.5 TimVals[5] = time + Dur[pres5] Set Velflags.5 Else Clear notes.5 Clear Velflags.5 Set TimVals[5] EndIf Case OrRight_note '124 pres6 = velo Set OrRight If pres6 < 127 Then Set notes.6 TimVals[6] = time + Dur[pres6] Set Velflags.6 Else Clear notes.6 Clear Velflags.6 Set TimVals[6] EndIf Case Else Set noteAan GoTo Check_Timers EndSelect EndIf Set noteAan '= 255 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 'not implemented If prog = 255 Then 'single byte message prog = Bytein ' If prog < 8 Then ' HRSOut ProgChange_Status, prog ' prog changes 0-7 passed. ' EndIf 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 ' not used on this board If pblsb = 255 Then pblsb = Bytein Else pbmsb = Bytein GoSub Pitchbend EndIf GoTo Check_Timers EndSelect EndIf resort: GoSub SortTimers ' so we resort only if an incoming midi command changed something Check_Timers: If idx < 7 Then ' we moeten alleen checken wanneer er een timer loopt If time >= 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 ' note Horn1_note ' just toggle on/off If notes.0 = 0 Then ' no repeats required Clear Horn1 Set TimVals[0] Else ' repeat flag is set Toggle Horn1 TimVals[0] = time + Dur5[pres0] EndIf Case 1 ' horn2_note If notes.1 = 0 Then Clear Horn2 Set TimVals[1] Else Toggle Horn2 TimVals[1] = time + Dur5[pres1] ' =Rate1 EndIf Case 2 ' If notes.2 = 0 Then ' Clear OrLite_pwm Set TimVals[2] ' Else ' Toggle OrLite_pwm ' TimVals[2] = time + Dur[pres2] ' EndIf Case 3 ' oranje zwaailicht If notes.3 = 0 Then ' we let the motor run continuously Clear OrLite_pwm Set TimVals[3] Else Toggle OrLite_pwm TimVals[3] = time + Dur[pres3] EndIf Case 4 ' If notes.4 = 0 Then ' Clear BlueLite Set TimVals[4] ' Else ' Toggle BlueLite ' TimVals[4] = time + Dur[pres4] ' EndIf Case 5 If notes.5 = 0 Then Clear OrLeft Set TimVals[5] Else Toggle OrLeft TimVals[5] = time + Dur[pres5] EndIf Case 6 If notes.6 = 0 Then Clear OrRight Set TimVals[6] Else Toggle OrRight TimVals[6] = time + Dur[pres6] EndIf '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 time Clear notes Set TimVals EndIf Else ' idx > 5, no timers running, so to avoid overflows, we can reset the loop timer If maxtim = 1 Then Clear time ' 16.06.2015 EndIf Btg PORTB.0 ' average loop-speed: 10 microseconds or 84kHz (Tektronix measurement, 27.05.2016) ' with glitches ca. 50 microseconds in length. ' to be measured again! ' 18.12.2018: measured as 115kHz at no load. Loop ' = GoTo Hoofdlus 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 6 If TimVals[i] < Nxt Then Nxt = TimVals[i] ' 7 dword comparisons idx = i EndIf Next i Return KeyPres: Select notePres 'Case siren_low_note To siren_high_note ' HRSOut Keypres_Status, notePres, pres Case Horn1_note ' should program the repetition rate - notes.0 flag pres0 = pres Case Horn2_note pres1 = pres Case horn3_note, horn4_note HRSOut Keypres_Status, notePres, pres Case OrLite_note ' zwaailicht pres3 = pres ' flashing rate Case OrLeft_note pres5 = pres Case OrRight_note pres6 = pres EndSelect ' we do not need to resort here Set notePres '= 255 Return ProgChange: ' not implemented here. Set prog '= 255 'this is not realy required Return Pitchbend: Set pblsb Return Aftertouch: 'this is the channel aftertouch, affecting any playing note 'not implemented here. Set aft ' reset Return Controller: Select Ctrl Case 7 HRSOut Control_Status, 7, value ' controller passed to midi out Case siren2_note ' not a bug! = 24 HRSOut Control_Status, 24, value ' controllers passed to midi out Case siren3_note ' = 25 HRSOut Control_Status, 25, value Case 30 ' can be used for global repeat frequency ' do we need to forward this to the motor boards? ' we dont do this, as repeats there are for the horns only pres0 = value pres1 = value pres3 = value pres5 = value pres6 = value pres7 = value Case 48 ' lsb controller for big siren on motorboard 1 HRSOut Control_Status, 48, value Case 66 'on/off for the robot ' this should also go to the motor boards! HRSOut Control_Status, 66, value If value = 0 Then Clear PowerOn 'CC66.0 =0 GoSub PowerDown Else High Power_Relay Set BlueLed Set PowerOn 'CC66.0 =1 EndIf Case 67 HRSOut Control_Status, 67, value Case 68 HRSOut Control_Status, 68, value Case 120 ' motor for the orange flashlight MotSpeed = value + value HPWM 1, MotSpeed, fPwm Case 123 ' all notes off - no controller resets HRSOut Control_Status, 123, 0 Clear notes Clear Velflags Clear Horn1 Clear Horn2 'HPWM 2, 0, fPwm Clear OrLite_pwm HPWM 1, 0, fPwm Clear BlueLite Clear OrLeft Clear OrRight EndSelect Set Ctrl 'mandatory reset Return PowerDown: Low Power_Relay Clear BlueLed Clear Velflags 'stop all running timers Clear notes Clear pres0 Clear pres1 Clear pres3 Clear pres5 Clear pres6 Clear pres7 Clear Horn1 Clear Horn2 'HPWM 2, 0, fPwm Clear OrLite_pwm HPWM 1, 0, fPwm ' stop motor MotSpeed = 127 ' set to default Clear BlueLite Clear OrLeft Clear OrRight Clear CC66 Return Dur_Lookup: 'lookup for repeat frequencies Set Dur[0] ' used for lights ' durations for note repetition on Chi ' the dur values are for a half period ! ' the frequencies are for the full period. ' on Flex-Pi/e-saw used for the beater repeats 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 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 Return '[EOF]