• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 20:39
CEST 02:39
KST 09:39
  • 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
BGE Stara Zagora 2025: Info & Preview8Code S RO12 Preview: GuMiho, Bunny, SHIN, ByuN3The Memories We Share - Facing the Final(?) GSL44Code S RO12 Preview: Cure, Zoun, Solar, Creator4[ASL19] Finals Preview: Daunting Task30
Community News
GSL Ro4 and Finals moved to Sunday June 15th7Weekly Cups (May 27-June 1): ByuN goes back-to-back0EWC 2025 Regional Qualifier Results26Code S RO12 Results + RO8 Groups (2025 Season 2)3Weekly Cups (May 19-25): Hindsight is 20/20?0
StarCraft 2
General
Serious Question: Mech CN community: Firefly accused of suspicious activities Jim claims he and Firefly were involved in match-fixing The Memories We Share - Facing the Final(?) GSL BGE Stara Zagora 2025: Info & Preview
Tourneys
$5,100+ SEL Season 2 Championship (SC: Evo) WardiTV Mondays Master Swan Open (Global Bronze-Master 2) $1,200 WardiTV June (June 4th-June 15th) SOOPer7s Showmatches 2025
Strategy
[G] Darkgrid Layout Simple Questions Simple Answers [G] PvT Cheese: 13 Gate Proxy Robo
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 476 Charnel House Mutation # 475 Hard Target Mutation # 474 Futile Resistance Mutation # 473 Cold is the Void
Brood War
General
BW General Discussion FlaSh Witnesses SCV Pull Off the Impossible vs Shu Will foreigners ever be able to challenge Koreans? BGH auto balance -> http://bghmmr.eu/ Battle.net is not working
Tourneys
Small VOD Thread 2.0 [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET [Megathread] Daily Proleagues [ASL19] Grand Finals
Strategy
I am doing this better than progamers do. [G] How to get started on ladder as a new Z player
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile Mechabellum Monster Hunter Wilds
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
LiquidLegends to reintegrate into TL.net
Heroes of the Storm
Simple Questions, Simple Answers
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia TL Mafia Community Thread TL Mafia Plays: Diplomacy TL Mafia: Generative Agents Showdown Survivor II: The Amazon
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread European Politico-economics QA Mega-thread Canadian Politics Mega-thread
Fan Clubs
Maru Fan Club Serral Fan Club
Media & Entertainment
Korean Music Discussion [Manga] One Piece
Sports
2024 - 2025 Football Thread Formula 1 Discussion NHL Playoffs 2024 NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread Cleaning My Mechanical Keyboard How to clean a TTe Thermaltake keyboard?
TL Community
The Automated Ban List
Blogs
Heero Yuy & the Tax…
KrillinFromwales
Research study on team perfo…
TrAiDoS
I was completely wrong ab…
jameswatts
Need Your Help/Advice
Glider
Trip to the Zoo
micronesia
Poker
Nebuchad
Info SLEgma_12
SLEgma_12
Customize Sidebar...

Website Feedback

Closed Threads



Active: 14107 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 Monday
00:00
#34
PiGStarcraft506
SteadfastSC92
CranKy Ducklings91
rockletztv 24
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
PiGStarcraft506
RuFF_SC2 134
Livibee 99
SteadfastSC 92
Nina 15
StarCraft: Brood War
Artosis 898
ZZZero.O 51
Icarus 5
Dota 2
monkeys_forever254
NeuroSwarm83
Counter-Strike
fl0m6741
Fnx 396
Super Smash Bros
hungrybox445
C9.Mang0227
AZ_Axe103
PPMD27
Other Games
summit1g7104
shahzam1247
Day[9].tv979
ViBE234
Maynarde206
Trikslyr38
Organizations
Other Games
gamesdonequick1152
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• Hupsaiya 101
• RyuSc2 30
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Azhi_Dahaki17
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Doublelift6038
Other Games
• Day9tv979
Upcoming Events
WardiTV Qualifier
10h 21m
Bellum Gens Elite
11h 21m
OSC
15h 21m
The PondCast
1d 9h
Bellum Gens Elite
1d 10h
WardiTV Invitational
1d 10h
Replay Cast
1d 23h
OSC
1d 23h
Bellum Gens Elite
2 days
WardiTV Invitational
2 days
[ Show More ]
Replay Cast
2 days
CranKy Ducklings
3 days
SC Evo League
3 days
Bellum Gens Elite
3 days
Fire Grow Cup
3 days
CSO Contender
3 days
Replay Cast
3 days
SOOP
4 days
SHIN vs GuMiho
Sparkling Tuna Cup
4 days
AllThingsProtoss
4 days
Fire Grow Cup
4 days
Replay Cast
4 days
Replay Cast
5 days
Replay Cast
6 days
WardiTV Invitational
6 days
Liquipedia Results

Completed

CSL Season 17: Qualifier 1
DreamHack Dallas 2025
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
BSL Season 20
KCM Race Survival 2025 Season 2
NPSL S3
Rose Open S1
CSL Season 17: Qualifier 2
2025 GSL S2
Bellum Gens Elite Stara Zagora 2025
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
ECL Season 49: Europe
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025
YaLLa Compass Qatar 2025
PGL Bucharest 2025
BLAST Open Spring 2025

Upcoming

CSL 17: 2025 SUMMER
Copa Latinoamericana 4
CSLPRO Last Chance 2025
CSLAN 2025
K-Championship
SEL Season 2 Championship
Esports World Cup 2025
HSC XXVII
Championship of Russia 2025
Murky Cup #2
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
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.