Serial Commands to ...
 
Notifications
Clear all

Serial Commands to address and run the program in smart motors via RS232

18 Posts
1 Users
0 Reactions
38.9 K Views
(@gwood24)
Posts: 0
New Member Guest
 

Hi,

I have 2 SM23156DT motors (drive enabled). I am using a Red Lion G306 HMI connected to the motors via 2 separate RS232 ports (not daisy chain). I would like to know the commands to send to the motor in order to address the motors individually (I'll arbitrarily assign the numbers) as well as run the program inside the motors.

I need to do this whenever the motor is powered on. Ideally, I'll have the HMI send raw serial commands to the motor. Question is:

What is the command to address the motor? Once that is complete, I'm assuming I can just send a "RUN" command to the motor via the RS232 connection?

Thank you in advance for your help. Much appreciated.

 
Posted : 07/02/2012 7:51 am
(@csearcy)
Posts: 316
Reputable Member Guest
 

The program in the motor will RUN when power is applied, unless the program has the RUN? command.

The command to set the address of the motor is SADDRx.

You can combine the two if you want the motor addressed, but you don't want the program to run yet.

Example:

SADDR2 'Set motor address
RUN? 'Wait for RUN command to be issued from host.
MP 'Set motor to position mode
.
.
END

 
Posted : 07/02/2012 11:21 am
(@gwood24)
Posts: 0
New Member Guest
 

Ok, I could essentially put that code at the beginning of my program to address the motor on startup. However, since I have two motors and they run exactly the same program, I'd rather not hard code the motor address directly in the program.

Is there a way based on I/O wired connection to the motor, to determine what the address should be based on connections wired directly to the motor's I/O?

Example, I have two motors, one with pins 7 and 8 connected... this would get address x. If the motor was to have its wiring changed, to pins 9 an 10 that would constitute address 2?

Reason for doing this is so that I can have a hot spare motor that could be put into our machine with either an address of 1 or 2 depending on how we wire them? This assumes SM23165DT (drive enabled) motor with DB-15 D-Sub connector

 
Posted : 07/02/2012 12:04 pm
(@csearcy)
Posts: 316
Reputable Member Guest
 

The I/O ports on your motor are pin1-pin7. Pin13 is GND.
1. Connect pin1 to pin13 on Motor1's 15pin connector.
2. Connect pin2 to pin13 on Motor2's 15pin connector.

Here is the code that will set the address...

IF IN(0)==0 SADDR1 ENDIF
IF IN(1)==0 SADDR2 ENDIF

 
Posted : 07/02/2012 12:11 pm
(@gwood24)
Posts: 7
Active Member Guest
 

Thank you for the quick reply. I'll try that.

 
Posted : 07/02/2012 12:16 pm
(@gwood24)
Posts: 0
New Member Guest
 

I've proven that the motor program is running and is addressing the motor correctly, however, the Red Lion HMI cannot communicate with the motor after a power cycle unless we disconnect the motor from the HMI and connect the motor to the computer and run the communication wizard to establish comms between the motor and the PC. After we establish comms between the PC and the motor, we can then disconnect the motor from the PC and then reconnect the motor to the HMI and instantly the HMI sees and communicates with the HMI.

So, the question is, what bit is the SMI software's communications wizard, changing in the motor. This software HAS to be changing something in the motor to enable comms between the motor and the HMI. If I knew what bit, I could have that included in my motor program to eliminate the need to connect to the PC before comms can be established with the motor and the HMI.

 
Posted : 08/02/2012 4:12 am
(@csearcy)
Posts: 316
Reputable Member Guest
 

You may need to add the ECHO command after the IF SADDRx commands (before the RUN? command)to satisfy the HMI requirements.

 
Posted : 08/02/2012 9:38 am
(@gwood24)
Posts: 7
Active Member Guest
 

Below is our motor program... I'm unclear as to where to put the Echo and RUN? commands as I don't fully understand why I would need them

'hardbander SmartMotor Program
'd (motion: on/off) is passed from the HMI and is used to tell the motor if motion is required
'e (motion type: oscillation / jog) is passed from the HMI and is used to tell the motor what type of motion is required (oscillation or Jog)
'f (oscillation left limit) is passed from HMI and is used to tell the motor the left limit of the oscillation cycle
'g (oscillation right limit) is passed from HMI and is used to tell the motor the right limit of the oscillation cycle
'h (Jog move velocity) is passed from HMI

'address the motors based on how the inputs are wired
IF IN(0)==0 SADDR1 ENDIF
IF IN(1)==0 SADDR2 ENDIF

'Main program loop watches for changes in data values passed from HMI and responds accordingly
C1
IF d==1 'HMI indicated motion required (value of d passed from HMI)
SWITCH e 'value of e passed from HMI
CASE 0 'oscillation motion requested
GOSUB(10) 'call oscillation subroutine
BREAK
CASE 1 'Home / Step motion requested
GOSUB(20) 'call Home subroutine
BREAK
CASE 2 'Jog motion requested
GOSUB(30) 'call Jog subroutine
BREAK
ENDS
ENDIF
GOTO(1)
END 'Required END statement never gets reached (by design motor is constantly responding to changes in variable values)

'Oscillation Subroutine
C10
SLD 'disable software limits
EIGN(W,0) 'disable hardware limits
ZS 'clear faults
MP 'set position mode
ADT=a*4.096 'set acceleration
VT=(b/100)*32768 'set velocity
WHILE d==1
PT=f 'go to left limit passed by HMI
G 'start first motion of oscillation
GOSUB(40) 'process commands while move is in progress
PT=g 'go to right limit passed by HMI
G 'start second motion of oscillation
GOSUB(40) 'process commands while move is in progress
LOOP
RETURN

'Home / Step Subroutine
C20
SLD 'disable software limits
EIGN(W,0) 'disable hardware limits
ZS 'clear faults
MP 'set position mode
ADT=a*4.096 'set acceleration
VT=(b/100)*32768 'set velocity
PT=c 'set home position
G 'start motion
TWAIT 'wait for motion to complete before processing any further commands
RETURN

'Jog Subroutine
C30
SLD 'disable software limits
EIGN(W,0) 'disable hardware limits
ZS 'clear faults
MV 'set velocity mode
ADT=a*4.096 'set acceleration
VT=h*32768 'set velocity
WHILE d==1
G 'Start motion
GOSUB(40) 'Check for other commands during move
LOOP
RETURN

'WAIT Subroutine
'This subroutine allows us to react to events while the motor is in
'motion instead of pausing program execution until motion is complete
C40
WHILE Bt 'Loop while motor is in trajectory
IF d==0
X
ENDIF
LOOP
RETURN

 
Posted : 08/02/2012 9:47 am
(@csearcy)
Posts: 316
Reputable Member Guest
 

The RUN? command is optional. You would only use it if you didn't want the program to run until a RUN command is received.

The ECHO commmand would be after...

IF IN(0)==0 SADDR1 ENDIF
IF IN(1)==0 SADDR2 ENDIF
ECHO

 
Posted : 08/02/2012 10:19 am
(@gwood24)
Posts: 0
New Member Guest
 

That doesn't work... I can't get the HMI to send a command to the motor...

I've tried a couple of variations of your suggestion...

IF IN(0)==0 SADDR1 ENDIF
IF IN(1)==0 SADDR2 ENDIF
ECHO
RUN?

Thinking that I could get the HMI to send a run command to the motor after boot up... but still HMI cannot communicate with motor after power cycle UNLESS I address the motor with SMI software... NOT a viable solution

I've also tried this...

RUN?
IF IN(0)==0 SADDR1 ENDIF
IF IN(1)==0 SADDR2 ENDIF
ECHO

thinking that after a power cycle that I could have the HMI send a RUN command to the motor... problem is simple... HMI CANNOT see or communicate with the motor UNLESS I use SMI software to address the motor...

Red Lion says it's a motor issue... I have to agree considering that as soon as I use the SMI software to address the motors, the HMI can see them immediately. This SMI software MUST be doing something to the motor in order for the HMI to see it... I just can't figure out what

I've also tried ... ADDR=1 at the beginning of my program instead of the above two variations and STILL the HMI WON'T see the motor unless I use the SMI software to address the motor. Also, unless I use the terminal to give a RUN command... the HMI does NOT see the program as running in the motor.

Interesting to note that I get a RED LED on the PWR/SERVO light after a power cycle... only way to get rid of this is to use the SMI software to address motor then issue a RUN command.

I NEED to get this resolved... your help is appreciated.

 
Posted : 08/02/2012 11:00 am
(@csearcy)
Posts: 316
Reputable Member Guest
 

Call me tomorrow morning between 8am-1pm EST... at 1-888-356-0357. If you don't reach me... leave a message for "Chuck" with your phone number.

 
Posted : 08/02/2012 8:59 pm
(@Jamarac)
Posts: 4
New Member Guest
 

Not to revive a dead thread, but I'm curious as to resolution on this. I have a substantially similar problem, only a Maple HMI and 4 daisy chain smart motors on RS-232. Connect with SMI first, HMI works fine. Direct from HMI to animatics after power up, no comms. Motor programs are addressed at beginning as following. Only trying to HMI communicate to drive 1.

SADDR1
ECHO
PRINT(#128,"SADDR2",#13)
WAIT=10
PRINT(#130,"ECHO",#13)
WAIT=10
PRINT(#130,"SLEEP",#13)
WAIT=10

PRINT(#128,"SADDR3",#13)
WAIT=10
PRINT(#131,"ECHO",#13)
WAIT=10
PRINT(#131,"SLEEP",#13)
WAIT=10

PRINT(#128,"SADDR 4",#13)
WAIT=10
PRINT(#132,"ECHO",#13)
WAIT=10
PRINT(#128,"WAKE",#13)
WAIT=10

 
Posted : 19/06/2014 6:37 am
(@csearcy)
Posts: 316
Reputable Member Guest
 

The easiest fix is to download a short program to each motor...

Motor1 Program

SADDR1
ECHO
END

Motor2 Program

SADDR2
ECHO
END

etc...

That way... each motor boots up knowing it's own address. Will this work for you?

-Chuck

 
Posted : 19/06/2014 6:46 am
(@Jamarac)
Posts: 4
New Member Guest
 

Downloaded
SADDR1
ECHO
END

to motors 1 through 4 changing SADDR for each motor.

Same problem. Connect with SMI first HMI works. Connect direct to HMI on power-up no comms.
This is a series D that on initial powerup will only turn on control power, and not drive power, until a reset button is hit. Would that make a difference?

Also, baud rate was changed to 115200 from default, do I need to add BAUD(0)=115200 to motor?

 
Posted : 19/06/2014 7:05 am
(@Jamarac)
Posts: 4
New Member Guest
 

Did as requested

SADDR1
ECHO
END

Changed addresses as needed for 4 motors.

Same issue. Connect with HMI on power up, comm fail. Connect to SMI and then back to HMI comms good.

This is a D-series and is wired such that on power up only control power is applied until a supplied reset button is pushed. Should this make a difference?

 
Posted : 19/06/2014 7:30 am
Page 1 / 2
Share: