SPI for Samsung VFD on the raspberry Pi

TL:DR version - use spi.mode = 3
For an Internet radio project, I wanted to display "Now Playing" information on a beautiful Samsung VFD sourced from adafruit.com. Adafruit has provided a nice arduino library for this display which I used as a starter set to translate into/build a python SPI-VFD class for the raspberry Pi.

I'm a complete noob at python but I tackled the translation of C code to python without too much trouble. I got things going in fairly short order after some google searches, was able to print "Hello, World!" However, the VFD was behaving a bit oddly on a few commands, the cursor. Well, you have to have a cursor to get to the second line, right?


Initially, I found a very useful thread on the raspberry Pi forum from poster bgreat on setting up a Nokia LCD to work with the Pi. That didn't fit my use case because it used more connections for SPI than the Samsung's three wires. It did give me a model of how to code for SPI on the Pi in general, however. The posting thread is also good for getting background on how to install/activate hardware SPI on the Pi.

But I hit a wall for a couple of weeks on fixing the cursor. I did a lot of searches based on guesses as to what the problem was. TTL voltage? Tried a 74HCT244 TTL up converter, same cursor result.  Under-current flakiness? Used a 2A power supply and separate, powered hub. Same. Some kind of SPI under-run, tried sending extra dummy bytes, still flakey. Think, think, think!

In my googling, I tripped over a posting reference to 3-WIRE mode in SPI. Hmn... The Samsung VFD uses only three SPI connections. Look at the data sheet, there's just a quick, passing reference to "three wire serial interface" and nothing else said.  OK, let's experiment!

I saw a test program on mitchtech.net that included source code to set SPI mode with a variety of parameters. Those parameters triggered a memory of an answer on stackoverflow.com about some Py object bindings. OK. So first, not knowing what I'm doing, I stupidly try the command:
spi.mode = 1
thinkng the mode is either on/off. The python interpreter accepts that, but I still get the same flakey results. Go back and look at the SPI test program again. There's a case statement for mode  that clearly says "3  #3-wire mode". Doh! Missed that.

Try:
spi.mode = 3

Success!











Comments

  1. Hi, I'm trying to do something similar - i.e. drive the adafruit VFD from a Raspberry Pi. Are you able to share the python code you came up with?

    Regards,
    Andrew

    ReplyDelete
    Replies
    1. Hi Andrew-
      Sorry about about the delay. I have been on a long vacation away from home base until September 25. Just now starting to get my affairs in order. I will try to put a sample program and class up on github. I have been away from this project for a long time, so will have to get back up to speed on it.

      Delete
    2. I've placed a "Hello_World.py" example in github:
      https://github.com/thisoldgeek/RPi_SPI_VFD
      Should get you started.

      Delete
  2. Apologies - I've only just caught up with your reply. Thanks for the code! I will let you know how I get on

    ReplyDelete

Post a Comment

Popular Posts