Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Interfacing Pots with a PC

Status
Not open for further replies.

Brian

New Member
I have 3 linear pots that I need to interface with a PC. When I turn a pot, my software should detect it and react accordingly based on the value returned. So far, I haven't had any luck. I'm using the 74HC14 Hex Schmitt Inverter to generate a pulse that my software can detect. The circuit I'm using is attached. I just can't get it to work. I'm using 100k pots and the unmarked caps are 10 uF. I am a novice at electronics, but trying to learn.

Any ideas (or alternative methods)? I have no joystick port and adding one is not a possibility, so rule that one out.

Thanks
 

Attachments

  • 5POT2PC.gif
    5POT2PC.gif
    12.1 KB · Views: 735
The circuit you have generates a square wave whose frequency depends on the pot. Windows is really bad at timing things like square wave inputs.

A better way would be to use a I2C AtoD(analog to digital) converter. You can then emulate the I2C bus with your parallel port. There should be lots of examples of how to do this on the web. One leg of the pot goes to +5 and the other goes to ground. The wiper goes to the AtoD input.

Another possibility would be to use rotary encoders. they are simple mechanical switches that output digital codes depending on their position.

Look at Digikey.com to buy components for either method.

Brent
 
Actually, rotary encoders were the first things I looked at, but could never get a clear answer about whether they could be connected directly to LPT1 or would require other hardware. So should I be able to connect it to the parallel port directly? I've done parallel programming in the past, so that's not a concern. I simply need a clear signal that tells the current position of the pot.

Also, this is being done on a linux system, not Windows.

Thanks for your help.
 
Brian said:
Actually, rotary encoders were the first things I looked at, but could never get a clear answer about whether they could be connected directly to LPT1 or would require other hardware. So should I be able to connect it to the parallel port directly? I've done parallel programming in the past, so that's not a concern. I simply need a clear signal that tells the current position of the pot.

Rotary encoders wouldn't work for you, there's no way to tell their current position - with a pot you can alter them when the computers not running, and find there position as soon as it is.

Also, this is being done on a linux system, not Windows.

Presumably Linux has the same timing problems as Windows?, basically as a multitasking system you don't usually have 100% control of what it's doing.

You could always use a PIC, something like a 16F876, feed the pots into three of it's A2D converter inputs and feed the results out as RS232. All the analogue parts will be done by the PIC, all the PC has to do is read the serial port and process the data.

I have a PIC tutorial that does this for two inputs, it would be trivial to do it for three!.
 
Linux has the same probelm as Windows as far as timing goes. There are Real-Time versions of Linux that are desinged to do timming sort of stuff but its probably more trouble that its worth. The real-Time version will give each task exactly 1ms (or some simmilar time) before running a new task. This guarantees the time between tasks which lets you time things acurately.

Nigel is right about some rotaty encoders. Some rotary encoders only give you relative position. This means that as you turn them they output a signal that tells you the change in position. If your program is always keeping track of the position then this is no porblem. You wont be able to see any changes when the computer is off. This might not be a problem though. For a voulume control you just have toe computer store the last position before it shuts down. You don't really need to worry about position changes when the computer is off. If position changes are important when the computer is off they do make rotaty encodes that output a binary number that tells you the absolute position of the knob. Both of these types can be connected to the parallel port with a couple of resistors.

Brent
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top