How to adjust values to a new range


+ Reply to Thread
Results 1 to 27 of 27

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default Re: How to adjust values to a new range

    Quote Originally Posted by HenrikOlsson View Post
    This has been covered many many times on the forum so why not one more time...
    You've explained it, using my own problem as example, and I still don't completely understand it. My eyes sort of gloss over when I've read these explanations on the forum. And it's not getting better as I get older.


    I really do appreciate you holding my hand while you pound this into my skull.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

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


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: How to adjust values to a new range

    Allright...

    [1] I believe you're with me for the 135/1023=0.132 part, right?

    [2] IF the description for the */ operator WOULD have said "....resulting in an automatic division by 1000" then I think you'd see that the solultion WOULD be OutputValue = 100 + (InputValue */ 132), because 0.132*1000=132, correct?

    [3] But since the */ operator "....resulting in an automatic division by 256" we must multiply 0.132 by 256 instead of 1000. Hence the value 34.

    Makes sense? If not, which step?

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default Re: How to adjust values to a new range

    I follow. I just could not have thought of this by myself.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: How to adjust values to a new range

    Or maybe use a formula

    X=135*256/1023

    where X is the number you wan to use in the */

    135 is the max scale value

    1023 is the max ADC value

    Ioannis

  5. #5


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: How to adjust values to a new range

    error posting
    Last edited by amgen; - 19th August 2024 at 19:29.

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default Re: How to adjust values to a new range

    Quote Originally Posted by amgen View Post
    not to beat this up too much........
    A horse is never too dead on the web.


    Quote Originally Posted by amgen View Post
    ... if you only need 135 output values, and you want to scale pot for 0 to 100%..... just use the top 8 bit from a/d and this trend line function that excel gave.
    I can't believe I was playing with excel all that time and never thought of using the chart feature.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  7. #7
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default Re: How to adjust values to a new range

    My ADC is only 10 bits, not 16.

    So I just divide 10bits by 4 to reduce from 1023 down to 255, then slap it through your formula.

    I haven't done any math yet (just thinking, while I work on my encoder logic), but this probably equates to what Ioannis is suggesting.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  8. #8


    Did you find this post helpful? Yes | No

    Default Re: How to adjust values to a new range

    deleted because I realized the formula excel created was not correct...... me bad

Similar Threads

  1. Simple way to adjust interrupt speed in DT_INTS-14 ?
    By CuriousOne in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th January 2015, 12:01
  2. Use a pot to adjust COUNT value
    By Sam in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 20th November 2011, 15:56
  3. Select Case range of values
    By kenif in forum PBP Wish List
    Replies: 3
    Last Post: - 25th June 2009, 13:27
  4. Replies: 9
    Last Post: - 31st July 2008, 08:56
  5. If Then Range
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 29th June 2005, 14:33

Members who have read this thread : 12

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