chess57
Posts: 2
Joined: Thu Apr 21, 2016 3:34 am

USB serial communication with Roboteq sdc 2130

Tue May 17, 2016 5:46 pm

Hello all,
I am doing a project where we want to use a raspberry pi to communicate with a motor controller using a usb connection. The motor controller already has this functionality, I am just having trouble getting it to work. I am posting here and on the manufacturers website in hopes to find the issue. Below is the code I am trying to send via usb to the motor controller. I am asking for the motor controllers device ID and expecting it to reply after I send it. If there are any errors in my code or how I am going about this, I would greatly appreciate any help you can provide.

Code: Select all

import serial
import time

ser = serial.Serial('/dev/ttyACM0', 115200, bytesize = serial.EIGHTBITS, parity = serial.PARITY_NONE, stopbits=Serial.STOPBITS_ONE, wiriteTimeout = 0, rtscts = False, dsrdtr=False,xonxoff=False, timeout = 10)

time.sleep(2)
command = '?FID'
ser.write(bytes(command.encode('ascii')))
s= ser.readline
print str(s)

asandford
Posts: 1997
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: USB serial communication with Roboteq sdc 2130

Tue May 17, 2016 10:58 pm

/dev/ttyACM0 is the uart on the gpio pins (pre-pi3). Your device will be something else. Plug it in to a running pi and type dmesg in a terminal to see if the pi can identify it and assign a device driver to it; you should then see something like /dev/ttyuSB0 (or at least another device added).

dwwaddell
Posts: 4
Joined: Sun Nov 02, 2014 10:08 am

Re: USB serial communication with Roboteq sdc 2130

Sun Feb 05, 2017 9:51 am

No, it isn't. The device /dev/ttyACM0 is created automatically when something is plugged into the USB port that supports serial communications. For example, I use it to communicate with a Trinamic Steprocker:

Code: Select all

var SerialPort = require('serialport');
// 01 04 01 00 00 00 19 64 83 MVP rel, 0, 6500
var movp = new Buffer([0x01, 0x04, 0x01, 0x00, 0x00, 0x00, 0x19, 0x64, 0x00]);
function Checksum(buf) {
  var i;
  for(i=0; i<8; i++) {
    buf[8]+=buf[i];
  //  console.log("Value at = ", buf[i].toString(16));
  }
//  console.log("Checksum = ", buf[8].toString(16));
};
Checksum(movp);
var myPort = new SerialPort('/dev/ttyACM0', {
    autoOpen: true
    }, function (err) {
  if (err) {
    return console.log('Error: ', err.message);
  }
  myPort.write(movp, function(err) {
    if (err) {
      return console.log('Error on write: ', err.message);
    }
    //console.log('message written');
  });
});

Return to “Advanced users”