Further down is the program that will record the ADC value into eeprom. It works perfectly and i can read all the stored values from the EPIC programmer. It also cycles through the individual segments to prove my wiring is correct, which it is.
I see that this could be the basis for a new program.
Take an ADC reading, place it in eeprom, read it, and display it.
Questions regarding this would be, how do i get the value stored in eeprom into decimal, and how do i display the 100's, 10's and 1's on their correct digit?
How would i create a lookup table where i can specifically say that a number "one" should be:
PortB.0 = 0 'A
PortB.1 = 0 'B
PortB.2 = 0 'C
PortB.3 = 0 'D
PortB.4 = 0 'E
PortB.5 = 0 'F
PortB.6 = 1 'G
PortB.7 = 1 'DP
Then i just call for "ONE" when a 1 needs to be displayed.
If i could do this for all the numbers, then figure out which number should be displayed on which digit, life would be good!
I have tried a lookup table like this where i am calling PortB = bin2seg
bin2seg: Lookup psitimes100, [%1000000, %1111001, %1000100, %1110000, %0011001, %0010010, %0000010, %1111000, %0000000, %1000000], psitimes100
It does not seem to work!
Anyway, here is the extend of several days of frustration!!....
include "modedefs.bas"
DEFINE OSC 20
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50
TRISA = %11000001 'set portA
ADCON0 = %11000101 'read as analog
ADCON1 = %00001110
RAW VAR WORD 'Set ADC value to name of RAW
millivolts VAR WORD
psitimes100 var word
Pause 100
TRISB = %00000000 'set portB all outputs
PortA.2 = 0
PortA.3 = 0
PortA.4 = 0
PortB.0 = 1 'A
PortB.1 = 1 'B
PortB.2 = 1 'C
PortB.3 = 1 'D
PortB.4 = 1 'E
PortB.5 = 1 'F
PortB.6 = 1 'G
PortB.7 = 1 'DP
Main
ADCIN 0, RAW 'READ ADC store value to RAW
millivolts = RAW */ 1250 'convert ADC to millivolts
psitimes100 = millivolts ** 47527 'convert millivolts to psi*100
psitimes100 = psitimes100 + 145 ' add sensor offset
PortB.0 = 0 'A
PAUSE 1000
PortB.0 = 1 'A
PortB.1 = 0 'B
PAUSE 1000
PortB.1 = 1 'B
PortB.2 = 0 'C
PAUSE 1000
PortB.2 = 1 'C
PortB.3 = 0 'D
PAUSE 1000
PortB.3 = 1 'D
PortB.4 = 0 'E
PAUSE 1000
PortB.4 = 1 'E
PortB.5 = 0 'F
PAUSE 1000
PortB.5 = 1 'F
PortB.6 = 0 'G
PAUSE 1000
PortB.6 = 1 'G
WRITE 0, psitimes100
pause 100
WRITE 1, psitimes100
pause 100
WRITE 2, psitimes100
pause 100
WRITE 3, psitimes100
pause 100
WRITE 4, psitimes100
pause 100
WRITE 5, psitimes100
pause 100
WRITE 6, psitimes100
pause 100
WRITE 7, psitimes100
pause 100
WRITE 8, psitimes100
pause 100
WRITE 9, psitimes100
pause 100
WRITE 10, psitimes100
pause 100
WRITE 11, psitimes100
pause 100
WRITE 12, psitimes100
pause 100
WRITE 13, psitimes100
pause 100
WRITE 14, psitimes100
pause 100
WRITE 15, psitimes100: write 16, millivolts: write 17, raw
pause 5000
GOTO Main
Regards,
James.




Bookmarks