RS232 Serial Setup with HMS-EN2SE-R


#1

Hi,

I’ve bought an HMS-EN2SE-R to talk with an industrial PC running Cognex Designer via RS232 serial.

I’ve setup on Designer side to start reading bits from COM port (shown below).

image

I looked in the manual for configuration help but only lists a Modbus serial example. Is there documentation on setting up comms between PC and gateway?

I’ve setup the gateway in Studio 5000 and have no errors within Studio 5000 IO tree.

Screenshot of gateway configuration (I added the Transaction folder just to explore settings, this will be removed if not needed).


#2

The HMS-EN2SE-R is acting as a master on the Serial side, so it can read and write to registers on the serial slave, which in this case would be your PC (or application in this case). I am not familiar with Cognex Designer. You will need to provide more info about exactly what you are trying to do (i.e. what data you are trying to exchange) with the PC for me to be able to help. Usually you are going to need a memory map of the serial “device.”


#4

Hi Kyle,

I am trying to exchange string data (string with comma delimiters) and BOOL bits between the PC and the gateway.

I have 2 string data variables and 2 BOOL bits.


#5

OK. The comma will be the end character, but there are a few more things we need to know in order to set it up:

Are the strings a set length or a variable length?

Which way is the data going, one way or both?

Does the data need to be requested from the PC or is the PC just streaming it on it’s own?


#6

The strings will be a set length.

Here’s the data map below. The words in parenthesis are the tag name for my reference.

1 string variable (Recipe) - 126 characters going from gateway to PC
1 string variable (Result) - 42 characters going from PC to gateway
1 string variable (Score) - 4 characters going from PC to gateway
1 string variable (Timestamp) - 60 characters going from PC to gateway
1 string variable (Model) - 10 characters going from gateway to PC
1 BOOL variable (Flag) - 1 bool bit going from PC to gateway
1 BOOL variable (Flag_Ack) - 1 bool bit going from gateway to PC

I have multiple variables but they can be concatenated within the Cognex program if needed for the gateway.


#7

So that we are on the same page with terminology, remember the EN2SE-R is a gateway designed to link 2 devices. In this case the PC (serial slave) and eventually, I assume, an EIP Rockwell controller. The gateway has an input and output memory space where the devices can read and write and hence exchange data. So when you are saying “going from gateway to PC” I am assuming that this data is being written to the gateway by the PLC and read by the PC and vice-versa.

So if you are just exchanging serial data, and there is no set protocol or commands, like modbus, I would recommend that you set the gateway to Generic Data Mode and create Produce and Consume tags, like this:

You’ll just keep track of where you are putting the data and stack it up like this:

You can check the Subnet Monitor by right clicking Subnetwork to select it.


#8

That is correct. An EIP controller is connected to the gateway and the PC is connected to the gateway via RS232 com port. These 2 devices are the only ones communicating with each other.

I followed the instructions and I am able to see data sent from PLC to gateway to PC. But when the PC sends data from PC to gateway to PLC, the PLC only sees the first character of the sent string. The gateway also only sees the first character of the string. We used a laptop running Putty to verify the string coming out from PC is not corrupted, we confirmed that we can see data coming from PC with the comma delimiter.

Below is a screenshot of the setting for consume. I went ahead and created process tags for both consume and produce transactions.

I also want to confirm, for the serial cable, we have right now the Tx pin on gateway side connected to Rx on PC and Rx on gatway side connected to Tx on PC side.

Is this the correct configuration or does it need to be straight-through?


#9

The crossover cable should work fine.

Can you take a log? You’ll connect and then click the symbol to the right for “Start Logging” and then give it about 30 seconds and hit the next one “Stop Logging.” Your log should pop up and then you can save it as a text file. Can you share that with me as well as the cfg file (choose “Export” in the Configuration Manager). I should be able to get a better idea of what’s going on after that.


#10

Does it need to be crossover or can a straight-through be ok?

I can, see attached. I’ve also attached a screenshot of the node monitor since I don’t seem to see the “t” in the received column but I can see it in node monitor.

config.cfg (16.0 KB)
Log.txt (23.0 KB)
config.cfx (17.9 KB)


#11

It needs to be a crossover or a straight cable with a null modem.

Try this:
Under Subnetwork > Timing : change Message delimiter to 10.
Then under Consume 1 > Timing : change Offline timeout time to 250.

In case it’s timing out after the first character.

Also, try to keep your byte numbers even, for example on the produce 1 max data length you have 9 bytes, but since the gateway is counting in registers, you are using half a register.

Try to get a log of the PC sending data so you can see how it is being sent. That will help you to create the right Consume transaction.


#12

I made the settings change and I’m able to see the string coming from the PC on the gateway side, but I’m seeing nothing on the PLC side. I used to be able to see the first letter ‘t’ followed by a bunch of null characters, now I just see null characters on the PLC side. I’ve posted a log of what I’m seeing. For the Tx, it shows a bunch of nulls followed by a comma since I cleared out what was being written from PLC to gateway.

That brings another question, if I want to stop continuously sending data from PLC to gateway so the gateway doesn’t continuously send packets from gateway to PC, how would I disable from PLC side?

log2.txt (17.9 KB)


#13

If you are seeing all zeros than that is what the PC application is sending. You can confirm this by using a modbus scanner simulator if you want. You are going to need to figure out how to get the PC to send the data you want, which will probably involve getting better documentation on how the PC application handles the data.

You can enable the Control/Status word:

You will have to remap your data so the first register is free:
image


#14

I figured out how to get the data show up on the PLC.

I confirmed using Putty from the PC to a laptop hooked to an RS232, I am able to see data coming from the application so data is coming out of the PC. I am able to see data in the log coming from the PC but it doesn’t show up in the PLC tags on the PLC side until I made the following changes below.

I had to set the Timing->Message delimiter set to the highest setting (5000) and set the Consume 1 Timing->Offline timeout time set to 1000 and now I can see the string on the PLC.

I posted the config file for review. Would these setting changes cause any issue?

config2.cfg (16.0 KB)


#15

I think you are seeing the data now because you have the message delimiter set to longer than the timeout and the offline option to freeze, so it’s timing out and freezing the data instead of updating multiple times a second like it was before. This could cause issues if you need the data to update quickly. (The messages are being sent every 50 seconds, but the timeout is 10 seconds.)

In order to make sure you have it right so it’s going to act predictably, you are going to need to find out more about how the PC application is sending the data.


#16

The PC application is simply writing the string onto the COM port every x seconds that the program is set to. I can have it written every 500ms, 1000ms, etc. As soon as the code is ran, the string is written to the com port and if I have my laptop running Putty, I immediately see the string. The next time the string is written, I see it again on my laptop appended. I have a screenshot of the PC application sending me the string but without the “,” at the end.


#17

I’ve posted a log below. The string with the beginning character (“t”) with the relative time of around 1 second, does that mean it took about 1 second between messages?

log3.txt (3.4 KB)


#18

Think I finally figured it out. There was a routine in PC application that was taking some time to complete which is why I was getting data through when I increased the timeout settings. Receiving data seems to be working how I want it.

For the Produce tags, I enabled the Control/Status word and remapped the tags but when I make a download to the PLC, I don’t see the control tags in the PLC program. Do I need to add another object inside the gateway to setup the control register?


#19

Yes, the PC is sending the data about every second.

No, the register should be mapped automatically to the first register like in the screenshot above. I would confirm it’s mapped in the gateway and then try to download again. See: