Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Storage of values to be looked up

Status
Not open for further replies.

BrianThor

Newbie level 4
Joined
Mar 13, 2017
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
Viginia
Activity points
50
I am working with the results of the A to D and I need to convert the voltage value to airspeed. I have the equations but most require floating point or some form of exponential math. I don't think the pic can do that. So my next option is to merely do a look up based on whatever value I read. At this point I am in over my head with the pic. I am using a Pic877a, not locked into it at this point. I am also using the PBP3 compiler and Pic basic. Any guidance would be wonderful.
The input is from a Motorola MPX series transducer. I am reading from 20 knots up to about 160. The voltage range is 0 up to about 1.20. I have vref set at 1.25.
Brian
 

Floating point math uses lots of memory but a 16F877A can do it and it has an ADC on-board as well. Please post the formula and I'll see if it will fit.

Look up tables are easy in a PIC, especially if there are less than about 254 entries per table because of the neat way you can use a variable to 'jump ahead' from the table start to an entry further along. If you use a PIC18F series processor they have instructions dedicated to accessing look up tables so it's even easier.

another Brian.
 

y = 0.0304x2 - 0.0994x + 166.22 From the excel work I have done,
X = KNOTS
Y = BINARY VALUE from about 145 to 960
The binary value is the result from the 10 bit conversion. The knots are values that I have pre calculated from the Motorola data sheet (MPX5010 Differential transducer)and some actual testing using a pressure input and measured against a prime standard. The knots are actually calculated from an equation dealing with PSi I can provide that as well if you are interested,
With respect to the limit of 254 , there are pre-calculated values from 10 knots up to 160 knots in 1 knot increments. I am targeting the one knot increment display. The math would preclude the "lookup " function.
Thanks so much
The other other Brian
 

You don't need necessarily to use float point notation. You could try to scale the whole equation to turn all values to an integer form, as follows:

Code:
y = ( 1/10,000 ) * ( 304*x^2 - 994*x + 1,662,200 )

And in order to save a lot of calculations due to the division opperation, you could even try approximate the factor to a power of two:

Code:
y = ( 1/8,192 ) * ( 249 *x^2 - 914*x + 1,361,674)

Replacing division by right shift opperation:

Code:
y = ( 249 *x^2 - 914*x + 1,361,674) >> 13

Considering that the above calculation would exceed the LONG magnitude, you could split the function within 2 manageable parts:

Code:
y = ( ( 249 *x^2 - 914*x) >> 13 ) + 166

In shorts, you have to make several attempts to fit the above calculation in your 8-bit microcontroller, perhaps succeeded, but pehaps leading you to the conclusion that it should be done just with float numbers, but you have to experiment in practice.
 

I ran the first code in my spreadsheet and it works well. However I do not understand the pic well enough to actually translate this into actual pic basic. I am sorry, I am learning just really slow!
 

Don't forget if you are using the PICs ADC, the values it produces are from 0 to 1023 so the formula needs adapting accordingly.

I'm pretty sure that formula will fit inside a 16F877A quite nicely and leave room to drive an LCD or LED display or serial interface. I program in C though, I've never used PBP3. I do have a copy of Oshonsoft's PIC BASIC but I find the language quite tedious to use.

Brian.
 

I am working on coming up to speed on the HI TEC C compiler so let me see what you have. I went with the basic because the tool was already here. I don't really have any loyalty to it.
Brian

With respect to the value range of the A2D , it will be fine for what I am doing. Right now I go from about 134 to 945
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top