You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old February 24th, 2004, 04:16 PM   #1
Borte
Member
Norway

Borte is offline
 
Borte's Avatar
 
Join Date: Feb 2004
Location: Norway
Posts: 238
Problems with Siemens CP340 RS232C communication

Hello!

Have anyone in here used the Siemens CP340 RS232C communication processor (6ES7 340-1AH01-0AE0)?
I'm trying to figure out how to use this card to send ASCII codes (or string data) to an external unit that only accepts straight ASCII.

The card came with some examples but none of them have straight ASCII communication, the examples are for printer communication (special setup of the card) and send / receive (step7 db's). None of this suits my needs.

Hope anyone can help me with this; an example would be greatly appreciated.

Regards
Borte
__________________
Failure is not an option
  Reply With Quote
Old February 24th, 2004, 05:20 PM   #2
S7Guy
Member
United States

S7Guy is offline
 
Join Date: Nov 2003
Location: Dayton, Ohio
Posts: 1,250
I've done a ton of programming with the CP340 and 341 modules, and can help you if you provide a little more info. What type of device are you talking to? How much data are you trying to send, and how often?
  Reply With Quote
Old February 24th, 2004, 11:20 PM   #3
Borte
Member
Norway

Borte is offline
 
Borte's Avatar
 
Join Date: Feb 2004
Location: Norway
Posts: 238
Hello!

I'm talking to a Telesis Pin Writer witch only accepts straigh ASCII codes at the input.

The data I'll be sending will be in the range of 10 - 20 Bytes (10 - 20 characters).

And it'll be sent each 10 sec so the time is not an issue here I think.

So far I have just set up a test system with my computer to see if I vere able to send some data, but still no luck. I've been looking at the examples that Siemens provide but they are not easy to understand.

Hope this is all the information you need.

Regards
Borte
__________________
Failure is not an option
  Reply With Quote
Old February 25th, 2004, 05:54 PM   #4
S7Guy
Member
United States

S7Guy is offline
 
Join Date: Nov 2003
Location: Dayton, Ohio
Posts: 1,250
Ok, the first thing you will want to do is copy the required function block from the Simatic CP PtP library. Then, create an associated Instance Data Block to go with this FB. You would create an IDB for each printer that you are talking to. I’m assuming you know how to do this, but if not, I’ll go into further detail.

To send data, you will need to determine the length of the data in bytes, plus the starting byte of the data. In the code example I am giving you, I have used absolute addresses and a fixed data length, but in reality you will need to determine these dynamically based on the actual data. I have used “512” as the CP340 module address, and I set the “Send Request” every ten seconds. I always use symbolic programming and pass a udt into my Printer Control function, but there are a dozen other ways to do it depending on your programming style. Or, if you only have one printer and don’t need multiple instances, you can continue to use absolute values.

I haven’t tested this, so maybe I made a typing mistake, but this should get you started. If you need help in determining things like the data length for your live conditions, then let us know.

By the way, if it doesn't seem to communicate with your pin writer, then try sending the data to your laptop instead via HyperTerminal. That is probably the easiest way to test hardware like this.

Here's the code:

//******************************
//Sample Data: "THIS IS A TEST!"
//******************************
L 'T'
T "Test CP340".Printer.AsciiCharacter[1]
L 'H'
T "Test CP340".Printer.AsciiCharacter[2]
L 'I'
T "Test CP340".Printer.AsciiCharacter[3]
L 'S'
T "Test CP340".Printer.AsciiCharacter[4]
L ' '
T "Test CP340".Printer.AsciiCharacter[5]
L 'I'
T "Test CP340".Printer.AsciiCharacter[6]
L 'S'
T "Test CP340".Printer.AsciiCharacter[7]
L ' '
T "Test CP340".Printer.AsciiCharacter[8]
L 'A'
T "Test CP340".Printer.AsciiCharacter[9]
L ' '
T "Test CP340".Printer.AsciiCharacter[10]
L 'T'
T "Test CP340".Printer.AsciiCharacter[11]
L 'E'
T "Test CP340".Printer.AsciiCharacter[12]
L 'S'
T "Test CP340".Printer.AsciiCharacter[13]
L 'T'
T "Test CP340".Printer.AsciiCharacter[14]
L '!'
T "Test CP340".Printer.AsciiCharacter[15]
//******************************
//Load Parameters
//******************************
L 0
T "Test CP340".Printer.CP340Parameters.DataByteNumber
L 15
T "Test CP340".Printer.CP340Parameters.LengthOfData
L DBNO
T "Test CP340".Printer.CP340Parameters.SourceDataDataBlock
//******************************
//Transfer Module Address
//******************************
L 512
T "Test CP340".Printer.CP340Parameters.ModuleAddress
//******************************
//Send Data every 10s
//******************************
AN "Test CP340".Printer.CP340Parameters.Request
L S5T#10S
SD T 300
A T 300
S "Test CP340".Printer.CP340Parameters.Request
//******************************
//Send Data
//******************************
CALL "P_SEND" , "CP340"
REQ :="Test CP340".Printer.CP340Parameters.Request
R :="Test CP340".Printer.CP340Parameters.Reset
LADDR :="Test CP340".Printer.CP340Parameters.ModuleAddress
DB_NO :="Test CP340".Printer.CP340Parameters.SourceDataDataBlock
DBB_NO:="Test CP340".Printer.CP340Parameters.DataByteNumber
LEN :="Test CP340".Printer.CP340Parameters.LengthOfData
DONE :="Test CP340".Printer.CP340Parameters.SendComplete
ERROR :="Test CP340".Printer.CP340Parameters.SendError
STATUS:="Test CP340".Printer.CP340Parameters.StatusWord

A "Test CP340".Printer.CP340Parameters.SendComplete
R "Test CP340".Printer.CP340Parameters.Request

Or, here's the same code with absolute value representation:

//******************************
//Sample Data: "THIS IS A TEST!"
//******************************
L 'T'
T DB200.DBB 0
L 'H'
T DB200.DBB 1
L 'I'
T DB200.DBB 2
L 'S'
T DB200.DBB 3
L ' '
T DB200.DBB 4
L 'I'
T DB200.DBB 5
L 'S'
T DB200.DBB 6
L ' '
T DB200.DBB 7
L 'A'
T DB200.DBB 8
L ' '
T DB200.DBB 9
L 'T'
T DB200.DBB 10
L 'E'
T DB200.DBB 11
L 'S'
T DB200.DBB 12
L 'T'
T DB200.DBB 13
L '!'
T DB200.DBB 14
//******************************
//Load Parameters
//******************************
L 0
T DB200.DBW 206
L 15
T DB200.DBW 208
L DBNO
T DB200.DBW 204
//******************************
//Transfer Module Address
//******************************
L 512
T DB200.DBW 202
//******************************
//Send Data every 10s
//******************************
AN DB200.DBX 200.0
L S5T#10S
SD T 300
A T 300
S DB200.DBX 200.0
//******************************
//Send Data
//******************************
CALL FB 300 , DB300
REQ :=DB200.DBX200.0
R :=DB200.DBX200.1
LADDR :=DB200.DBW202
DB_NO :=DB200.DBW204
DBB_NO:=DB200.DBW206
LEN :=DB200.DBW208
DONE :=DB200.DBX200.2
ERROR :=DB200.DBX200.3
STATUS:=DB200.DBW210

A DB200.DBX 200.2
R DB200.DBX 200.0

Last edited by S7Guy; February 25th, 2004 at 05:58 PM.
  Reply With Quote
Old September 1st, 2004, 11:01 AM   #5
Borte
Member
Norway

Borte is offline
 
Borte's Avatar
 
Join Date: Feb 2004
Location: Norway
Posts: 238
Woohhhaaa This is a long time ago...

I have finally got around to test this, but I'm still running into problems... Hopefully someone in here can help!

I'm using the test program that S7Guy created for me (thanks for the program S7Guy) but it seems like my computer or the plc has a problem when I'm sending more than 4 characters at the same time. If I'm using 15 as in the example then all my computer is receiving is the last character (!). I tried playing with character delay and transmission speeds without any luck.

Anyone has any ideas on this?

Regards
Borte
__________________
Failure is not an option
  Reply With Quote
Old September 1st, 2004, 11:28 AM   #6
Borte
Member
Norway

Borte is offline
 
Borte's Avatar
 
Join Date: Feb 2004
Location: Norway
Posts: 238
I worked it out, it seemd to a configuration problem in the CP card.

I had to set the parameters correct, just a user problem!

Regards
Borte
__________________
Failure is not an option
  Reply With Quote
Old April 19th, 2007, 09:33 AM   #7
emapers
Member
Italy

emapers is offline
 
Join Date: Apr 2007
Location: Bergamo
Posts: 3
CP340 Print String DB ISSUE!!!

Hello everybody,
I've an issue printing data from a DB (on a CPU315) to a Printer via CP340 (RS232).
Module configuration and test exercise from Simens Manual seems don't write properly.
The string should be:
'At %Z the value %N the limit of %i liters'
where:
%Z: Is the conversion instruction for the data type TIME_OF_DAY
%i: Is the conversion instruction for the data type INT, WORD, DINT, DWORD
%N: Is the conversion instruction for outputting a message configured in HW Config

So the printed message should be:
---------------------------------------------------------
At xx:xx:xx.xxx the value reached the limit of 1500 liters.
---------------------------------------------------------

But the printed message is:
---------------------------------------------------------
had

172842 h vau ahd h m ****** s
---------------------------------------------------------

Extra information:
If I connect the PC directly to printer via serial and use Hyperterminal, I can write properly sentences, numbers, chars...

Do you have any hint maybe about the CP340 configuration parameters?

THANKS,
Ema
  Reply With Quote
Old April 20th, 2007, 09:19 AM   #8
Ken M
Member
Scotland

Ken M is offline
 
Join Date: Mar 2004
Location: .
Posts: 1,136
My guess is that there is nothing wrong with the CP340 configuration parameters. After all, you are getting a message successfully delivered from the module to the printer, so things like baud rate etc must be OK.

What does seem to be screwed up is the content of the message. I've had a look at the Siemens CP340 printer driver 'Getting Started' guide. Is this the example you're referring to? In DB10 there is a STRING variable which holds the structure of the output message. Are you sure you have observed the correct structure of a STRING data-type? Remember that the 1st byte holds the overall length of the STRING, the 2nd byte defines how many valid characters are in the STRING (must be less than or equal to 1st byte) and the data only begins at the 3rd byte. If you get these wrong you may find that any operation using the STRING will incorrectly interpret where the data starts, and therefore what each subsequent character is intended to be. I would start by checking this and any other STRINGs to make sure they're properly formatted.

regards

Ken
  Reply With Quote
Old February 16th, 2009, 11:11 PM   #9
ALU
Member
Viet Nam

ALU is offline
 
ALU's Avatar
 
Join Date: Feb 2008
Location: Da nang
Posts: 17
Quote:
Originally Posted by S7Guy View Post
I've done a ton of programming with the CP340 and 341 modules, and can help you if you provide a little more info. What type of device are you talking to? How much data are you trying to send, and how often?
Hi S7Guy,
Please have a look here and give me some guide http://www.plctalk.net/qanda/showthr...t=29358&page=3
(Sorry but I am a newbie in Step7, STL is difficult for me...I try to read your code but it seems so big project to me..
Could you give me some guide to write a program which function as belows (I think it simple with you but for me it difficult because the first time I do this, please guide me in LAD):
- Hardware: CPU 314c-2DP + CP340 connected to 05 indicators (can be addressed) through RS485, 2wire, ascii 8data bits+1stop bit.
- Step7 program:
+ Send code <STX>PA<CR> (eg: ^BP!^M for addres 1) to Poll for data from indicators
+ Receive data return from indicators.
(I can do the setting for HW already)

Many thanks for your attention!)
__________________
World Wide Work
  Reply With Quote
Old February 25th, 2009, 10:22 PM   #10
ALU
Member
Viet Nam

ALU is offline
 
ALU's Avatar
 
Join Date: Feb 2008
Location: Da nang
Posts: 17
Urgent help please!

Quote:
Originally Posted by S7Guy View Post
I've done a ton of programming with the CP340 and 341 modules, and can help you if you provide a little more info. What type of device are you talking to? How much data are you trying to send, and how often?
Hi S7Guy,
I have CPU314-2DP with CP340(rs485) on my desk.
I have connected cpu-cp above to a display via 2wired rs485, the command and data frame of display as in the attatchment, I done all settings for both partners (I already do parameter for ASCII data exchange in cp340). I write user program to communication. However, in P_receive the STATUS shown 811 in HEX. I check CP340 manual and found desciption for this error but cannot solve it.
I jugde that you are expert on this matter so please share me a little of your time to look through the attatchment and give me some guide...
This very urgent with me...Thank you very must for your attention!
Attached Images
File Type: jpg cont mode.jpg (77.7 KB, 114 views)
File Type: jpg poll mode.jpg (71.5 KB, 80 views)
File Type: jpg config.jpg (38.1 KB, 80 views)
__________________
World Wide Work
  Reply With Quote
Old February 17th, 2010, 05:16 AM   #11
richardjstarr
Member
United Kingdom

richardjstarr is offline
 
Join Date: Feb 2010
Location: Sheffield
Posts: 1
Status value 811

Hello all,

I to am getting the status value 811, which when converted to binary does not match with any of the error codes.

I am using a SI module ASCII 32 bit reading from an RS232C input. The Module Rx light is flashing but no data is populating the data block assigned in the function block.

Does anyone have any ideas as to where my problem may lie.

Many thanks

Richard
  Reply With Quote
Old December 25th, 2019, 08:38 PM   #12
honeymae
Member
Philippines

honeymae is offline
 
Join Date: Dec 2019
Location: Davao City
Posts: 1
CP-340 RS 232C ptp module printing problem

Hi all,

I hope anyone here can help me with my problem regarding on CP-340 RS 232C ptp module.

This is my first time working with printing module, Our client has an existing CP-340 module communicating with epson Lx-310. They want to replace their printer with the same printer but the old epson Lx-310 was obsolete already so they bought the newer version of Lx-310. I don't have problem communicating the two devices because I can able to print the problem is the printer printing unknown characters (Ç). Supposed to be the printer will print temperature data every 5 minutes. But when I install again the old printer the printing was working properly. I don't know what is the problem because the only thing I change in the existing program is the communication parameters.

Thank you.
  Reply With Quote
Old December 26th, 2019, 04:23 PM   #13
Lare
Member
Finland

Lare is offline
 
Join Date: Jan 2006
Location: Finland
Posts: 1,897
Quote:
Originally Posted by honeymae View Post

Hi all,

I hope anyone here can help me with my problem regarding on CP-340 RS 232C ptp module.

This is my first time working with printing module, Our client has an existing CP-340 module communicating with epson Lx-310. They want to replace their printer with the same printer but the old epson Lx-310 was obsolete already so they bought the newer version of Lx-310. I don't have problem communicating the two devices because I can able to print the problem is the printer printing unknown characters (Ç). Supposed to be the printer will print temperature data every 5 minutes. But when I install again the old printer the printing was working properly. I don't know what is the problem because the only thing I change in the existing program is the communication parameters.

Thank you.

You should open new thread for this.


It can be wrong character set selected on printer side or com speed, parity.


If you have some odd characters, then check character coding selected on old and new
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
CP340 or CP 341 communication processor aprilchu LIVE PLC Questions And Answers 5 August 10th, 2015 09:00 AM
Problems with Siemens MMC cards RMA LIVE PLC Questions And Answers 8 November 24th, 2006 03:52 AM
Siemens 316-2DP / CP343-1 / OPC Communication Issue PDBeal LIVE PLC Questions And Answers 16 April 10th, 2006 06:23 PM
Problems with S7 MPI communication RMA LIVE PLC Questions And Answers 15 November 19th, 2004 08:40 AM
Siemens S7-313 to OP270B Communication qee LIVE PLC Questions And Answers 4 December 18th, 2003 07:40 AM


All times are GMT -4. The time now is 04:55 AM.


.