Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 7th January 2007, 11:05 AM   #1
Default compare a value to a table

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
pouchito is offline  
Old 7th January 2007, 11:32 AM   #2
Default

How many values do you need?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 7th January 2007, 11:57 AM   #3
Default

i minimize it to 128 values
pouchito is offline  
Old 7th January 2007, 12:02 PM   #4
Default

Is it a linear progression?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 7th January 2007, 12:08 PM   #5
Default

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%
pouchito is offline  
Old 7th January 2007, 12:21 PM   #6
Default

If it's not linear you need a table then! - unless you can produce a formula that fits it?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 7th January 2007, 12:31 PM   #7
Default

how to do a table ?
pouchito is offline  
Old 7th January 2007, 02:35 PM   #8
Default

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
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk

Last edited by Nigel Goodwin; 7th January 2007 at 02:39 PM.
Nigel Goodwin is offline  
Old 7th January 2007, 02:50 PM   #9
Default

unfortunately , it does not support this
pouchito is offline  
Reply

Tags
compare, table

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
PIC: Table lookup across page boundary eblc1388 Micro Controllers 11 16th August 2005 03:43 PM
18F Lookup Table Cose Snippet [ASM] pittuck Micro Controllers 0 14th December 2004 08:40 AM
PIC 16F873 resetting by itself? nclark Micro Controllers 10 30th June 2004 10:30 PM
truth table vs lookup table alamy Micro Controllers 14 16th June 2004 08:48 PM
Lookup table for LCD and 7 segment display patricktran Micro Controllers 3 23rd April 2004 02:43 PM



All times are GMT. The time now is 04:32 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker