ad pot fastest response!


Closed Thread
Results 1 to 13 of 13
  1. #1
    Alaskanphoenix's Avatar
    Alaskanphoenix Guest

    Default ad pot fastest response!

    HI,
    i must poll 7 pots on a 16f88 and send a message only when the pot is used,i tried to write and read the adval on the on-chip eeprom but it is a very slow process and i need a fast response!
    Any idea or code example?

    Thank you very much

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Alaskanphoenix, Is there some reason you are writing the value to EEPROM?

    Dave Purola,
    N8NTA

  3. #3
    Alaskanphoenix's Avatar
    Alaskanphoenix Guest


    Did you find this post helpful? Yes | No

    Default

    My programming skill is very low, so i write in eeprom only for my laziness!
    But i thing it is not very good!

    Thanks

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


    Did you find this post helpful? Yes | No

    Default

    if you plan to do something usefull with those value when the power is removed and then power up.. i'll suggest to detect the when the power is remove and then save your value to the EEPROM.

    I know Melanie already posted something on that with the according circuit... can't find it as now.

    ow if you need for speed, don't use ADCIN but read/write and configure your PIC A/D yourself. not hard, code space saving and much faster. OK for assembly too but... accessing register in PBP could be really fast enough.
    Last edited by mister_e; - 14th April 2006 at 17:20.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    OK got the post of Melanie

    http://www.picbasic.co.uk/forum/show...52&postcount=3

    So now, depending of your current stuff, you may use Interrupts (on PORT change, INT0, INT..., Analog comparator...) or polling the PIN for a low level. quite simple to do.
    Steve

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

  6. #6
    Alaskanphoenix's Avatar
    Alaskanphoenix Guest


    Did you find this post helpful? Yes | No

    Default

    thank you Mister_e

    i already use the ad configuration registers,but the polling of the 7 pots isn't fast enough!I read instant interrupt post and I think i must use the A/D Converter Interrupt but i don't understand how to configure and use interrupts! Could you post an example or another way to poll the ad pins and send only the one is used?

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


    Did you find this post helpful? Yes | No

    Default

    A/D interrupt will be produce ONLY (as i remind) if a A/D conversion is finished.

    We really don't know what you'll do, what you need to do so we can just throw some idea now. Help us and describe exactly what you need to do. That way we will avoid to waste your and our time.
    Steve

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

  8. #8
    Alaskanphoenix's Avatar
    Alaskanphoenix Guest


    Did you find this post helpful? Yes | No

    Default

    You are right!
    I use a 16f88 to control 7 pots connected at the 7 ad pin and 3 bottons, one to calibrate the pots and the other to send midi control change messages.The pots, when rotated, must send midi continuos change message through the ausart.The ausart is configured comply with the midi protocol(31250 baud).this is an example of the midi message:

    define osc 20
    define HSER_TXSTA 20h ' enable TX register
    DEFINE HSER_RCSTA 90h ' enable RX register
    define HSER_BAUD 31250 ' midi baud rate

    for j = 0 to 6
    RESULT[J] = NEW[j]
    ADCON0 = %11000001 + (J*8) 'SET A/D rC + A/D = ON
    PAUSEus 10 'PAUSE 10uS FOR CHANNEL SETUP
    ADCON0.2 = 1 'SET GO/DONE-BIT + START CONVERSION
    PAUSEus 10 'PAUSE 10uS FOR CONVERSION
    RESULT[J] = ADRES
    RESULT[J] = RESULT[J] >> 1
    'read j, NEW[j]
    if RESULT[J] <> NEW[j] then
    'write j, NEW[j]
    hserout [$b0, j, RESULT[J]]
    endif

    next j
    goto loop

    RESULT is the value of the controller comply with midi,it must be 0-127
    $bo is the statusbyte, j the channel.
    The problem is that the program sends midi messages continuously,i want it sends midi only when the pot is rotated, sending all the values untill i stop to rotate!
    Also i want to limit the range of the pot with the calibrate button,when i first press the button i set the min value to 0, then i rotate the pot to set another value corresponding to 127 pressing the button.

    Thanks

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


    Did you find this post helpful? Yes | No

    Default

    sounds familiar with tons of recent MIDI controller i built here.

    OK let's try to do some rough explanation
    -------------------------------------------------------------------------------------------------------------------------
    1.i want it sends midi only when the pot is rotated, sending all the values untill i stop to rotate!

    what i suggest, is to store every POT valu in an array variable or different variable for each pot. You'll read ALL pot in a continuous loop then compare the result you have with the according variable or Array Index. Sure you'll have to insert a error percentage as the AD result may vary a little bit.

    Once you have a different value you send it on the MIDI line.

    -------------------------------------------------------------------------------------------------------------------------
    2. i want to limit the range of the pot with the calibrate button,when i first press the button i set the min value to 0, then i rotate the pot to set another value corresponding to 127 pressing the button.

    Perfect situation to introduce some POWER-UP check up. To make things clear figure the following. When you power up your system, you check if one (or more) specific push button are press, if so, you jump to the calibration routine
    In the calibration routine, a LCD or XYZ LED will prompt for a start point on POTx, you place the pot to the according position then you press on a button. Once it's done same thing apply to the end point. Same for all POTs. Once it's done, it's up to you what you'll do as calibration confirmation.

    Calibration must be store in a external EEPROM (or internal if available). When you boot your system, it just read the calibation and store them in some variables.

    Hope this help
    Steve

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

  10. #10
    Alaskanphoenix's Avatar
    Alaskanphoenix Guest


    Did you find this post helpful? Yes | No

    Default

    Thank you mister_e!
    It's time to experiment!

    I'll try some of your suggestions

    Bye

  11. #11
    moyejw's Avatar
    moyejw Guest


    Did you find this post helpful? Yes | No

    Default

    Alaskanphoenix, I'm not familiar with pbp syntax but try something like this IF...THEN statement in place of yours--

    IF RESULT[J] = ADRES THEN NoCHANGE
    CHANGE RESULT[J] = ADRES
    /calculate mididata :see below
    /send mididata
    NoCHANGE NEXT J

    To convert your AD input to proportional value between 0 and 127---
    /this is simiiar to Farenheit to Centigrade temp conversion

    You need these values from when you calibrate your pots. JCALLOW, JCALHI
    are values received @ CALIBRATE BUTTON1. BUTTON2

    JMIDIVALUE=127(ADRES - JCALLOW)/(JCALHI - JCALLOW)

  12. #12
    moyejw's Avatar
    moyejw Guest


    Did you find this post helpful? Yes | No

    Default

    I'm not familiar with pbp syntax but try something like this IF...THEN statement in place of yours--

    IF RESULT[J] = ADRES THEN NoCHANGE
    CHANGE RESULT[J] = ADRES
    /calculate mididata :see below
    /send mididata
    NoCHANGE NEXT J

    To convert your AD input to proportional value between 0 and 127---
    /this is simiiar to Farenheit to Centigrade temp conversion

    You need these values from when you calibrate your pots. JCALLOW, JCALHI
    are values received @ CALIBRATE BUTTON1. BUTTON2

    JMIDIVALUE=127(ADRES - JCALLOW)/(JCALHI - JCALLOW)

  13. #13
    blainecf's Avatar
    blainecf Guest


    Did you find this post helpful? Yes | No

    Cool One more method (unless you're an octopus):

    If you make the assumption that only one pot at a time is changing (unless you're an octopus and have 8 hands on 7 pots), you could do this:

    [Pseudocode]

    1. read one pot
    2. compare to previous reading (see above threads)
    3. if a pot changes
    3a. Act on the change
    3b. (now for the assumption) Instead of advancing on to the next pot, decrement your pot pointer so that the same pot will be read again (which will cancel out step #4, below)
    4. increment your pot pointer
    5. loop to #1

    Why? If you assume one hand on a pot, once you start changing, probability suggests that you'll continue changing that pot. Assuming that that one pot is still changing, and therefore, re-reading, you'll save time NOT READING 6 other pots that, in all likelihood, are not changing!

    Regards,

Similar Threads

  1. Using the Pot command.
    By timseven in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 17th August 2009, 20:23
  2. A/D, Pot, Input, A,B So lost now....
    By Helmutt in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 9th March 2008, 22:23
  3. "quantizing" AD values
    By dar303 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 21st February 2007, 21:49
  4. Replies: 4
    Last Post: - 24th January 2007, 22:20
  5. pot controlled pwm -- help
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 29th January 2006, 12:29

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