"quantizing" AD values


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2007
    Posts
    2

    Default "quantizing" AD values

    Hi,

    I'm looking for an easy way to take a 8 bit AD value read from a pot and have it divided into different "zones". This is to have an ordinary pot select different modes in the program and determine what is set by looking at the pot without the need for a display of some sort.

    like this:
    read AD converter to variable
    quantize to one of 16 values and put into new variable
    read quantized variable and determine what to do

    This is my first post here and I did search the archives and found a lot of good stuff but not quite the answer to my question...

    Regards

    /Daniel

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    hi,
    you could use few IF then and branch to different subroutine OR use SELECT CASE.

    Code:
    If (AdVal>0) and (AdVal<10) then GOSUB Routine1
    If (AdVal>10) and (AdVal<20) then GOSUB Routine2
    ' etc etc etc
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    LMAO! i don't know why, but it should have hit my mind first...
    Code:
    RoutineToJumpTo=AD_Value/16
    
    BRANCHL RoutineToJumpTo,[Routine0, Routine1, Routine2, Routine3.....Routine15]
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Feb 2007
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    Thanks!

    I'll try it out and post the results!

Similar Threads

  1. WRITECODE stores wrong 14-bit word values in FlashMEM
    By BobPigford in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 26th June 2009, 04:35
  2. Funny PULSIN values: what is going on???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th April 2008, 08:02
  3. 16F876 AD comparisation help needed
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 29th April 2008, 18:41
  4. 16F877A problem: "coupled" digital values
    By Lupo83 in forum General
    Replies: 16
    Last Post: - 4th December 2007, 12:46
  5. ADC problem
    By NacNud in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th December 2004, 02:27

Members who have read this thread : 1

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