Re: [buildcheapeeg] gameport

From: Joerg Hansmann (info_at_jhansmann.de)
Date: 2001-05-20 14:12:11


Hi,

----- Original Message -----
From: <jiva_at_humboldt1.com>
To: <buildcheapeeg_at_yahoogroups.com>
Sent: Saturday, May 19, 2001 6:46 PM
Subject: [buildcheapeeg] Joerg: gameport

> >
> > In some way this is less performance than using the PC-gameport as
> an ADC.
> > (I have done this some time ago, and it worked quite well under DOS)
> >
>
> I noticed your game port design but didn't look at it.
> (I've reinstalled Eagle with same lack of ability to open those
> files, not sure what I'm doing wrong.)

a)Try to reinstall your eagle4.01 . Before that look for all TMP-directories,
Windows might use and clear their contents.

Look into your autoexec.bat for lines like this, to identify these directories:

set TEMP=C:\TEMP
set TMP=C:\TEMP

b)The installation file you downloaded from www.cadsoft.de could be damaged.
Try to reload it.

c)If this does not solve the problems, try to ask the email-support at
cadsoft.

> I've had terrible experience with stability/repeatability when
> I've played with the game port. How did you overcome that?

I have made good experience with the gameport on 3 different machines.
So it might be, that this was by pure chance.

On the other hand I have detected several reasons for bad behaviour
of the gamport and have eliminated them uncompromisingly :

1.) Retriggering the gamport timer before the R*C timeconstant is over will
produce a random number on next gameport readout.
This condition should be strictly avoided by
a) waiting in the gamport-polling-routine until all timers are ready
b) limiting the highest R-value to 100kOhms

2.) Unshielded cables, line noise:
Each of the 4 gamport timers charge a capacitor through a variable resistor (Joystick)
until a fixed voltage theshold is met.
Near to this theshold very small interference voltages can produce premature reaching
of the threshold or delay it and produce scattering of values.

3.) To get high readouts and bit-resolutions I have written my own sampling routine
instead of using e.g. BIOS or Windows routines.

2 channel gameport routine for Turbo C 1.00 under DOS:
/*gameport sampling. Time requirement is about 1ms or less , dependent on Joystick position */
word c,i,li;
int ch1,ch2;
word maxcount=1000; /* estimated max count for timeout detection, CPU dependent, should be calibrated with some sort of benchmark
*/

int far fixed_get_xy(int *x,int *y)
{
outp(0x201,0); /* generate trigger pulse for gameport timer */
c=0;
*x=0;
*y=0;
li=0;
repeat /* polling loop */
i=(inp(0x201)&0x03)^0x03;
if(i!=li){
switch(i^li){
case 1:*x=c;break;
case 2:*y=c;break;
case 3:*x=*y=c;break;
}
li=i;
}
c++;
until( c==maxcount); /* wait until x and y channel timers are ready or timeout*/

if(c==maxcount){ /* limit values, if timeout has been detected*/
if(*x==0) *x=maxcount;
if(*y==0) *y=maxcount;
return 0;
}
else{
return 0; // all ok
}
}

#################################

Regards,

Joerg



This archive was generated by hypermail 2.1.4 : 2002-07-27 12:28:30 BST