Sending string to VFD but cannot send $00
chetw77cruiser            
            
                Posts: 12            
            
                    Hello, I am working on a trip computer for automotive use and I am using a serial VFD (vacuum florescent display) for the output.  So far I have everything working for the most part.
I have run into a problem with sending a string to a serial VFD. I am using the full duplex serial object to send data but I can not send a character that is something other than 1 to 255, i.e., ZERO. Maybe I am missing something but I am stumped.
Here is a string I am trying to send:
Or this:
Apparently the string function does not like anything less than 1. If I cannot get this to work, I will need to find a new way of transmitting commands to the vfd. Any ideas?
                            I have run into a problem with sending a string to a serial VFD. I am using the full duplex serial object to send data but I can not send a character that is something other than 1 to 255, i.e., ZERO. Maybe I am missing something but I am stumped.
Here is a string I am trying to send:
vfd.str(string($1f, $28, $67, $03,$00))
Or this:
vfd.str(string($1f,$24,$01,$00,$06,$00))
Apparently the string function does not like anything less than 1. If I cannot get this to work, I will need to find a new way of transmitting commands to the vfd. Any ideas?

                            
Comments
Strings in most languages are a string of characters terminated by a null. That is, the null or 00 is a terminator and not a character of the string. You must send this character separately as a character using vfd.tx.
Except for the power, the VFDs are nice for retro projects and dimming displays. You don't mention which VFD you use but I have always used the individual ascii for commands. When I want to simplify the code, I write short methods to avoid cluttering up the main code. You can even drop it into an objects as a library. It also gives you opportunities to modify the functions. For example, to provide a variety of screen clearing options I use this method with a Noritake GU144X16D-7053B :
Pub Clear_Screen(Style)
case Style
3,4:'Quick Clear
serial.tx($1B)
serial.tx($40)
2:'Quick Scroll Clear
serial.tx($1F)
serial.tx($28)
serial.tx($61)
serial.tx($10)
serial.tx($08) 'wl width of byte scrolled, odd caused bounce up and down
serial.tx($00) 'wh
serial.tx($2F) 'cl number of times a width is moved
serial.tx($00) 'ch
serial.tx($02) 's speed at which byte is moved
1:'Slow Scroll Clear
serial.tx($1F)
serial.tx($28)
serial.tx($61)
serial.tx($10)
serial.tx($08) 'wl width of byte scrolled, odd caused bounce up and down
serial.tx($00) 'wh
serial.tx($2F) 'cl number of times a width is moved
serial.tx($00) 'ch
serial.tx($04) 's speed at which byte is moved
0:'Bouncing Clear
serial.tx($1F)
serial.tx($28)
serial.tx($61)
serial.tx($10)
serial.tx($08) 'wl width of byte scrolled, odd caused bounce up and down
serial.tx($00) 'wh
serial.tx($20) 'cl number of times a width is moved
serial.tx($00) 'ch
serial.tx($0A) 's speed at which byte is moved
waitcnt(cnt+clkfreq)
waitcnt(cnt+clkfreq*3)
return
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 tx_pin = 30 Baud = 19_200 PUB Main dira[tx_pin]~~ outa[tx_pin]~~ repeat str(string($FF,"A","B","C")) ' Send 0 (cls), "A", "B", "C" to serial terminal at 19,200bps waitcnt (cnt + 8_000_000) PUB str(stringptr) ' Replace the str method in full-duplex serial with this one repeat strsize(stringptr) if byte[stringptr] == $FF ' $FF is the substitute for 0 tx(0) stringptr++ else tx(byte[stringptr++]) PUB tx(tx_byte) | t tx_byte := (tx_byte | $100) << 1 t := cnt repeat 10 outa[tx_pin] := tx_byte & 1 waitcnt (t += clkfreq / baud) tx_byte := tx_byte >> 1 outa[tx_pin]~~dat Cmd1 byte $05, $1f, $28, $67, $03, $00 pub send_cmd(pntr) | len len := byte[pntr++] repeat len tx(byte[pntr++])It costs one extra byte per string, but with them being stored in a DAT section (versus inline), this may actually save a bit of space.