Single line VFDs from fruit machines are available cheaply on eBay and nearly always have an SPI interface so can be easily interfaced with any PICAXE that supports hardware SPI. But best of all, they are massive compared to ordinary HD44780 LCD and HD44780-compatible OLED displays.
The OLED display (right) is a lot bigger than the ones Rev-Ed sell, and yet it is still small compared to the VFD. The VFD is about 20cm across.
The three types of VFD I found on eBay are:
- 5x7 dot matrix (I have)
- Starburst (I have)
- Graphic (don't have)
[hr][/hr]5x7 dot matrix display - Samsung 16L102DA4
This display (see also - initial problems) is based on the OKI MSM9202 M9202-04 and has 16 characters each with a comma and an 8-bit SPI interface.
Required connections:
Download circuit not shown.
Because SPI only has chip select, data and clock, there needs to be a way of choosing between commands and data. As the VFD will be the only thing on the bus for now, /SEL can remain low when idle. Before sending an command, it must then be pulsed high. If the command is for something where data might then be sent (e.g. set character pointer), any bytes sent after the command without /SEL going high are treated as data and /SEL must be pulsed high before another command can be sent.
The commands are:
- Set character pointer (data is the characters to display, character pointer is automatically incremented after each byte of data)
- $10 + zero indexed display location
- Following data: Character according to table in datasheet
- Set comma pointer (data is whether to display no comma, a decimal point or comma, and the comma pointer is incremented after each byte of data)
- $30 + zero indexed display location
- Data: $00 = no comma or decimal point, $01 = decimal point, $03 = comma, $02 = tail of comma on its own
- Brightness level
- $50 (dim) to $57 (bright)
- Display on/off
- $70 = on
- $71 = off
- $72 or $73 = all segments on
- Set custom characters
- $20 + location on character map (you can set first 8 characters)
- Data: Character pattern where each byte is a column starting with the first column of the character and the LSB is the top pixel
- Set display length
- $60 for 16 characters
The next problem is that there is no facility built in to the VFD to scroll the message, but that doesn't matter as with a little bit of work, the PICAXE can do it, as seen in the code.
Code example:
Code:
#picaxe 28x2
#no_table
symbol cs = C.2
symbol dataoutpin = pinC.5
symbol vfddata = b4
main:
high cs
setfreq m16
hspisetup spimode00,spimedium
low cs
vfddata = $20 : gosub sendcommand 'Command for custom characters
vfddata = %00000000 : gosub senddata 'Data for custom character
vfddata = %00010100 : gosub senddata '(a little 'x')
vfddata = %00001000 : gosub senddata
vfddata = %00010100 : gosub senddata
vfddata = %00000000 : gosub senddata
vfddata = $10 gosub sendcommand 'Command for characters/text
for b0 = 0 to 15
lookup b0,("VFD "),vfddata 'Initial message goes here
gosub senddata
next
vfddata = $60 : gosub sendcommand 'Set display length
vfddata = $57 : gosub sendcommand 'Set initial brightness to max
vfddata = $30 : gosub sendcommand 'Command for commas
for b0 = 0 to 15 'Set commas
lookup b0,($02,$03,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00),vfddata
gosub senddata
next
vfddata = $70 gosub sendcommand 'Turn on display
#rem
This loop scrolls the message set below in the last 12 spaces of the VFD, with "VFD "
left displayed in the first four spaces then flashes the display by alternating
between max and min brightness a few times. The last character is the custom character defined earlier.
#endrem
do
for b7 = 0 to 69
vfddata = $14 : gosub sendcommand
for b0 = 0 to 11
b8 = b0 + b7
lookup b8,(" interfacing with PICAXE by nick12ab from PICAXE Forum ",0," "),vfddata 'Text to scroll
gosub senddata
next
pause 20
next
pause 500
vfddata = $50 : gosub sendcommand
pause 200
vfddata = $57 : gosub sendcommand
pause 200
vfddata = $50 : gosub sendcommand
pause 200
vfddata = $57 : gosub sendcommand
pause 200
vfddata = $50 : gosub sendcommand
pause 200
vfddata = $57 : gosub sendcommand
loop
sendcommand:
pulsout cs,1
senddata:
vfddata = vfddata rev 8
hspiout (vfddata)
return
For now, this is the only VFD I have but I've worded the title to suggest more than one because I'm hoping to aquire some more VFDs and I'll post about those too. I'll also do a video of the display running the example code soon.
Last edited: