• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 01:14
CET 07:14
KST 15:14
  • 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 Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
[BSL21] Ro.16 Group Stage (C->B->A->D)1Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win2RSL Season 3: RO16 results & RO8 bracket13Weekly Cups (Nov 10-16): Reynor, Solar lead Zerg surge2[TLMC] Fall/Winter 2025 Ladder Map Rotation14
StarCraft 2
General
When will we find out if there are more tournament Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win SC: Evo Complete - Ranked Ladder OPEN ALPHA Weekly Cups (Nov 10-16): Reynor, Solar lead Zerg surge RSL Season 3: RO16 results & RO8 bracket
Tourneys
Tenacious Turtle Tussle RSL Revival: Season 3 $5,000+ WardiTV 2025 Championship StarCraft Evolution League (SC Evo Biweekly) Constellation Cup - Main Event - Stellar Fest
Strategy
Ride the Waves in Surf City: Why Surfing Lessons H
Custom Maps
Map Editor closed ?
External Content
Mutation # 501 Price of Progress Mutation # 500 Fright night Mutation # 499 Chilling Adaptation Mutation # 498 Wheel of Misfortune|Cradle of Death
Brood War
General
Which season is the best in ASL? FlaSh on: Biggest Problem With SnOw's Playstyle soO on: FanTaSy's Potential Return to StarCraft Data analysis on 70 million replays 2v2 maps which are SC2 style with teams together?
Tourneys
[BSL21] RO16 Tie Breaker - Group B - Sun 21:00 CET [BSL21] GosuLeague T1 Ro16 - Tue & Thu 22:00 CET [Megathread] Daily Proleagues [BSL21] RO16 Tie Breaker - Group A - Sat 21:00 CET
Strategy
Game Theory for Starcraft How to stay on top of macro? Current Meta PvZ map balance
Other Games
General Games
Stormgate/Frost Giant Megathread Should offensive tower rushing be viable in RTS games? Nintendo Switch Thread Path of Exile Clair Obscur - Expedition 33
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
Mafia Game Mode Feedback/Ideas
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine YouTube Thread Artificial Intelligence Thread
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
The Health Impact of Joining…
TrAiDoS
Dyadica Evangelium — Chapt…
Hildegard
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2246 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
PiGosaur Cup
01:00
#59
SteadfastSC138
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SteadfastSC 138
SortOf 80
StarCraft: Brood War
Larva 1101
Sharp 126
Snow 107
Noble 33
Icarus 8
Soulkey 1
BeSt 0
Dota 2
monkeys_forever542
League of Legends
JimRising 675
Counter-Strike
C9.Mang0289
Other Games
summit1g8130
WinterStarcraft395
ViBE151
Trikslyr22
Organizations
Other Games
gamesdonequick746
Dota 2
PGL Dota 2 - Main Stream307
StarCraft: Brood War
UltimateBattle 118
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 18 non-featured ]
StarCraft 2
• LaughNgamezSOOP
• sooper7s
• AfreecaTV YouTube
• intothetv
• Migwel
• Kozan
• IndyKCrew
StarCraft: Brood War
• Azhi_Dahaki29
• RayReign 11
• ZZZeroYoutube
• STPLYoutube
• BSLYoutube
Dota 2
• lizZardDota238
League of Legends
• Rush1444
• Lourlo1190
• Stunt346
• HappyZerGling122
Other Games
• Scarra1802
Upcoming Events
Replay Cast
2h 47m
Wardi Open
5h 47m
OSC
6h 47m
Tenacious Turtle Tussle
17h 47m
The PondCast
1d 3h
Replay Cast
1d 16h
OSC
2 days
LAN Event
2 days
Replay Cast
2 days
Replay Cast
3 days
[ Show More ]
WardiTV Korean Royale
3 days
Sparkling Tuna Cup
4 days
WardiTV Korean Royale
4 days
Replay Cast
4 days
Wardi Open
5 days
Monday Night Weeklies
5 days
Replay Cast
5 days
Wardi Open
6 days
Liquipedia Results

Completed

SOOP Univ League 2025
RSL Revival: Season 3
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
CSCL: Masked Kings S3
Slon Tour Season 2
META Madness #9
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
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.