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

TOPIC: How to communicate with SMART via RS232?

How to communicate with SMART via RS232? 1 year, 8 months ago #1702

  • Jimmy
  • OFFLINE
  • Posts: 23
  • Karma: 1
hi,csearcy,I need to communicate with SMART via RS232.Now I can build a link to SMART and also download my code.Now I want to talk to SMART in using OMRON serial module. OMRON PLC can send a message in ASCII HEX.
Unfortunately, I don't know how does SMART restore the message if I send a message in ASCII via RS232.Which command should I use to get this message in SMART code.
I have an example parser.The code is as below.I don't understand how to calculate the Main Checksum--"ss",Command-Only Checksum---"tt",Incoming Checksum--"zz".Is is automatic to calculate checksum after i send the message?




SADDR1
ECHO_OFF
PID4
KP=100
KD=500
F
A=1600
V=4000000
MP
mm=1 //Minus Flag to one
ss=0 //Main Checksum
tt=0 //Command-Only Checksum
nn=0 //Input Number to zero
yy=0
zz=0
al[0]=0
al[1]=0
al[2]=0
al[3]=0
p=0
q=104
ab[p]=0
OCHN(RS2,0,N,9600,1,8,D)
C10
IF LEN
vv=GETCHR
IF yy==0
ss=ss*2
ss=ss+vv
ab[q]=vv
q=q+1
ab[q]=0
ENDIF
IF vv<33
IF yy
zz=nn
ELSEIF nn
al[p]=nn*mm
nn=0
ENDIF
SWITCH tt
CASE 1173
GOSUB100
BREAK
CASE 1214
GOSUB200
BREAK
CASE 500
GOSUB300
BREAK
CASE 1239
GOSUB400
BREAK
DEFAULT
GOSUB500
BREAK
ENDS
ss=0
tt=0
al[0]=0
al[1]=0
al[2]=0
al[3]=0
p=0
nn=0
mm=1
yy=0
zz=0
q=104
ab[q]=0
ELSEIF vv==44
al[p]=nn*mm
nn=0
p=p+1
mm=1
ELSEIF vv==126
al[p]=nn*mm
nn=0
p=p+1
mm=1
yy=1
ELSE
IF vv>65
IF vv<123
tt=ss
ENDIF
ELSEIF vv<58
IF vv>44
IF vv==45
mm=-1
ELSE
nn=nn*10
uu=vv-48
nn=nn+uu
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
GOTO10

C100
PRINT("MOVING TO:",al[0],#13)
PRINT("P",al[0],"V",al[1],"A",al[2],#13)
PRINT("CCS:",tt,#13)
PRINT("TCS:",ss,#13)
PRINT("ICS:",zz,#13)
IF ss==zz
P=al[0]
IF al[1]>0
V=al[1]
ENDIF
IF al[2]>0
A=al[2]
ENDIF
G
ELSE
PRINT("CHECKSUM ERROR, TCS:",ss,"ICS:",zz,#13)
q=104
PRINT("CMD:")
WHILE ab[q]
PRINT("ab[q]")
q=q+1
LOOP
PRINT(#13)
ENDIF
RETURN

C200
PRINT("STAT:")
RS
PRINT(#13)
PRINT("CCS:",tt,#13)
PRINT("TCS:",ss,#13)
PRINT("ICS:",zz,#13)
RETURN

C300
PRINT("ENDING...",#13)
PRINT("CCS:",tt,#13)
PRINT("TCS:",ss,#13)
PRINT("ICS:",zz,#13)
OFF
OCHN(RS2,0,N,9600,1,8,C)
END
RETURN

C400
PRINT("ZEROING",#13)
PRINT("CCS:",tt,#13)
PRINT("TCS:",ss,#13)
PRINT("ICS:",zz,#13)
O=al[0]
RETURN

C500
PRINT("ERROR",#13)
PRINT("CCS:",tt,#13)
PRINT("TCS:",ss,#13)
PRINT("ICS:",zz,#13)
RETURN
END

Re: How to communicate with SMART via RS232? 1 year, 8 months ago #1703

  • csearcy
  • OFFLINE
  • Posts: 480
  • Karma: 23
You should be able to send all of the commands needed with the OMRON serial module without using Data Mode and parsing. Leave the SmartMotor in command mode(default... no OCHN command needed).
If the motor has an SADDR1 command... then the messages to that motor need to be prefixed with 0x81. You can open up the "nose" icon in the SMI2 software to see exactly what is being sent with commands.

Re: How to communicate with SMART via RS232? 1 year, 8 months ago #1704

  • Jimmy
  • OFFLINE
  • Posts: 23
  • Karma: 1
Thanks a lot.So if i want to send a message, this message should start with HEX81(motor1),and end with HEX20(space).And if i send "END" via terminal,it will prefix 81 in front of END and add 20 in the end automaticly?
In this code variable tt means Command-Only Checksum. How can i calculate "tt"? And the same queation about "ss","zz".
al[0] is P,al[1] is V,al[2] is A. How can i send data to al[0],al[1],al[2]?

Re: How to communicate with SMART via RS232? 1 year, 8 months ago #1705

  • csearcy
  • OFFLINE
  • Posts: 480
  • Karma: 23
You are correct with HEX81 and HEX20. You don't have to deal with a Checksum... just straight ASCII (default is 9600,8,N,1).
To set the first array variable equal to 123... send HEX81al[0]=123HEX20.

Re: How to communicate with SMART via RS232? 1 year, 8 months ago #1706

  • Jimmy
  • OFFLINE
  • Posts: 23
  • Karma: 1
The code that i upload from the SMART is similar with the example parser as this code. The former user use parser model,so I need to know how to calculate "tt",and then i can figure out former user's code.It's important for me.And from my point of view, the parser is used for shakehands.It's used
for judging if the command that you send is right.But i am not sure about that, do you have any decuments about parser.I fell really confused about it.
Now i can set al[0] using your method,thanks a lot.
  • Page:
  • 1
Moderators: hsummer, csearcy
Time to create page: 0.46 seconds