SparkFun Forums 

Where electronics enthusiasts find answers.

Have a good idea for a new product for SFE or Olimex? Let us know!
By scotty42
#3313
I spent a few years developing some real cheap resistance lab probes using the game port.
http://jnoodle.com
Kids would build their own probes and write their own programs in QBasic to read and calibrate the analog channels of the gameport. I had a $3 connector that adapted the game port to use a phone plug.
By next year all my older computers will be replaced with Dells that have no gameports!!!
So, any hints (software & hardware) on how can I cheaply interface a PC to a variable resistor using a USB or SERIAL port?
I'm commited to this project and will have an answer by this summer or sooner but I'd rather not reinvent the wheel :)
By Vraz
#3354
In terms of simplicity, my suggestion would be an inexpensive microcontroller with an analog to digital converter connected to the serial port. I suspect you could get away with pulling power from the serial port if you are careful about component selection. The following provides some information:

http://www.hut.fi/Misc/Electronics/circ ... power.html

In terms of microcontroller selection there are lots of choices. I like the Atmel AVRs myself. Atmel has several application notes on ADC interfacing. The following is the simplest. I will say that I have never done ADC with the Atmel myself so I don't have personal experience.

http://www.atmel.com/dyn/resources/prod ... OC0942.PDF

For my projects I typically use an existing microcontroller design to do my prototyping before building something dedicated. Though I have not used it, it looks like SFEs AVR-P20 would get you started and the ATTINY2313 is seems like a reasonable choice. (I have used and like the AVR-MT128 but the hardware is much less like something you would end up building.)
Last edited by Vraz on Fri Mar 11, 2005 3:55 pm, edited 1 time in total.
By Vraz
#3374
For one of my own projects I want to read an analog joystick from an AVR microcontroller so I did some experimenting this weekend. Turns out the following seems to work reasonably well:

+5v -- (150k variable resistor) -- 1k -- Microcontroller -- 0.1 uF -- GND

The code merely sets the microcontroller pin to output low for a perod of time, discharging the capacitor. Then, it sets it as an input with the internal pullup disabled. The code counts until the capacitor is charged and the pin reads high.

It appears that with the values listed above, the read time was in the range 0-1ms. I was using a 32khz clock and was getting counts in the 0-27 range. Obviously a faster clock would result more precision.

I had originally tried using the analog comparator, and while it seemed like it was going to work, it requires more components and many AVRs can only sample one input and I needed more for a dual axis joystick. I suspect I could get more precision that way, but I am not sure it is enough to matter.

Based on this experience, I would say that a joystick (probe) to serial adaptor would require only an 8-pin controller, a regulator (to self power) and the required resistor/capacitor for the analog sampling.