Shop OBEX P1 Docs P2 Docs Learn Events
How to make an ADC out of components? — Parallax Forums

How to make an ADC out of components?

MicrocontrolledMicrocontrolled Posts: 2,461
edited 2011-08-17 20:28 in Propeller 1
Hi,

I recently received a precision hall effect joystick that I'm wanting to use for the second version of my Stingray robot remote. The problem is: I have no ADC chips and I want to get this working ASAP. Does someone know of a schematic or code to read the voltage from the joystick without using an ADC? It is a 5V joystick, so I'll be using a resistor on each line.

Thanks,
Microcontrolled

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-08-16 16:37
    An "ADC" out of "components".
    So, the joystick outputs are a variable/varying voltage?

    If you're really game to mess around a little... you could try "voltage to frequency -- V-to-F".

    If you have some 555's (or, even better, 7555's) then you can make VCOs (voltage controlled oscillator).

    The VCO from/in a 4046 would be even better, but you probably don't have any of those.

    http://ecelab.com/circuit-vco-555.htm

    http://www.555-timer-circuits.com/555-vco.html

    http://www.robthefiddler.com/electronics-audio-diy/circuit-experiments/555-as-vco/
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-08-16 16:53
    Checkout the ADC AppNote on the ParallaxSemi website. The prop can do this with 2 pins and a few resistors and 2 caps. You will need to divide the input. Is is all spelt out in the app note.
  • RaymanRayman Posts: 14,876
    edited 2011-08-16 17:55
  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2011-08-16 18:43
    @PJ Allen: Thanks for the info! I would be willing to try the various options, and I have a couple of 555's and a 4046 so I'll start experimenting with those, though with 3 outputs I'm guessing I would need more than one 4046. I imagine that Voltage to Frequency would be an accurate method of reading the voltage output, which is what I am going for. I'll check out the links you gave me and the datasheet for the 4046.

    @Cluso99 & Rayman: This is what I was looking for! Thanks! I'll give this a shot tonight since I have all of the components on hand.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-16 19:37
    Micro,

    Placement of the feedback resistor and caps right next to the Propeller pins is critical for a sigma-delta converter to work well. Putting them on a solderless breadboard, for example, will not work. 'Just a heads up.

    -Phil
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-08-16 21:28
    As you start experimenting. How about ordering some MCP3208-ADC chips in the meanwhile?

    best regards

    Stefan
  • Nick McClickNick McClick Posts: 1,003
    edited 2011-08-16 22:19
    Sigma Delta is the right approach. I've made the circuit on a breadboard and it 'worked', but not as well as a direct connection. If you're feeling adventurous, you can build an ADC with an OpAmp - there are a few circuit examples here.
  • Jorge PJorge P Posts: 385
    edited 2011-08-17 04:03
    As Nick McClick said, I'd use an 8 pin dip socket and solder the circuit into that. You might be able to fit two in it by sharing power and ground if possible with this circuit. I haven't done that with this particular circuit, but I've done it with several others.

    Here are a couple of pics with the circuit from http://www.rayslogic.com/propeller/Programming/ADC.htm

    I used some random caps and resisters, just use the values you need...

    100_0311.jpg
    100_0312.jpg
    Click to zoom

    PINOUT
    1 = Prop output pin
    2 = Prop input pin
    3 = Input signal
    4 = VSS
    5 = NC
    6 = NC
    7 = NC
    8 = VDD

    I didn't solder the connections since I want to use these components for other purposes...
    498 x 667 - 186K
    564 x 457 - 152K
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-08-17 05:33
    I built my adc circuit on a pin header socket and plugged that into a prop pin header on my TriBlade. The connections are close like on the Parallax protoboards. It worked fine reading a touch screen display, but I did not check the accuracy, just the concept.
  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2011-08-17 08:47
    Thanks for all the help!!!

    OK, so I've done the simple setup and soldered it directly to the board that I am working with very close to the pins. However, for some reason, I cannot get it to work. I run the ADC program included with the AppNotes and the value only changes when the joystick goes up, not when it goes down (I have not yet tested the other axes). I connected my Propscope to it and got the following, the flat part being when it is pushed up.
    OscopeScreenshot.jpg

    This is strange, because when I connect the Joystick output directly to the Propscope I get a nice curve when I move it up and down.

    Can someone tell me what I am missing here? I followed the schematic on Rayman's site exactly, and built 2 circuits with the same results.

    Thanks,
    Microcontrolled
    1024 x 550 - 90K
  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2011-08-17 16:26
    OK, I've fixed the problem and I have the ADC's working correctly. Thanks for all your help!
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-08-17 18:35
    microcontrolled: I am curious. Firstly what was the problem? Secondly, how accurate was it?

    Here is an alternative suggestion for joystick control. The wii nunchuck and the wii classic controller both have joysticks and other buttons. Both are I2C. Both have cheap clones on eBay. The nunchuck also includes an accelerometer. The wii motion plus has a gyro and can be daisy-chained to the nunchuck or classic controller. Food for thought!
  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2011-08-17 19:05
    @Cluso99: I don't know how it works, I don't know what was wrong, but I know what I did to fix it. Maybe one of the more analog-experienced people here can answer those for me. The circuit worked fine once I removed both of the capacitors. The O'scope stopped picking up noise, and the readings are very accurate. I have no idea what made this happen, since the capacitors are supposed to balance it out, but it did. It is now accurate to the slightest touch, and will be great for variable speed control. I'll post pics when I have time (probably tomorrow. :( )

    To your alternate suggestion: I've eyed those both before! I'm thinking about getting a cheap clone of the motion plus or the Nunchuck off eBay just for the purpose of using the accelerometer/gyro. I've used them before (but had to return them!) and they are very easy to work with.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-08-17 20:28
    I have a couple of generic Wii Motes and Nunchucks from Woot. I couldn't get the generic Nunchuck to work with the Propeller. (I use a "real" Nunchuck a lot with my projects.)

    I've also had a bad experience with a generic PlayStation 2 controller. The Prop could communicate with it but it only had 5-bits of resolution instead of the normal 8-bits.

    I now avoid generic controllers.

    Duane
Sign In or Register to comment.