Interface design for school project - Page 1
Forum section: electronics / projects

author: aalbri
author_rank: Contributor
timestamp: July 12, 2013, 01:03:18 am
content: So I am working on a project and one part of it is a keypad and LCD screen. I want to let some people check this out and give any feedback (positive or negative) on it. It is my FIRST design from scratch and very simple. If I am doing something fundamentally stupid, I would much rather catch it now than after I order and build it.This is just the first part of the project, so depending on how well this goes, I will be back to show you guys other designs.One thing that I am not 100% positive on is the LCD. I will be only writing data to it, never need to read it back as far as I know. Are the connections I have correct for that?Thanks yall!

author: Paul Price
author_rank: Super Contributor
timestamp: July 12, 2013, 01:10:01 am
content: Looks good to me.

author: mariush
author_rank: Super Contributor
timestamp: July 12, 2013, 01:44:53 am
content: I think R/W should also be digital input/output or grounded , if you tie it to Vin wouldn't that tell the lcd controller that it's always set to digital 1? (therefore commands won't work)DB0 to DB3 may also have to be grounded, not left floating.Do you really need 12v for buttons? Can the ADC handle 12v, if you're using an adc to get what buttons were pressed?What are you going to do about key debouncing? When you push the buttons the contact will bounce for a few ms before it settles. A tiny capacitor at each button would do a sort of low pass filter and clear the bouncing problems but you add too many components.Then, you're going to have the latency of the ADC - depending on the frequency of the microcontroller you're going to need a few ms to convert the value from analogue to digital. Are you going to do continuous conversions and waste power?Since you have exactly 8 buttons, it could be a good idea to have 8 DPST buttons (double pole single throw) tied to a parallel to serial shift register like the following:SN74HC165Nhttp://uk.farnell.com/texas-instruments/sn74hc165n/ic-8bit-parallel-load-shift-regist/dp/959120674HC165Nhttp://uk.farnell.com/nxp/74hc165n/ic-8bit-shift-register-16dip/dp/380635cd4021bmhttp://uk.farnell.com/texas-instruments/cd4021bm/logic-static-shft-reg-8stg-16soic/dp/1740087cd4014behttp://uk.farnell.com/texas-instruments/cd4014be/logic-static-shft-reg-8stg-16dip/dp/1740086and others and basically use 2 pins of your microcontroller to get the state of all 8 buttons without messing about with resistors and their tolerances and large voltage etc.You could get the button state in a loop since it takes ns to shift in 8 bits or, since the buttons are double pole, you could connect all 8 buttons at one pole and route that wire to another controller pin which would trigger an interrupt in the controller that would shift the data from the register and let you know which buttons are actually pressed.later edit:and since you'd basically have 7 data lines going to the lcd, you could use a serial to parallel shift register to set all 7 pins through just 2-3 wires. You basically shift the data and then trigger the register to output all 8 bits through its outputs.Look at CD4094BE , M74HC595RM13TR , SN74AHCT595PW, SN74HC595DR etc etc (search for bolded stuff in the shift registers section of the site above)So you'd have 2-3 wires for lcd , 2-3 wires for buttons and 5v for everything with just a bit more complexity added.

author: David_AVD
author_rank: Super Contributor
timestamp: July 12, 2013, 01:51:59 am
content: Quote from: mariush on July 12, 2013, 01:44:53 amI normally ground DB0..DB3 in 4-bit mode. For all the common types of character LCDs, the R/W line should be grounded if you don't need the read mode. I don't think I've ever connected R/W to the micro - driving it "blind" works well for most applications.

author: David_AVD
author_rank: Super Contributor
timestamp: July 12, 2013, 01:56:09 am
content: Quote from: mariush on July 12, 2013, 01:44:53 amUsing the analog input like this is fine, although I'd use the micro's Vcc as the reference personally. I haven't checked to see what voltage range (at the micro pin) those resistors give you. Using the micro's (regulated) rail as the reference for the switches will also give you a repeatable result vs a potentially unregulated 12V rail.

author: mariush
author_rank: Super Contributor
timestamp: July 12, 2013, 02:02:31 am
content: Quote from: David_AVD on July 12, 2013, 01:51:59 amYou're right, I added the "to ground" remark for the R/W line probably at the same time you wrote your comment.

author: aalbri
author_rank: Contributor
timestamp: July 12, 2013, 02:52:54 am
content: This is exactly what I wantedIt probably would be better to use a lower supply voltage.Also I was thinking about the shift register you were talking about... Do you think a 8:1 mux would be usable? I'm not sure how difficult it would be to coordinate the select bits with the switches outputs though.What do you guys think about cycling through the select bits quick enough to catch a press but slow enough for my program to check the data? Then I could just use a digital pin.

author: mariush
author_rank: Super Contributor
timestamp: July 12, 2013, 03:19:01 am
content: I don't think mux would work.Parallel to serial registers are quite easy.. you send a clock through one pin and with each clock pulse on the other pin you get the state of one of the eight inputs, so you can read sequentially all eight buttons.If you want to keep using the potential divider, I'd suggest settling on three resistors : 100 ohm , 1kohm , 10 kohm all at 1% precision (not expensive)100 ohm alone, 50 ohm (two in parallel) , 200 ohm (2 in series)1 kOhm alone, 500 ohm || , 2 kOhm - -10 kOhm alone , 5 kOhm || , 20 kOhm - -so you have 1kOhm on one side and then on the other side50 ohm , 100 ohm , 200 ohm , 500 ohm, 1kohm, 2 kohm , 5 kohm , 10 kohm1 kohmand you have voltages : 4.75v, 4.5v , 4.15v, 3.33v, 2.5v, 1.66v, 0.83v, 0.45vor100 , 500 , 1000, 2000, 3333 (10k x 3 parallel) , 5000, 10000, 2000050004.9v, 4.55v, 4.16v, 3.58v, 3v, 2.5v,1.68v,1v

author: David_AVD
author_rank: Super Contributor
timestamp: July 12, 2013, 03:19:18 am
content: The analog with resistors method will be fine. I've used that before with no issues. It's very common on consumer goods, although they use a string of series resistors with the switches going to Vss.

author: AndyC_772
author_rank: Super Contributor
timestamp: July 12, 2013, 06:43:09 am
content: You might well need a series resistor in line with the LCD backlight. Joining A to +5V and K to ground could result in the backlight being very bright for a brief period, then dim and smoky.