I am trying to do some experiments on the Trinamic StepRocker Stepper Motor Controller in Gnu/Linux. I had attahched the device through USB to a Windows machine previously and used Trinamic's proprietary software to test if the controller is functional as expected, and it seems to be. The beginner's manual of the StepRocker mentions certain commands that should be sent over the serial interface to rotate the motor left, right, or bring it to a halt. But when I connect this controller over USB to a Gnu/Linux computer, and want to write my own C++ (libusb) program to make the motor move, I am not quite sure what my starting point should be. The console application (which I plan to write) should be non-blocking.
Here is an image of the datagrams being sent and response received while a rotate command is issued:
I tried to write a simple program to feed the rotation value datagram shown in the picture to the motor controller:
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <unistd.h>
int fd1;
int wr;
int main()
{
fd1=open("/dev/ttyACM0", O_RDWR | O_NOCTTY | O_NDELAY);
if (fd1 == -1 )
{
perror("open_port: Unable to open /dev/ttyACM0");
}
else
{
fcntl(fd1, F_SETFL,0);
printf("Port 1 has been sucessfully opened and %d is the file description\n",fd1);
char moveMsg[9]={0x01,0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0xbc, 0xc0};
wr = write(fd1, moveMsg, 9);
}
close(fd1);
return 0;
}
But this does not alter the LED behaviour of the controller in any way (and does not move the motor, of course).