A couple of you know that I recently lost a hard drive and had to get another one. In the course of getting things set back up I had issues with Arduino not compiling the sample code that comes with the libraries or previous code that I wrote to work with Noritake vacuum fluorescent displays. What happens is the code compiles fine but the displays output garbage. Apparently the avr-gcc compiler Arduino has bundled with its IDE is either broken or old and out of date. I run Archlinux so I don’t know if this is the case for other distros or it it’s the case for windows users but if you run into this issue, here’s what I did to fix it. First, the fix for a broken avr-gcc:
Install avr-gcc with pacman (not an AUR version) and do the following. # cd /usr/share/arduino/hardware/tools/avr/bin # mv ./avr-gcc ./avr-gcc-backup # ln -s /usr/bin/avr-gcc ./
Now the code compiles right and ouputs what it should. On to the fun part. I came across the secret voltmeter code on a forum somewhere and ended up atGoogle where the original code was published. I had also recently gotten a sample of a Noritake GU128X32D-7003 after a recent post over at EEVBlog forums. I had the thought that it would be nice to combine the two and see what I could come up with. If you follow the directions that came with the display and hook pin 1 to 5V, pin 2 to #2, pin 3 to GND, pin 4 to #3, (pin 5 isn’t used) and pin 6 to #4 on the Arduino board and compile the following code and upload it, you’ll have what’s in the pic. Neat huh?
#include <GU7000_Interface.h> #include <GU7000_Serial_Async.h> #include <Noritake_VFD_GU7000.h> GU7000_Serial_Async interface(115200, 2, 3, 4); // BAUD,SIN,BUSY,RESET const long scaleConst = 1135.53 * 1000; // internalRef * 1023 * 1000 (mine reads 1.11V so 1.11*1023*1000=1135530) long readVcc() { // Read 1.1V reference against AVcc // set the reference to Vcc and the measurement to the internal 1.1V reference ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); delay(2); // Wait for Vref to settle ADCSRA |= _BV(ADSC); // Start conversion while (bit_is_set(ADCSRA,ADSC)); // measuring uint8_t low = ADCL; // must read ADCL first - it then locks ADCH uint8_t high = ADCH; // unlocks both long result = (high<<8) | low; result = scaleConst / result; // Calculate Vcc (in mV) return (int)result; // Vcc in millivolts } Noritake_VFD_GU7000 vfd; void setup() { vfd.begin(128, 32); // 128x32 module vfd.interface(interface); // select which interface to use vfd.isModelClass(7003); // select display model 128x32 vfd.GU7000_reset(); // reset module vfd.GU7000_init(); // initialize module _delay_ms(300); // wait for device to power up } void printVoltage(){ int mv = readVcc(); vfd.GU7000_setFontSize(3, 2, false); vfd.GU7000_setFontStyle(false, false); vfd.print(mv / 1000, DEC); // print the integer value of the voltage vfd.print("."); // print the decimal place vfd.print(mv % 1000, DEC); // print the rest of the voltage in millivolts vfd.GU7000_lineFeed(); // start new line vfd.GU7000_carriageReturn(); // return to the left vfd.print("Volts"); vfd.GU7000_lineFeed(); // start new line vfd.GU7000_carriageReturn(); // return to the left } void loop() { printVoltage(); _delay_ms(300); }
Original post from:
http://electronics-lab.com/community/index.php?/topic/40674-arduino-voltmeter-and-a-noritake-vfd/
Leave a Reply
You must be logged in to post a comment.