Solved

Switch LPT1 Pin1 on & off

Posted on 2004-08-16
16
763 Views
Last Modified: 2008-02-01
Hi !
I've searched EE and the Web for switching on/off a PIN of LPT1 under W2K. I always found WinIO
and the WinIO unit. Can somebody explain me how to use this thing ? I only want to turn off/on
one pin. This can't be so hard ?? A short function would be nice.

Thanks
Philip
0
Comment
Question by:fuluppi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 7
16 Comments
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 11817865
Hi,
you can try with zlportio :
http://www.delphi32.org/vcl/4848/

also :
http://sourceforge.net/projects/tpapro
This is the definite component suite for COM port programming.
Manual and sample programs included.

Regards
Amir
0
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 11817874
LPT port address = 378H  OR 278H
0
 

Author Comment

by:fuluppi
ID: 11818009
hi amir !
i already tried zlportio. i have no idea how to use it with the parallell
port. can you post some demo code for winio or zlportio ?

Thanks
Philip
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:fuluppi
ID: 11818150
i guess it works like this:

  SetPortVal(378,0,0);

what must i set to disable and to enable all pins ?
  SetPortVal(378,256,0); for all on and   SetPortVal(378,0,0); for all off ??
0
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 11818869
the zlportio is include a demo to read/wrtite from/to ports,
anyway, this is some codes :

/////////////////////////////////////////////////////////
// for write to port 378H
procedure TMain.Button1Click(Sender: TObject);
var Port,data:dword;
begin
      try
       Port := str2int('378',true); // str2int func. convert a hex value to decimal.
      except
       Port := 0;
      end;
// it'll write 'FF' (HEX) to the 378H ( enable all the data pins ( pins 2-9) )
 zlioportwrite(port,coDataType.itemindex,str2int('FF', true));

// it'll write '01' (HEX) to the 378H ( enable pin 2 and disable pins 3 - 9 )
//  zlioportwrite(port,coDataType.itemindex,str2int('01', true));

end;
/////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////
// for read from port 378H
procedure TMain.Button2Click(Sender: TObject);
var Port,data:dword;
begin
     try
       Port := str2int('378',true); // str2int func. convert a hex value to decimal.
      except
       Port := 0;
      end;

 setthreadpriority(GetCurrentThread,THREAD_PRIORITY_TIME_CRITICAL);
 data := zlioportread(Port,coDataType.itemindex);
 setrdata(data);
end;
/////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////
function TMain.str2int(const value:string;const HEX:boolean):integer;
begin // convert a hex value to decimal value
  if HEX then
     result := strtoint('$' + value)
    else
     result := strtoint(value);
end;
/////////////////////////////////////////////////////////



/////////////////////////////////////////////////////////
procedure TMain.setrdata(const Data:dword);
begin // convert an integer value to hex value and show that in an edit box
 erData.Text := inttohex(Data,coDataType.Tag);
end;
/////////////////////////////////////////////////////////
0
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 11818898
Also, not bad to take a look at this link for more details about interfacing the standard parallel port :
http://azhdari.europe.webmatrixhosting.net/parallel.pdf

0
 

Author Comment

by:fuluppi
ID: 11820076
hi amir !
nothing changes on the port when i call the functions with zlio ???
0
 
LVL 6

Accepted Solution

by:
Amir Azhdari earned 500 total points
ID: 11820739
Hi  Fuluppi,
download this project , it work on my pc :
http://azhdari.europe.webmatrixhosting.net/Q_21095463.zip

Let me know if you have problem yet...
0
 

Author Comment

by:fuluppi
ID: 11820891
it works ! thanks a lot ! i found a component which works well, too. but it's not free.
0
 

Author Comment

by:fuluppi
ID: 11821143
In my application it doesn't work any longer.  if ZLIOStarted returns false. Any ideas what I do wrong ? Do I need to do something special to start the driver ???

thanks
philip
0
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 11822036
philip, thanks for the points,

Copy file zlportio.sys to your project directory
It should be in the one directory with you application.
0
 

Author Comment

by:fuluppi
ID: 11822284
i did that already. still doesn't work.
0
 

Author Comment

by:fuluppi
ID: 11823710
i found out the problem. my projects ly on a network drive. it only works on a physical disk. no idea why. this is really strange.
0
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 11825208
Hi philip,
I tested that on my client,
you are right, it only works on a physical disk ,not on a network drive,
it's because of the driverinstall func. can't read the driver file from network drive,
so I made some changes to the zlportio.pas file to copy the zlportio.sys to 'C:\' first and then load it from 'C:' instead of
network drive and it work now ,

download the zlportio.pas from here and recompile your project :
http://azhdari.europe.webmatrixhosting.net/zlportio.pas

by the way , don't forget to Copy file zlportio.sys to your project directory
0
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 11825319
0
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 11838261
Hi philip,
did you test your project on the server ?
Let me know if you have any problem
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question