CP341 Sample Program Question

theNoob

Member
Join Date
Apr 2008
Location
New York
Posts
19
I can't seem to get the Siemens CP341 sample program to send 20 bytes of data without calling the "SEND" routine four consecutive times. Does anyone know why this might be true?

From reading the sample code and the manual, it would seem that once should suffice.

-theNoob
 
Just to elaborate a bit, and bump my post -- only the "RECEIVE" routine is being called in OB1. I put the the "SEND" routine in a separate function that's called once every second.
 
The function needs to be called cyclically, so that could be part of your problem. I don't recal the exact size of the CP341 data record (I think it's 30 bytes), but it is possible to send 20 bytes in one write.

So, pay attention to the request bits, and see if the return value at the function is telling you anything. Also, doublecheck the length parameter and verify that you are actually only sending 20 bytes.
 
S7Guy said:
The function needs to be called cyclically, so that could be part of your problem. I don't recal the exact size of the CP341 data record (I think it's 30 bytes), but it is possible to send 20 bytes in one write.

So, pay attention to the request bits, and see if the return value at the function is telling you anything. Also, doublecheck the length parameter and verify that you are actually only sending 20 bytes.

Thank you -- after reading over the sample code again, that's definitely the case.

Since I only need to send data every 1s, I set up a 1s SFB4 timer to call a while loop when it fires. Inside the while loop I call the SEND routine while "P_SND_RK_REQ" is active. That seems to work pretty effectively.

Just out of curiosity, I put a counter in the while loop to see how long it would take for one SEND cycle to complete. In case anyone was dying to know, it takes ~400 iterations of the SEND routine on average to successfully complete one send with the CP341 on a CPU319-3.

My trivia contribution for the day...
 
There is something wrong there. The CP341 uses a standard SFC to write the data buffer, and it will write the whole 20 bytes at one time. The moment you set the request, the code will format an any pointer using the data start and data length parameters you gave it, and then write the data. Once the SFC returns a "completed" return value (usually the same scan), the data transfer is done. At the most, it would take two scans (one to send the data, and one to then evaluate that the request went back to 0).

I use these all the time, and send much larger messages at a faster rate. If it was taking 400 iterations (scans), it would not even be close to keeping up.
 

Similar Topics

Hi i have a cp341 1CH01 Rs485 and et200m ,i wanna use that to interface with a non simense slave device ion7330 are any deference between 1CH02...
Replies
2
Views
1,789
Hi guy 's, can i use cp341 modbus rtu to interface with a non_siemnes slave device , such as schneider ion7330 ?
Replies
4
Views
1,946
Hi, I am using the CP341 for modbus RTU in an ET200 rack. Usually we are using the CP341 for this application in the same central rack as the...
Replies
0
Views
1,057
Hi all, Does anyone have any experience trying to simulate a Modbus master using a PC, The PLC is a cpu 300 with a CP341 RS485. I am...
Replies
5
Views
2,653
Hi, I had RS485 ASCII string going into a CP340 @ 9600baud rate. This was working fine. I had to change my baud rate to 19200 so I got ripped...
Replies
4
Views
2,510
Back
Top Bottom