I am trying to communicate through serial to an external device(a vfd). I have done this before with abb, but years ago. I am planning to use com3, which is available port on PC in controller. I have visited HW_INF.ini and Serial.ini. I am setting my serial INI to
[COM3]
BAUD=9600
CHAR_LEN=7 ; 7,8
STOP_BIT=1 ; 1,2 at time not changeable
PARITY=2 ; EVEN=2, ODD=1, NONE=0
PROC=1 ; 3964R=1, SRVT=2, WTC=3, XONXOFF=4
because I "think" my device wants to use ascii. Actually it claims to be able to work with any setting, so I have set it to match this to be sure. Also When I used ABB for this, I know we were using ascii due to the code.
Now I have tried to convert my old RAPID program to KRL.
Here is the RAPID:
PROC StartSPD()
VAR iodev SPD;
VAR num write_buffer{17};
write_buffer{1}:=58;
write_buffer{2}:=48;
write_buffer{3}:=49;
write_buffer{4}:=48;
write_buffer{5}:=54;
write_buffer{6}:=50;
write_buffer{7}:=48;
write_buffer{8}:=48;
write_buffer{9}:=48;
write_buffer{10}:=48;
write_buffer{11}:=48;
write_buffer{12}:=48;
write_buffer{13}:=50;
write_buffer{14}:=68;
write_buffer{15}:=55;
write_buffer{16}:=13;
write_buffer{17}:=10;
Open "COM1:", SPD\Bin;
Writebin SPD, write_buffer, 17;
Close SPD;
ENDPROC
Here is what I have come up with as KRL
DEFDAT StartSPD
; -------- Declaration section --------
INT SPD
INT WRITE_BUFFER[17]
DECL STATE_T SW_T, SC_T
DECL MODUS_T MW_T
ENDDAT
&ACCESS RVP
&REL 7
Def StartSPD()
MW_T=#ASYNC
WRITE_BUFFER[1]=58
WRITE_BUFFER[2]=48
WRITE_BUFFER[3]=49
WRITE_BUFFER[4]=48
WRITE_BUFFER[5]=54
WRITE_BUFFER[6]=50
WRITE_BUFFER[7]=48
WRITE_BUFFER[8]=48
WRITE_BUFFER[9]=48
WRITE_BUFFER[10]=48
WRITE_BUFFER[11]=48
WRITE_BUFFER[12]=48
WRITE_BUFFER[13]=50
WRITE_BUFFER[14]=68
WRITE_BUFFER[15]=55
WRITE_BUFFER[16]=13
WRITE_BUFFER[17]=10
COPEN (:SER_3, SPD)
CWRITE (SPD, SW_T, MW_T, "%R", WRITE_BUFFER[])
CCLOSE (SPD, SC_T)
End
This should, in theory, be sending the command to run to the device. Of course nothing is happening. Things I know:
The rapid program is using open in a binary mode; therfore I am selecting binary format in CWRITE.
Am I even close here?