Simple Quick Basic program for remote control of UHF Video / Nicam stereo tuner unit. Display Electronics ref MY00

download

data sheet

home

DECLARE SUB iicstart ()
DECLARE SUB wrtiicbyte (arg!)
DECLARE SUB wrtiicbit (arg!)
DECLARE SUB iicstop ()
DECLARE SUB iicack ()
Dim freq As Double, fint As Long
Dim portadr As Integer

Print
DEF SEG = 0
portadr = PEEK(&H408) Or PEEK(&H409) * 256
If portadr < &H200 Or portadr > &H3FF Then
       Beep
       Print "No printer port found"; Hex$(portadr)
       End
End If
Print "Using LPT1 port at "; Hex$(portadr)
Do
If Command$ = "" Then
       INPUT "Frequency (MHz) or channel: "; freq
Else
       freq = Val(Command$)
End If
If freq >= 21 And freq <= 69 Then
        freq = (freq - 21) * 8 + 510.15
Else
        freq = freq + 38.9
End If
Print "Freq="; freq
fint = Int(freq * 1000000! / 31250 + 0.5)
Print "Fint="; fint
iicstart
wrtiicbyte (&HC0): iicack 'send chip address
wrtiicbyte (&HC6): iicack 'control info
wrtiicbyte (8): iicack 'band control bit
wrtiicbyte (fint \ 256): iicack 'send hi freq byte
wrtiicbyte (fint And 255): iicack 'send low freq byte
iicstop
Loop While Command$ = ""

Sub iicack()
     OUT portadr, 2 'let data go floppy
     OUT portadr, 3 'pulse clk hi
     OUT portadr, 2 '& lo again
End Sub

Sub iicstart()
     OUT portadr, 1 'take data low while clk hi
     OUT portadr, 0 'now take clk lo
End Sub

Sub iicstop()
     OUT portadr, 1 'take clk hi
     OUT portadr, 3 'now take data hi while clk is hi
End Sub

Sub wrtiicbit(arg)
     If arg Then
     OUT portadr, 2 'take data hi
     OUT portadr, 3 'now pulse clk hi
     OUT portadr, 2 'take clk lo again
Else
     OUT portadr, 0 'make sure data is lo
     OUT portadr, 1 'pulse clk hi
     OUT portadr, 0 'take it low again
End If
End Sub

Sub wrtiicbyte(arg)
      Dim temp As Long
      temp = arg
      For i = 1 To 8
           If temp And 128 Then 'keep picking off the hi bit
          wrtiicbit (1)
      Else
          wrtiicbit (0)
          End If
temp = temp + temp 'shunt all bits left
Next
End Sub

www.distel.co.uk