Go Down

Topic: Reading serial data from motor controller via RX/TX (Read 2001 times) previous topic - next topic

MartinAbom

I want to read hex data that a motor controller from Golden Motors transmits through RX/TX. Originally three wires (RX, TX and GND) from the motor controller is connected to a USB connector and used with a supplied software on a PC. I used "USBlyzer" to listen on the USB port while the program was running so I know what to send to call a transmit and how the received package should look and how to interpret it into things like rpm, voltage and so on.

The transmitted command is as picture "command". The expected reply is as picture "reply".

I use a Arduino Uno (also tried Pro 3.3V) with softwareSerial library to connect the RX/TX line (as I am using the hardware RX/TX to send via XBee to remote computer).

The problem is when I send the command I get incomplete HEX data in return. The reply is different in length and content from time to time but never longer than 30 or so bytes of expected 64 (usually 24-28 bytes). I can recognise the correct individual bytes but I can't seam to read it all.
The code in it's simplest form is this:

Code: [Select]


SoftwareSerial motorController(12, 13); // RX, TX

byte controllerPacket[] = {0x81, 0x7E, 0x00, 0x00, 0x04, 0x00, 0x00, 0xFF, 0xFC, 0x0D, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC};

byte outArray[64];

void setup() 
{

  // set the data rate for the SoftwareSerial port
  motorController.begin(9600);
 
  motorController.write(controllerPacket, sizeof(controllerPacket));


  delay(2000);
 
  for (int i = 0; i < 64; i++)
  {
    outArray[i] = motorController.read();
  }
 
  for (int i = 0; i < 64; i++)
  {
    Serial.print(outArray[i], HEX);
    Serial.print(" ");
  }
   
}


Example of some replies:

Code: [Select]
7E 0 0 90 16 0 3 FF FD DC 0 0 0 0 0 0 0 96 0 FB BC 0
7E 0 0 4 16 0 3 FF FD DC 0 0 0 0 0 0 0 96 0 FB BC 0
7E 0 0 4 16 0 3 25 FE 0 0 4 0 0 1 1 1 2 2 4 64 6 4 68 4 0
7E 0 0 4 16 0 3 25 FE 0 0 4 0 0 0 0 0 0 0 0 BB D 0
7E 0 0 4 16 0 6 4A FD B8 8 1 1 2 2 2 4 4 4 8 C8 C 10 D0 DF B7 21 0
7E 0 0 4 90 0 0 25 FF 0 DC 4 0 0 0 0 0 0 96 0 FB D 0

(I think these printouts are from a different code as there are no "FF"s in the end, but it looks like this regardless of print approach)

Please help me if you can :-)

bzrncev

Have you made any progress so far? I am trying to do the same thing, but I get the same response.

holmes4

What make you think that you can read a USB signal with Serial! You can't!

Mark

alfrond

Hi all!
I'm heavily interested in any progress on this, as I'm too hoping to extract running data from the controller and hopefully manage to control it on the run.
Please get in touch if you see this!

//alfred

Go Up