SX Video Display Module Hitt Consulting Rev F Firmware Rev F * Serial In Video Out 105 S Locust Street * 4800 baud serial input (8N1) Shiremanstown Pa 17011 * NTSC or PAL monochrome video output info@hittconsulting.com * 6 x 16 characters / 12 x 32 pixels www.hittconsulting.com * Audio Output
SX VIDEO DISPLAY MODULE The Null (128) value is useful to send at startup just in case a multi-byte command (like CrsrXY) was send without the parameters. The next values sent would then be interpreted as the parameters for the CrsrXY command, instead of the commands intended. The Null value is simply ignored if received on it s own. AUDIO / VIDEO OUTPUTS The video output must be connected to a video input. This is usually a yellow colored RCA jack on a TV, monitor, VCR or DVD player. Video inputs have an impedance of about 75 ohms, and this is needed to get the correct voltage from the module. OVERVIEW The SX Video Display Module is used to create text and low-resolution graphics on a TV or video monitor. Popular uses include: simple games, status displays and demonstrations. The video module creates a display of 6 lines each consisting of 16 characters. Each character is 8 pixels wide and 8 pixels high. The module accepts serial data at 4800 baud or 480 characters per second. An entire screen of 96 characters takes only 1/5 of a second. This makes games and rapidly updating display possible. SERIAL DATA FORMAT The serial data is received at a baud rate of 4800 8N1. Character data is sent using standard ASCII codes. In other words on the Basic Stamp microntrollers a simple message might be: SEROUT SPin,Baud,[ Hello ] Also pixels (1/4 character size) can be turned on or off with the special plot and unplot serial commands. You only need to specify the location of the pixel on the screen. The audio output has a level of about 0.21volts peak-to-peak. It is meant to be connected to the (usually white colored) audio input of a TV, VCR or DVD player. OPTION SWITCHES There are two switches on the board. The first one determines if the video output will be NTSC (U.S.A.) or PAL (U.K.). The second switch determines if the serial input is an inverted or a true serial input. Serial input is always 4800 8N1 format. ON-BOARD VOLTAGE REGULATOR There is also an on-board voltage regulator. You can connect the +5 pin to a regulated 5 volt supply, or you can connect the Vin pin to a 6volt to 12volt supply. The module requires about 35 milliamps. DIGITAL OUTPUTS Eight of the SX pins are brought out and the command VidOuts (134) is used to set the output states. This gives you eight additional output that can be used for other purposes. These really come in handy if the module is receiving data from a wireless receiver. The output pins are set by sending the serial command VidOuts (134) followed by the value you want on the output pins. SEROUT Spin,Baud,[v_PlotXY, X, Y] COMMANDS Received data values from 16 to 127 and 144 to 255 are display characters. Values from 0 to 15 and 128 to 143 are commands. Some commands require additional data that is send immediately following the command. For example the CrsrXY command must be followed by the X value then the Y value. Commands for values from 0 to 15 are the same as the DEBUG commands for the Basic Stamps, and the constants for DEBUG can be used.
Power: Size: Controller: Display: Characters: SPECS +5VDC or +6 to 9VDC 35mA 2.0 x 1.5 (not including connectors) Ubicom SX28AC/DP microcontroller operating at 20 MHz. 6 lines of 16 characters each NTSC (USA) or PAL (UK) output 224 including upper & lower case and inverse Serial Input to module that accepts serial data at 4800 baud, 8 data bits, 1 stop bit and no parity (4800-8N1). Depending on the setting of the INV/TRUE jumper will determine if the serial data must be inverted or true. The default setting is inverted which will be the case if the serial data is coming from a PC serial port. When sending data from the basic stamp, make sure the format matches the jumper setting. Gnd Power supply ground. This MUST also be connected to ground on the device sending the serial data to the module. Graphics: Audio: CN1 CN2 Vin 32 horizontal, 12 vertical 1/4 character blocks 255 Tones, 255 Durations SPECIAL FEATURES * Low Res graphics plot and unplot commands * Invert Screen command * 8 Digital Outputs (20ma total current) * No delays needed when sending data PIN FUNCTIONS Yellow RCA jack. This is the video output from the module. Connect this to the video input of your video display using an RCA cable. White RCA jack. This is the audio output from the module. Connect this to the audio input of your video display device (if desired). The signal level is about 0.21volts. Supply voltage input to regulator. Vin may be between 6 volts and 9 volts. This source must be able to supply 50 milliamps of current. +5 Regulated 5 volt supply voltage input to module. This voltage MUST be regulated to 5 volts and be able to supply 40 milliamps of current. If you are using Vin to supply power to the module, this pin can supply small amounts of power to other devices. Do not draw more than 20mA from this pin. Out.0 Additional output pins. These pins are set by Thru using the VidOuts (134) Command. This is Out.7 similar to setting output pins on the BS2. Do not draw more than 20mA from each pin, or 50mA from all pins combined. Out.0 has a binary value of 1, Out.1=2, Out.2=4, Out.3=8, Out.4=16, Out.5=32, Out.6=64, Out.7=128. Simply add the values of the pins you want on (+5) and send that value to the module after the VidOuts (134) command. For example to set all the pins high (+5) send 134 then 255, to set all the pin low (0), send 134 then 0. SOUND COMMAND DETAILS The SOUND command will generate a tone with a frequency of (7622/tone)Hz for a duration of (17.2*duration)ms. The module will continue to accept and display characters while the sound is being generated. If another SOUND command is issued before the previous SOUND command is finished, the new tone will start immediately. Any tone with a duration of zero will immediately stop any sound in progress. Note that the BELL command is the same as SOUND 5,10. Therefore it will generate a frequency of (7622/5)=1524Hz for a duration of (17.2*10) = 172milliseconds. Firmware updates, demo programs and additional info can be found on the website www.sxvm.com
COMMANDS Commands from 0 to 15 are the same as the Basic Stamp(R) DEBUG commands. VALUE NAME PARAMETERS DESCRIPTION 0 Cls (none) Clears the screen and moves cursor to 0,0 1 Home (none) Moves cursor to 0,0 2 CrsrXY (2) X,Y Moves cursor to specified coordinates 3 CrsrLf (none) Moves cursor 1 position to the left 4 CrsrRt (none) Moves cursor 1 position to the right 5 CrsrUp (none) Moves cursor 1 position upward 6 CrsrDn (none) Moves cursor 1 position downward 7 Bell (none) Creates a 1.5Khz tone for 170mSecs 8 Bksp (none) Moves cursor 1 position to the left (destructive) 9 Tab (none) Moves cursor to next tab stop (0,4,8,12) 10 Lf (none) Linefeed; Moves cursor down 1 line 11 ClrEol (none) Clears from cursor to end-of-line 12 ClrDn (none) Clears from cursor to end-of-screen 13 Cr (none) Carriage Return; Moves cursor to start of next line 14 CrsrX (1) X Moves cursor to specified column 15 CrsrY (1) Y Moves cursor to specified row 128 Null (none) Ignored 129 InvOn (none) Turns on inverse mode 130 InvOff (none) Turns off inverse mode 131 InvScrn (none) Inverts the whole screen 132 PlotXY (2) X,Y Plots a point(1/4 char) at X,Y 133 UnPlotXY (2) X,Y Unplots a point(1/4 char) at X,Y 134 VidOuts (1) Value Sets the modules output pins 135 VidVer (none) Displays the firmware version letter 136 DecByte (1) Value Displays the next value in decimal 137 HexByte (1) Value Displays the next value in hexadecimal 138 Sound (2) Pitch,Duration Creates an audio tone of Pitch,Duration 139 --- [ RESERVED ] 140 --- [ RESERVED ] 141 --- [ RESERVED ] 142 --- [ RESERVED ] 143 --- [ RESERVED ]
16 CHARACTER SET (+128 for Inverse) +0 +1 +2 +3 +4 +5 +6 +7 24 32 40 48 56 64 72 80 88 96 104 112 120
Basic Stamp Example Programs =========================================== File... Video AllChars.BS2 Purpose... Demo the SX-Video Module Author... Terry Hitt E-mail... terry@hittconsulting.com Started... Mar 4, 2005 =========================================== Stamp to Video Module Connections BS2 Video Module --- ------------- P0 ----- Serial GND ----- Gnd {$STAMP BS2} {$PBASIC 2.5} #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_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 Baud CON T4800 + Inverted Sout PIN 0 Cnt VAR Word Start: OUTPUT Sout PAUSE 100 SEROUT Sout,baud,[v_Null, v_null, v_null,cls] Again: FOR Cnt=16 TO 127 SEROUT Sout,baud,[v_DecByte,Cnt," = ",Cnt," ",v_decbyte,(cnt+128)," = ",(Cnt+128),CR] PAUSE 250 NEXT GOTO Again End of program listing =========================================== File... Lab Simulation.BS2 Purpose... Demo the SX-Video Module Author... Terry Hitt E-mail... terry@hittconsulting.com Started... Mar 4, 2005 =========================================== Stamp to Video Module Connections BS2 Video Module --- ------------- P0 ----- Serial GND ----- Gnd {$STAMP BS2} {$PBASIC 2.5} #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_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 v_ohms CON 30 Baud CON T4800 + Inverted Sout PIN 0 R VAR Word Volts VAR Word MilliVolts VAR Word MilliAmps VAR Word TemperatureW VAR Word TemperatureF VAR Word Relay1 VAR Bit Relay2 VAR Bit Relay3 VAR Bit PAUSE 100 SEROUT Sout,baud,[v_Null,v_Null,v_Null,CLS, v_invoff] SEROUT Sout,baud,["Lab Simulation", CR] PAUSE 3000 SEROUT Sout,baud,[CLS] Volts=5 MilliVolts=0
MilliAmps=100 TemperatureW=25 TemperatureF=0 Relay1=1 Relay2=0 Relay3=1 Start: SEROUT Sout,baud,[HOME, "Volts: ", DEC1 Volts, ".", DEC3 MilliVolts, CR] SEROUT Sout,baud,["Amps: 0.", DEC3 MilliAmps, CR] SEROUT Sout,baud,["Temp: ", DEC2 TemperatureW, ".", DEC2 TemperatureF, v_ohms, "C", CR] SEROUT Sout,baud,["Relay1: "] IF Relay1=1 THEN SEROUT Sout,baud,["ON ",CR] ELSE SEROUT Sout,baud,[v_InvOn,"OFF",v_InvOff,CR] SEROUT Sout,baud,["Relay2: "] IF Relay2=1 THEN SEROUT Sout,baud,["ON ",CR] ELSE SEROUT Sout,baud,[v_InvOn,"OFF",v_InvOff,CR] SEROUT Sout,baud,["Relay3: "] IF Relay3=1 THEN SEROUT Sout,baud,["ON ",CR] ELSE SEROUT Sout,baud,[v_InvOn,"OFF",v_InvOff,CR] PAUSE 250 Update 4 times a second Simulate changes to parameters IF R < 16384 THEN MilliVolts=MilliVolts+2 IF MilliVolts > 999 THEN MilliVolts=MilliVolts-1000 Volts=Volts+1 IF r > 49152 THEN IF MilliVolts < 2 THEN Volts=Volts-1 MilliVolts=MilliVolts+1000 MilliVolts=MilliVolts-2 IF R < 16384 THEN MilliAmps=MilliAmps+1 IF R > 49152 THEN MilliAmps=MilliAmps-1 IF R < 16384 THEN TemperatureF=TemperatureF+1 IF TemperatureF > 99 THEN TemperatureF=TemperatureF-100 TemperatureW=TemperatureW+1 IF r > 49152 THEN IF TemperatureF < 1 THEN TemperatureW=TemperatureW-1 TemperatureF=TemperatureF+100 TemperatureF=TemperatureF-1 IF R < 4096 THEN Relay1=~Relay1 IF R < 4096 THEN Relay2=~Relay2 IF R < 4096 THEN Relay3=~Relay3 GOTO Start End of program listing =========================================== File... Pong1.BS2 Purpose... Demo the SX-Video Module Author... Terry Hitt E-mail... terry@hittconsulting.com Started... Mar 14, 2005 =========================================== Stamp to button connections --------------------------- 4.7K Player1Down P1 -+-/\/\/\-- Vdd +---_\---- GND Button 4.7K Player1Up P2 -+-/\/\/\-- Vdd +---_\---- GND Button Stamp to Video Module Connections BS2 Video Module --- ------------- P0 ----- Serial GND ----- Gnd {$STAMP BS2} {$PBASIC 2.5} #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_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 Baud CON T4800 + Inverted Sout PIN 0 Player1Dn PIN 1 Player1Up PIN 2 BallX VAR Byte BallY VAR Byte BallLastX VAR Byte BallLastY VAR Byte BallDirX VAR Byte BallDirY VAR Byte Player1 VAR Byte Delay VAR Byte Score VAR Byte Balls VAR Byte
GOTO Start BallFlash: SEROUT Sout,baud,[CRSRXY, 4, 1, "Score:", DEC Score, CRSRXY, 4, 4, "Balls:", DEC Balls] BallLastX=(BallX-10)/2 BallLastY=(BallY-10)/2 FOR Delay=1 TO 3 SEROUT Sout,baud,[v_PlotXY, BallLastX, BallLastY] PAUSE 300 SEROUT Sout,baud,[v_UnPlotXY, BallLastX, BallLastY] PAUSE 300 NEXT BallX=15*2+10 BallY=5*2+10 BallLastX=(BallX-10)/2 BallLastY=(BallY-10)/2 BallDirX=1 BallDirY=1 SEROUT Sout,baud,[CRSRXY, 4, 1, " ", CRSRXY, 4, 4, " "] Erase text RETURN Start: Score=0 Balls=3 PAUSE 100 SEROUT Sout,baud,[v_Null,v_Null,v_Null,v_Null, v_invoff,cls] SEROUT Sout,baud,[CRSRXY, 1, 1, v_invon, "Hitt Consulting", CRSRXY, 4, 2, v_invoff, "SX-Video", CRSRXY, 5, 3, v_invon, "Module", CRSRXY, 6, 5, v_invoff, "Pong1"] PAUSE 5000 SEROUT Sout,baud,[CLS] FOR BallX=1 TO 31 SEROUT Sout,baud,[v_PlotXY, BallX, 0, v_plotxy,ballx, 11] IF BallX < 12 THEN SEROUT Sout,baud,[v_PlotXY, 31, BallX] NEXT Player1=5 FOR BallY=5 TO 6 SEROUT Sout,baud,[v_PlotXY, 0, BallY, v_plotxy, 31, BallY] NEXT BallX=15*2+10 BallY=5*2+10 GOSUB BallFlash BallLastY=(BallY-10)/2 Check if ball is at far left IF BallX < 12 THEN Check if player1 paddle is in position IF (Player1=(BallY-10)/2) OR (Player1=(BallY- 10)/2-1) THEN Yes, Player1 hit ball SEROUT Sout,baud,[BELL] Score=Score + 1 BallDirX=-BallDirX BallX=BallX+BallDirX BallLastX=15 ELSE Player1 missed Balls=Balls-1 GOSUB BallFlash Flash ball at missed location IF Balls=0 THEN GOTO Start GOSUB BallFlash Flash ball to start location Check if ball hit back wall IF BallX > 72 THEN SEROUT Sout,baud,[BELL] BallDirX=-BallDirX BallX=BallX+BallDirX BallLastX=15 Check if ball hit top or bottom IF (BallY < 12) OR (BallY > 30) THEN Yes, make ball bounce SEROUT Sout,baud,[BELL] BallDirY=-BallDirY BallY=BallY+BallDirY BallLastX=(BallX-10)/2 BallLastY=(BallY-10)/2 Update ball position BallX=BallX+BallDirX BallY=BallY+BallDirY GOTO Main End of program listing Main: Delay=0 Check if player1 is trying to move up IF (Player1Up = 0) AND (Player1 > 0) THEN Player1=Player1-1 SEROUT Sout,baud,[v_UnPlotXY, 0, Player1+2, v_plotxy, 0, Player1] Delay=Delay+10 Check if player1 is trying to move down IF (Player1Dn = 0) AND (Player1 < 10) THEN Player1=Player1+1 SEROUT Sout,baud,[v_UnPlotXY, 0, Player1-1, v_plotxy, 0, Player1+1] Delay=Delay+10 Game delay IF Delay < 20 THEN PAUSE 20-delay Move ball on screen IF BallLastX <> 31 THEN SEROUT Sout,baud,[v_UnPlotXY, BallLastX, BallLastY] SEROUT Sout,baud,[v_PlotXY, (BallX-10)/2, (BallY-10)/2] Remember new ball position BallLastX=(BallX-10)/2