CP340 serial

userxyz

Member
Join Date
May 2002
Location
any
Posts
2,768
Hi,

I have and S7-315-2DP on my desk with a CP340 on the same rack.

I connected the Serial port with a standard serial-cable to Com-2 of my PC.

how should I begin, I will download the manuals of the CP340 on the siemens site, but, is it good to test a connection to the pc ?? what should I do...

I need to test a Serial communication, just to know how it works, and later (in 2 or 3 months, doing a project with it)

greetz
 
some snapshots

I configured the CP340 in S7:
ger1.JPG


I've chosen ASCII:
ger2.JPG


I checked the protocol in S7:
ger3.JPG


Transfer Settings: (I didn't change anything here):
ger4.JPG



Made the Hyperterminal settings identical:
ger5.JPG



every time I hit a key (when hyperterminal is connected) I see the RXD led blink on the CP340, so there is data exchange.
I've installed the software for CP340, so I have the standard CP ptp blocks:

Now, how do I config such blocks in S7 ?
ger6.JPG
 
hey

I found a sample project CP_340_ptp_Com_CP34x
I'll try it first...

Can u read out data with hyperterminal ?
 
Some more snaps

So I used the send block to send something to the PC

I send the value 73 and receive I in ASCII.


iii.JPG



iii2.JPG


Now I'm gonna use the opposite, sending from the hyperterminal to the S7,

can I convert ASCII to Decimal in some way in the S7 cpu ?
 
Combo, to make your life much easier when dealing with ASCII comm in S7, set up your DB with an array of CHARs. That way, you can monitor the DB online and see the actual ASCII values.

Open up your DB, make a variable called something like "Message", and make it an array of type CHAR, from [1..1024] (or whatever reasonable values are for you).

Also, there are better apps than Hyperterminal for what you are doing. I like Eltima, but there are other free ones out there: http://www.eltima.com/products/serial-port-monitor/?gr=sniffer&gclid=CL65pYea8ooCFQtpGAodQQUUpw
 
made standard block of it for myself:
dhhs.JPG



And tested in a vat:

avat.JPG


71 69 82 82 89 is my name that I send to Hyperterminal, and I receive GERRY :)

115 100 107 89 were 4 keys that I pressed at the same time

This is what settings I connected on the outside:

fb120.JPG




So, I must say, thanks all so far !!!!!


Okay, I made chars instead of decimal numbers in my Vat, thanks S7Guy:

charrr.JPG



Now, here comes my last step...

I will receive analog values that will be given in ASCII to my S7 PLC on the CP340 card. How can I convert ASCII/CHAR to Decimal values ?







Can I c
 
To convert individual ASCII values to decimals, just subtract 48 from each digit. For instance, ASCII "5" is actually a 53.

Once you do that, you will have to do some math to interpret the ones place, 10s place, 100s place, etc, but that is easy.

I think Siemens also makes a canned function for this, but you can do this quite easily as well.
 
:)

I'm not sure how they will give the values to me...

The project is: 24 sensors grouped in 4 sensors / tds box. each box has a RS485 serial communication. To be a bit ready for serial communication, I did this test with a CP340.

4 analogue values wil be given / box. Each box has it's own adress...

See the attachement also...

any idea how the values will look like ?


I don't have the tds boxes yet, so further tests are not possible
 
hey I got more info

it will be 4 values in ASCII like this:

A175B211C566D222

A = 17,5 degrees
B = 21,1 degrees
...
...

like that.

on RS485, not ptp

each box has an other request code
 
I think you are right. It is a simple ascii protocol. With the RS485 interface you may read out all TDS units with one CP340. Poll the units cyclic. Only there is no error checking in this protocol, so if a bit "fall" due interference or something you will receive wrong data.
 
Last edited:
...

So, if there is a fault, the data may not be sended into my program...

that's a good idea

then I'll make a HMI alarm for it
 

Similar Topics

Hi! We are a group of students located in norway, and i have a challenge communicating between a laptop and the Siemens CP340 RS232 module. The...
Replies
23
Views
8,904
Hallo, I have Tia Portal V16 and I'm upgrading an older machine. That machine has a component running on rs232. The machine has still the old...
Replies
7
Views
951
Hi all, i have a module from b&r automation and i am want to get the data from it, but the com port is already taken. Is it possible to monitor...
Replies
1
Views
1,157
Hi, I am planning to use the 300 series in redundacy by using two cpus, and IM153 modules in Profibus DP. I am having some problems with my...
Replies
0
Views
1,194
Hi, been looking everywhere for this info but cant find it. Does anyone know if the CP340 RS232 card supplies 5v to Pin 9. Thanks
Replies
2
Views
1,418
Back
Top Bottom