Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Cricket (thermostat kit concept) 16F917 & LCD

Status
Not open for further replies.

blueroomelectronics

Well-Known Member
Well I just got a 2.5digit 7 Segment LCD display running with a 16F917. It was a little tricky at first as I could find few examples on the net for a Static type display & the PIC16F917 LCD driver.
But finally got the hang of it. Easy as 123 once you understand it. Nice high contrast reflective super low power LCD; teriffic for a thermostat as it creates almost no heat and super low current draw.
The 16F917 does all the work driving the display, it even can run it during sleep. Here's the code to display "188" on the display. I'll post the schematic soon.
It's a Lumex LCD-S2X1C50TR less than $2 each. 3V to 5V operating.
https://www.lumex.com/product.aspx?id=462

**broken link removed**

Code:
; *** Enable LCD 16F917
        banksel LCDCON
        movlw   .7 -1           ; 1:7 postscale 31Hz refresh
        movwf   LCDPS           ; static bias COM0 (RB4)
        movlw   b'11011000'     ; LCD & VLCD (RC2) on
        movwf   LCDCON          ; clock INTRC/32
        movlw   b'11111111'
        movwf   LCDSE0
        movwf   LCDDATA0
        movlw   b'11111110'
        movwf   LCDSE2
        movwf   LCDDATA2
 
Thanks for the bump. Now there is something useful for the 16f917 debugger board laying around (Digikey had them for $5 a while back, clearing the way for the 16f887 board). Those bare glass displays are really cheap. What would be cool is one of those with the battery indicator, voltage, etc.

Admit to just glossing over the datasheet. Were the problems encountered with getting the voltage bias, setting up particular registers, or ?
 
I was under the impression that I didn't need VLCD (externally) enabled since its 5V glass and they refer to it as VDD so I assumed it was connected internally (another term might have been nice). It was tough to find any info for Static (one COM) glass.

The app notes provided the key, although the midrange LCD reference is WAY off for the 16F917.

The 16F917 double duties the USART & MSSP pins. I was going to use an SPI or I2C temperature sensor but think I'll go with an LM34 or LM35 and a 2.5V precision reference instead.

I've got the prototype running with a 32768Hz crystal and a supercap 1F for power failure clock backup. That works quite well. Another fun part is a two coil latching relay to keep the current consumption and internal heating down to a minimum.
 
Last edited:
Thanks for the tips.

Too bad about the double duty pins, bound to be some tradoffs somewhere. The I2C DS1721 is nice because of the Tout(Thermostat) pin for controlling whatever your trying to heat/cool with. What surprises me about the lm35, or its offshoots, is the price ranging from around $1 to over $5. One wire temp sensor would be less parts, but probably more on cost.

Need to google on the 16f917, to see if that would work with a GLCD or not.

EDIT: Never mind on the GLCD
 
Last edited:
I'd like to use a DS18S20PAR 1wire sensor, the wonderful beasties are not recommended for thermostats according to Maxim.

I've got two I/O pins available for temperature sensors, RA0 & RA3 (VREF+)

So they could be used with LM35, 1wire is possible in digital mode, or even an DS1721 with software I2C.

I wanted to save a little room on the PCB for a 7555 based Humidity sensor.

You can only control 96 pixels (12x8) with the 16F917, pretty small GLCD display and it would use up most of the available I/O
 
The 16f917 lcd mode is embarrasingly easy to use, the datasheet has 24 pages but I had to read it a few times before I understood it.
Once its setup properly it's completely automatic, you simply set bits in the LCDDATAx registers to turn pixels on and off.
The static displays are the highest contrast with wide viewing angles but require the most pins to use.
 
I'll post a photo of it with LCD on, and the ladybug Ethernet prototype tomorrow (Sunday).

Here's the circuit brief.
pins
17 LCD, COM0 & VLCD
3 ICD2
3 RS485
3 Pushbuttons (up, dwn, set)
3 Relay latching + sense
2 32768Hz crystal
1 TL431 2.5V precision shunt + setup jumper RA3 VREF+
1 LM34, LM35 or thermistor RA0
1 power loss detection
2 RB0 + ??? spare (possible humidity)
 
Last edited:
Even without a backlight, that display is a lot easier to read than the normal alphanumeric displays.

Looks good, but is such a large cap needed ? It takes up a lot of space.
 
The large 1F supercap is there to test the simple power backup system. Runs the PIC, tmr1 32KHz & display for about 2.5hrs The PIC LCD driver can be programmed to run the display in sleep.

The display is slightly higher contrast than in the photo (very black segments)

The prototype boards are made locally by LAB-EASY (site down) he makes scads of different types and they're very thin so you can cut them with sissors.

The single retailer is Creatron Inc in Toronto.
 
Can't seem to find anything (google) on the Lab-Easy products. Bummer!

Anyway, back to your project. It's very impressive. Is there a direct drive display similar to that with a decimal point?
 
The 917 can drive some pretty fancy displays, the Lumex LCD-S301C31TR has 3digits plus dp. It'll work but needs lots of I/O as it's a static display.
1 common + number of segments 23 + VLCD power 1 = 25 pins...

**broken link removed**
A muxed display will also work but the higher the mux (up to 4) the lower the contrast (you can use the B waveform to improve the contrast but you can only write to the display at specific intervals ie IRQ)
It's harder to find the 1/3duty displays
Mouser page 67 has lots of LCD displays the one I've used in Cricket is the first one on the page. All those displays are the static type though (seems that's all Lumex makes)
https://www.mouser.com/catalog/631/67.pdf

I'm adding a [SIZE=-1]Humirel HS 1101 Humidity Sensor to the design today (with the 555 in astable mode)

On a sidenote the LM35 / LM34 & TL431 combo work like a charm.
The conversion is ANRESL * 4.096

PS Mike I'd be happy to include a couple of lab-easy boards next time I send you off a sample board.
[/SIZE]
 
Last edited:
Thanks!

How are you measuring temperature? Are you using the 0.0v to 1.5v (2°..150°) LM35 configuration with the TL431 configured as a 2.5v reference or perhaps as a 1.5v reference?
 
The 2.5V reference is hooked up to RA3 (VREF+) and the sensor is directly on RA0.

So ADRES = RA0/(2.5V/1024)
23c would be 0.23/0.00244140625 = 94 (the A/D throws away the remainder)
To convert to decimal multiply * 4.096 or in integer math ADRES*125/512
More precision can be gained by using the bits left over. It works like a charm.

Works fine upto 120F too, (16bit integer math)

Now the HS1101 I'm trying something new by using the comparators and internal vref+. Much like the BASIC Stamp reads a cap.

500K 1% resistor, HS1101 (160pf to 200pf)
 
Last edited:
Here's the almost finished schematic. The power supply and power fail caps are missing. Any ideas on the last two I/O pins? (I'm keeping one for power loss detection)
It's very low power design (with the exception of the RS485) could be adapted to battery operation.
I'm thinking of a 1wire / iButton port, Dallas Semi even make an iButton designed to watch concrete dry.

Edit: A 3xAA (4.5V Alkaline) battery power supply as the battery level drops you can measure it by switching RA3 to analog (2.5v ref) as the A/D value will increase as VDD drops. Also 5V switch mode wall warts are cheap nowadays and would work very well as the main power source. A pair of diodes would act as the power switchover, the 3xAA should last for years as it's easy to put the Nanowatt PIC to sleep and wake it up every 4 seconds to update the RTCC.
**broken link removed**
 
Last edited:
Bill,

As you now have a very nice (and clever) way to measure Vdd could you now reconsider using the comparator to measure the capacitance of the humidity sensor?
With a comparator set up as an inverting amp with a feedback resistor and sensor to ground. You could activate it with the output polarity (or output enable) bit and gate timer1 from the comparator. With the amount of program space you could store lookup tables to eliminate any complex calculations.

Mike.
 
Hi Mike, the PIC internal comparator method I tried did work to some degree. But 8Mhz would only give me a clock count of less than 50 cycles between discharge & threshold.
The TLC555 is right out of the HS1101 datasheet, I've added the gating by controlling the reset line on the 555. Idea is I'll clear TMR0 and let it collect for 2 seconds via TMR1 interrupt service routine.

Other small revisions are a 4th pushbutton has been added (mode). I've left RB5 & RA2 available for expansion (thermistor, another LM34 or LM35) etc.

I'm thinking of ditching the LM35 in favor of an LM34 and doing the conversion to C in software as the LM34 will measure below 0C. Of course choice of an LM35 or LM34 is up to the builder.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top