It's not a waste of memory if you're not wanting it for something else - otherwise it's just sat there as completely wasted memory.
I knew i'd regret getting involved in this logic stuff. Clearly don't have the mind for it!
Anyway, your advice was taken on board and today I coded two similar ways around the problem:
Here's the first: (pseudocode, or plain thoughts)
1. Read analog input, store in temporary register
2. move to GPR so next adc input can go in the above register
3. call function lookuptable
- adc value is loaded back into w, and added to PC counter, which in theory steps the program 255 steps (if 5v is present), meanwhile the following lines are structured like this (255 lines in this lookup table:
retlw 0; ;adc value of 0, digital output wants to be 0psi
retlw 0; ;adc value of 1, digital output still wants to be 0psi
retlw 1; ; adc value of 2, digital output is now 1psi
This is how most internet tutorials seem to lay out the theory, my problem being that on testing the code, it compiles fine but the lcd remains blank.
Code example:
; BOOST LOOKUP
BSTLOOKUP ADDWF PC
RETLW .0
RETLW .0
RETLW .0
RETLW .0
RETLW .0
RETLW .0
So I decided to try another approach:
1. Read analog input, store in temporary register
2. move to GPR so next adc input can go in the above register
3. call function lookuptable
4. 255 entires in this look up table - each containining code to XOR literal value (1,2,3-255 etc) with the adc input. The zerobit is then checked and if the xor compared the results as equal it returns the value of psi i am looking for (instead of the adc digital value).
This can then be relatively easy and sorted to call the function to display values on the LCD.
I tested this approach by writing the code to display up to 3 psi for a limited range of voltages, however the lcd printed 0psi1psi2psi all the time regardless of input. My routines for display interfacing are fine as I can alter the code to call functions that send letters to it no problem.
Its getting hard to get across what i've coded now. I doubt anyone can really offer much to specifically help, but any ideas welcome. Surely my logic isn't wrong?