Docs.

Docs.

Design.

Design.

Gallery.

Gallery.

Help.

Help.

Python example

Python example

C# example

C# example

Matlab example

Matlab example

Tutorials.

The tutorials can show how to realize specific demo applications

Code Examples

The HDrive Servo can be controlled by various interfaces. Find tutorials and code examples below for a smooth start.

For the Ethernet interface, we suggest using a TCP-Client/Server connection to the motor. Therefore you need to open a TCP socket to the HDrive. The Servo is acting as a server and is able to handle one client connection.

The web interface can be used to observe the TCP connection in parallel.

import socket with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect(('192.168.1.102', 1000))
s.sendall(b'<control pos=\"1000\" speed=\"500\" current=\"200\" mode=\"129\" acc=\"1000\" decc=\"1000\" />')
using System;
using System.Net.Sockets;
using System.Text;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            //create instance from TCPClient Object
            var client = new TcpClient("192.168.1.102", 1000);

            //if a client has found, the program continues
            Console.WriteLine("client found!");

            //create an instance of the C# Stream class and get the Stream to the client
            var networkStream = client.GetStream();
            byte[] encodedBytes = System.Text.Encoding.ASCII.GetBytes("");

            //send the drive order to the HDrive
            networkStream.Write(encodedBytes, 0, encodedBytes.Length);

            //continuously read data comming from the HDrive
            byte[] buffer = new byte[85]; // read in chunks of 85 Byte 
            int bytesRead;
            while ((bytesRead = networkStream.Read(buffer, 0, buffer.Length)) > 0)
            {
                Console.WriteLine(Encoding.Default.GetString(buffer));
            }
        }
    }
}

SEND DRIVE ORDER

t=tcpip('192.168.1.102', 20000, 'NetworkRole', 'client'); %configure TCP Client and Port
fopen(t); % open TCP Connection
fwrite(t, '<control pos=\"1000\" speed=\"500\" current=\"200\" mode=\"129\" acc=\"1000\" decc=\"1000\" />') % send XML drive order
pause( 5 ) % wait 5 seconds ( because the motor would stop if you close the connection before )
fclose(t);

RECEIVE HDRIVE TICKET (TCP-MODE)

please notice: The HDrive is sending the Tickets with up to 2 kHz. This means you have to read very fast to always get the newest ticket. Therefore it is recommended to read the ticket in a loop or to reduce the send frequency by setting up a pre-scaler with the web interface.

clear all;
t=tcpip('192.168.1.102', 1000, 'NetworkRole', 'client'); %configure TCP Client and Port
fopen(t);%open TCP Connection
A = fread(t, 150); %receive one HDrive ticket
% convert received bytes into string
recieved_string = sprintf('
% interpret string
time_ms = str2num(recieved_string(137:146));
position = str2num(recieved_string(23:32));
calibration = str2num(recieved_string(59:62));
speed_RPM = str2num(recieved_string(42:49));
% close connection
fclose(t);

RECEIVE HDRIVE TICKET (UDP-MODE)

In this scenario, the HDrive has to be configured to send UDP tickets to the host. This configuration can be done in the Web interface

hold on;
clear all;
%configure and open UDP Connection
u=udp('192.168.1.102','RemotePort',2000,'Localport',1001);
set(u,'DatagramTerminateMode','off');
u.ByteOrder = 'littleEndian';
fopen(u);
% read UDP data and convert to 32bit integers
data = fread(u, 3, 'int32');
%store data to local variables
time = data(1);
position = data(2);
speed = data(3);
% close connection
fclose(u);

Transform Your Ideas Into Reality and Launch Your Product.

Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

0