• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 20:31
CEST 02:31
KST 09:31
  • 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
[ASL20] Ro24 Preview Pt2: Take-Off6[ASL20] Ro24 Preview Pt1: Runway132v2 & SC: Evo Complete: Weekend Double Feature4Team Liquid Map Contest #21 - Presented by Monster Energy9uThermal's 2v2 Tour: $15,000 Main Event18
Community News
Weekly Cups (Aug 18-24): herO dethrones MaxPax5Maestros of The Game—$20k event w/ live finals in Paris30Weekly Cups (Aug 11-17): MaxPax triples again!13Weekly Cups (Aug 4-10): MaxPax wins a triple6SC2's Safe House 2 - October 18 & 195
StarCraft 2
General
Weekly Cups (Aug 18-24): herO dethrones MaxPax What mix of new and old maps do you want in the next 1v1 ladder pool? (SC2) : A Eulogy for the Six Pool Geoff 'iNcontroL' Robinson has passed away 2v2 & SC: Evo Complete: Weekend Double Feature
Tourneys
WardiTV Mondays Maestros of The Game—$20k event w/ live finals in Paris RSL: Revival, a new crowdfunded tournament series Sparkling Tuna Cup - Weekly Open Tournament Monday Nights Weeklies
Strategy
Custom Maps
External Content
Mutation # 488 What Goes Around Mutation # 487 Think Fast Mutation # 486 Watch the Skies Mutation # 485 Death from Below
Brood War
General
No Rain in ASL20? BW General Discussion Flash On His 2010 "God" Form, Mind Games, vs JD BGH Auto Balance -> http://bghmmr.eu/ [ASL20] Ro24 Preview Pt2: Take-Off
Tourneys
[ASL20] Ro24 Group E [Megathread] Daily Proleagues [ASL20] Ro24 Group D [ASL20] Ro24 Group B
Strategy
Simple Questions, Simple Answers Fighting Spirit mining rates [G] Mineral Boosting Muta micro map competition
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread General RTS Discussion Thread Dawn of War IV Path of Exile
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
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread Things Aren’t Peaceful in Palestine The year 2050 European Politico-economics QA Mega-thread
Fan Clubs
INnoVation Fan Club SKT1 Classic Fan Club!
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2026 Football Thread TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion
World Cup 2022
Tech Support
High temperatures on bridge(s) Gtx660 graphics card replacement Installation of Windows 10 suck at "just a moment"
TL Community
The Automated Ban List TeamLiquid Team Shirt On Sale
Blogs
Evil Gacha Games and the…
ffswowsucks
Breaking the Meta: Non-Stand…
TrAiDoS
INDEPENDIENTE LA CTM
XenOsky
[Girl blog} My fema…
artosisisthebest
Sharpening the Filtration…
frozenclaw
ASL S20 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 5971 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
#46
PiGStarcraft236
SteadfastSC38
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
PiGStarcraft236
NeuroSwarm 147
Nina 136
ProTech85
CosmosSc2 43
Nathanias 41
SteadfastSC 38
StarCraft: Brood War
Artosis 781
Hyuk 470
NaDa 54
Sharp 36
Dota 2
monkeys_forever368
Counter-Strike
fl0m1044
taco 101
Super Smash Bros
hungrybox316
AZ_Axe83
PPMD44
Liquid`Ken8
Other Games
summit1g7182
shahzam1616
Day[9].tv847
C9.Mang0352
WinterStarcraft245
ViBE244
Maynarde150
ToD130
Organizations
Other Games
gamesdonequick833
BasetradeTV16
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• RyuSc2 43
• rockletztv 11
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• masondota22476
League of Legends
• Stunt236
Other Games
• Day9tv847
Upcoming Events
Afreeca Starleague
9h 29m
hero vs Alone
Royal vs Barracks
Replay Cast
23h 29m
The PondCast
1d 9h
WardiTV Summer Champion…
1d 10h
Clem vs Classic
herO vs MaxPax
Replay Cast
1d 23h
LiuLi Cup
2 days
MaxPax vs TriGGeR
ByuN vs herO
Cure vs Rogue
Classic vs HeRoMaRinE
Cosmonarchy
2 days
OyAji vs Sziky
Sziky vs WolFix
WolFix vs OyAji
BSL Team Wars
2 days
Team Hawk vs Team Dewalt
BSL Team Wars
2 days
Team Hawk vs Team Bonyth
SC Evo League
3 days
TaeJa vs Cure
Rogue vs threepoint
ByuN vs Creator
MaNa vs Classic
[ Show More ]
Maestros of the Game
3 days
ShoWTimE vs Cham
GuMiho vs Ryung
Zoun vs Spirit
Rogue vs MaNa
[BSL 2025] Weekly
3 days
SC Evo League
4 days
Maestros of the Game
4 days
SHIN vs Creator
Astrea vs Lambo
Bunny vs SKillous
HeRoMaRinE vs TriGGeR
BSL Team Wars
4 days
Team Bonyth vs Team Sziky
BSL Team Wars
4 days
Team Dewalt vs Team Sziky
Monday Night Weeklies
5 days
Replay Cast
5 days
Sparkling Tuna Cup
6 days
Liquipedia Results

Completed

CSLAN 3
uThermal 2v2 Main Event
HCC Europe

Ongoing

Copa Latinoamericana 4
BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Qualifiers
ASL Season 20
CSL Season 18: Qualifier 1
Acropolis #4 - TS1
CSL Season 18: Qualifier 2
SEL Season 2 Championship
WardiTV Summer 2025
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
BLAST.tv Austin Major 2025

Upcoming

CSL 2025 AUTUMN (S18)
LASL Season 20
BSL Season 21
BSL 21 Team A
Chzzk MurlocKing SC1 vs SC2 Cup #2
RSL Revival: Season 2
Maestros of the Game
EC S1
Sisters' Call Cup
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
MESA Nomadic Masters Fall
CS Asia Championships 2025
Roobet Cup 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall 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 © 2025 TLnet. All Rights Reserved.