-3

I have a motor connected to my computer, which is connected through CAN to the motor. Basically, I have a USB-to-CAN adapter, to which I connect a USB cable from my computer. Then, from the adapter, the motor is connected through CAN.

Now, I wish to send data to the motor- I already know what sequence of bytes I need to send, but I'm not sure what commands to use to "talk" to my motor that is connected through CAN. I have been able to send data by direct USB connection from my computer to motor (using the WriteFile command in C++), but this method does not work for CAN.

Are there any libraries/functions that I can use to talk to my motor via CAN in C++?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • This is a bit broad. CANBUS has 11 or 29-bit addressing, acceptance filters and all such gunge. We don't know what protocol is used to communicate with the USB<>CAN adaptor to set bus bitrate etc. We don't even know if your CAN network works physically, ie. is correctly terminated etc. – Martin James Jan 30 '14 at 20:25
  • 1
    Every motor controller vendor invents their own protocol, doggedly insisting that their command set is superior to the competitor's. Sometimes it is, controllers are not created equal. Sometimes it is not, but you invested your time so you'll buy it again. You'll have to RTFM. – Hans Passant Jan 31 '14 at 00:33

1 Answers1

2

Since you cannot connect a motor directly to a CAN bus, there must be some sort of motor controller, drive or I/O controller between the bus. Details of this device are required in order to advise on a more than fundamental level.

CAN itself does not define an application layer protocol, and several application protocols exist for CAN, such as CANopen, DeviceNet and SDS. Your device may use such a protocol or possibly something entirely proprietary. Your starting point should be the documentation for your I/O device.

For testing, most PC CAN adapter manufacturers will provide some sort of debug or development tool that allows you to construct and send individual messages and message sequences at a low-level; such a tool will allow you to verify the operation of the bus and I/O device.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Clifford
  • 88,407
  • 13
  • 85
  • 165