Welcome, Guest
Messages posted to this category need to be reviewed by the moderator before it gets posted.
  • Page:
  • 1
  • 2

TOPIC: Sending commands through Arduino with RS232 Shield

Sending commands through Arduino with RS232 Shield 8 months 2 weeks ago #2377

Found a way to input HEX format through arduino but the motor is not moving to target position, Please find the program below used to move the motor 1 to a target position.

the command used is <129> PT=19590 G (used through termite and it works)
the command used is (81 50 54 3D 31 39 35 39 30 20 30 20 47 20) (through arduino to motors)

Tested the program in the computer through RS232 Termite terminal and it looks like arduino is pushing right command but the motor is not moving though same command in characters in termite window works.


// Serial Communication
// 2019
// Purpose: Control the motor position using RS232 communications
// Status:

#include <SoftwareSerial.h>

// Do not use 0 and 1 if you want to be able to upload code while RS232 shield is attached to Arduino
SoftwareSerial mySerial(3, 2); //2 is TX, 3 is RX

// Motor Commands

byte preset1[4] = {0x52, 0x50, 0x41, 0x20}; // RPA
byte preset2[12] = {0x81, 0x50, 0x54, 0x3D, 0x31, 0x39, 0x35, 0x39, 0x30, 0x20, 0x47, 0x20}; // <129> PT=19590 G



int delayTime = 500; //Time between commands

void setup()
{
Serial.begin(9600); // Serial Communication w/ Computer for Debugging
mySerial.begin(9600); // Serial Communication w/ motor

//for (int i = 0; i < (sizeof(preset1)); i++) // sizeof returns a count of bytes, not numbers if using int, float, or long
//{
//mySerial.write(preset1); // sends each byte sequentially
//Serial.println("motor comand 1 Byte Sent");
//}

for (int i = 0; i < (sizeof(preset2)); i++) // sizeof returns a count of bytes, not numbers if using int, float, or long
{
mySerial.write(preset2); // sends each byte sequentially
Serial.println("motor comand 1 Byte Sent");
}

delay(delayTime); //delay to allow motor time for next command


}

void loop()
{
}


Thanks and regards,
Amrinder Singh
The administrator has disabled public write access.

Sending commands through Arduino with RS232 Shield 8 months 2 weeks ago #2378

  • mmeyer
  • mmeyer's Avatar
  • OFFLINE
  • Moderator
  • Posts: 34
  • Thank you received: 9
  • Karma: 3
Amrinder,

Do you get a response from the motor for the RPA command in your arduino code? If not, the method of communication is still not correct.

Either way, you will need to send additional commands to the motor in order to see motion. For a position move, you will also need to define MP, VT= , ADT=. You will also need to disable hardware travel limits with EIGN(W,0) once at the beginning of your program.
Last Edit: 8 months 2 weeks ago by mmeyer.
The administrator has disabled public write access.

Sending commands through Arduino with RS232 Shield 8 months 2 weeks ago #2379

Dear Meyer,

Finally motors are responding back to RPA commands and I am able to move the motors using PT= positionnumber G comand send in the HEX format.
The issue was that the RS 232 shield has 2nd pin as TX and 3rd as RX and it was same configuration on the 9 pin of motors. After swapping the pins coming from RS232, motor started responding. code looks good.

Is there any way to get the the only position number from motors rather than having the RPA xxxxx xxxx as reply back from motor.

Thanks for the support and quick replies.
The administrator has disabled public write access.

Sending commands through Arduino with RS232 Shield 8 months 2 weeks ago #2380

  • swalters
  • swalters's Avatar
  • OFFLINE
  • Moderator
  • Posts: 13
  • Karma: 0
See the ECHO command in the dev guide. Please note this is not the default state. Also please note that the ADDR value is not initialized automatically on boot up. These settings are changed when SMI detects or finds motors.
Did you restart it?
The administrator has disabled public write access.

Sending commands through Arduino with RS232 Shield 8 months 2 weeks ago #2381

ECHO_OFF worked smoothly.
Thanks and regards,
Amrinder Singh
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 0.190 seconds
Powered by Kunena Forum