compare a value to a table

Status
Not open for further replies.

pouchito

New Member
Hi All

Need your help

- using PICBASIC PRO (pic simulator IDE 6.2 compiler)
- i input an analog value ranging from 0-2.5V and i converted it to digital 10bit


MY PROBLEM is :

what i need to do for example :
if the digital value is 0000010101 output 2%
if the digital value is 0000011011 output 2.2%

should i place the 2% .... in an array table and compare them,
if yes how this can be done?

Please help
 
not 100% linear
i.e: in some cases, for different input values, we can get same % results

ex: for 0000001010 ==> 2%
for 0000001011 ==> 2%
for 0000001100 ==> 2%
for 0000001101 ==> 2.1%
for 0000001110 ==> 2.2%
for 0000001111 ==> 2.3%
for 0000010000 ==> 2.3%
for 0000010001 ==> 2.3%
 
If it's not linear you need a table then! - unless you can produce a formula that fits it?.
 
I don't use PICBASIC, so I can't help you with that, in assembler you use a series of RETLW's.

Can you define a single dimensional array in your BASIC?.

EDIT:

Quick rethink! - does your BASIC support the DATA statement?, this is an example from the PIC BASIC compiler version of WinPicProg I was working on.

Code:
DATA 45, 255, 0, "H", "e", "l", "l", "o" - store 8 bytes of data. 
READ A - read the first three bytes of data to three variables.
READ B
READ C 
RESTORE 4 - reset the read point to 4th byte
FOR X=1 TO 5 - print a stored string.
    READ A
    PRINT CHR$(A)
NEXT X
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…