Sparkfun "Serial Enabled 3.3V LCD"?

Support forum for the mightyohm.com Geiger Counter.
http://mightyohm.com/geiger
Post Reply
ceratophyllum
Posts: 7
Joined: Thu Dec 27, 2012 11:07 am

Sparkfun "Serial Enabled 3.3V LCD"?

Post by ceratophyllum »

Sparkfun sells a 16x2 3.3V "Serial Enabled" LCD which just needs to be connected to Vcc, GND, and TX.

Has anyone tried this with the Geiger Counter Kit? The spec sheet for the "black on green" version says it uses only 3mA with the backlight off. I think this could be a really simple way to add a display with minimal changes to the code. The only thing is one might have to shorten the serial output to less than 16 characters before you send a newline character(s) if the display wraps >16 character line 1 to line 2. (Or does something else bad when you try to write off screen?)

About $30, including shipping is a little steep just to add an LCD, so I thought I'd ask if anyone has been able to use this LCD easily.
User avatar
mightyohm
Site Admin
Posts: 1064
Joined: Fri Apr 03, 2009 10:29 pm
Location: Seattle, WA
Contact:

Re: Sparkfun "Serial Enabled 3.3V LCD"?

Post by mightyohm »

I haven't played with it but it should work if the display is tolerant of voltages below 3.3V. The geiger kit gets down close to 2V when the batteries go dead, if you use fresh batteries (or an external power supply) that will probably help the display run longer! You'll want to modify the firmware on the ATtiny to make a nicely formatted display!
ceratophyllum
Posts: 7
Joined: Thu Dec 27, 2012 11:07 am

Re: Sparkfun "Serial Enabled 3.3V LCD"?

Post by ceratophyllum »

Well, I finally got that 3.3V serial LCD and tested to see that it works ok, powering it off the leftmost pin on the "pulse" headers. The output is legible, but jumps around a bit because the long lines wrap in an ugly manner.

I've got the source code and it compiles without problem. There is one thing I'm not sure about and that is how to send the ascii code to turn off the backlight. (The BL is on by default and it actually makes the screen harder to read!)
If this were an Arduino, I would simply put this code in my sketch:

Code: Select all

Serial.write(0x7C);   //command flag for backlight stuff
Serial.write(128);     //light level for off.
Would this just be

Code: Select all

uart_putchar(124);     // or uart_putchar('|') ?
uart_putchar(128);     //dunno how to type a c with cedilla on US keyboard!
If I had a programmer, I would just upload the hex file and test...which leads me to the next question:

Is there a step-by-step tutorial or forum thread about programming ATtiny2313? I've got the general idea, but have not done this before. I'm thinking of using a Seeeduino V3 or Arduino Uno I have laying around as programmer by uploading the ISP programming sketch. Is this a reliable method? Or should I just get a dedicated AVR programmer kit like they sell at adafruit? I'll probably not be using it that much, once I've made the serial output LCD-friendly, so the idea of temporarily using an Arduino I already have and 6 jumper wires appeals.
User avatar
mightyohm
Site Admin
Posts: 1064
Joined: Fri Apr 03, 2009 10:29 pm
Location: Seattle, WA
Contact:

Re: Sparkfun "Serial Enabled 3.3V LCD"?

Post by mightyohm »

uart_putchar takes a byte as an argument, so it can be in any format - binary, hex, ascii, etc. It just transmits one byte at a time (no newlines). Make sure to enclose ASCII characters in single quotes.

You probably could use an Arduino as a programmer, but I wouldn't recommend it. You're just making things more complicated. I would spend the money and get a dedicated programmer like the usbtiny or AVRISP mkII.

Ladyada has a tutorial about flashing AVR's with avrdude (command line) here:
http://www.ladyada.net/learn/avr/avrdude.html

If you install the AVR toolchain (http://mightyohm.com/blog/tutorials/avr ... tallation/) then you should be able to run "make" and then "make flash" from the geiger source directory in order to program the part. You'll need to apply power to the geiger kit during programming, and the jumper on the usbtiny should be removed when you connect it to the board, otherwise you'll short the 3V geiger supply to 5V (bad).
ceratophyllum
Posts: 7
Joined: Thu Dec 27, 2012 11:07 am

Re: Sparkfun "Serial Enabled 3.3V LCD"?

Post by ceratophyllum »

Already got the avr tools; I'm using Linux Mint so it looks like apt-get installing arduino sucked in most, if not all of it when I apt-get installed the arduino IDE. In any case, typing make in the source directory produces a hex file. Didn't notice that the Makefile included a target 'flash' to handle the avrdude commandline incantation. Thanks for pointing that out.

After reading a bunch of confusing, outdated blogs on the subject, I came to the conclusion that using an Arduino to program att2313 is a fiddly exercise in masochism...especially the first time around. With my brain like a steel sieve, I'm probably gonna have to flash this guy about 40 times before I get things just right. Soldering kits is fun, so I'll just get the programmer.
You'll need to apply power to the geiger kit during programming, and the jumper on the usbtiny should be removed when you connect it to the board, otherwise you'll short the 3V geiger supply to 5V (bad).
Thank you! You anticipated my question (3.3 or 5?) before I've even ordered the programmer.
ceratophyllum
Posts: 7
Joined: Thu Dec 27, 2012 11:07 am

Re: Sparkfun "Serial Enabled 3.3V LCD"?

Post by ceratophyllum »

So I got my USB tiny and everything worked as expected: all I had to do make some changes to the source and type make install as root. For now, I just commented the commands that display the microsieverts. Maybe I'll stick them on line 2; there's a 2-byte serial command for that. But first, the problem:

The commands above(0x7C and 0x80) do not turn off the backlight. Nothing seems to happen. I used uart_putchar() to send the commands to place the cursor at the top of the first row after printing the text and it worked as expected.

Code: Select all

 
//LCD cursor-to-top-right command bytes just add a little garbage to the log.
//Gnuplot ignores not-a-number junk in the log file so no problem.
		uart_putchar(0xFE); uart_putchar(128);
Since this is not really a geiger counter problem, I asked over at sparkfun. Hopefully they'll know what's wrong.
User avatar
mightyohm
Site Admin
Posts: 1064
Joined: Fri Apr 03, 2009 10:29 pm
Location: Seattle, WA
Contact:

Re: Sparkfun "Serial Enabled 3.3V LCD"?

Post by mightyohm »

I'm not familiar with the display so unfortunately I can't help much. Watch out for stuff like binary/hex and end of line characters in case the LCD is expecting you to send a sequence followed by a newline.
ceratophyllum
Posts: 7
Joined: Thu Dec 27, 2012 11:07 am

Re: Sparkfun "Serial Enabled 3.3V LCD"?

Post by ceratophyllum »

Looks like you only have to send the command once; the BL setting is stored in EEPROM. So I hooked up the LCD to a cheap USB FTDI I got on ebay and did the following at the command (BASH shell) prompt:

Code: Select all

# only need to do this once
# BL will stay off after this
env printf '\x7C' > /dev/ttyUSB0
env printf '\x80' > /dev/ttyUSB0
Thank the gods for the texinfo docs on printf; I never would have guessed this stuff!

You have to have the 'env' and putting the 2 bytes together won't work:

Code: Select all

# This doesn't work:
env printf '\x7C80' > /dev/ttyUSB0
# nor does this:
 printf '\x7C80' > /dev/ttyUSB0
Now I need to think about how to attach the screen and/or put screen+board in a bigger box, so my kit does not have a ball & chain hanging off it.
ceratophyllum
Posts: 7
Joined: Thu Dec 27, 2012 11:07 am

Re: Sparkfun "Serial Enabled 3.3V LCD"?

Post by ceratophyllum »

Well, it works and didn't require a big fuss with the output format. Gnuplot doesn't choke on the garbage representing CRLF for the LCD, and the LCD doesn't choke too horribly on the CRLF needed for tidy redirection to file.
100_4126.JPG
User avatar
mightyohm
Site Admin
Posts: 1064
Joined: Fri Apr 03, 2009 10:29 pm
Location: Seattle, WA
Contact:

Re: Sparkfun "Serial Enabled 3.3V LCD"?

Post by mightyohm »

Nice! :D
Post Reply