HartX70 Getting Started

 

Creating a C# Project

 

1. Open Visual Studio.

 

2. Create a new project by selecting File->New->Project and fill out the form.

 

 

3. Click OK.

 

The HartX70 component is not installed automatically into Visual Studio. It is more convenient to use only a reference to the BaHartX70.dll. In this case you have only to make sure that the DLL is available on the target computer you copy your application to. The only thing is that you have to take care that .NET 2.0 is also installed on the target machine.

 

4. Open the Toolbox (View->Toolbox).

 

 

5. Right Click on the category where you like to place the HartX70 control and select 'Choose Items...'.

 

 

6. Click 'Browse'.

 

 

7. Select the BaHartX70.dll, which is located in the Windows System directory. Click open.

 

Now the control appears in the list of the .NET components.

 

 

8. Click OK and the control appears on the Toolbox.

 

 

9. Pick it from the Toolbox and drop it onto the form.

 

 

10. It does not appear on the form because it is only a class library which is not visible.

 

If you like you can give it another name in the properties window.

 

 

11. Set the com port property to the com port which you like to use with your Hart device.

 

 

All what is needed now to get a first Hart communication is a button for launching an action and a text box for displaying the result.

 

 

It is very few code that is needed. The most things of Hart communication are handled by the control.

 

using System.Text;

using System.Windows.Forms;

namespace TestHartX

{

  public partial class Form1 : Form

  {

    public Form1()

    {

      InitializeComponent();

    }

    private void butGetTag_Click(object sender, EventArgs e)

    {

      butGetTag.Enabled = false;

      butGetTag.Refresh();

      txtTagName.Text = "-/-";

      txtTagName.Refresh();

      if (HartX.DoCommand(13) == BaHartX.EN_LastError.ERR_Success)

      {

        txtTagName.Text = HartX.p13TagName;

      }

      else

      {

        txtTagName.Text = "Error!";

      }

      butGetTag.Enabled = true;

    }

  }

}

 

12. Build the solution and start the program.

 

If the communication was successful you will get a display like the following.

 

 

If there was an error (no device response) it will be shown in the Textbox.

 

 

If the tag name is read the first time it will take about 600 ms because the control has to get the unique identifier from the device (command 0). This is done automatically. The next time the 'Get Tag Name' button is clicked it works faster.


 

Contact

 

Im Wingert 4
DE-65626 Fachingen

GERMANY

Voice: +49 (0)6432 989176

Fax: +49 (0)6432 989129

Home: http://borst-automation.com

Email: info@borst-automation.de