+or-


Closed Thread
Results 1 to 13 of 13

Thread: +or-

Hybrid View

  1. #1
    Join Date
    Jan 2004
    Location
    Exeter, England
    Posts
    25


    Did you find this post helpful? Yes | No

    Default

    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

  2. #2
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    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...

  3. #3
    Join Date
    Jan 2004
    Location
    Exeter, England
    Posts
    25


    Did you find this post helpful? Yes | No

    Default

    I had never thought about the ABS function before. Many thanks, it appears to work fine.
    Keep your motor running

  4. #4
    Join Date
    Jan 2004
    Location
    Exeter, England
    Posts
    25


    Did you find this post helpful? Yes | No

    Default

    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

  5. #5
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    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...

  6. #6
    Join Date
    Jan 2004
    Location
    Exeter, England
    Posts
    25


    Did you find this post helpful? Yes | No

    Default

    Yes, I think that was another problem. It does seem to be working now.
    Thanks.
    Keep your motor running

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts