Value of ADC to 7 Seg. Display
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
Re: Value of ADC to 7 Seg. Display
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:
Code:
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
Re: Value of ADC to 7 Seg. Display
Your loop will only convert first 8 characters (0-7).
Robert
Re: Value of ADC to 7 Seg. Display
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
Re: Value of ADC to 7 Seg. Display
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[IDX] '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 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(?).