OCCRA
Go to Post the rookies come up with amazing stuff (I have seen it happening), they amaze me at times. - Arefin Bari [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Events   CD-Media   CD-Spy   FRC-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 10-27-2002, 08:54 PM
Ian W. Ian W. is offline
College? What?
no team (Gompei and the Herd)
Team Role: College Student
 
Join Date: Jan 2002
Rookie Year: 2002
Location: Worcester, MA | Smithtown, NY
Posts: 1,464
Ian W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to all
Send a message via AIM to Ian W.
Programming for a Gameport

Yet another crazy idea from team 810. this time, instead of the serial port, we need help with the gameport. my friend found out how to hook up two joy sticks to the gameport, and has some crazy idea for a program. i can't say what it is, for that will ruin the surprise.

basically, what i need is a simple way (prefereablly just a console app) that can read the gameport. something similar to the serial white paper (the author's name escapes me at the moment) would help a lot. we do know how to make it work if we were to use two serial ports, but we're not sure if that's possible (i think it is, but i can't be sure).

so, if anyone has any information on how to use the gameport in a C++ program, or how to set up a joystick on a serial port (i'm not sure how you would read back analog values), i'd be very thankful.
__________________
AIM --> Woloi
Email --> ian@woloschin.com
  #2   Spotlight this post!  
Unread 10-28-2002, 12:46 AM
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
OK, you've got a few options. Let me know which one appeals to you and I'll write another paper (the serial one was mine).

Option 1: DirectX. Advantages: Industry standard. Can support more axes/buttons than the next method. Disadvantages: a lot of overhead for setting up DirectInput, only works under Windows

Option 2: Assembly!!!!!! Yup, you can do it straight from assembly. Advantages: none of the DirectX stuff, can be used w/o windows. Disadvantages: it's assembly. 'nuf said.

In all honesty, assembly isn't really that bad, especially if you have someone tell you exactly what to write in your code--it's the method I'd recomend for a simple project like this.

However, as I said before DirectInput is the industry standard nowadays, so if you want to learn it for the pure sake of learning some introductory DirectX, I'd be happy to write a paper on that too.

As for doing it through a serial port, it just isn't going to happen. A joystick uses a different pin for each axis/set of buttons, but a serial port has only one pin for data.

My Linux box just died a slow, painful death with lots of pretty colors, so I'm off to remedy that (and maybe sleep?), but let me know which you'd prefer.

--Rob

(I could have the assembly one done in about 20 mins. The DirectInput might take a few days)
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #3   Spotlight this post!  
Unread 10-28-2002, 07:10 PM
Ian W. Ian W. is offline
College? What?
no team (Gompei and the Herd)
Team Role: College Student
 
Join Date: Jan 2002
Rookie Year: 2002
Location: Worcester, MA | Smithtown, NY
Posts: 1,464
Ian W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to all
Send a message via AIM to Ian W.
assembly or directx?

i was kind of hoping there'd be a nice happy thing like the serial port (the readfile thing). i finally understand that now .

i'm mostly a C++/PBASIC programmer, but i guess i could learn either assembly or directx (isn't that a library extension onto C++ or something like that?). one thing though, i believe like the dashboard program i made, it will be creating a text file that is read into a flash program. that means there needs to be enough resources to let the flash program work (which there should be either way if we use a good computer, but i believe we'll be using this at school, and well, the school computers pretty much suck ). if you can write something up in assembly in 20 minutes, then it never hurts to try. if you can find the directx stuff it'd be interesting to try, but don't kill yourself trying to do it. and thanks for the help .
__________________
AIM --> Woloi
Email --> ian@woloschin.com
  #4   Spotlight this post!  
Unread 10-28-2002, 08:26 PM
mtaman02's Avatar
mtaman02 mtaman02 is offline
FIRST's Spare, Queuer & Tech guy =)
AKA: Mike M. / Mouse =)
no team (FRC Volunteer)
Team Role: Alumni
 
Join Date: Jun 2002
Rookie Year: 2001
Location: Staten Island, NYC
Posts: 1,508
mtaman02 has a brilliant futuremtaman02 has a brilliant futuremtaman02 has a brilliant futuremtaman02 has a brilliant futuremtaman02 has a brilliant futuremtaman02 has a brilliant futuremtaman02 has a brilliant futuremtaman02 has a brilliant futuremtaman02 has a brilliant futuremtaman02 has a brilliant futuremtaman02 has a brilliant future
Send a message via AIM to mtaman02 Send a message via Yahoo to mtaman02
i second that motion that school computers suck. Board of Ed in NYC stinks all together and needs to start chippin and gettin us robotics schools something decent to work with other then the old 486's / penitium 100's and pros etc. how does a 486 make it in the year 2002 must create thread on this. cya
__________________
Past FIRST Robotics Events that I proudly volunteered at:
FLL: NY State Competition '03
FRC: NYC Remote Kickoff '04 & NYC Regionals '04-'07 ,'10-'13 & NJ Regionals '06-'10, Finger Lakes Regional '09 & SBPLI Regional '08-'13 and the World Championship in '05 (Galileo Field) '07 (Newton Field) '09 (Practice Fields Attendant / FTA(A)), CeBIT Convention in '04 & NextFEST in '06 both held @ the Javitts Center, Monty Madness '07-'10, Panda-monium '08, B.Eruption '08 & '09, Ramp Riot '08, PARC '09 & '10, BR^2 '09 & Wol. Inv. '09 -'12
2013 FIRST Robotics Off Season Events that I hope to volunteer at:
Where is Wolcott Invitational
2013 FIRST Robotics Events that I will be volunteering at:
SBPLI Reg.
Volunteer Resume:
Alt & Lead Team Queuer, Field Repair/Reset, Field Setup/Breakdown, Spare Parts Attendant, Field Power Controller/Score Keeper, Co-Emcee & Official Scorer, Control System Advisor, FIRST Tech Advisor Assistant & recently Practice Field Attendant.
  #5   Spotlight this post!  
Unread 10-28-2002, 08:31 PM
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 7,902
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
I believe that a program using assembly will not work in any NT based operating system(2000 and XP). I could be wrong, though.
  #6   Spotlight this post!  
Unread 10-28-2002, 09:33 PM
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Well, I tried the assembly stuff I had lying around and it worked fine under DOS but gave a BSOD under Windows. I know I've asked this before, but what compiler are you using? If it's VC++, I think I have a fairly painless solution for you. Otherwise, things could get difficult. Also, do you normally use the Win32 SDK (with Windows, WndProc, etc)? If not, this could get very interesting very fast.

If you want to see some DirectInput code, it's included in RoboEmu 1.03(?) and higher in order to allow binding to real joysticks.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #7   Spotlight this post!  
Unread 10-28-2002, 10:43 PM
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
OK, I finally figured this out w/o DirectX or assembly! Here's the code you need:

Code:
#include <windows.h>
#include <mmsystem.h>
....

	JOYINFOEX joyInfo1;
	MMRESULT err;

	ZeroMemory(&joyInfo1, sizeof(JOYINFOEX));
	joyInfo1.dwSize=sizeof(JOYINFOEX);
	joyInfo1.dwFlags=JOY_RETURNALL;

	err=joyGetPosEx(JOYSTICKID1, &joyInfo1);
	if(err!=JOYERR_NOERROR){
		switch(err){
		case MMSYSERR_NODRIVER:
			//no driver installed
			break;
		case MMSYSERR_INVALPARAM:
			//invalid parameter passed
			break;
		case MMSYSERR_BADDEVICEID:
			//joystick ID is invalid
			break;
		case JOYERR_UNPLUGGED:
			//joystick is not pluged in
			break;
		}
	}
At this point, the joyInfo1 struct contains everything you could ever want. Here's a quick rundown of the important fields:

dwXpos: the x pos
dwYpos: the y pos
dwZpos: the z pos
dwButtons: All 32 buttons

In order to access an individual button, use the JOY_BUTTON1, JOY_BUTTON2, etc as a bit mask. I.e:

bool button1=(joyInfo1.dwButtons & JOY_BUTTON1 > 0 ? 1 : 0)

In order to use this stuff, you'll have to tell your compiler to link in the winmm.lib library.

Calibration comes from the Gaming Options control panel, but you'll probably want to check the values yourself just to make sure.

Finally, to access joystick #2, replace JOYSTICKID1 with JOYSTICKID2 in the joyGetPosEx function.


Anyway, I hope this helps. Let me know if something goes wrong or if you want some more detail/additional options. Alternatively, check out the MSDN library entry for JOYINFOEX.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #8   Spotlight this post!  
Unread 10-30-2002, 08:37 PM
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Anybody had a chance to try this yet? If it works on other peoples' systems, I'll write up a formal white paper, but I want to make sure it's going to work first. Anyway, let me know if you have questions or want more info.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #9   Spotlight this post!  
Unread 11-01-2002, 11:56 AM
Ian W. Ian W. is offline
College? What?
no team (Gompei and the Herd)
Team Role: College Student
 
Join Date: Jan 2002
Rookie Year: 2002
Location: Worcester, MA | Smithtown, NY
Posts: 1,464
Ian W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to all
Send a message via AIM to Ian W.
I haven't had a chance to try it yet because I'm in the middle of installing gentoo on my computer, but i should be able to give it a whirl sometime this weekend. If it works i'll tell you, but i'll need a bit of time to try it out. thanks for the help.
__________________
AIM --> Woloi
Email --> ian@woloschin.com
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming Compatition Angela06 Programming 30 04-08-2005 10:12 PM
programming the compressor archiver 2001 4 06-23-2002 10:19 PM
Pneumatics electrical wiring and programming archiver 2001 1 06-23-2002 10:10 PM
Error found in programming for the pump and pressure switch sjharobotics Programming 4 02-06-2002 04:46 PM
pbasic programming punarhero Programming 4 01-21-2002 10:32 PM


All times are GMT -5. The time now is 09:08 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi