SX Video - Output Logic question
T&E Engineer
Posts: 1,396
I'm sure someone has done this before and it can also be related to the BS2 output logic too. However, in this case I am refering to the SX Video module.
The outputs are arranged from Out.0 to Out.7 with setting them high by assigning a binary value to each output. (e.g. Out.0=1, Out.1=2, Out.2=4, Out.3=8 ... Out.7=128)
Add the values of the pins you want on (+5vdc) and send the value to the video module.
Examples:
T4800······ CON···· 188
Inverted····CON···· $4000
Baud········ CON···· T4800 + Inverted
Sout········ PIN 3····' Serial from SX Video module to P3
v_Outs······CON 134
SEROUT Sout, Baud, [noparse][[/noparse]v_Outs, 2]
'This command turns Out.1 HIGH
'It also turns Out.0,··· 2, 3, 4, 5, 6, 7 LOW
SEROUT Sout, Baud, [noparse][[/noparse]v_Outs, 8]
'This command turns Out.3 HIGH
'It also turns Out.1, 2,··· 4, 5, 6, 7 Low
SEROUT Sout, Baud, [noparse][[/noparse]v_Outs, 254]
'This command turns Out.1, 2, 3, 4, 5, 6, 7 HIGH
'It also turns Out.0 LOW
The question is how to turn on Out.3 (HIGH) without·changing the·condition of·Out.1 (either HIGH or LOW).
I should be able to turn on Out.3 (HIGH) and leave the other outputs in their previous states (either HIGH or LOW).
Bean??? or anyone else with similar logic experience.
·
The outputs are arranged from Out.0 to Out.7 with setting them high by assigning a binary value to each output. (e.g. Out.0=1, Out.1=2, Out.2=4, Out.3=8 ... Out.7=128)
Add the values of the pins you want on (+5vdc) and send the value to the video module.
Examples:
T4800······ CON···· 188
Inverted····CON···· $4000
Baud········ CON···· T4800 + Inverted
Sout········ PIN 3····' Serial from SX Video module to P3
v_Outs······CON 134
SEROUT Sout, Baud, [noparse][[/noparse]v_Outs, 2]
'This command turns Out.1 HIGH
'It also turns Out.0,··· 2, 3, 4, 5, 6, 7 LOW
SEROUT Sout, Baud, [noparse][[/noparse]v_Outs, 8]
'This command turns Out.3 HIGH
'It also turns Out.1, 2,··· 4, 5, 6, 7 Low
SEROUT Sout, Baud, [noparse][[/noparse]v_Outs, 254]
'This command turns Out.1, 2, 3, 4, 5, 6, 7 HIGH
'It also turns Out.0 LOW
The question is how to turn on Out.3 (HIGH) without·changing the·condition of·Out.1 (either HIGH or LOW).
I should be able to turn on Out.3 (HIGH) and leave the other outputs in their previous states (either HIGH or LOW).
Bean??? or anyone else with similar logic experience.
·
Comments
vidOuts··· VAR·· Byte
vOut1····· VAR·· vidOuts.0
vOut2····· VAR·· vidOuts.1
vOut3····· VAR·· vidOuts.2
Main:
· vOut1 = 1
··GOSUB Update_Vid_Outs
· PAUSE 1000
· vOut2 = 1
· GOSUB Update_Vid_Outs
·· ...
Update_Vid_Outs:
· SEROUT VMod, Baud, [noparse][[/noparse]134, vidOuts]
· RETURN
You can, of course, alias as many of the bits of "vidOuts" as you need for your program.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Thanks so much! You are certainly quick!
I will try this out and let you know. I actually thought it would deal with some sort of an AND & or OR type statement. But I will try this out.
Here is the basic test program I am working with:
' {$STAMP BS2}
' {$PBASIC 2.5}
'
' I/O Definitions
'
#SELECT $STAMP
· #CASE BS2, BS2E, BS2PE
··· T1200··· CON···· 813
··· T2400··· CON···· 396
··· T4800··· CON···· 188
··· T9600··· CON···· 84
··· T19K2··· CON···· 32
··· T38K4··· CON···· 6
· #CASE BS2SX, BS2P
··· T1200··· CON···· 2063
··· T2400··· CON···· 1021
··· T4800··· CON···· 500
··· T9600··· CON···· 240
··· T19K2··· CON···· 110
··· T38K4··· CON···· 45
#ENDSELECT
SevenBit···· CON···· $2000
Inverted···· CON···· $4000
Open········ CON···· $8000
' Video commands
v_CrsrXY···· CON 2
v_Null······ CON 128
v_InvOn····· CON 129
v_InvOff···· CON 130
v_InvScrn··· CON 131
v_PlotXY···· CON 132
v_UnplotXY·· CON 133
v_Outs······ CON 134
v_Version··· CON 135
v_DecByte··· CON 136
v_HexByte··· CON 137
' Audio command
a_Sound····· CON 138···················· ' Pitch, Duration
a_Bell······ CON 7······················ ' 1.5 KHz tone for 170 mSec (same as BELL)
Baud········ CON···· T4800 + Inverted
Sout········ PIN 3······················ ' Serial from SX Video module to P3
BinOutHIGH·· VAR Byte
BinOutLOW··· VAR Byte
BinOutHIGH = 1·························· 'Set Out.0 High, Out.1-7 Low
BinOutLOW = 255 - BinOutHIGH············ 'Set Out.1-7 High, Out.0 Low
SEROUT Sout, Baud, [noparse][[/noparse]v_Outs, BinOutHIGH]
...
PS: I have gotten my Video Clock to talk while displaying time. I need to free up some BS2 I/O and wanted to use the SX Video Outputs where ever I could.
PS: On a side note...what are the rules as far as using sniplets of your code or from Chris from past published projects (i.e. Nuts and Volts #66 ISD Lab , and Binary Digital Clock, etc..). I don't want to Plagerize but I know I have used code before from other programmers with no problem too giving them credit too for their work.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
The code sniplet you wrote caused an "Expected a variable modifier" error. I saw what it was and fixed it.
You wrote:
vidOuts··· VAR·· Byte
vOut1····· VAR·· vidOuts.0
vOut2····· VAR·· vidOuts.1
vOut3····· VAR·· vidOuts.2
It should be:
vidOuts··· VAR·· Byte
vOut1····· VAR·· vidOuts.BIT0
vOut2····· VAR·· vidOuts.BIT1
vOut3····· VAR·· vidOuts.BIT2
It works very well. I will post my code in the Projects section.
BEAN - Maybe you can use this as reference on your website for the SX Video Module.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax