Thanks folks. I think Dwaynes answer is the way to go. I will try it and let you know how I get on.
Thanks folks. I think Dwaynes answer is the way to go. I will try it and let you know how I get on.
Keep your motor running
The way that works is the following.
Lets say we are checking resisters, and need to know if they are within a certain tolerance....
say within 5 pecent....
Your known resistance is 1000 OHMS, and 5 percent is 50 ohms
The ABS function works as the following:
Lets say TEST is 1500 homes
ABS(test-1000)=500
Thus If (test-1000)<50 then output good resistor! (but its not less than 50)
Lets say TEST=900
ABS(test-900)=100 (if the value is negative, it changes to postive)
Thus If (test-1000)<50 then output good resistor! (but its not less than 50)
Lets say TEST = 970
ABS(test-1000)=30
Thus If (test-1000)<50 then output good resistor! (Wonderful!! good part)
Dwayne
Ability to Fly:
Hurling yourself towards the ground, and missing.
Engineers that Contribute to flying:
Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute
Pilots that are Flying:
Those who know their limitations, and respect the green side of the grass...
I had never thought about the ABS function before. Many thanks, it appears to work fine.
Keep your motor running
Well, I thought it worked fine. Now having added actual code to my prgramme I can't get it to compile. It gives an error "bad expression or missing then" for the line with ABS in it:
For word_no=0 to res_max
if (abs(adval-id_res[word_no]))<=((id_res[word_no]*res_tol)/100) then
answer=ok
goto endsub
endif
next word_no
Am I doing something stupid?
Edit: It's alright. I just forgot how to do arrays!!!! Seems OK now.
Last edited by moby; - 5th April 2005 at 11:51.
Keep your motor running
Hello Moby,
Moby>>if (abs(adval-id_res[word_no]))<=((id_res[word_no]*res_tol)/100) then
I believe you have 1 too many parentheses <sp> on your if statement...
lets divid it up a little ok??
yours:
if (abs(adval-id_res[word_no]))<=((id_res[word_no]*res_tol)/100) then
Divided up:
if (abs (adval-id_res[word_no]) ) <=((id_res[word_no]*res_tol)/100) then
if you notice, your ending parenthises <sp> end before your less than or equal sign....
It probably should look like this:
if(XXXXX<=YYYY) then zzzz
if ( abs(adval-id_res[word_no]) <=((id_res[word_no]*res_tol)/100) ) then
Another format is
if xxxxx<=yyyyy then zzzz
if abs(adval-id_res[word_no]) <=((id_res[word_no]*res_tol)/100) then
Dwayne
Ability to Fly:
Hurling yourself towards the ground, and missing.
Engineers that Contribute to flying:
Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute
Pilots that are Flying:
Those who know their limitations, and respect the green side of the grass...
Yes, I think that was another problem. It does seem to be working now.
Thanks.
Keep your motor running
Bookmarks