??? 07/14/04 15:08 Read: times |
#74228 - RE: MATH ROUTINE Responding to: ???'s previous message |
The magic with most embedded systems is that the inputs normally fall within a known range. In your application of measuring the power factor this is also the case. Your measurement is integer (ie phase difference in microseconds) therefore you can use this value to look up a table of solutions that has already been calculated. I normally write a program in BASIC to create the solutions and write them to a file. I then import the file to my code. Some time ago I had to control a aircraft direction finder instrument. This needed a sin and cos voltage to have the pointer point to a direction (0..360degrees). for the sin table I calculated the first 90 degrees worth and since my digital to analog converter was 8 bits (7bits with sign) the output of the table was from 0 to 127(+1). And since 0-360 doesn't work out binarily, I used 0 - 511 to represent 0-360 degrees. So my sin table was 128 bytes and a little bit of code inverted the input value if it was in the quadrant 2 or 4 or made the result negative if the input was in quadrant 3 or 4. For cos it was a matter of adding 64 to the input value to move the input value 90 degrees. So with a table and a little bit of code I did some trig and no floating point was involved and it did it very fast. I'm sure with a little thought you will be able to come to a similar solution to your problem. |
Topic | Author | Date |
MATH ROUTINE | 01/01/70 00:00 | |
RE: MATH ROUTINE | 01/01/70 00:00 | |
RE: MATH ROUTINE | 01/01/70 00:00 | |
RE: MATH ROUTINE | 01/01/70 00:00 | |
RE: -10 (for shouting) | 01/01/70 00:00 | |
RE: MATH ROUTINE | 01/01/70 00:00 | |
Not Floating Point! | 01/01/70 00:00 | |
RE: MATH ROUTINE | 01/01/70 00:00 | |
RE: MATH ROUTINE | 01/01/70 00:00 | |
RE: MATH ROUTINE | 01/01/70 00:00 | |
RE: Generating the Table - Excel | 01/01/70 00:00 | |
RE: Generating the Table - Excel | 01/01/70 00:00 | |
RE: Generating the Table - Excel | 01/01/70 00:00 | |
RE: Generating the Table - Excel | 01/01/70 00:00 | |
Meanwhile, back at the plot... | 01/01/70 00:00 | |
RE: Meanwhile, back at the plot...![]() | 01/01/70 00:00 |