Solved

Switch LPT1 Pin1 on & off

Posted on 2004-08-16
16
761 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
  • 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create Database on Android via Delphi dbExpress 3 88
Printing problem 2 91
Tvertscrollbox like a whatsapp layout 5 26
can i put an image from resource into image tag ? 6 24
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now