Maker Pro
Maker Pro

7 specific volatges to to 1,n,2,3,4,5,6 numbers in Alpha-numeric Display

E

ehsjr

Jan 1, 1970
0
John said:
Well, neglecting initialization and housekeeping, you're going to
wind up with two sections, basically.

The first will have to do with converting your sensor's output
voltage into a number beween zero and 255 and determining where that
number sits with reference to some 'magic numbers' you'll have to
program into the chip.

Your trip points are:

6 = Anything over 4.526v
5 = Anything over 4.052v
4 = Anything over 3.356v
3 = Anything over 2.660v
2 = Anything over 2.043v
1 = Anything over 1.022v

You have to equate those voltages to numbers, and if you have an 8
bit ADC with an input upper limit of 5V, then zero volts into it
will result in 0000 0000 (hex 0X00) out of it and five volts into it
will result in 1111 1111 (0Xff) out of it.

So, since you have 256 output states available from the ADC, the
sensitivity of the LSB will be equal to:

5V
LSB = ------------ = 0.01953 V
256 states

which means that the granularity of your ADC will be such that the
smallest change you'll be able to detect in the output of your
sensor will about 20 millivolts.

With that in mind, we need to 'normalize' your trip points to the 8
bit field we're playing in, and we can do that by dividing your
various trip points by the sensitivity of the ADC, like this:

4.526V
TP6 = --------- = 230.8 ~ 231 = 0xe8 = 1110 1000
0.01961

So, when your ADC outputs 1110 1000, you'll know that the output of
your sensor is pretty close to 4.526V (within about 20mV one way or
the other, anyway.)

If you performed that division and conversion for all of your trip
points, you could wind up a table that looked like this:

TP VOUT ADCHEX ADCBIN
---|-------|--------|--------|
6 | 4.526 | 0XE8 |11101000|
---|-------|--------|--------|
5 | 4.052 | 0XCF |11001111|
---|-------|--------|--------|
4 | 3.356 | 0XAC |10101100|
---|-------|--------|--------|
3 | 2.660 | 0X88 |10001000|
---|-------|--------|--------|
2 | 2.043 | 0X69 |01101001|
---|-------|--------|--------|
1 | 1.022 | 0X34 00110100|
---|-------|--------|--------|

Now, if at the end of every conversion you stored the value in the
ADC's output to a register, (let's call it ADCHEX) then to find out
what gear you're in all you'd have to do would be something like
this, in Motorola 6800 assembler:


ngear: lda adchex ;get ADC output
cmp #$e8 ;compare it to 232
bhs six ;branch if it's > = 232
cmp #$cf ;compare it to 207
bhs five ;branch if it's > = 207
cmp #$ac ;compare it to 172
bhs four ;branch if it's > = 172
cmp #$88 ;compare it to 136
bhs three ;branch if it's > = 136
cmp #$69 ;compare it to 105
bhs two ;branch if it's > = 105
cmp #$34 ;compare it to 52
bhs one ;branch if it's > = 52
bra ngear ;else loop


Now, what you'd like to have, at the branches's targets, is a
pattern stored which will get the seven-segment display to display
what gear you're in. To do that, you need to know how a
seven-segment display is set up.

It's like this, where 'a' through 'g' are the names of the segments:

a
-----
| |
f| g |b
-----
| |
e| |c
-----
d

So, if you turn on a,b,g,e, and d, the display will read '2'.

OK, so assuming (to make my life a little easier) that you've got a
common-cathode display and that the µC can source enough current to
make the segments easily visible, what we need to do is assign a
register to drive the IO port. If we call the register "segdata"
and the port "ledout", and agree that the LSB (bit0) of the register
and the port will correspond to segment 'a', bit 1 to segment 'b'
and so forth, with the MSB always being equal to 0, then the code
for the branches should look like this:


six: lda #$0d ;segment data for "6"
bra ledon ;to turn on the segments

five: lda #$65 ;segment data for "5"
bra ledon ;to turn on the segments

four: lda #$66 ;segment data for "4"
bra ledon ;to turn on the segments

three: lda #$4f ;segment data for "3"
bra ledon ;to turn on the segments

two: lda #$3b ;segment data for "2"
bra ledon ;to turn on the segments

one: lda #$06 ;segment data for "1"
ledon: sta ledout ;turn on the segments
bra ngear ;loop back to the beginning


That's about it...

Wow!

What a *great* example of how to tell a person to
"use a ______" (PIC, PICAXE, uc, stamp, whatever)

Ed
 
R

Rich Grise

Jan 1, 1970
0
What I am attempting is to take 7 specific voltages, and display certain
numbers for these specific voltages on an alpha-numeric display.

What I currently have is a resistor ladder that breaks up the voltage. The
resistors form a ladder that breaks up the 5v from a voltage regulator
into reference signals to determine at what voltages an LM339N will use to
ground each corresponding LED. It use 1% resistors to make sure I get
exact reference voltages because in the higher gears

the signal is very close and there is not much gap between voltages. The
output voltages from the sensor are as follows
1st gear = 1.782v
2nd gear = 2.242v
3rd gear = 2.960v
4th gear = 3.630v
5th gear = 4.310v
6th gear = 4.660v
Neutral = 5.000v
The comparators in this circuit will turn on each LED as follows:
1st LED = Anything over 1.022v
2nd LED = Anything over 2.043v
3rd LED = Anything over 2.660v
4th LED = Anything over 3.356v
5th LED = Anything over 4.052v
6th LED = Anything over 4.526v

So, you have six LEDs, and they turn on, first one, then the second while
the first is still on, then there's three, and so on?

http://www.chipdocs.com/datasheets/datasheet-pdf/Fairchild-Semiconductor/74HC148.html

This is a "priority encoder". Digi-key has them for $0.55 and less.

Then, any ol' BCD-7 segment decoder, like a 7447 or 82S23 or whatever. ;-)

Have Fun!
Rich
 
Top