Jump to content
Sign in to follow this  
DaveE

Com Serial TX

Recommended Posts

Good Morning

I have not written my program yet, but I want to be able to communicate a string from my new Unistream to a RS232 device, in fact a Hitachi Printer

I have successfully done this with a Vision PLC, but now all of my inbuilt FB's have gone with Unistream, and I am struggling

I have added a Com device to the unit, and configured it ( I think)

I cannot see however to set the pre amble and post amble for my strings

 

what I want to do is

On the HMI have a string called lot and another string called Julian Date

I then want to be able to send those strings to the Hitachi with the correct coding for the machine

They will be sent at one time so the string to send will look lile

STX

[DLE] 1 (LOT) [DLE] 2 (JULIAN)

ETX

 

I looked in the help files and didnt see anything there so I am now asking for help here

Thanks in advance

 

Share this post


Link to post
Share on other sites

Hello DaveE,

 

Thank you for using our Unitronics Forum.

 

Sending ASCII information/messages can be accomplished in UniLogic by using our Message Composer found in the Solutions Explorer window on the left hand side.  Using this drop down tab, you can create a CPU Protocols Message to create your ASCII message to be sent to a device.

 

More information can be found in our help files in UniLogic under Protocols: Third-Party > Message Composer.

Share this post


Link to post
Share on other sites

Hello,

 

I am on a similar path with trying to figure out sending/receiving protocol messages. I see how you create the messages, but not how you trigger sending a message. The only options I see for COM: Protocol, Third-party are CRC, Build and Parse message and I can't find anything in the help explaining how to use these.

 

Jared

Share this post


Link to post
Share on other sites

Jared,

 

The function you are looking for to send messages is the Tx function block, and will be found under the COM: CPU TCP/IP and COM: Serial drop down menus.

 

Both the Tx and Rx function blocks work directly with buffers to send and receive information. This means that to receive or send messages you will be working with buffers when using these functions. It is also possible to directly convert tags to buffers and vice versa using the Buffer Tools within UniLogic.

 

When you receive a message using the Rx function block, it will be output to a buffer tag. To scan for an incoming message you can use the Parse Message function (under COM: Protocol, Third-party) which will compare the buffer to any messages being scanned for in the Message Composer. It will then display if there was a match to an indexed message, a result of -1 indicates the message was not found.

 

When you wish to send a message the Build Message function (under COM: Protocol, Third-party) is used to take a message from the Message Composer and convert it into a buffer tag. This buffer can then be selected in the Tx function block to send a message to a serial device or a connected Ethernet device.

Share this post


Link to post
Share on other sites

Thank you for the response. I added the Build Message and created a buffer.

 

My problem now is with the COM Tx block. For the A parameter it does not specify what data type it is looking for. I have tried several different data types but I keep getting an error saying "This parameter cannot be linked to this data type". What is this parameter looking for?

Share this post


Link to post
Share on other sites

You must set up the communication port you wish to use.  For instance, if you wish to use the RS485 port on the CPU, you must go into the PLC Communications drop down menu, then the Physical menu, and select the RS485 Serial option.  To the right you, in the Properties Window, you should have the work mode set to CPU.  This will allow you to choose this channel in the COM Tx function block.

  • Upvote 1

Share this post


Link to post
Share on other sites

Hello!

 

One more question about Rx\Tx. I'm using Rx box and output "B" of it fills buffer tag with only 1 byte in the current plc cycle, even incoming message consists of 2, 3, etc. Could you please help me with advice?

 

Regards.

Share this post


Link to post
Share on other sites

Is the tag for received information being used somewhere else in the program? This may cause it to display a value of 1 instead of 2-3. Also, can you verify the received information using another PC utility program such as Hercules?

 

This will allow you to see all of the raw information to see if you are truly receiving 1 or 3 bytes.

Share this post


Link to post
Share on other sites

Thank you for answer.

 

Buffer tag is unique for Rx.

I'm using ComPump (PC prog.) to comprise messages, guess they are similar with Hercules. So, I send message from PC and want to see it in PLC's tag, but it won't work  :o . Message contains ASCII-symbols, for examle: <STX>blabla123<ETX><CRC>.

 

Regards.

Share this post


Link to post
Share on other sites

When you go online in UniLogic do you see any information within the buffers tag?

 

If possible please send your program in for review to support@unitronics.com. Also send us the messages you are trying to send so we can properly test. Include any control characters, STX, ETX, and CRC (with method) so we can send the same information.

  • Upvote 1

Share this post


Link to post
Share on other sites

Hello!

 

 

When you go online in UniLogic do you see any information within the buffers tag?

Yes, it filled with 0-s (after reset), and holds last value received from port in first element of buffer. By the way, it is always last byte of send message, i. e. CRC.

 

If possible please send your program in for review to support@unitronics.com.

No problem, I have sent it to support@unitronics.com.

 

Regards.

Share this post


Link to post
Share on other sites

Hello,

 

This is an old topic, but I have the same behavior than Nikita.

The Com RX function replies with sometimes onlys one byte instead the whole frame.

Should I use a timer as soon as I detect at least one byte in the buffer before to call the Com Rx ?

Should the Com Rx function be used to fill a large temporary buffer with all readen bytes and apply a parse function to this large buffer ?

 

Do you had any helps for that matter from the support ?

 

Thanks for the replies.

 

Regards,

Patrice Barrot

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...