Sonic Depth Meter code & Math problems 12F683


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Posts
    34


    Did you find this post helpful? Yes | No

    Default Re: Sonic Depth Meter code & Math problems 12F683

    Excuse my last reply...Henrik's number of 3020 gets me a new tap setting of 127 (perfect empty value) but when the tank is full (8" away from the sensor) the new tap reading is 42 (not 0 or 1). If I subtract 42, the full reading gets to 0 or 1, but my empty reading is also reduced...not letting me see the empty value of 127.


  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,627


    Did you find this post helpful? Yes | No

    Default Re: Sonic Depth Meter code & Math problems 12F683

    Hi,
    I guess I'm a bit confused by your somewhat "conflicting" numbers.
    In your original post you said that the input value ranged from 92 from to 466 but that a full scale output (127) should be reached with an input value of 364.
    So, I need to convert the 92 and 364 to 1% or 100% respectively and apply to 127 to get a new tap setting
    Think of the ** operator as kind of like multiplying by units of 1/65536. With an input value of 920 (given we stick with the times ten accumulated result) the output value would (should) be 920 * (3060/65536) = 42 and with an input value of 3640 the output value will be 3640 * (3060/65536) = 169. Subtract 42 from the two numbers and you'll get 0 and 127 respectively. Note that it's 3060, not 3020.

    Is that not what you wanted? Or is that what you wanted but it doesn't actually give you those results - which is possible as I haven't tested it here. Please clarify.

    The */ operator is similar to the ** operator but instead of units of 1/65536 it's units of 1/256. The // operator is modolus or remainder. If you do 123//10 you'll get 3 which is the "left over" from 123/10. They have been covered multiple times on the forum and they are covered in the manual.

    /Henrik.

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,175


    Did you find this post helpful? Yes | No

    Default Re: Sonic Depth Meter code & Math problems 12F683

    And if I may add, to prevent negative results, a limit test for the two sides of the range will guarantee the result will be 0-127.

    Ioannis

Similar Threads

  1. Replies: 0
    Last Post: - 27th March 2011, 21:10
  2. PIC 12f683 AD/PWM Problems:
    By surfer0815 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th December 2005, 17:48
  3. math problems (again)
    By lab310 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th November 2005, 23:43
  4. 12F683 Comparator Problems
    By morethanenuf in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 9th September 2005, 16:36
  5. math problems - large numbers
    By Tomasm in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th February 2004, 08:48

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