'-------------------------------------------------------------------------------- 'name : MagneOSC_V2p3.bas 'purpose : Coil signal gen. ver.2.3 for u-robot & Ortho-Ring. 'micro controller : Mega328P with internal 8MHz CK. ' : NOTE: AVR was changed from Mega168 to Mega328P. 'pulse is output from FPGA (Cyclone) with fast DAC(AD9763). 'max frequency = 50 kHz (Objective spec.) 'max V-out from Power OP-AMP is displayed. ' AMP gain = 3. AMP Vmax/Vmin = +20V / -20V '. 'Phase control of two outputs version. 'Ver2.1 : only inphase & out phase. (PB0 is used for WRBusyN) 'Ver2.2 : Arbitral phase difference. (PB0 is used for WRBusyN) ' : data is software generated. 'Ver2.3 : Arbitral phase difference. (PB0 is used for /SS3) ' : phase difference is FPGA generated. '-------------------------------------------------------------------------------- Const Maxfreq = 50000.01 ' .01 is for error in single float OP ' operations '-------------------------------------------------------------------------------- ' Mode0 : Sine wave ' parameters P0 : freqency Hz ' P1 : V lowest ' P2 : V highest ' P3 : Phase difference between CH0 and CH1.(0 ~ 350, 10 deg. step) ' ' Mode1 : Square wave ' parameters P0 : freqency Hz ' P1 : V lowest ' P2 : V highest ' P3 : Phase difference between CH0 and CH1. ' ' Mode2 : Triangle wave ' parameters P0 : freqency Hz ' P1 : V lowest ' P2 : V highest ' P3 : Phase difference between CH0 and CH1. ' ' Mode3 : Saw-tooth wave ' parameters P0 : freqency Hz ' P1 : V lowest ' P2 : V highest ' P3 : Phase difference between CH0 and CH1. ' ' ' Mode4 : Arbitral wave (10 steps) ' parameters P0 : freqency Hz ' SQN[10] : sequence N (word) ' SQV[10] : sequence V (int) ' Note: phase difference is used that set in Mode0-3. ' Const Maxmode = 4 ' Currentry support upto mode 4 ' In future, will support mode 5 to 9, ' which support different setting of parameters to CH-2. ' Rem Used ports '-------------------------------------------------------------------------------- ' PB0 : /SS3 to FPGA (for setting of Phase difference 10-bit) ' PB1 : Data WR CH select (CH1/CH0) ' PB2 : /SS to FPGA (DAC data RAM WR) ' PB3 : MOSI to FPGA ' PB4 : MISO (used for programing Mega168) ' PB5 : SCK to FPGA ' PB6 : WR address counter /clear ' PB7 : Pulse output /Start ' PC0-3 : LCD - ' PC4 : LCD E ' PC5 : LCD RS ' PD0 : Rotary encoder A ' PD1 : Rotary encoder B ' PD2 : SW1 (1=Push), INT0 ' PD3 : SW2 (1=Push), INT1 ' PD4 : SW3 (1=Push), T0 ' PD5 : SW4 (1=Push), T0 ' PD6 : /SS2 to FPGA (for 32-bit Phase data out) ' PD7 : LED1 Red (1=emit) '-------------------------------------------------------------------------------- $regfile = "m328pdef.dat" $crystal = 8000000 ' 8MHz int. clock $hwstack = 128 ' Sufficient HardWare Stack for multiple interrupts etc. $swstack = 128 ' used in multiple GOSUB nest. $framesize = 64 Const Dly1 = 300 ' LED brink wait [ms] Const Dpoint = 1024 ' data point Const Dpoint2 = 512 ' half of Dpoint Const Lf0 = 100000000 Const Fd = 4294967296 ' 32-bit long max value Rem Liquid Crystal Display (LCD) pin number definition Config Lcdpin = Pin , Db4 = Portc.0 , Db5 = Portc.1 , Db6 = Portc.2 , Db7 = Portc.3 Config Lcdpin = Pin , E = Portc.4 , Rs = Portc.5 Config Lcd = 16 * 2 Rem I/O port pin number definitions Config Portb.0 = Output ' /SS3 Config Portb.1 = Output ' WR CH sel Config Portb.2 = Output ' /SS 'Config Portb.3 = Output ' MOSI 'Config Portb.5 = Output ' SCK Ssn3 Alias Portb.0 Wr_ch Alias Portb.1 Ssn Alias Portb.2 Config Portd.7 = Output ' LED1 Led1 Alias Portd.7 Config Portd.2 = Input ' /SW1, Int0 Config Portd.3 = Input ' /SW2, Int1 Config Portd.4 = Input ' /SW3, T0 Config Portd.5 = Input ' /SW4 Sw1 Alias Pind.2 Sw2 Alias Pind.3 Sw3 Alias Pind.4 Sw4 Alias Pind.5 Config Portd.0 = Input ' Rotary encoder A pin Config Portd.1 = Input ' Rotary encoder B pin Config Portb.6 = Output ' WR counter /clear Config Portb.7 = Output ' /Start Config Portd.6 = Output ' /SS2 Wc_clrn Alias Portb.6 Startn Alias Portb.7 Ssn2 Alias Portd.6 Rem type definition of variables Dim I As Word , J As Word , K As Word , I2 As Word Dim M As Word , N As Word ' Read count for sine table Dim X As Single , Y As Single , Z As Single Dim D As Integer , D1 As Integer , D2 As Integer Dim Sw1f As Bit , Sw2f As Bit , Sw4f As Bit ' SW flags Dim Sw3f As Byte Dim F As Single , F0 As Single , F2 As Single ' frequency Dim Delta As Single Dim Digit As Byte Dim Fflag As Byte , Fcount As Byte Dim Opmode As Byte ' mode Dim V As Single , Vlow As Single , Vhigh As Single Dim Vtemp As Single Dim Lng As Long Dim Lhword As Integer At Lng + 2 Overlay Dim Vdelta As Single Dim Lvdelta As Long Dim Lng2 As Long ' for working Dim Lhword2 As Integer At Lng2 + 2 Overlay Dim Hbyte As Byte At Lng2 + 3 Overlay Dim Hmbyte As Byte At Lng2 + 2 Overlay Dim Lmbyte As Byte At Lng2 + 1 Overlay Dim Lbyte As Byte At Lng2 Overlay Dim Sdao(4) As Byte Dim Lvlow As Long Dim Ivlow As Integer At Lvlow + 2 Overlay Dim Lvhigh As Long Dim Ivhigh As Integer At Lvhigh + 2 Overlay Dim Voffset As Single , Vmag As Single ' for sin wave Dim Lvoffset As Long , Lvmag As Long Dim Lvunit As Long Dim Svunit As Single Dim Smunit As Single Dim Dacch As Byte Dim Dacdata As Integer Dim Highbyte As Byte At Dacdata + 1 Overlay ' Dacdata higher byte Dim Lowbyte As Byte At Dacdata Overlay ' Dacdata lower byte Dim S As String * 20 Dim S2 As String * 20 Dim Cpos As Byte Dim B As Byte , B2 As Byte Dim Sqn(10) As Word ' sequence N Dim Sqv(10) As Integer ' sequence V Dim Sq As Word , Sqnn1 As Word , Sqnn2 As Word ' sequence step Dim Sqvv As Integer , Sqdelta As Integer Dim Fsqvv As Single , Fsqdelta As Single Dim Ivmin As Integer , Ivmax As Integer Dim Sq2 As Byte Dim Xf As Eram Single Dim Xvlow As Eram Single Dim Xvhigh As Eram Single Dim Xsqn(10) As Eram Word Dim Xsqv(10) As Eram Integer Dim Phase As Integer Dim Xphase As Eram Integer Rem program start Rem Port initialize Reset Led1 Set Ssn ' reset SPI SEL Set Ssn2 Set Ssn3 Set Startn Set Wc_clrn Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 4 , Noss = 1 Spiinit Rem initialize variables Vlow = Xvlow If Vlow < -20.1 Or Vlow > 19.51 Then Vlow = -20 Xvlow = Vlow End If Vhigh = Xvhigh V = Vlow + 0.49 If Vhigh > 20.1 Or Vhigh < -19.51 Then If Vhigh < V Then Vhigh = 20 Xvhigh = Vhigh End If End If Digit = 1 Gosub Deltaset F = Xf If F <= 0 Or F > Maxfreq Then F = 1 Xf = F End If Phase = Xphase If Phase > 350 Or Phase < 0 Then Phase = 0 Xphase = Phase End If Rem used variable set ' Hex value set Lng = &H01FF_0000 ' 10-bit max Z = Lng Svunit = Z / 20 Lvunit = Svunit ' Lvunit corresponds to 1V Long Hex value Smunit = Z ' magnify factor max unit X = 20 * Svunit Lng = X Ivmax = Lhword ' integer V max X = -20 * Svunit Lng = X Ivmin = Lhword ' integer V min X = Vlow * Svunit Lvlow = X Lng2 = Lvlow X = Vhigh * Svunit Lvhigh = X Rem initialize arbitral wave setting parameters For I = 1 To 10 K = Xsqn(i) If I = 1 Then If K <> 1 Then Sqn(i) = 1 Xsqn(i) = 1 End If Else If K > Dpoint Then K = Dpoint Xsqn(i) = K End If Sqn(i) = K End If D = Xsqv(i) If D > Ivmax Or D < Ivmin Then D = 0 Xsqv(i) = D End If Sqv(i) = D Next I Sq = 1 Sqn(1) = 1 Sqn(10) = Dpoint If Xsqn(10) <> Dpoint Then Xsqn(10) = Dpoint Sq2 = 1 Rem flag initialize Reset Sw1f Reset Sw2f Sw3f = 0 Reset Sw4f Opmode = 0 'Ttemp = 0 Rem LCD initialize Cls ' Clear LCD Screen Cursor Off Lcd "Coil driver F" ' Character print to LCD Lowerline ' move to lower line in LCD screen Lcd "ver. 0.3 Start" ' LED test ' toggle the LED bits Set Led1 For I = 1 To 8 Toggle Led1 ' change bit 1/0 Waitms Dly1 ' wait Dly1 ms Next I Reset Led1 Opmode = 0 Gosub Mdisp Config Int0 = Rising ' 1 to 0 rising edge makes interrupt Config Int1 = Rising On Int0 I0_intsub ' Interrupt subroutine definition On Int1 I1_intsub ' Interrupt subroutine definition Enable Int0 Enable Int1 Gosub Fchange ' set FPGA_phase (frequency) Gosub Vchange ' set volt parameters Gosub Pchange ' set Phase difference between CH0 & 1 Enable Interrupts ' SW1 = Mode set ' SW2 = Signal output ON/OFF ' SW3 = Parameter set change ' SW4 = digit change ' If rotate rotary encoder, change frequency or parameters Do B = Encoder(pind.0 , Pind.1 , Rencl , Rencr , 0) ' rotary encoder sense If Sw3 = 1 Then Incr Sw3f If Opmode < 4 Then If Sw3f > 3 Then Sw3f = 0 End If Else If Sw3f > 3 Then Sw3f = 0 End If End If Select Case Opmode Case 0 To 3: Select Case Sw3f Case 0: Locate 2 , 1 Lcd " "; Gosub Fdisp Case 1: Locate 2 , 1 Lcd "*"; Gosub Vldisp Case 2: Locate 2 , 1 Lcd "*"; Gosub Vhdisp Case 3: Locate 2 , 1 Lcd "*"; Gosub Delta_pdisp End Select Case 4: Select Case Sw3f Case 0: Locate 2 , 1 Lcd " "; Gosub Fdisp Case 1 To 3: Gosub Sqdisp End Select End Select Bitwait Sw3 , Reset ' wait SW3 release End If If Sw4 = 1 Then Gosub Change_digit Gosub Deltaset Gosub Fdisp Bitwait Sw4 , Reset ' wait SW4 release End If Loop Rem Subroutines Rem rotary encoder Left Rencl: If B <> &B00 Then Return If Sw2f = 1 Then Disable Interrupts Select Case Sw3f Case 0: F0 = F F = F - Delta If F < 0.01 Then F = F0 Else Gosub Fdisp Gosub Fchange End If Xf = F Case 1: If Opmode < 4 Then Vlow = Vlow - 1 If Vlow < -20.1 Then Vlow = -20 Else Gosub Vldisp Gosub Vchange Xvlow = Vlow End If Else If Opmode = 4 Then Sq2 = Sq2 - 1 If Sq2 < 1 Then Sq2 = 1 Gosub Sqdisp End If End If Case 2: If Opmode <> 4 Then Vtemp = Vhigh Vhigh = Vhigh - 1 V = Vlow + 1 If Vhigh < V Then Vhigh = Vtemp Else Gosub Vhdisp Gosub Vchange Xvhigh = Vhigh End If Else If Sq2 <> 1 Then K = Sqn(sq2) M = Sq2 - 1 J = Sqn(m) If K = Dpoint Then K = K - 4 Else K = K - 10 If K > M Then Sqn(sq2) = K Xsqn(sq2) = K End If Gosub Sqdisp End If End If Case 3: If Opmode = 4 Then Lng = 0 Lhword = Sqv(sq2) X = Lng X = X / Svunit X = X - 1 X = Round(x) If X > -20.1 Then X = X * Svunit Lng = X Sqv(sq2) = Lhword Xsqv(sq2) = Lhword End If Gosub Sqdisp Else Phase = Phase - 10 If Phase < 0 Then Phase = 350 Xphase = Phase Gosub Delta_pdisp Gosub Pchange End If End Select ' end of Select Case Sw3f If Sw2f = 1 Then Enable Interrupts Return Rem rotary encoder Right Rencr: If B <> &B10 Then Return If Sw2f = 1 Then Disable Interrupts Select Case Sw3f Case 0: F0 = F F = F + Delta If F > Maxfreq Then F = F0 Else Gosub Fdisp Gosub Fchange End If Xf = F Case 1: If Opmode <> 4 Then Vtemp = Vlow V = Vhigh - 1 Vlow = Vlow + 1 If Vlow < V Then If Vlow > 19.01 Then Vlow = 19.0 End If Gosub Vldisp Gosub Vchange Xvlow = Vlow Else Vlow = Vtemp End If Else Sq2 = Sq2 + 1 If Sq2 > 10 Then Sq2 = 10 Gosub Sqdisp End If Case 2: If Opmode <> 4 Then Vtemp = Vhigh Vhigh = Vhigh + 1 If Vhigh > 20.01 Then Vhigh = Vtemp Else Gosub Vhdisp Gosub Vchange Xvhigh = Vhigh End If Else If Sq2 <> 1 Then K = Sqn(sq2) M = Sq2 - 1 J = Sqn(m) K = K + 10 If K > Dpoint Then K = Dpoint Sqn(sq2) = K Else If K > M Then Sqn(sq2) = K Xsqn(sq2) = K End If End If Gosub Sqdisp End If End If Case 3: If Opmode = 4 Then Lng = 0 Lhword = Sqv(sq2) X = Lng X = X / Svunit X = X + 1 X = Round(x) If X < 20.1 Then X = X * Svunit Lng = X Sqv(sq2) = Lhword Xsqv(sq2) = Lhword End If Gosub Sqdisp Else Phase = Phase + 10 If Phase > 350 Then Phase = 0 Xphase = Phase Gosub Delta_pdisp Gosub Pchange End If End Select ' end of Select Case Sw3f If Sw2f = 1 Then Enable Interrupts Return Rem digit change Change_digit: Incr Digit If Digit > 5 Then Digit = 0 Return Rem delta set Rem Digit -> Delta Deltaset: Select Case Digit Case 0 : Delta = 0.1 Case 1 : Delta = 1 Case 2 : Delta = 10 Case 3 : Delta = 100 Case 4 : Delta = 1000 Case 5 : Delta = 10000 End Select Return Fdisp: S2 = Fusing(f , "#####.#") S = Format(s2 , "0000000") S = S + "Hz " Locate 1 , 5 Lcd S; Select Case Phase Case 0: S = ":I" ' In-phase out Case 1: S = ":O" ' Out-phase out Case 2: S = ":1" ' CH-1 only Case 3: S = ":2" ' CH-2 only Case 4: S = ":A" ' Arbitral phase difference End Select Lcd S; Cpos = 10 - Digit If Digit = 0 Then Incr Cpos Cursor Off Cursor On Locate 1 , Cpos Return ' V low display Vldisp: S2 = Fusing(vlow , "###.#") S = "V low = " + S2 S = S + "V " If Sw3f <> 0 Then S = "*" + S Else S = " " + S Locate 2 , 1 Lcd S Return ' V high display Vhdisp: S2 = Fusing(vhigh , "###.#") S = "Vhigh = " + S2 S = S + "V " If Sw3f <> 0 Then S = "*" + S Else S = " " + S Locate 2 , 1 Lcd S Return ' Sequence pattern display Sqdisp: Locate 2 , 1 If Sw3f = 1 Then Lcd "*"; Else Lcd " "; End If Lcd Sq2 ; ":"; If Sw3f = 2 Then Lcd "*"; Else Lcd " "; End If K = Sqn(sq2) Lcd K; If Sw3f = 3 Then Lcd ",*"; Else Lcd ", "; End If Lng = 0 Lhword = Sqv(sq2) X = Lng X = X / Svunit S2 = Fusing(x , "###.#") S2 = S2 + " " Lcd S2 Return ' Phase difference display Delta_pdisp: S2 = Str(phase) S = "Phase Dif = " + S2 S = S + " " If Sw3f <> 0 Then S = "*" + S Else S = " " + S Locate 2 , 1 Lcd S Return Rem mode display Mdisp: Cls Upperline Select Case Opmode Case 0: Lcd "Sin " Case 1: Lcd "Sqr " Case 2: Lcd "Tri " Case 3: Lcd "Saw " Case 4: Lcd "Arb " End Select If Opmode < 4 Then Gosub Vldisp Else Gosub Sqdisp End If Gosub Fdisp Return Rem F change Fchange: F2 = F / Lf0 F2 = F2 * Fd Lng2 = F2 Sdao(1) = Hbyte Sdao(2) = Hmbyte Sdao(3) = Lmbyte Sdao(4) = Lbyte If Sw2f = 1 Then Set Startn Reset Ssn2 Spiout Sdao(1) , 4 ' FPGA frequency phase Set Ssn2 If Sw2f = 1 Then Reset Startn Return Rem V change Vchange: Select Case Opmode Case 0 : ' sin wave X = Vhigh - Vlow X = X / 40 ' mag. factor X = X * Smunit ' normalize factor Lng = X Lvmag = Lng / &H200 ' convert to fractional of 10-bit X = Vhigh + Vlow X = X / 2 X = X * Svunit Lvoffset = X ' offset Case 1 ' square wave: X = Vlow * Svunit Lvlow = X X = Vhigh * Svunit Lvhigh = X Case 2: ' triangle wave X = Vlow * Svunit Lvlow = X X = Vhigh * Svunit Lvhigh = X Vdelta = Vhigh - Vlow Vdelta = Vdelta / 512 X = Vdelta * Svunit Lvdelta = X Case 3 : ' saw-tooth wave X = Vlow * Svunit Lvlow = X X = Vhigh * Svunit Lvhigh = X Vdelta = Vhigh - Vlow Vdelta = Vdelta / Dpoint X = Vdelta * Svunit Lvdelta = X ' Case 4 : ' arbitral wave ' does not change voltage in Opmode4 End Select If Opmode < 4 Then If Sw2f = 1 Then Gosub Wr_fpga End If End If Return Rem data write to FPGA Wr_fpga: Select Case Opmode Case 0: ' mode0 = sin wave Reset Wr_ch Reset Wc_clrn Set Wc_clrn Restore Tsine For I = 1 To Dpoint If I = Dpoint2 Then Restore Tsine Read D If I >= Dpoint2 Then D = -d Lng2 = D Lng2 = Lng2 * Lvmag Lng2 = Lng2 + Lvoffset Lng2 = Lng2 + &H8000 ' 4sya-5nyu Gosub Wrdata Next I Set Wr_ch Reset Wc_clrn Set Wc_clrn Restore Tsine For I = 1 To Dpoint If I = Dpoint2 Then Restore Tsine Read D If I >= Dpoint2 Then D = -d Lng2 = D Lng2 = Lng2 * Lvmag Lng2 = Lng2 + Lvoffset Lng2 = Lng2 + &H8000 ' 4sya-5nyu Gosub Wrdata Next I Case 1: ' mode1 = square wave Reset Wr_ch Reset Wc_clrn Set Wc_clrn For I = 1 To Dpoint If I <= 512 Then Lhword2 = Ivlow Else Lhword2 = Ivhigh End If Gosub Wrdata Next I Set Wr_ch Reset Wc_clrn Set Wc_clrn For I = 1 To Dpoint If I <= 512 Then Lhword2 = Ivlow Else Lhword2 = Ivhigh End If Gosub Wrdata Next I Case 2: ' mode2 = triangle wave Reset Wr_ch Reset Wc_clrn Set Wc_clrn Lng2 = Lvlow For I = 1 To Dpoint Gosub Wrdata If I <= 512 Then Lng2 = Lng2 + Lvdelta Else Lng2 = Lng2 - Lvdelta End If Next I Set Wr_ch Reset Wc_clrn Set Wc_clrn Lng2 = Lvlow For I = 1 To Dpoint Gosub Wrdata If I <= 512 Then Lng2 = Lng2 + Lvdelta Else Lng2 = Lng2 - Lvdelta End If Next I Case 3: ' mode3 = saw-tooth wave Reset Wr_ch Reset Wc_clrn Set Wc_clrn Lng2 = Lvlow For I = 1 To Dpoint Gosub Wrdata If I < Dpoint Then Lng2 = Lng2 + Lvdelta Else Lng2 = Lvlow End If Next I Set Wr_ch Reset Wc_clrn Set Wc_clrn Lng2 = Lvlow For I = 1 To Dpoint Gosub Wrdata If I < Dpoint Then Lng2 = Lng2 + Lvdelta Else Lng2 = Lvlow End If Next I Case 4: ' mode4 = arbitral wave Reset Wr_ch Reset Wc_clrn Set Wc_clrn Sq = 2 Sqnn1 = 1 Sqnn2 = Sqn(2) D1 = Sqv(1) D2 = Sqv(2) D = D2 - D1 K = Sqnn2 - Sqnn1 X = D Y = K Fsqdelta = X / Y Fsqvv = D1 For I = 1 To Dpoint Lhword2 = Fsqvv Gosub Wrdata If I <= Sqnn2 Then Fsqvv = Fsqvv + Fsqdelta Else Sqnn1 = Sqn(sq) D1 = Sqv(sq) Sq = Sq + 1 Sqnn2 = Sqn(sq) D2 = Sqv(sq) D = D2 - D1 K = Sqnn2 - Sqnn1 X = D Y = K Fsqdelta = X / Y Fsqvv = D1 End If Next I Set Wr_ch Reset Wc_clrn Set Wc_clrn Sq = 2 Sqnn1 = 1 Sqnn2 = Sqn(2) D1 = Sqv(1) D2 = Sqv(2) D = D2 - D1 K = Sqnn2 - Sqnn1 X = D Y = K Fsqdelta = X / Y Fsqvv = D1 For I = 1 To Dpoint Lhword2 = Fsqvv Gosub Wrdata If I <= Sqnn2 Then Fsqvv = Fsqvv + Fsqdelta Else Sqnn1 = Sqn(sq) D1 = Sqv(sq) Sq = Sq + 1 Sqnn2 = Sqn(sq) D2 = Sqv(sq) D = D2 - D1 K = Sqnn2 - Sqnn1 X = D Y = K Fsqdelta = X / Y Fsqvv = D1 End If Next I End Select Return Rem Write data to FPGA Wrdata: Sdao(1) = Hbyte Sdao(2) = Hmbyte Sdao(1) = Sdao(1) + 2 ' 10-bit offset binary Reset Ssn Spiout Sdao(1) , 2 Set Ssn ' Bitwait Wrbusyn , Set Waitus 1 Return Rem set Phase difference to FPGA Pchange: X = Phase X = X / 360 X = X * Dpoint Lng2 = X Sdao(1) = Lmbyte Sdao(2) = Lbyte Reset Ssn3 Spiout Sdao(1) , 2 Set Ssn3 Return Rem Start pulse out ' Drive output Drive: If Opmode <> 4 Then Gosub Vchange End If Gosub Wr_fpga Set Led1 Reset Startn Return ' Drive stop Stop_drive: Set Startn Reset Led1 Return Rem Interrupt subroutines Rem SW1 INT0: mode change I0_intsub: Reset Sw2f Gosub Stop_drive If Opmode = 4 Then Sw3f = 0 Incr Opmode If Opmode > Maxmode Then Opmode = 0 End If Sq2 = 1 Gosub Mdisp Return Rem SW2 INT1: pulse out ON/OFF I1_intsub: Toggle Sw2f If Sw2f = 1 Then Gosub Drive Else Gosub Stop_drive End If I1_int20: Return End Rem 1024 point 10-bit integer sine table (offset binary) ' store only theta = 0 to pi. ' In the area of pi to 2 pi, sine = - sine(0 to pi). Tsine: Data 0% , 3% , 6% , 9% , 12% , 15% , 18% , 21% Data 25% , 28% , 31% , 34% , 37% , 40% , 43% , 46% Data 50% , 53% , 56% , 59% , 62% , 65% , 68% , 71% Data 74% , 78% , 81% , 84% , 87% , 90% , 93% , 96% Data 99% , 102% , 105% , 108% , 111% , 115% , 118% , 121% Data 124% , 127% , 130% , 133% , 136% , 139% , 142% , 145% Data 148% , 151% , 154% , 157% , 160% , 163% , 166% , 169% Data 172% , 175% , 178% , 180% , 183% , 186% , 189% , 192% Data 195% , 198% , 201% , 204% , 207% , 209% , 212% , 215% Data 218% , 221% , 224% , 226% , 229% , 232% , 235% , 238% Data 240% , 243% , 246% , 249% , 251% , 254% , 257% , 260% Data 262% , 265% , 268% , 270% , 273% , 276% , 278% , 281% Data 283% , 286% , 289% , 291% , 294% , 296% , 299% , 301% Data 304% , 306% , 309% , 311% , 314% , 316% , 319% , 321% Data 324% , 326% , 328% , 331% , 333% , 336% , 338% , 340% Data 343% , 345% , 347% , 350% , 352% , 354% , 356% , 359% Data 361% , 363% , 365% , 367% , 370% , 372% , 374% , 376% Data 378% , 380% , 382% , 384% , 386% , 388% , 391% , 393% Data 395% , 396% , 398% , 400% , 402% , 404% , 406% , 408% Data 410% , 412% , 414% , 415% , 417% , 419% , 421% , 423% Data 424% , 426% , 428% , 430% , 431% , 433% , 435% , 436% Data 438% , 439% , 441% , 443% , 444% , 446% , 447% , 449% Data 450% , 452% , 453% , 455% , 456% , 457% , 459% , 460% Data 461% , 463% , 464% , 465% , 467% , 468% , 469% , 470% Data 472% , 473% , 474% , 475% , 476% , 477% , 478% , 480% Data 481% , 482% , 483% , 484% , 485% , 486% , 487% , 488% Data 488% , 489% , 490% , 491% , 492% , 493% , 494% , 494% Data 495% , 496% , 497% , 497% , 498% , 499% , 499% , 500% Data 501% , 501% , 502% , 502% , 503% , 504% , 504% , 504% Data 505% , 505% , 506% , 506% , 507% , 507% , 507% , 508% Data 508% , 508% , 509% , 509% , 509% , 509% , 510% , 510% Data 510% , 510% , 510% , 510% , 510% , 510% , 510% , 510% Data 511% , 510% , 510% , 510% , 510% , 510% , 510% , 510% Data 510% , 510% , 510% , 509% , 509% , 509% , 509% , 508% Data 508% , 508% , 507% , 507% , 507% , 506% , 506% , 505% Data 505% , 504% , 504% , 504% , 503% , 502% , 502% , 501% Data 501% , 500% , 499% , 499% , 498% , 497% , 497% , 496% Data 495% , 494% , 494% , 493% , 492% , 491% , 490% , 489% Data 488% , 488% , 487% , 486% , 485% , 484% , 483% , 482% Data 481% , 480% , 478% , 477% , 476% , 475% , 474% , 473% Data 472% , 470% , 469% , 468% , 467% , 465% , 464% , 463% Data 461% , 460% , 459% , 457% , 456% , 455% , 453% , 452% Data 450% , 449% , 447% , 446% , 444% , 443% , 441% , 439% Data 438% , 436% , 435% , 433% , 431% , 430% , 428% , 426% Data 424% , 423% , 421% , 419% , 417% , 415% , 414% , 412% Data 410% , 408% , 406% , 404% , 402% , 400% , 398% , 396% Data 395% , 393% , 391% , 388% , 386% , 384% , 382% , 380% Data 378% , 376% , 374% , 372% , 370% , 367% , 365% , 363% Data 361% , 359% , 356% , 354% , 352% , 350% , 347% , 345% Data 343% , 340% , 338% , 336% , 333% , 331% , 328% , 326% Data 324% , 321% , 319% , 316% , 314% , 311% , 309% , 306% Data 304% , 301% , 299% , 296% , 294% , 291% , 289% , 286% Data 283% , 281% , 278% , 276% , 273% , 270% , 268% , 265% Data 262% , 260% , 257% , 254% , 251% , 249% , 246% , 243% Data 240% , 238% , 235% , 232% , 229% , 226% , 224% , 221% Data 218% , 215% , 212% , 209% , 207% , 204% , 201% , 198% Data 195% , 192% , 189% , 186% , 183% , 180% , 178% , 175% Data 172% , 169% , 166% , 163% , 160% , 157% , 154% , 151% Data 148% , 145% , 142% , 139% , 136% , 133% , 130% , 127% Data 124% , 121% , 118% , 115% , 111% , 108% , 105% , 102% Data 99% , 96% , 93% , 90% , 87% , 84% , 81% , 78% Data 74% , 71% , 68% , 65% , 62% , 59% , 56% , 53% Data 50% , 46% , 43% , 40% , 37% , 34% , 31% , 28% Data 25% , 21% , 18% , 15% , 12% , 9% , 6% , 3% Data 0% Rem table end