Pulser3NET API Reference Guide
Pulser3 Device Communication Library • .NET Class Library • C#
1. Overview
Pulser3NET is a .NET class library designed to communicate with Pulser3 motion control devices over a network. It brings together device connection management, symbolic variable (tag) definition, data read/write, and FTP-based transfer of G-code files under a single interface.
The main entry point is the Pulser3NET class. Internally it uses a DeviceManager and an SGProject object to manage the device list, the variable dictionary, and the communication state.
Key Features
- Communication with the Pulser3 device over Modbus TCP (default port 502).
- Symbolic, tag-based addressing — use meaningful names instead of raw numeric addresses.
- Efficient data exchange through buffered batch reads.
- Read/write of Bool, Number (signed 16/32-bit) and String data types.
- Asynchronous upload of G-code files to the device via FTP.
2. Architecture and Concepts
| Component | Description |
|---|---|
| Pulser3NET | The main class your application interacts with. All read/write and connection operations go through it. |
| DeviceManager | Internal manager responsible for opening, closing, and accessing data on devices. |
| SGProject | Project object holding the device list (devices) and variable definitions (variables). |
| Variable (Tag) | A symbolic definition mapped to a device address and accessed by name. |
| Buffer | Mechanism that reads multiple variables in a single batch operation. |
3. Quick Start
The following steps show a typical workflow: creating the object, adding variables, connecting, reading/writing data, and disconnecting.
3.1 Creating the Object
A Pulser3NET object is created with the device IP address and port number. The constructor automatically adds the device to the project.
var pulser = new Pulser3NET.Pulser3NET("192.168.1.100", 502);
3.2 Defining Variables (Tags)
Use AddVar to assign meaningful names to device addresses. After all variables are added, call CreateDict to build the dictionary.
pulser.AddVar("hmi_Start", "Pulser3", "1200.1", "Start bit");
pulser.AddVar("hmi_Stop", "Pulser3", "1200.2", "Stop bit");
pulser.AddVar("dint_XAbs", "Pulser3", "...", "X absolute pos");
pulser.CreateDict(); // Build the variable dictionary
3.3 Connecting and Disconnecting
bool ok = pulser.Connect(); // ... read / write operations ... pulser.Disconnect();
4. API Reference
4.1 Constructor and Connection Management
Pulser3NET(string ip, int port)
Creates a new Pulser3NET instance and adds the Pulser3 device to the project using the given IP/port.
Parameters:
ip— Device IP address (e.g. "192.168.1.100").port— Modbus TCP port (default 502).
bool Connect()
Starts communication with all devices in the project.
Returns: true if the operation was started.
bool Disconnect()
Closes all device connections.
Returns: true when completed.
4.2 Variable (Tag) Management
void AddVar(string tag, string device, string address, string description)
Adds a new symbolic variable to the project, enabling access to a device address by name.
Parameters:
tag— Unique variable name (e.g. "hmi_Start").device— Name of the owning device (e.g. "Pulser3").address— Address on the device (e.g. "1200.1").description— Optional description.
void CreateDict()
Builds a dictionary from all added variables for fast lookup. Call once after all AddVar calls.
4.3 Reading and Writing Data
bool ReadBool(string address, ref bool value)
Reads a boolean value from the given address (from the buffer). Use ReadBoolDirect to read directly from the device.
Parameters:
address— Variable name or address.value— Reference that receives the read value.
Returns: true on success.
bool WriteBool(string address, bool value)
Writes a boolean value to the given address.
Parameters:
address— Variable name or address.value— Value to write.
Returns: true on success.
bool ReadNumber(HMI_DataFormat dataFormat, string address, ref long value)
Reads a numeric value from the given address. ReadNumberDirect is available for direct reads.
Parameters:
dataFormat— Data format (e.g. Signed_16bit, Signed_32bit).address— Variable name or address.value— Reference that receives the value.
Returns: true on success.
bool WriteNumber(HMI_DataFormat dataFormat, string address, long value)
Writes a numeric value to the given address.
Parameters:
dataFormat— Data format.address— Variable name or address.value— Value to write.
Returns: true on success.
bool ReadString(string address, int word_length, ref string value)
Reads a text value from the given address.
Parameters:
address— Variable name or address.word_length— Number of words to read.value— Reference that receives the text.
Returns: true on success.
bool WriteString(string address, int word_length, string value)
Writes a text value to the given address.
Parameters:
address— Variable name or address.word_length— Number of words to write.value— Text to write.
Returns: true on success.
4.4 Buffered Reading
Use the buffer mechanism to read multiple variables efficiently in a single pass.
void BeginBuffer()
Starts a buffered read cycle; clears previously buffered data.
void Buffer(HMI_DataType dataType, HMI_DataFormat dataFormat, string address, ushort word_length)
Adds a variable to the read buffer. The actual read happens on ReadBufferedData.
Parameters:
dataType— Data type (e.g. Bool, Number).dataFormat— Data format (e.g. Signed_32bit).address— Variable name or address.word_length— Word count (0 for bool).
void ReadBufferedData()
Reads all buffered variables from the device in one operation. Retrieve values afterward with ReadBool / ReadNumber.
4.5 G-Code File Transfer
void SelectGCode(string fileName)
Asynchronously uploads the given G-code file to the Pulser3 device over FTP.
Parameters:
fileName— Full path of the G-code file to upload.
5. Complete Usage Example
The example below covers object creation, variable definition, connecting, buffered reading, and writing. It demonstrates timer-based periodic reading in a Windows Forms application.
5.1 Initialization and Variable Definition
pulser = new Pulser3NET.Pulser3NET(txtIP.Text,
Convert.ToInt32(txtPort.Text));
// Add custom variables
pulser.AddVar("hmi_Reset", "Pulser3", "1200.0", "");
pulser.AddVar("hmi_Start", "Pulser3", "1200.1", "");
pulser.AddVar("hmi_Stop", "Pulser3", "1200.2", "");
pulser.AddVar("hmi_RAPID", "Pulser3", "1201.12", "");
pulser.AddVar("bit_ESP", "Pulser3", "1220.0", "");
// Build the variable dictionary
pulser.CreateDict();
5.2 Connecting
bool result = pulser.Connect();
if (result == true)
{
timer1.Start();
_connected = true;
}
5.3 Periodic Buffered Reading
pulser.BeginBuffer();
pulser.Buffer(HMI_DataType.Bool, HMI_DataFormat.Signed_16bit, "bit_ESP", 0);
pulser.Buffer(HMI_DataType.Bool, HMI_DataFormat.Signed_16bit, "hmi_RAPID", 0);
pulser.Buffer(HMI_DataType.Number, HMI_DataFormat.Signed_32bit, "dint_XAbs", 0);
pulser.Buffer(HMI_DataType.Number, HMI_DataFormat.Signed_32bit, "dint_YAbs", 0);
pulser.ReadBufferedData();
pulser.ReadBool("bit_ESP", ref eStop);
pulser.ReadBool("hmi_RAPID", ref rapid);
pulser.ReadNumber(HMI_DataFormat.Signed_32bit, "dint_XAbs", ref xAbs);
pulser.ReadNumber(HMI_DataFormat.Signed_32bit, "dint_YAbs", ref yAbs);
5.4 Writing Values
// Toggle a bit from a button
eStop = eStop ^ true;
pulser.WriteBool("bit_ESP", eStop);
// Press-and-hold (jog) example
pulser.WriteBool("hmi_XP", true); // MouseDown
pulser.WriteBool("hmi_XP", false); // MouseUp
5.5 Disconnecting
timer1.Stop(); pulser.Disconnect(); _connected = false;
6. Notes and Tips
- Call
CreateDictexactly once, after allAddVarcalls. - In buffered reading, always begin the cycle with
BeginBuffer, then finish withReadBufferedDataafter theBuffercalls. ...Directmethods (e.g.ReadBoolDirect) read straight from the device instead of the buffer; suitable for one-off, infrequent reads.- G-code transfer is asynchronous; for large files the upload continues in the background.
- When buffering bool variables, pass
word_lengthas 0.
