Inpout32 Dll Serial Port Examples Of Resignation

Inpout32 Dll Serial Port Examples Of Resignation 4,2/5 207votes

Sep 05, 2013 Controlling 8 Relay via LPT Port Using InpOut32.dll. Controlling 8 Relay via LPT Port Using InpOut32.dll Hi. Thanks for example of.

I've been given this simple VB application and library which I'm told can open a door/turnstyle attached to the printer port at 0x378 base address. 'Inp and Out declarations for port I/O using inpout32.dll. Public Declare Function Inp Lib 'inpout32.dll' Alias 'Inp32' _ (ByVal PortAddress As Integer) _ As Integer Public Declare Sub Out Lib 'inpout32.dll' Alias 'Out32' _ (ByVal PortAddress As Integer, _ ByVal Value As Integer) ------------------------------------------------------------------------------------ Option Explicit Dim Value As Integer Dim PortAddress As Integer Private Sub cmdWriteToPort_Click() 'Write to a port. Out PortAddress, Value 'Read back and display the result.

Text1.Text = Inp(PortAddress) Value = Value + 1 If Value = 255 Then Value = 0 End Sub Private Sub Form_Load() 'Test program for inpout32.dll Value = 0 'Change PortAddress to match the port address to write to: '(Usual parallel-port addresses are &h378, &h278, &h3BC) PortAddress = &H378 End Sub However I need to re-write it in Delphi 5 to integrate in to my application. • Is it possible to access the same library through D5?

• Am I in the right direction with the following code? //Inp and Out declarations for port I/O using library function Inp(PortAddress:String); external 'inpout32.dll.dll' begin return?? End; procedure Output(PortAddress:String;Value:Integer); external 'inpout32.dll.dll' procedure TForm1.FormActivate(Sender: TObject); begin //Test program for inpout32.dll Value:= 0; //Change PortAddress to match the port address to write to: //(Usual parallel-port addresses are &h378, &h278, &h3BC) PortAddress:= '&H378'; end; procedure TForm1.Button1Click(Sender: TObject); begin //Write to a port. Output(PortAddress, Value); //Read back and display the result. Edit1.Text:= Inp(PortAddress); Value:= Value + 1; if Value = 255 then Value:= 0; end; I'm not sure exactly how to declare the library functions and what to declare the variables as (&H378 is obviously not an integer) thanks. PortAddress is declared as an Integer, so don't use strings. Your code should look something like this: //Inp and Out declarations for port I/O using inpout32.dll.

Function Inp(PortAddress: Integer): Integer; stdcall; external 'inpout32.dll' name 'Inp32'; procedure Output(PortAddress, Value: Integer); stdcall; external 'inpout32.dll' name 'Out32'; procedure TForm1.FormActivate(Sender: TObject); begin //Test program for inpout32.dll Value:= 0; //Change PortAddress to match the port address to write to: //(Usual parallel-port addresses are $378, $278, $3BC) PortAddress:= $378; end; procedure TForm1.Button1Click(Sender: TObject); begin //Write to a port. Output(PortAddress, Value); //Read back and display the result.

Edit1.Text:= IntToStr(Inp(PortAddress)); Value:= Value + 1; if Value = 255 then Value:= 0; end. @notidaho: That 255 decimal (FF hex) value is the expected value for 'there is nothing at this address'. A long time ago, in DOS you could directly access hardware at its 'base address' which was the address where it mapped to using the ISA expansion cards. To keep that capacity in a modern operating system, you are using a device driver and a DLL that give you access to those IO addresses. Printer ports were usually an expansion card with jumper switches to set the base address on the ISA bus. $378 is the default address of LPT1 on an original IBM PC.

– Nov 23 '11 at 14:27.

• • • Contents at a Glance • • • • • • • • • • The parallel port, or printer port, is one of the easiest pieces of hardware available to users for communicating with external circuitry or homemade hardware devices. Most people think that interfacing with an external circuit is hard and never come up with a solution. However, in this article, I am trying to convince you that porting with another external device is very easy and it has only a few tricks to be remembered! I will also be discussing a sample surveillance application that can be developed with few requirements. It is very simple and anyone who reads this article can use it at home. I will then be giving an introduction to Serial Port Programming, which will be my next article on The Code Project.

In that section, I will illustrate some basics of Serial Data Transmission and how to use a more advanced serial port instead of a parallel port. The application that I have given is developed in Visual Basic.NET and it uses inpout32.dll for direct port access.

In Windows XP and NT versions, direct port accessing is prohibited, so we need to have a driver in order to communicate with ports directly. Therefore we are using a freeware driver, inpout32.dll, which can be found. WARNING Parallel Ports that are built into your machine can be damaged very easily! So, use all of my sample code at your own risk. All of these sample programs and circuits are thoroughly tested and they will never lead you to damage your hardware or your computer. I have never experienced such a bad incident!

However, use these programs with great care The parallel port usually comes as a 25-pin female port and it is commonly used to connect printers to a computer. Many geeks also use it to connect their own devices to their PCs. There is a few more things to remember when using a PC's Parallel Port. It can load only 2.5mA and ~2.5 volts. It is better to use opto-couplers or ULN2803 when interfacing with an external device. If you're just thinking of lighting up an LED through a Printer Port, try to connect a 330 ohm resistor in between.

There is some more useful information to consider when programming a Printer Port: the usual Printer Port is a 25-pin female D-shaped port and it has several registers. A register is a place where you can write values and retrieve them. There are different types of registers called Data Register, Control Register and Status Register. Data Register This is the register that allows the user to write values into the port. In simple words, these pins can be used to output a specific value in a data register.

You can also change voltages in specific pins. These are called output pins. There are altogether 8 output pins available, ranging from D0 to D7. Status Register (Pins) These are called input pins or status registers and can hold a value that the outside world gives to the Parallel Port.

So, this port acts like a reader and it has 5 pins for inputs. The pin range is S4 to S7. Control Register (Pins) This register can be used in both ways: it enables a user to write values to the outside world, as well as read values from the outside world.

However, you need to remember that most of the control pins work in an inverted manner. You can see them with a dash sign on the top of the pin. Pin range is C0 to C3. Ground pins are used as neutral; these pins are used as (-) in batteries. If you're connecting a device to a Parallel Port in order to read or write, you have to use one or more ground pins and a read/write pin to work. For example, if you're trying to light up an LED, then you have to connect the (-) of the LED to a ground pin and the (+) of the LED to an output pin.

For reading purposes, use the same mechanism. 8 Output pins [ D0 to D7] 5 Status pins [ S4 to S7 and S3] 4 Control pins [ C0 to C3] 8 ground pins [ 18 to 25] Port addressing controls a great deal in port programming, as it is the door that enables programs to connect to the external circuit or device. Therefore I would like to explain all the available port addresses. In normal PCs, a parallel port address can be one of the addresses given below, but depending on the BIOS settings and some other issues, the parallel port address can vary. However, it always lies in one of these address ranges. LPT1 03BC (hex) 956(decimal) LPT2 0378(hex) 888(decimal) LPT3 0278 (hex) 632(decimal) As I mentioned above, those are the commonly used address ranges for parallel ports.

Now you might be wondering how we communicate with each of them and how they work. It's very simple! Each of those above-mentioned address ranges has its own address for Data Register, Control Register and Status Register. So, if you want to access a Data register of port 888, then the Data register is also 888. However, if you want to access a status register, then add +1 to the 888 = 889 and this is the status register. To access a control register, what you have to do is add another +1 so that it is 890 and that is the Control register of the 888-based parallel port. If your parallel port address is different, please do this accordingly to find its corresponding registers.

There is another simple way to check the parallel port address of your computer. You can get to know the parallel port I/O addresses through the device manager. First, open the device manager (Start ->Settings ->Control Panel ->System ->Hardware ->Device Manager). Then select the parallel port you are interested in from the Ports (COM & LPT) section. With the mouse's right button, you can get the menu where you select Properties. When you go through steps, you will see a dialog similar to this. Locate the first item in the listbox and it carries the value 0378 – 037F so that this is the address range of the Printer Port.

Berpikir Dan Menjadi Kaya Pdf Merger. The data register address is 0378 in hex or 888 in dec. Here in this article, we are using a third party tool called inpout32.dll to connect to ports available in your PC. We are using it because in Windows NT based versions, all the low-level hardware access is prohibited and a separate I/O driver is needed. When we read the status of the port, we have to take the support of that third party application. In inpout32.dll, all of the system drivers and small tools needed to activate and run that system driver are included. So, we don't have to consider much or think about how this happens; it will do everything for us As far as we are using a DLL file to communicate with the hardware, we have to know the links that this particular file provides for the user, or the entry points for that particular file. Here, I will describe all the entry points one by one.

DLL Entry used to read Public Declare Function Inp Lib ' inpout32.dll' Alias ' Inp32' _ ( ByVal PortAddress As Integer) As Integer DLL Entry used to output values Public Declare Sub Out Lib ' inpout32.dll' Alias ' Out32' _ ( ByVal PortAddress As Integer, ByVal Value As Integer) The Inp32 function can be used to read values from any address that is given through its PortAddress parameter. Also, the Out32 function is specifically used to write values to data ports. A long description on both functions can be found below. Inp32 is a general-purpose function defined inside inpout32.dll to communicate with various hardware addresses in your computer. This function is included in a DLL, so this file can be called within any programming language that supports DLL import functions. Here, for this sample application, I have used Visual Basic.NET because it can be used by any person who knows a little about the.NET Framework. What you have to do to read the status of a parallel port is very simple.

I will explain everything in steps, but keep in mind that in the sample coding I assume that the Address of the status register is 889 or 0x379h in hex. • Open Visual Studio.NET (I made this in the.NET 2005 version).

• Make a new Visual Basic.NET Windows application. • Go to the Project menu and Click on 'Add new Item.' Then select the Module item in the listbox.

• Type any considerable name for the new module that you're going to create, for example, porting.vb. • In the Module file, there should be some text like this: Module porting Public Declare Function Inp Lib ' inpout32.dll' _ Alias ' Inp32' ( ByVal PortAddress As Integer) As Integer End Module • Go to your form and add a new text box. Then add a Command button and, in the click event of the command button, paste this code: ' Declare variables to store read information and Address values Dim intAddress As Integer, intReadVal As Integer ' Get the address and assign intAddress = 889 ' Read the corresponding value and store intReadVal = porting.Inp(intAddress) txtStatus.Text = intReadVal.ToString() This will work well only if the name of the text box you just made is txtStatus. • Run your application and click on the button so that the text should be 120 or some similar value. Then that is the status of your parallel port. • If you want to check whether this application runs properly, you just have to take a small wire (screen wire or circuit wire is ok) and short a Status Pin and a Ground Pin. For example, Status pins are 10,11,12,13,15 and if you short the 10th pin and 25th (Ground) pin, then the value in the textbox will be 104.

If you short some other pins, like the 11th and 25th, then the value of the text box will be 88 or a similar value. Now you can clearly see that all the power is in your hands. If you're a creative person with a sound knowledge of electronics, then the possibilities are endless Note! Before you run and compile this application, download inpout32.dll from this page and copy it to the Bin folder of your project directory, the place where the executable file is made, so that the DLL should be in the same directory to work. Alternatively, you can just copy and paste the DLL file to your Windows System directory and then you don't want to have that file in your application path. You only have to follow one guide. When writing data to the Data Register, you have to follow the same rules.

There is no difference in basics! As you learned in the above context, do the same thing here with a few differences. I will explain to you what they are, but keep in mind that in the sample coding I assume that the address of the data register is 888 or 0x378h in hex. • Go to the Project menu and Click on 'Add New Item.' Then select the Module item in the list box, the same as above. • Type any considerable name for the new module that you're going to create, for example, porting.vb.

• In the Module file, there should be some text like this: Module porting Public Declare Sub Out Lib ' inpout32.dll' _ Alias ' Out32' ( ByVal PortAddress As Integer, ByVal Value As Integer) End Module • Go to your form and add a Command button. In the Click event of the Command button, paste this code: intVal2Write As Integer ' Read the corresponding value and store intVal2Write = Convert.ToString(txtWriteVal.Text) ' porting is the name of the module porting.Out( 888, intVal2Write) This will work properly only if the name of the text box you just made is txtWriteVal. • Run your application and click on the Button so that the parallel port will output voltages in pins according to the value you entered in the text box. Now to test the value that you output. Assume that you wrote value 2 to the data register and you want to know which pin outputs +5V. It's really simple to check. The data register starts from pin number 2 and ends in pin number 9, so there are 8 pins for output.

In other words, it's an 8-bit register. So, when you write 2 to its data register, +5 voltage will be there in the 3rd pin. You have to take a scientific calculator and convert Decimal 2 to Binary; then the value is 2(DEC) = 1 0(BIN), so 1 0 means 0 0 0 0 0 0 1 0 is the status at the data register. Example 2 If you write value 9 to a data register, then the binary of 9 is 0 0 0 0 1 0 0 1. So, +5V can be taken from the 2nd pin and the 5th pin.

Binary Value 0 0 0 0 1 0 0 1 Data Register D7 D6 D5 D4 D3 D2 D1 D0 Actual Pin number 9 8 7 6 5 4 3 2 Example 3 Assume you're writing 127 to a data register. Then the binary of 127 is 0 1 1 1 1 1 1 1 and therefore all the pins will be +5V, excluding the 9th pin. Binary Value 0 1 1 1 1 1 1 1 Data Register D7 D6 D5 D4 D3 D2 D1 D0 Actual Pin number 9 8 7 6 5 4 3 2 When you want to light up an LED, there is a special way to connect them to a data register. So, you need some tools to connect. As a tutorial, I will explain how to connect only 1 LED.

Here you have to connect a ground pin to any pin starting from the 18th to 25th. All are ground pins, so there is no difference. The output pin or positive of the LED should be connected to a pin in the data register. When you write a value which enables that particular data register pin, then the LED will light up. Never connect devices that consume more voltage than LEDs, as this would burn your parallel port or entire motherboard. So, use them at your own risk.! I recommend that you refer to the method written below if you're going through more advanced methods.

If you want to switch electric appliances on and off, then you will obviously have to use relays or high voltage Triacs. I recommend using relays and connecting them through the method I have illustrated below. If you're not satisfied with lighting up LEDs and you're hungry to go further, then use this method to connect all your advanced or more complex devices to the Parallel Port. I would recommend that you consider using ULN2803 IC. This is an 8-channel Darlington Driver and it is possible to power up devices with 500mA and +9V with it. Here in this diagram, you can see how to connect a set of LEDs to this IC. Also remember that you can replace these LEDs with any devices such as relays or Solenoids that support up to 500mA and they will run smoothly.

The surveillance system that I have written is very small and can only be used at home or for personal use. However, you can make it more advanced if you know how more complex security systems work. Here, the application has a timer and it always checks for status register changes. If something changes, then the application's status will be changed and a sound will be played accordingly. This can be used to check whether your room's door is closed. What you have to do is place a push to turn on the switch on the edge of the door and you have to place it in a manner which activates when the door is opened. If you're not using a push to turn on the switch, then just place two layers of thin metal that can be bent and place them on the door.

However, those two layers of metal should be able to make a short circuit when the door is closed. One piece of metal layering should be soldered to a screen wire (circuit wire) and that should be connected to the ground pin. The other layer of metal piece should be connected to a status pin of the parallel port. Status pins are 10, 11,12,13,15.

I have learned to program hardware ports since the year 2000. As far as I can remember, most of the time I used to get resources from Google.com, and I have used the links I found there. However, keep in mind that creativity cannot be searched from the web.

It should be in your mind. So be creative and support the community. Member 11755621 10-Jun-15 1:58 10-Jun-15 1:58 I am a beginner and I have to make a project that will be connected to 4 switches that are used to on/off lights of different colours. How can I connect my computer to the switches to know when a particular switch is turned on /off.? How can I program this in visual studio (preferably c#).

I just need to read the status of the switch to build a simple application showing the timestamp of switching on and off the switch. I would be really grateful to you. You are most welcome. I will inform you as soon as I have made my circuits for the parallel port and of course finished my program. There are some issues about Windows 7 & 8 and parallel interfacing, but this can be overcome see I have only tested writing to 8 LED’s using the Data pins (2 – 9) on a Windows 7 32 & 64 bit PC. The code used for that looks just like yours.

Do you know how to set the bit no. 5 of the control bus in VB.Net and if the Data pins in input mode shall be connected like the Status pins? This should be the bit to turn the Data pins to input pins. Cheers, Henrik. PRIYKANT 8-Jun-12 20:16 8-Jun-12 20:16 thank you very much.right now I am final year student of electronics & communication working on a project that includes automation of a plant for energy generation. I need to interface computer with microcontroller as the plant owner wants to make plant fully automatic and controlled by a click on computer screen.

I have just read your article. I do not know what happen at the time I practically implement it or whether how much this article will help me out but it taught me something so thank you again. P.S.: one more thing I would like to as whether you help me and guide for my project if in case I need? PRIYKANT 8-Jun-12 20:15 8-Jun-12 20:15 hank you very much.right now I am final year student of electronics & communication working on a project that includes automation of a plant for energy generation.

I need to interface computer with microcontroller as the plant owner wants to make plant fully automatic and controlled by a click on computer screen. I have just read your article. I do not know what happen at the time I practically implement it or whether how much this article will help me out but it taught me something so thank you again.

P.S.: one more thing I would like to as whether you help me and guide for my project if in case I need? Rddezh 10-Dec-11 1:10 10-Dec-11 1:10 Hi! First, I would like to thank you for that tutorial, it is great. Everythink works fine for me, but I don't know how to use control register as an output? Can you please write some code, how to do that using the inpout32.dll. Thanks a lot! Last Visit: 31-Dec-99 19:00 Last Update: 31-Dec-17 7:34 1 General News Suggestion Question Bug Answer Joke Praise Rant Admin Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

It is a formal letter and should be written in the suitable format. Make sure to reiterate facts like the post from which you are resigning and the effective date of your release. It is also imperative to give genuine and valid reasons for leaving a job. It is a good time to thank the organization, peers and superiors for the work-experience and overall growth you have garnered. This gesture helps you leave with good will and can stand you in good stead when you are looking for a reference letter.