'--- DVB QPSK a MPEG QPSK Calculator 7/26/99 8:37:01 AM --- '--- Directives --- $APPTYPE GUI $TYPECHECK ON $INCLUDE "RAPIDQ.INC" '--- Declarations --- DECLARE FUNCTION doubleSTR (Number AS DOUBLE#, N1 AS INTEGER) AS STRING DIM frmDvbQpsk AS QFORM DIM btnQuit AS QBUTTON DIM btnHelp AS QBUTTON DIM btnAbout AS QBUTTON DIM lblFec AS QLabel DIM cmbFec AS QComboBox DIM btn188Rate AS QBUTTON DIM edt188Rate AS QEDIT DIM btn204Rate AS QBUTTON DIM edt204Rate AS QEDIT DIM btnSymbolRate AS QBUTTON DIM edtSymbolRate AS QEDIT DIM btnBw AS QBUTTON DIM edtBw AS QEDIT '--- global variables --- DIM P AS INTEGER P = 3 DIM Fec as Double Fec = .5000 DIM Rate188 as Double DIM Rate204 as Double DIM RateSymbol as Double DIM Bw as Double '--- Sub and Func --- '--- exit application --- SUB DoQuit frmDvbQpsk.Close END SUB '--- help message --- SUB DoHelp SHOWMESSAGE "Select FEC and enter a known parameter." +CHR$(13) +_ "Click the button associated with the known" + CHR$(13) + " parameter to calculate all parameters." END SUB '--- about message --- SUB DoAbout SHOWMESSAGE "DVB QPSK is a simple calculator provided to" + CHR$(13) + _ "aid in the setup of DVB digital video transmitters and IRD's." + CHR$(13) + _ CHR$(13) + _ "Freeware by E.J. Livaditis" +CHR$(13) + _ "Developed with RAPID-Q by William Yu" END SUB '--- select Fec --- SUB ItemChanged Select Case cmbFec.ItemIndex Case 0 Fec = .50000 Case 1 Fec = .66666 Case 2 Fec = .75000 Case 3 Fec = .83333 Case 4 Fec = .87500 End Select END SUB '--- calculate using FEC and 188 byte transport rate --- SUB Crunch188 IF (edt188Rate.Text = "") then DoHelp EXIT SUB END IF Rate188 = VAL(edt188Rate.Text) Rate204 = 204/188 * Rate188 RateSymbol = (Rate204 * 1/Fec * .5) Bw = RateSymbol * 1.35 edt204Rate.Text = doubleSTR(Rate204,3) edtSymbolRate.Text = doubleSTR(RateSymbol,3) edtBw.Text = doubleSTR(Bw,3) END SUB '--- calculate using FEC and 204 byte transport rate --- SUB Crunch204 IF (edt204Rate.Text = "") then DoHelp EXIT SUB END IF Rate204 = VAL(edt204Rate.Text) Rate188 = 188/204 * Rate204 RateSymbol = Rate204 * 1/Fec * .5 Bw = RateSymbol * 1.35,P edt188Rate.Text = doubleSTR(Rate188,3) edtSymbolRate.Text = doubleSTR(RateSymbol,3) edtBw.Text = doubleSTR(Bw,3) END SUB '--- calculate using FEC and symbol rate --- SUB CrunchSymbol IF (edtSymbolRate.Text = "") then DoHelp EXIT SUB END IF RateSymbol = VAL(edtSymbolRate.Text) Rate188 = RateSymbol / (204/188 * 1/Fec * .5) Rate204 = 204/188 * Rate188 Bw = RateSymbol * 1.35 edt188Rate.Text = doubleSTR(Rate188,3) edt204Rate.Text = doubleSTR(Rate204,3) edtBw.Text = doubleSTR(Bw,3) END SUB '--- calculate using FEC and BW (bandwidth) --- SUB CrunchBw IF (edtBw.Text = "") then DoHelp EXIT SUB END IF Bw = VAL(edtBw.Text) RateSymbol = Bw / 1.35 Rate188 = RateSymbol / (204/188 * 1/Fec * .5) Rate204 = 204/188 * Rate188 edt188Rate.Text = doubleSTR(Rate188,3) edt204Rate.Text = doubleSTR(Rate204,3) edtSymbolRate.Text = doubleSTR(RateSymbol,3) END SUB '--- a function to round off double to N1 places and converts it to string --- FUNCTION doubleSTR(Number AS DOUBLE#, N1 AS INTEGER) AS STRING DIM NumStr as STRING DIM rr as DOUBLE DIM nn as DOUBLE DIM dp as INTEGER rr = INT(10^N1 + .5) nn = INT(rr * Number + .5) NumStr = STR$(nn/rr) dp = instr(NumStr,".") if (dp = 0) then dp = len(NumStr) + N1 else dp = dp + N1 end if doubleSTR = LEFT$(NumStr,dp) END FUNCTION '--- main form setup --- frmDvbQpsk.BorderStyle = bsToolWindow frmDvbQpsk.Center frmDvbQpsk.Caption = "DVB QPSK By EJsoft" frmDvbQpsk.Height = 205 frmDvbQpsk.Width = 260 btnQuit.Parent = frmDvbQpsk btnQuit.Left = 50 btnQuit.Top = 10 btnQuit.Width = 40 btnQuit.Caption = "&Quit" btnQuit.OnClick = DoQuit btnHelp.Parent = frmDvbQpsk btnHelp.Left = 110 btnHelp.Top = 10 btnHelp.Width = 40 btnHelp.Caption = "&Help" btnHelp.OnClick = DoHelp btnAbout.Parent = frmDvbQpsk btnAbout.Left = 170 btnAbout.Top = 10 btnAbout.Width = 40 btnAbout.Caption = "&About" btnAbout.OnClick = DoAbout lblFec.Parent = frmDvbQpsk lblFec.Left = 10 lblFec.Top = 50 lblFec.Width = 40 lblFec.Caption = "FEC" cmbFec.Parent = frmDvbQpsk cmbFec.Left = 10 cmbFec.Top = 70 cmbFec.Width = 45 cmbFec.AddItems "1/2", "2/3", "3/4", "5/6", "7/8" cmbFec.ItemIndex = 0 cmbFec.OnChange = ItemChanged btn188Rate.Parent = frmDvbQpsk btn188Rate.Left = 60 btn188Rate.Top = 50 btn188Rate.Width = 120 btn188Rate.Caption = "&188 Byte Rate Mbps" btn188Rate.OnClick = Crunch188 edt188Rate.Parent = frmDvbQpsk edt188Rate.Left = 190 edt188Rate.Top = 52 edt188Rate.Width = 50 btn204Rate.Parent = frmDvbQpsk btn204Rate.Left = 60 btn204Rate.Top = 80 btn204Rate.Width = 120 btn204Rate.Caption = "&204 Byte Rate Mbps" btn204Rate.OnClick = Crunch204 edt204Rate.Parent = frmDvbQpsk edt204Rate.Left = 190 edt204Rate.Top = 82 edt204Rate.Width = 50 btnSymbolRate.Parent = frmDvbQpsk btnSymbolRate.Left = 60 btnSymbolRate.Top = 110 btnSymbolRate.Width = 120 btnSymbolRate.Caption = "&Symbol Rate Msps" btnSymbolRate.OnClick = CrunchSymbol edtSymbolRate.Parent = frmDvbQpsk edtSymbolRate.Left = 190 edtSymbolRate.Top = 112 edtSymbolRate.Width = 50 btnBw.Parent = frmDvbQpsk btnBw.Left = 60 btnBw.Top = 140 btnBw.Width = 120 btnBw.Caption = "-20 dB &Bandwidth MHz" btnBw.OnClick = CrunchBw edtBw.Parent = frmDvbQpsk edtBw.Left = 190 edtBw.Top = 142 edtBw.Width = 50 frmDvbQpsk.ShowModal