Lost converting Visual Basic to PBASIC
Wolfbrother
Posts: 129
Hello all,
My latest battle is a simple one I think, but I'm really not getting something working. I have a serial LED that I want to display text strings on. I have a sample of Visual Basic code that is supposed to work on the LED just fine. I thought I converted to PBASIC but I get no response from the sign. I'm lost on that, but I am also lost on a way to debug, since I can't output to the serial port for the sign and to the computer screen.· The sign is a BetaBrite 1036. I'm using a BS2. My code is attached.
thanks in advance,
Dave
My latest battle is a simple one I think, but I'm really not getting something working. I have a serial LED that I want to display text strings on. I have a sample of Visual Basic code that is supposed to work on the LED just fine. I thought I converted to PBASIC but I get no response from the sign. I'm lost on that, but I am also lost on a way to debug, since I can't output to the serial port for the sign and to the computer screen.· The sign is a BetaBrite 1036. I'm using a BS2. My code is attached.
thanks in advance,
Dave
' {$STAMP BS2}
' {$PBASIC 2.5}
DisplayPin PIN 1 ' BS2 pin tied to display serial input.
T1200 CON 813 ' Various baud rates for display; T9600 used below
T2400 CON 396
T4800 CON 188
T9600 CON 84
T19K2 CON 32
T38K4 CON 6
Start:
' <Initialize display>
'Send start of message bytes.
' SEROUT DisplayPin, T9600,[noparse][[/noparse]$01][noparse][[/noparse]"Z00"][noparse][[/noparse]$02][noparse][[/noparse]"AA"][noparse][[/noparse]$1B][noparse][[/noparse]$20][noparse][[/noparse]$62][noparse][[/noparse]$1C][noparse][[/noparse]$31]
' Visual Basic version
' String(10, 0) & Chr(&H1) & "Z00" & Chr(&H2) & "E$AAU0800FF00BAU0800FF00" & Chr(&H4)
' PBasic version
SEROUT DisplayPin, T9600, [noparse][[/noparse]$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,"Z00",$02,"AA",$1B,$20,$62,$1C,$31,$04]
' This second line sends the message into Text File A. The "AA" says this packet is sending a text message
' into Text File A.
' The Chr(&H1B) & Chr(&H20) & Chr(&H62) is the command for middle position on the sign and hold the message in place.
' The Chr(&H1C) & Chr(&H31) is command for red color
' String(10, 0) &Chr(&H1) &"Z00" &Chr(&H2) &"AA" &Chr(&H1B) &Chr(&H20) &Chr(&H62) &Chr(&H1C) &Chr(&H31)
' &"HELLO" &Chr(&H4)
' PBasic version,
SEROUT DisplayPin, T9600, [noparse][[/noparse]$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,"Z00",$02,"AA",$1B,$20,$62,$1C,$31, "HELLO", $04]
'This is what I think would output Hello to the sign. But instead.. darkness.
'Send message terminator byte.
' SEROUT DisplayPin, T9600, [noparse][[/noparse]$04]
PAUSE 3000 'wait around a bit and try again
GOTO Start
Comments
I have the datasheet downloaded from the web. ( To me it reads like stereo instructions) but it's supposed to be·looking for 9600,8 bit no parity true. I can try the inverted though and report back.· I'm more stuck on whether I have converted the Visual Basic to Pbasic correctly. I'm not really good at code development. The VB code came from the display manufacturer directly. So I am hoping that isn't the problem. I'd attach the datasheet but it's huge and since it's a pdf file I can't cut and paste the main details.
Thanks,
Dave
Post Edited (Wolfbrother) : 6/25/2009 4:31:21 AM GMT
Also, many serial devices that expect to be driven by a PC lack the negative voltage circuitry which many simpler serial devices need in order to properly transmit. They typically "steal" the negative voltage from the PC.
You may find that using port 16, the programmng port (and going back to True logic may) also help.
Also, have you successfully driven the display from the PC?
Cheers,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
I found a paper describing the protocol but it didn't specifically say it was for the 1036 but it did say all signs. Initialization began with 6 nulls not 10.
Jeff T.
$NUL = "\0\0\0\0\0\0"; # NUL - Sending 6 nulls for wake up sign and set baud neg.$SOH = "\x01"; # SOH - Start of header$TYPE = "Z"; # Type Code - Z = All signs. See Protocol doc for more info$SIGN_ADDR = "00"; # Sign Address - 00 = broadcast, 01 = sign address 1, etc$STX = "\x02"; # STX - Start of Text character# These are other useful variables$ETX = "\x03"; # End of TeXt$ESC = "\x1b"; # Escape character$EOT = "\004"; # End of transmission# We group some of the variables above to make life easy.# This leaves us 2 type of init strings we can add to the front of our frame.$INIT="$NUL$SOH$TYPE$SIGN_ADDR$STX"; # Most used.$INIT_NOSTX="$NUL$SOH$TYPE$SIGN_ADDR"; # Used for nested messages.
Post Edited (Unsoundcode) : 6/25/2009 2:16:13 PM GMT
Here's my question on that idea, If I look at the Basic Stamp book, pin 1 of the BS2 is SOUT, but when I look at the Serial port complete book or the BASIC stamp reference, it implies that if I set TPIN to 16, it really uses pin 1 as Sout? How is that different than setting to pin 1 like I did? I'm just curious on that one. I can use the display successfully from the PC with the standard software they supply and several things I found on the internet. Unfortunately all the things I have found are .exe type files and I can't see what it is that they do internally.
Unsoundcode,
Thanks for looking that up, I also found a reference that used only 5 nulls. That one also said 9600, e, 7, 1 for communication and I found it on the Alpha American site. The VB code I have came directly from the software engineer that works for Alpha American in San Diego, so I figured that was stronger information than the datasheet, since there are other errors in it. I didn't run the VB code because I don't have Visual Basic on this computer.
I'll try all these suggestions a little later today when I get back and post my successes or whatever happens. Thanks everyone.
I couldn't go into work without at least trying these ideas. I know you all know that feeling... Turns out changing DisplayPin to 16 was the ticket. I downloaded that code to the Stamp, turned it off, plugged in the sign, turned it on and magically "HELLO" appeared. Thanks so much for the help everyone. This project is going into a San Diego Museum next month and I will be sure to post it in Completed Projects.
Cheers,
Dave