Click here to Skip to main content
15,881,852 members
Articles / Programming Languages / C#

Controlling a Real Measurement "3153 Hioki Hipot" Device by Using Serial and Parallel Ports in C#

Rate me:
Please Sign up or sign in to vote.
3.43/5 (3 votes)
2 Feb 2008GPL37 min read 43K   552   34  
Controlling the 3153 Hioki Hipot device by using serial and parallel ports in C#.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;

namespace ParallelPort
{      
    public partial class HipotParPort : Form
    {
        public static int nAddress = 888;  //Default is LPT1. If you want to use LPT2 choose 632
        public static Int32 onValue = 1; //decimal 1 -> only D0 is high.
        public static Int32 offValue = 0; //decimal 0 -> all data pins of the ParallelPort is low.
        public static int nDelay = 1000; // put some time between ON/OFF states in case of burning...                                                                

        public class PortAccess 
        {
            //http://logix4u.net/Legacy_Ports/Parallel_Port/Inpout32.dll_for_Windows_98/2000/NT/XP.html
            //Check the upper url to learn how the inpout32.dll works
            //Note that inpout32.dll must be put to the C:\Windows\System32 folder.
	        [DllImport("inpout32.dll", EntryPoint="Out32")]
	        public static extern void Output(int nAddress, int nDecimalValue);                        
        }  //public class PortAccess

        public static void HipotParPort1(Boolean bBulbOn)
        {            
            Application.DoEvents();

            if (bBulbOn)            
                PortAccess.Output(nAddress, onValue);                            
            else            
                PortAccess.Output(nAddress, offValue);            
            
            Thread.Sleep(nDelay);
        }

        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // HipotParPort
            // 
            this.ClientSize = new System.Drawing.Size(104, 47);
            this.Name = "HipotParPort";
            this.ResumeLayout(false);
        } //public static void HipotParPort1(Boolean bBulbOn)
    }
                                                             
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Engineer
Turkey Turkey
Design engineer in the Aerospace field.

Comments and Discussions