Jump to content
  • Advertisement
Sign in to follow this  
Mari_p

problems with analog joystick

This topic is 5415 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I built my own analog joystick using a 100K linear potentiometer. In my 3d application, I get data from it by DirectInput. It works, but the value received for a specific position is not always constant (it oscillates). Please, does anyone know why this happens and how to solve the problem? I wrote a filter, but this solution is good only in high fps. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
hey, that's awesome! Do you have pictures of it?

Anyway, I don't know much about hardware, but can't you make the filter in hardware? I remember reading long time ago that a lo-pass was really easy to make with a pot.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
specs of your pot?

Share this post


Link to post
Share on other sites
Sorry, I do not know.. it will be based on the signal I assume? Like I say, I don't know much about hardware. Although I do remember using a 10k (log) pot once for sound.

-j

Share this post


Link to post
Share on other sites
If you could draw a crude schematic or the like it would be very helpful in diagnosing the problem. Also, how large is the transient signal compared to the data signal (something like signal to noise ratio I guess).

Is the joystick connected via USB, a seriel port, or maybe the 'joystick port' on a sound card?

More information about the hardware and the problem would be most helpful in diagnosing the problem.

Share this post


Link to post
Share on other sites
Thanks all.

Well, I just connected the potentiometer directly on the joystick port. I'm testing the application in a old computer, so that port is from a sound card (...is this bad?...)
Basically, this sound card has a monostable CI 558, that emit a sinal where the number of pulses is proportional to the potentiometer resistance value.
Suppose, for example, that the values sent by potentiometer are in the interval [0,100]. If I select a specific position, correspondents to value 60, it give me something oscillating into [55,65].

Some months ago I played with a XBOX and I remember that its analog joystick worked very fine. It was very precise and smooth.



Share this post


Link to post
Share on other sites
A variation of 5-10% is normal for a simple resistor connected directly to a game port of a cheap/old sound card. It's the sum of transition noise from the connecting part to the resisting part inside the potentiometer and the noise created at the input of the A/D convert of the sound card.
Good Joysticks do use use some compensation with OPA's for the first part of the effect. The second part creating noise you might only get rid off by using a better sound card/game card with less noise at the input, I guess.
Well, that's what I know so far about this...

Well, you might try to compensate a little by attaching a condensator to the signal against ground. This might flatten noise a little. But only use small values, or the signal will not follow your joystick anymore. And keep in mind that this will create a non linear effect of compensation to your signal.

Hope this gives you some hints for your joystick project ;o)

Share this post


Link to post
Share on other sites
i've also made similar thing several years ago(heck, it was teh funnay device, real joystick!).
Potentiometr must be linear,IIRC.
There's several sources of noise:

1: Potentiometr. If it's bad, after some use conductive line earses a bit and it causes problems. There's noise when you move thing.
I repaired my potentiometr when it's resistance became very big, using graphite pencil :). (it's needed to first draw line on potentiometr then wipe unnecessary graphite using piece of paper, and you also need to measure resistance while cleaning)

2: 50 or 60 Hz signal that comes from ac line. You can try to use shielded cable to connect your joystick.

3: power noise in computer. Unlikely to cause serious problems.

4: Inperfectness in PC's timing. Probably it's a biggest problem today.

How position measurement works with good-old joysticks:
There's no oscillator(!). At least i never had a port with oscillator.

Computer writes some value to port, and it charges some capacitor. Then computer reads from port in the loop, waiting till capacitor discharges through your resistor(potentiometr). That is, in old days it was done like
WriteToPort();//charge capacitor
int n=0;
//find how long it takes for capacitor to be discharged
while(n<BigValue){if(ReadFromPort()&somemask ==0)break; n++; }
n is proportional to position of joystick. Joystick is re-calibrated at installation.

So, if windows joystick drivers is done like in old days, there will be noise, because speed of port reading on modern boards fluctuates ALOT. The best would be to use RDTSC for timing, and after measurements use

if(NewDischageTime-PreviousDischargeTime <= TimeOfReadFromPortCommand)NewDischageTime=PreviousDischargeTime;else PreviousDischargeTime=NewDischageTime;
so NewDischageTime hopefully will not jump at every reading.

And , i think, noise of transistors is smallest thing there, and alot below detectable level.

Note that for some reason you have both ground and +5 in joystick, be careful not to connect 'em, or you'll fry something(i once fried cable. Really, PSU pulls >20A at +5, it completely fried thin cable in no-time [grin] Good that it was only cable and not a lines on card or on mobo...)(anyway,it was 286 12Mz....)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!