PDA

View Full Version : Value of ADC to 7 Seg. Display



precision
- 3rd March 2006, 12:33
Hi all
My code is

adcin 0, B0

The value of B0 is 1021

if i send to lcd code is

LCDOUT $FE,1
LCDOUT "VALUE ",DEC B0

But how can B0 value (1021) send to 4, comn. anod 7 seg. display ?
becoz with lookup table we send first 1 and second 2 third 0 and forth 1

but value is combined how we extract this in four variable, eg B0, B1, B2, B3

Please HELP

sougata
- 3rd March 2006, 14:24
Hi,

There are two solutions to your problem. One is hardwiring some 7-Segment Decoder/Driver chips to drive the LED displays like CD4543.The other is to multiplex the LED displays and drive them from the PIC directly. The first one is not cheap but leaves you room (time) for other tasks if you are doing plenty. The second one is cheap and most opted method. You drive all the segments (of all the displays) from a PIC port and use four additional transistors to switch the common cathods.

PBP has got a DIG function that gets you the BCD equivalent from a varaiable. So you just get DIG0,DIG1,DIG2,DIG3 to some different variables and throw them to the display. If you are using multiplexing then you need to convert this value into suitable segment drives by the lookup (63,6,91,79,102,109,125,7,127,111) assuming you a-g (common catode) is connected to PORT.0-PORT.6

I don't have the schematics handy. May be someone else does.

Regards

Sougata

boroko
- 28th October 2014, 11:27
Having a problem that I don't understand concerning this subject, wonder if I can resurrect it?

I'm driving 8 digits of LED 7 segment display multiplexed with a 18F4431. The display elements are decoded with a lookup table. All is well with numbers 0-9, but I'm having trouble understanding how to add a few Alpha characters.

Another bit of info is that this is a menu portion of the code and is selected using a rotary encoder with a push button for entry. It just increments Temp.

What I believe are the relevant lines of code are below:


FOR Idx = 0 TO 7
SELECT CASE Idx
CASE 0
Temp = ValueD DIG 0
CASE 1
Temp = ValueD DIG 1
CASE 2
Temp = ValueD DIG 2
......
END SELECT
' 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, dp, L, H, C, S, A, n, blank ( what they represent)
LOOKUP Temp,[63,6,91,79,102,109,125,7,127,111,128,56,119,57,109 ,119,84,0] DigDef

SEGDIF (Idx) = DigDef


The problem is that I don't seem to be able to incorporate a single digit value to a lookup table more than 0-9. I realize that the table is 18 elements long , and I can drop 2 to get it into a HEX representation (16), but I can't even get past 9 (10). Any ideas?

Thanks for looking
Mark

Demon
- 28th October 2014, 14:40
Your loop will only convert first 8 characters (0-7).

Robert

boroko
- 28th October 2014, 15:51
Thanks Demon

I may not have explained very clearly, sorry.
The Idx sequence is to separate the different digits. There are 8 digits total. I'm trying to use the lookup table to access the values that will activate the segments to display properly on a 7 seg display.

It does 0-9 properly, The issue that I'm having is getting it to display a few more characters...

My way of thinking is that I should be able to have the variable with a value of 0-15 with a single value in the variable (in HEX), and it should be able to access that many steps into the table. Evidently, I'm wrong, because I haven't gotten it to work.

The issue revolves around accessing >10 indexes in the table with a variable that I have to separate into digits for the 7 seg display (using the DIG modifier). I may have to rethink how I'm doing that part to get this to work.

Thanks for any input.
Mark

Amoque
- 28th October 2014, 23:18
I'm going to try...

Lets look at displaying 123S4n

First, I think, you will need to convert the segment definition for each character you wish to display to decimal and place it in the lookup table. For the digits this is easy because the index = the number you wish to display: For the first digit (1) the lookup index is 1, so DigDef is loaded correctly (1=1)... Same for 2 (2=2) and 3 (3=3)... Each digit you want displayed occupies the correct index, so all is fine.

Now we come to "S". What is the index of the definition of "S"? S=?? There is no numerical equivalent to S... So, I think, in order to make it work, you'll have to change your CASE statements to decode the character rather than the position like:

If your byte array contains 6 elements [0] being 1 ... [5] being "n" - from the example above, then:

FOR IDX = 0 to 5
SELECT CASE STRING 'Return the character in position IDX
CASE 0
TEMP=0 'CHARACTER 0 is at index 0
CASE 1
TEMP=1 ' 1 is at index 1...
CASE 2
TEMP=2
CASE 4
TEMP=4
...
CASE "S" ' I think you'll need the ASCII value for "S" here
TEMP=15 ' "S" is at index 15
CASE "n"
TEMP = 17 ' "n" is at index 17
...
END SELECT
NEXT IDX

My thought, if I understand correctly, is that you will want to select the correct index [I]based on the character rather than the position. I'm something of a noob myself and I don't know for sure that you can decode strings like I've demonstrated ("S"). You may need to use the ASCII value of the letter 83(?).