Project:Mini VFD

From Nottinghack Wiki
(Redirected from Mini VFD)
Jump to: navigation, search

A small Vacuum Flourescent Display I recovered from the skip at work.

It is housed in a project box with a mains transformer - it use to have a mystery 9-pin serial port input but it wouldn't work until we worked out that it was expecting a 5V TTL serial signal.

The Futaba Corp M202SD08G module is a 20 character x 2 line, 5x8 dot matrix display. It has a European font with characters in the range from 0x20 (space) through the ASCII range and up to 0xFF with a bunch of Greek and Cyrillic characters.

I've put a Xino into the box and I'm working on something amusing for it to do in the hackspace.

The module has a single 20 pin connector (2x10 0.1" pins) of which we only need connection for +5V, GND, serial data in and a busy line out. The module asserts the busy line when it is working but it is enough to just make short delays in your code!

I have a simple Arduino sketch that just shows each character. It uses NewSoftSerial on pins 2 and 3 as well as regular serial on pins 0 and 1 (on old Arduino0022) just for testing to see if NewSoftSerial is any good.

 1 #include <NewSoftSerial.h>
 2 #include <icrmacros.h>
 3 
 4 NewSoftSerial mySerial(2, 3);
 5 void setup() 
 6 { 
 7   Serial.begin(9600);
 8   mySerial.begin(9600);
 9 } 
10 
11 int b = 0x20; 
12 
13 void loop() 
14 { 
15   Serial.print(b, BYTE);
16   mySerial.print(b, BYTE);
17   delay(100);
18   b++;
19   if(b == 0xff){
20     b = 0x20; // the first char in the VFD table
21     delay(1000);
22   }
23  
24 }

The mains transformer in the box is this LASCAR PSU 201 Fixed Voltage Single Rail Power Supply...

Although the unit is useful as a plain serial-driven ASCII display there are some interesting capabilities alluded to in the various datasheets. The VFD character table includes some programmable characters. I'd like to have a go at this! There are control sequences to shift the screen and create a scrolling effect.

 1 /**
 2  *   Futaba VFD box Software serial
 3  *
 4  */
 5 #include <SoftwareSerial.h>
 6 #include <math.h>
 7 // supports 3 major temperature scales
 8 enum {
 9   T_KELVIN=0,
10   T_CELSIUS,
11   T_FAHRENHEIT
12 };
13 
14 // manufacturer data for episco k164 10k thermistor
15 // simply delete this if you don't need it
16 // or use this idea to define your own thermistors
17 #define EPISCO_K164_10k 4300.0f,298.15f,10000.0f  // B,T0,R0
18 #define NOTTINGHACK_47K 4090.0f,298.15f,47000.0f  // B,T0,R0
19 
20 SoftwareSerial mySerial(2, 3); // RX, TX
21 
22 void setup()
23 {
24   // Open serial communications and wait for port to open:
25   Serial.begin(9600);
26   while (!Serial) {
27     ; // wait for serial port to connect. Needed for Leonardo only
28   }
29   Serial.println("FutabaBox1 v1.0");
30   // set the data rate for the SoftwareSerial port
31   mySerial.begin(9600);
32   mySerial.println("Hello, world?");
33 }
34 
35 void loop() // run over and over
36 {
37   while(Serial.available()){
38     mySerial.write(Serial.read());
39   }
40   updateTemp();
41   delay(1000);
42 }
43 
44 void updateTemp(void)
45 {
46   mySerial.print("Temperature: ");
47   delay(10);
48   mySerial.println(Temperature(1,T_CELSIUS,NOTTINGHACK_47K,10000.0f));
49   delay(10);
50 }
51 
52 // Temperature function outputs float , the actual
53 // temperature
54 // Temperature function inputs
55 // 1.AnalogInputNumber - analog input to read from
56 // 2.OuputUnit - output in celsius, kelvin or fahrenheit
57 // 3.Thermistor B parameter - found in datasheet
58 // 4.Manufacturer T0 parameter - found in datasheet (kelvin)
59 // 5. Manufacturer R0 parameter - found in datasheet (ohms)
60 // 6. Your balance resistor resistance in ohms  
61 
62 float Temperature(int AnalogInputNumber,int OutputUnit,float B,float T0,float R0,float R_Balance)
63 {
64   float R,T;
65 
66   R=1024.0f * R_Balance / float( analogRead(AnalogInputNumber) ) - R_Balance;
67   T=1.0f/(1.0f/T0+(1.0f/B)*log(R/R0));
68 
69   switch(OutputUnit) {
70     case T_CELSIUS :
71       T-=273.15f;
72     break;
73     case T_FAHRENHEIT :
74       T=9.0f*(T-273.15f)/5.0f+32.0f;
75     break;
76     default:
77     break;
78   };
79 
80   return T;
81 }