Shop OBEX P1 Docs P2 Docs Learn Events
Analogin, Comp, or AD Convertor — Parallax Forums

Analogin, Comp, or AD Convertor

datacpsdatacps Posts: 139
edited 2007-07-05 22:28 in General Discussion
rolleyes.gif·· I am using analogin but I am still having trouble setting it up.

·· Should I use the SX comparator or an AD convertor maybe even an encoder?
I am going to scale down the freqout max to lets say from 500hz to
5000 Khz. I was wondering what would be the best way to go on this.
I need it to be pretty accurate and I want to be able to dail any number with in the specified range. Thanks

Comments

  • BeanBean Posts: 8,129
    edited 2007-07-05 11:53
    An encoder would probably be the best choice. It will let you dial in a specific number with no jitter.
    If you can use it just a pair of "UP" "DOWN" buttons would be the easiest to interface.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • datacpsdatacps Posts: 139
    edited 2007-07-05 12:07
    Bean do you have a suggestion on which encoder I can use . I planned on using two momentary push buttons on the design. Can I use those? I can also add a third button to scale the frequencies. Maybe I can·write the code so everytime I pressed the button·I go to a different scale setting. Like·500 to 5000·the first time I press it. Then 5000hz to 10000hz·the second time and then back to 500 to 5000. Can I make it that way. Also can I use two encoders one for Fine the other for coarse.··Let me know if this is possible and what encoders can·I use..

    Thanks
  • BeanBean Posts: 8,129
    edited 2007-07-05 12:58
    Using JUST an UP and DOWN button will make the code much easier to write. You can make the buttons change the value faster the longer they are held down. Something like:

    Push button - Moves 1 Hz
    If button is held for 0.5 seconds, then start moving 1Hz every 0.1 seconds
    If button is held for 2 seconds, then start moving 10Hz every 0.1 seconds
    If button is held for 4 seconds, then start moving 100Hz every 0.1 seconds

    A coarse and fine encoder would probably make it easier for the user to select a frequency. But encoder are not cheap.

    A quick search on Digikey turned up part # P10860-ND,·24 pulses per revolution and only $1.52 !

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • datacpsdatacps Posts: 139
    edited 2007-07-05 21:53
    I see what you are saying Bean. I think I will try the buttons to see if I can dial in a number easily.
    I am not too concerned about the encoders for $1.52. I will use two as long as the unit is easy to operate and dial in the desired freqout is what I am after. I am going to overnight the encoders and test them.
    Bean it looks like the encoder has a max of 24 pulses per 360 degrees. So if my range is from 500hz to 20Khz I have to divide the 360 by 20 which equals 15. SO every 15 degrees or every 1.5 pulses is equal to 1khz. Then my other encoder I can scale to make it easy to dail in increments of 1hz at a time. . I guess now I have to find info on how to scale an encoder. I remember scaling the POT on the BS2 but the SX is a lot diff. Thanks for all your help now I will hunt down the information so I can finish my project..
  • BeanBean Posts: 8,129
    edited 2007-07-05 22:03
    You can do the same thing with the encoder as you would with the buttons. When you turn the encoder really fast you make it adjust the value more per step. That makes it easy to get in the right range. Then you turn the encoder slowly to move 1 value per step. Again it takes programming effort to get this effect. And to get it right.

    I just checked my spare parts and I two of these from digikey ECW1JB24BC0024-ND . They are only $3.46 each and they are nice. I would assume they would work just about the same way as the other ones I mentioned before.

    I have some code to read they encoders that I wrote for a client, but it uses a periodic interrupt which you cannot use since you are using the interrupt to generate the frequency. But they aren't too hard to read, I think Jon Williams has some code posted that does it. Try a search.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-07-05 22:28
    If you are going to use two encoders you might consider using the first encoder to adjust the frequency in steps of 100Hz. 20KHz / 100Hz = 200 intervals. (200 intervals) / (24 intervals/revolution) = 8.333 revolutions. So you would need to rotate the first encoder eight and a third revolutions to cover your coarse frequency range.

    The second encoder can be used to adjust the frequency in steps of 1Hz yielding 100 intervals between values reachable by the first encoder. (100 intervals) / (24 intervals/revolution) = 4.167 revolutions. So you would need to rotate the second encoder four and a sixth revolutions to cover your fine frequency range.

    This might be more straightforward to program if you do not mind using two encoders.

    - Sparks
Sign In or Register to comment.