• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 22:24
CET 04:24
KST 12:24
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)8Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns6[BSL21] Non-Korean Championship - Starts Jan 103SC2 All-Star Invitational: Jan 17-1822Weekly Cups (Dec 22-28): Classic & MaxPax win, Percival surprises3
StarCraft 2
General
Chinese SC2 server to reopen; live all-star event in Hangzhou Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns SC2 All-Star Invitational: Jan 17-18 Weekly Cups (Dec 22-28): Classic & MaxPax win, Percival surprises Starcraft 2 Zerg Coach
Tourneys
$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7) WardiTV Winter Cup WardiTV Mondays SC2 AI Tournament 2026 OSC Season 13 World Championship
Strategy
Simple Questions Simple Answers
Custom Maps
Map Editor closed ?
External Content
Mutation # 507 Well Trained Mutation # 506 Warp Zone Mutation # 505 Rise From Ashes Mutation # 504 Retribution
Brood War
General
Potential ASL qualifier breakthroughs? BGH Auto Balance -> http://bghmmr.eu/ I would like to say something about StarCraft BW General Discussion StarCraft & BroodWar Campaign Speedrun Quest
Tourneys
[Megathread] Daily Proleagues [BSL21] Grand Finals - Sunday 21:00 CET [BSL21] Non-Korean Championship - Starts Jan 10 SLON Grand Finals – Season 2
Strategy
Game Theory for Starcraft Simple Questions, Simple Answers Current Meta [G] How to get started on ladder as a new Z player
Other Games
General Games
Mechabellum Beyond All Reason Stormgate/Frost Giant Megathread Awesome Games Done Quick 2026! General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas
Community
General
US Politics Mega-thread European Politico-economics QA Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine Trading/Investing Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List TL+ Announced
Blogs
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
Psychological Factors That D…
TrAiDoS
James Bond movies ranking - pa…
Topin
StarCraft improvement
iopq
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1763 users

need program help

Blogs > gumbum8
Post a Reply
gumbum8
Profile Blog Joined December 2008
United States721 Posts
Last Edited: 2010-07-07 15:49:43
July 07 2010 14:55 GMT
#1
Let me begin by saying: I'm in way over my head. I'm currently (as in for the last 3 weeks, and until Monday) working at an internship at UGA, in riverbend research lab.
It all went wrong when I wrote a program that simplified some of my grub work (Can't really explain, I signed this NDA for research that's already been done T_T), and now I have to write a program that can control the running of a small motor with a full GUI n' shit. This motor USED to have a program it would use in labVIEW, however I was told this labVIEW program only worked on 1 computer here (?). Before I go any further, let me clarify a little with some pretty pictures.
+ Show Spoiler +
[image loading]
this is the motor controller, the Cyberpak CY-21. Sorry guys, this is the best picture I could find.

[image loading]
as you can tell, this is how the motor system is currently wired. Exactly how it appears on my chart.


So as you can see, I'm using a piece of hardware known as the DB-25 to connect to the CY-21 controller. a little info on the DB-25 for those who don't know:
[image loading]
http://www.nullmodem.com/DB-25.htm
(an explanation is here, scroll down until you reach IBM-PC)

These are the printer port values of the DB-25. Thus, we see that pins 2-9 are the only pins that are good for input/output data (also pins used in wiring schematic), while pins 25-18 are simply grounds (one is used in wiring).

So what data am I trying to transmit? Well, for the ENA pin on the CY-21, I need a 0 to activate and a 1 to disable the motor. for the DIR pin, 0 is clockwise and 1 is counterclockwise (Not sure which is which right now, but it's not really important yet), and then there is the STEP pin. This motor controller is special in that it is a "microstepping motor driver", thus I quote: "The CY-21 has 16 microsteps per full step, which is 3,200 steps/rev with a standard 1.8° motor." I'm not entirely sure on this one, but I'm fairly sure that the STEP pin is to set the speed of the motor, and I think a good value to try would be 16.

one pic of the actual circuit I've got goin on: Is here!
+ Show Spoiler +
[image loading]
[image loading]
[image loading]
note: some guy dis attached my motor. I'll put it back on later.


So now down to code. Unfortunately, a ton of the google results you'd get on parallel port programming are old. reallllly old. Back when your program could access hardware eZpZ old. But times have changed, and the best guide I could find was this one.

you'll notice that for XP and up, a .dll called Inpout32.dll is supposedly critical to success. upon downloading this .dll, the best thing I found was the test program.
test program:
+ Show Spoiler +
/**************************************************/
/*** ***/
/*** TEST.c -- test interface to inpout32.dll ***/
/*** ( [url=http://www.logix4u.net/inpout32.htm]http://www.logix4u.net/inpout32.htm[/url] ) ***/
/*** ***/
/*** Copyright (C) 2003, Douglas Beattie Jr. ***/
/*** ***/
/*** <beattidp@ieee.org> ***/
/*** [url=http://www.hytherion.com/beattidp/]http://www.hytherion.com/beattidp/[/url] ***/
/*** ***/
/**************************************************/


/*******************************************************/
/* */
/* Builds with Borland's Command-line C Compiler */
/* (free for public download from Borland.com, at */
/* [url=http://www.borland.com/bcppbuilder/freecompiler]http://www.borland.com/bcppbuilder/freecompiler[/url] ) */
/* */
/* Compile with: */
/* */
/* BCC32 -IC:\BORLAND\BCC55\INCLUDE TEST.C */
/* */
/* */
/* Be sure to change the Port addresses */
/* accordingly if your LPT port is addressed */
/* elsewhere. */
/* */
/*******************************************************/




#include <stdio.h>
#include <conio.h>
#include <windows.h>


/* Definitions in the build of inpout32.dll are: */
/* short _stdcall Inp32(short PortAddress); */
/* void _stdcall Out32(short PortAddress, short data); */


/* prototype (function typedef) for DLL function Inp32: */

typedef short _stdcall (*inpfuncPtr)(short portaddr);
typedef void _stdcall (*oupfuncPtr)(short portaddr, short datum);

int main(void)
{
HINSTANCE hLib;
inpfuncPtr inp32;
oupfuncPtr oup32;

short x;
int i;

/* Load the library */
hLib = LoadLibrary("inpout32.dll");

if (hLib == NULL) {
printf("LoadLibrary Failed.\n");
return -1;
}

/* get the address of the function */

inp32 = (inpfuncPtr) GetProcAddress(hLib, "Inp32");

if (inp32 == NULL) {
printf("GetProcAddress for Inp32 Failed.\n");
return -1;
}


oup32 = (oupfuncPtr) GetProcAddress(hLib, "Out32");

if (oup32 == NULL) {
printf("GetProcAddress for Oup32 Failed.\n");
return -1;
}


/***************************************************************/
/* now test the functions */

/* Try to read 0x378..0x37F, LPT1: */

for (i=0x378; (i<0x380); i++) {

x = (inp32)(i);

printf("port read (%04X)= %04X\n",i,x);
}



/***** Write the data register */

i=0x378;
x=0x77;

(oup32)(i,x);

printf("port write to 0x%X, datum=0x%2X\n" ,i ,x);

/***** And read back to verify */
x = (inp32)(i);
printf("port read (%04X)= %04X\n",i,x);



/***** One more time, different value */

i=0x378;
x=0xAA;

(oup32)(i,x);

printf("port write to 0x%X, datum=0x%2X\n" ,i ,x);

/***** And read back to verify */
x = (inp32)(i);
printf("port read (%04X)= %04X\n",i,x);




FreeLibrary(hLib);
system("PAUSE");
return 0;
}

which would return something like this on my comp without a DB-25 hooked up:
port read <0378>= 00FF
port read <0379>= 0078
port read <037A>= 0004
port read <037B>= 0004
port read <037C>= 0004
port read <037D>= 0004
port read <037E>= 0004
port read <037F>= 0004
port write to 0x378, datum=0x77
port read <0378>= 0077
port write to 0x378, datum=0xAA
port read <0378>= 00AA
(I don't have access to the actual computer right now, but the return wasn't very different IRC. I'll update this as soon as I can get in the room!)


So every code attempt I have made has failed. Like everything else, my source file has gone on the run with my supervisor's little hard drive, and he's not coming back. So my broken code is gone.

eDiT: DB-25 clarification: The DB-25 acts as the printer port connection: thus it's default location is LPT1, and the base address for the first data pin is 0x378, whereas the last data pin goes by 0x37f, and the next value for an incremental interger would be 0x380.

Anyway, despite the slightly incomplete blog, I was really hoping to get some assistance doing this program >.< I've run out of ideas and while the logic seems to make sense, I just don't understand how do do it syntactically. Plz help, I will update as soon as I can!

but really, has anyone REALLY been far even as decided to use even go want to do look more like?
nath
Profile Blog Joined May 2010
United States1788 Posts
Last Edited: 2010-07-07 15:00:04
July 07 2010 14:59 GMT
#2
im busy as fuck this week but if i have any spare time at all i'll help, will edit this post if i do. i also do research as an undergrad and i know how it feels when shits over ur head
Founder of Flow Enterprises, LLC http://flow-enterprises.com/
indecision
Profile Blog Joined November 2004
Germany818 Posts
July 07 2010 15:05 GMT
#3
You're doing all of this in Windows? You're not talking over RS232 or anything like that, right? Need to directly access the pins of the nullmodem connection?
(Don't get your hopes up too much from my questions: The closest I got to this was switching outputs on a Microcontroller, but the PC was always using RS232)
gumbum8
Profile Blog Joined December 2008
United States721 Posts
Last Edited: 2010-07-07 15:36:54
July 07 2010 15:10 GMT
#4
On July 08 2010 00:05 indecision wrote:
You're doing all of this in Windows? You're not talking over RS232 or anything like that, right? Need to directly access the pins of the nullmodem connection?
(Don't get your hopes up too much from my questions: The closest I got to this was switching outputs on a Microcontroller, but the PC was always using RS232)

I have been told that using the printer port was how the motor worked previously, so I figured that would be the correct configuration. I'm not entirely sure if an RS-232 connection would do what I would want it to. Yes, this is all being done in windows XP, and yes, I need to directly access the pins of the null modem connection to send the proper values to the CY-21.

On July 07 2010 23:59 nath wrote:
im busy as fuck this week but if i have any spare time at all i'll help, will edit this post if i do. i also do research as an undergrad and i know how it feels when shits over ur head

Thanks! Yeah it sucks T_T
but really, has anyone REALLY been far even as decided to use even go want to do look more like?
love1another
Profile Blog Joined December 2009
United States1844 Posts
Last Edited: 2010-07-07 16:04:34
July 07 2010 16:04 GMT
#5
Do this on a linux box. None of this windows XP Dll, bullshit.
"I'm learning more and more that TL isn't the place to go for advice outside of anything you need in college. It's like you guys just make up your own fantasy world shit and post it as if you've done it." - Chill
sob3k
Profile Blog Joined August 2009
United States7572 Posts
July 07 2010 16:11 GMT
#6
Simple, just remodulate the deflector array to generate a multiphasic tachyon field.
In Hungry Hungry Hippos there are no such constraints—one can constantly attempt to collect marbles with one’s hippo, limited only by one’s hippo-levering capabilities.
Uranium
Profile Blog Joined May 2010
United States1077 Posts
Last Edited: 2010-07-07 16:30:20
July 07 2010 16:29 GMT
#7
OK I'm doing a little googling here. First things first:
+ Show Spoiler +

To establish communication with the LPTx port, you must stop the Print Spooler service. To do this, use the Services tool in Administrative Tools.


This comes from the Microsoft KB at http://support.microsoft.com/kb/823179. The relevant article begins halfway down and is titled "Use platform invoke services to call Win32 API functions in Visual Basic .NET to access serial and parallel ports". Obviously this is all VB.NET code but it shows you how to use P/Invoke to call base Win32 APIs to send your raw data. If you are using C/C++ you can access this API natively.


Now I got this little gem of wisdom from .NET 24/7:

+ Show Spoiler +
The VB code you posted uses many API calls
not working against LPT ports.
Thus, try to remove all the ClearCommError, GetCommState ...
and only use CreateFile/ReadFile/WriteFile.

I don't remember the details, but for working with direct lpt port,
on 2000/XP it could help if you stop the spooler service; enter:
net stop spooler
and use CreateFile("\\.\NONSPOOLED_LPT1",...



Basically you use the Win32 API CreateFile & WriteFile functions to access the LPT1 port and send data. As stated in the 2 above links you will need to stop the print spooler service and attempt to use the nonspooled LPT port. This may involve setting the baud rate to the correct speed for your motors and streaming movement commands, or attempting to send the data one bit at a time. If you have an oscilloscope or multimeter with which to test the exact output timings of the LPT port that would help.

As a last resort he claims that you can buy a custom port driver at www.ntport.com which should give you full control. Might be worth trying to convince your boss as I think it would save you a lot of time.
"Sentry imba! You see? YOU SEE??!!" - Sen | "Marauder die die!" - oGsMC | "Oh my god, she texted me back!" - Day[9]
gumbum8
Profile Blog Joined December 2008
United States721 Posts
July 07 2010 16:53 GMT
#8
On July 08 2010 01:04 love1another wrote:
Do this on a linux box. None of this windows XP Dll, bullshit.

I prefer to use windows instead of emulating it

On July 08 2010 01:11 sob3k wrote:
Simple, just remodulate the deflector array to generate a multiphasic tachyon field.

Son, I got 99 problems, but a hull breach ain't one

On July 08 2010 01:29 Uranium wrote:
+ Show Spoiler +
OK I'm doing a little googling here. First things first:
+ Show Spoiler +

To establish communication with the LPTx port, you must stop the Print Spooler service. To do this, use the Services tool in Administrative Tools.


This comes from the Microsoft KB at http://support.microsoft.com/kb/823179. The relevant article begins halfway down and is titled "Use platform invoke services to call Win32 API functions in Visual Basic .NET to access serial and parallel ports". Obviously this is all VB.NET code but it shows you how to use P/Invoke to call base Win32 APIs to send your raw data. If you are using C/C++ you can access this API natively.


Now I got this little gem of wisdom from .NET 24/7:

+ Show Spoiler +
The VB code you posted uses many API calls
not working against LPT ports.
Thus, try to remove all the ClearCommError, GetCommState ...
and only use CreateFile/ReadFile/WriteFile.

I don't remember the details, but for working with direct lpt port,
on 2000/XP it could help if you stop the spooler service; enter:
net stop spooler
and use CreateFile("\\.\NONSPOOLED_LPT1",...



Basically you use the Win32 API CreateFile & WriteFile functions to access the LPT1 port and send data. As stated in the 2 above links you will need to stop the print spooler service and attempt to use the nonspooled LPT port. This may involve setting the baud rate to the correct speed for your motors and streaming movement commands, or attempting to send the data one bit at a time. If you have an oscilloscope or multimeter with which to test the exact output timings of the LPT port that would help.

As a last resort he claims that you can buy a custom port driver at www.ntport.com which should give you full control. Might be worth trying to convince your boss as I think it would save you a lot of time.

hmm ok I'll try all this Thanks a lot! I will update with results!
but really, has anyone REALLY been far even as decided to use even go want to do look more like?
gumbum8
Profile Blog Joined December 2008
United States721 Posts
July 12 2010 14:59 GMT
#9
Yeah, so after looking at the code and suggestions of Uranium, I realized that I am still completely lost, because I don't really follow the VB. Could anyone else help me out?
but really, has anyone REALLY been far even as decided to use even go want to do look more like?
Please log in or register to reply.
Live Events Refresh
AI Arena Tournament
20:00
Swiss - Round 1
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
WinterStarcraft467
RuFF_SC2 211
NeuroSwarm 114
Ketroc 7
StarCraft: Brood War
GuemChi 1130
Shuttle 176
NaDa 65
Noble 28
Icarus 7
Dota 2
LuMiX1
League of Legends
JimRising 737
Counter-Strike
summit1g8203
fl0m4197
m0e_tv29
minikerr20
Super Smash Bros
Mew2King109
amsayoshi28
Other Games
tarik_tv5983
ToD160
monkeys_forever157
ViBE112
KnowMe62
PiLiPiLi15
Liquid`Ken3
Organizations
Other Games
gamesdonequick52054
BasetradeTV136
StarCraft: Brood War
UltimateBattle 50
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• davetesta46
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV722
League of Legends
• Doublelift7190
• Scarra1907
Upcoming Events
WardiTV Invitational
9h 36m
ByuN vs Percival
Percival vs Rogue
Percival vs Classic
ByuN vs Classic
ByuN vs Rogue
Classic vs Rogue
IPSL
16h 36m
DragOn vs Sziky
Replay Cast
1d 5h
Wardi Open
1d 8h
Monday Night Weeklies
1d 13h
WardiTV Invitational
2 days
WardiTV Invitational
3 days
The PondCast
4 days
All Star Teams
5 days
INnoVation vs soO
sOs vs Scarlett
uThermal 2v2 Circuit
6 days
[ Show More ]
All Star Teams
6 days
MMA vs DongRaeGu
Rogue vs Oliveira
Liquipedia Results

Completed

Proleague 2026-01-10
Big Gabe Cup #3
META Madness #9

Ongoing

C-Race Season 1
IPSL Winter 2025-26
BSL 21 Non-Korean Championship
OSC Championship Season 13
Underdog Cup #3
NA Kuram Kup
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025

Upcoming

CSL 2025 WINTER (S19)
Escore Tournament S1: W4
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Rongyi Cup S3
Thunderfire SC2 All-star 2025
Nations Cup 2026
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.