• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 06:06
CEST 12:06
KST 19:06
  • 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
Team TLMC #5: Winners Announced!3[ASL20] Ro8 Preview Pt2: Holding On9Maestros of the Game: Live Finals Preview (RO4)5TL.net Map Contest #21 - Finalists4Team TLMC #5: Vote to Decide Ladder Maps!0
Community News
5.0.15 Patch Balance Hotfix (2025-10-8)59Weekly Cups (Sept 29-Oct 5): MaxPax triples up3PartinG joins SteamerZone, returns to SC2 competition275.0.15 Balance Patch Notes (Live version)119$2,500 WardiTV TL Map Contest Tournament 154
StarCraft 2
General
PartinG joins SteamerZone, returns to SC2 competition Geoff 'iNcontroL' Robinson has passed away 5.0.15 Patch Balance Hotfix (2025-10-8) Classic Games #3: Rogue vs Serral at BlizzCon Team TLMC #5: Winners Announced!
Tourneys
SC2's Safe House 2 - October 18 & 19 RSL Offline Finals Dates + Ticket Sales! SC4ALL $6,000 Open LAN in Philadelphia Sparkling Tuna Cup - Weekly Open Tournament $2,500 WardiTV TL Map Contest Tournament 15
Strategy
Custom Maps
External Content
Mutation # 494 Unstable Environment Mutation # 493 Quick Killers Mutation # 492 Get Out More Mutation # 491 Night Drive
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ I'm making videos again BW General Discussion Question regarding recent ASL Bisu vs Larva game Whose hotkey signature is this?
Tourneys
[Megathread] Daily Proleagues [ASL20] Ro8 Day 4 Small VOD Thread 2.0 [ASL20] Ro8 Day 3
Strategy
Current Meta TvZ Theorycraft - Improving on State of the Art Proposed Glossary of Strategic Uncertainty 9 hatch vs 10 hatch vs 12 hatch
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread ZeroSpace Megathread Dawn of War IV Path of Exile
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
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
SPIRED by.ASL Mafia {211640} TL Mafia Community Thread
Community
General
US Politics Mega-thread Stop the Construction YouTube Thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread
Fan Clubs
The herO Fan Club! The Happy Fan Club!
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread
Sports
Formula 1 Discussion 2024 - 2026 Football Thread MLB/Baseball 2023 NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
How "Not Like Us" ripped of…
Peanutsc
From Tilt to Ragequit:The Ps…
TrAiDoS
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1346 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
CranKy Ducklings
10:00
Sea Duckling Open #139
CranKy Ducklings20
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 358
RotterdaM 196
MindelVK 28
Railgan 12
Rex 1
StarCraft: Brood War
Hyuk 1112
Shuttle 612
actioN 573
Larva 481
Zeus 343
firebathero 329
BeSt 325
Flash 264
EffOrt 205
sorry 176
[ Show more ]
Leta 174
Mini 78
Shine 51
Light 44
ZerO 37
Mong 36
Soulkey 31
zelot 26
HiyA 20
Sharp 11
Sacsri 9
Hm[arnc] 5
Britney 1
Dota 2
XcaliburYe440
Counter-Strike
Stewie2K606
Heroes of the Storm
Khaldor180
Other Games
summit1g3485
singsing1810
Happy221
Fuzer 95
Mew2King47
ZerO(Twitch)4
Organizations
Other Games
gamesdonequick667
BasetradeTV63
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• Berry_CruncH191
• LUISG 28
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1898
• Stunt664
Upcoming Events
Map Test Tournament
54m
MaxPax vs Ryung
TBD vs Classic
Zoun vs YoungYakov
Reynor vs Cure
ByuN vs Lambo
TBD vs Clem
OSC
4h 54m
[BSL 2025] Weekly
7h 54m
Safe House 2
7h 54m
Sparkling Tuna Cup
23h 54m
Map Test Tournament
1d
TBD vs Spirit
TBD vs herO
OSC
1d 1h
IPSL
1d 8h
Bonyth vs Art_Of_Turtle
Razz vs rasowy
Afreeca Starleague
1d 23h
Barracks vs Snow
Afreeca Starleague
2 days
Soma vs Bisu
[ Show More ]
The PondCast
4 days
CranKy Ducklings
6 days
Liquipedia Results

Completed

Acropolis #4 - TS2
Maestros of the Game
HCC Europe

Ongoing

BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
C-Race Season 1
IPSL Winter 2025-26
WardiTV TLMC #15
EC S1
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025

Upcoming

SC4ALL: Brood War
BSL Season 21
BSL 21 Team A
RSL Offline Finals
RSL Revival: Season 3
Stellar Fest
SC4ALL: StarCraft II
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
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 © 2025 TLnet. All Rights Reserved.