' 'C.Potma PA3CKR '20070203 v00 'Program to control a CONESCO type NW-MUX re1001 audio/video multiplexer 'This is a professional mux sold at a dump price because of the missing controller? ' 'See the schematic. A control box with 8 buttons and 8 leds is used. 'Anyone of the 8 buttons can be pressed to generate a three-bit binary code 'for the mux. 'An extra led is provided for feedback on the controller function. ' $regfile = "2313DEF.dat" $crystal = 4000000 Config Portd = Output Led Alias Portd.5 Mc0 Alias Portd.0 Mc1 Alias Portd.1 Mc2 Alias Portd.2 Dim Buttons As Byte Dim Leds As Byte Dim Muxcode As Byte Declare Sub Startup Call Startup Reset Led Leds = 254 Reset Mc0 Reset Mc1 Reset Mc2 Do 'make portd input, weak pull-ups Config Portb = Input Portb = 255 Waitms 1 'read button Buttons = Pinb If Buttons <> 255 Then 'button pressed, make portd output to light corresponding led 'make this explicit so not more than one led is lit at the time 'put binary code on portd0-1-2 Select Case Buttons Case 254: Leds = 254 Reset Mc0 Reset Mc1 Reset Mc2 Case 253: Leds = 253 Set Mc0 Reset Mc1 Reset Mc2 Case 251: Leds = 251 Reset Mc0 Set Mc1 Reset Mc2 Case 247: Leds = 247 Set Mc0 Set Mc1 Reset Mc2 Case 239: Leds = 239 Reset Mc0 Reset Mc1 Set Mc2 Case 223: Leds = 223 Set Mc0 Reset Mc1 Set Mc2 Case 191: Leds = 191 Reset Mc0 Set Mc1 Set Mc2 Case 127: Leds = 127 Set Mc0 Set Mc1 Set Mc2 End Select Toggle Led 'wait for button release While Portb <> 255 nop Wend End If Config Portb = Output Portb = Leds Waitms 100 Loop Sub Startup 'flash the leds Waitms 500 Set Led Config Portb = Output Leds = &B11100111 Portb = Leds Waitms 350 Leds = &B11000011 Portb = Leds Waitms 350 Leds = &B10000001 Portb = Leds Waitms 350 Leds = &B00000000 Portb = Leds Waitms 350 Leds = &B11100111 Portb = Leds Waitms 350 Leds = &B11000011 Portb = Leds Waitms 350 Leds = &B10000001 Portb = Leds Waitms 350 Leds = &B00000000 Portb = Leds Waitms 350 Leds = &B11111111 Portb = Leds Waitms 500 End Sub End