{"id":7282,"date":"2018-06-06T09:30:16","date_gmt":"2018-06-06T07:30:16","guid":{"rendered":"https:\/\/aceautomation.eu\/how-to-use-ace-plcs-with-2-serial-ports-as-a-serial-gateway\/"},"modified":"2018-07-27T12:10:02","modified_gmt":"2018-07-27T10:10:02","slug":"how-to-use-ace-plcs-with-2-serial-ports-as-a-serial-gateway","status":"publish","type":"page","link":"https:\/\/aceautomation.eu\/it\/how-to-use-ace-plcs-with-2-serial-ports-as-a-serial-gateway\/","title":{"rendered":"How to use Ace PLCs with 2 serial ports as a serial Gateway"},"content":{"rendered":"<p>[et_pb_section bb_built=&#8221;1&#8243;][et_pb_row][et_pb_column type=&#8221;4_4&#8243;][et_pb_text _builder_version=&#8221;3.9&#8243;]<\/p>\n<h1>How to use Ace PLCs with 2 serial ports as a serial Gateway<\/h1>\n<div>The <strong>Ace with 2 serial ports<\/strong> can be used as a serial gateway. If you want for example to convert a serial message from an equipment which include data to another serial equipment with the same data. This can be used with different speeds and parities parameters.<\/div>\n<div><\/div>\n<div>For this operation you must have an Ace PLC with 2 RS232 or RS485 port.<\/div>\n<div><\/div>\n<div>You must <strong>link each serial port to your devices.<br \/>\n<\/strong><\/div>\n<div style=\"text-align: justify;\">\n<table style=\"height: 59px;\" width=\"393\">\n<tbody>\n<tr style=\"height: 84px;\">\n<td style=\"width: 188.5px; height: 84px;\">RX to TX<br \/>\nTX to RX<br \/>\nGND to GND<\/td>\n<td style=\"width: 188.5px; height: 84px;\"><img decoding=\"async\" class=\"alignnone size-full wp-image-17584\" src=\"https:\/\/aceautomation.eu\/wp-content\/uploads\/serial-port_ace_plc.jpg1_.png\" alt=\"\" width=\"213\" height=\"64\" \/><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p><a href=\"https:\/\/aceautomation.eu\/wp-content\/uploads\/GatewaySerialSub.zip\">GatewaySerialSub<\/a>\u00a0program to your Ace with vBuilder (Unzip the file before)<br \/>\nThis program is for Ace 7096x version. Check the version in the &#8220;Setup Hardware&#8221;. Change it if needed.<br \/>\nYou must also configure the serial port as <strong>Custom type<\/strong> and all other parameters depending of your equipments configurations.<\/p>\n<table style=\"height: 48px; width: 560.65px;\">\n<tbody>\n<tr>\n<td style=\"width: 94px;\"><img decoding=\"async\" class=\"wp-image-2459 aligncenter\" src=\"http:\/\/aceautomation.eu\/wp-content\/uploads\/SetupHardware-button.png\" alt=\"\" width=\"67\" height=\"68\" \/><\/td>\n<td style=\"width: 15px; text-align: center;\">or<\/td>\n<td style=\"width: 96px;\"><img decoding=\"async\" class=\"alignnone size-full wp-image-17609\" src=\"https:\/\/aceautomation.eu\/wp-content\/uploads\/setup_30901.png\" alt=\"\" width=\"123\" height=\"124\" srcset=\"https:\/\/aceautomation.eu\/wp-content\/uploads\/setup_30901.png 123w, https:\/\/aceautomation.eu\/wp-content\/uploads\/setup_30901-100x100.png 100w\" sizes=\"(max-width: 123px) 100vw, 123px\" \/><\/td>\n<td style=\"width: 531.65px;\"><img decoding=\"async\" class=\"alignnone size-full wp-image-17589\" src=\"https:\/\/aceautomation.eu\/wp-content\/uploads\/serial_port_custom1.jpg\" alt=\"\" width=\"365\" height=\"58\" srcset=\"https:\/\/aceautomation.eu\/wp-content\/uploads\/serial_port_custom1.jpg 365w, https:\/\/aceautomation.eu\/wp-content\/uploads\/serial_port_custom1-300x48.jpg 300w\" sizes=\"(max-width: 365px) 100vw, 365px\" \/><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>How\u00a0<span id=\"result_box\" class=\"short_text\" lang=\"en\"><span class=\"\">does <\/span><\/span> the program work ?<\/h3>\n<p>The program is a subroutine called &#8220;SerialA1toA2&#8221;.<\/p>\n<p>In the main program, we call this subroutine at each program cycle.<br \/>\n<strong>NbMess.Processed<\/strong> (in the main program)<strong> and NbMessagReceived <\/strong>(in the subroutine) is the number of messages processed. This is just for information.<\/p>\n<p><span id=\"result_box\" class=\"\" lang=\"en\" tabindex=\"-1\"><span class=\"\">In our case here, the length of the received message is 14. The length of the message sent is 42. You must adjust these values for your application according to the length of your messages.<\/span><\/span><br \/>\nThe tags <strong>ReceivedArray<\/strong> and <strong>SendArray<\/strong> are arrays of size respectivley 14 and 42.<br \/>\nThe values in the array tags must be in decimal. See <a href=\"https:\/\/en.wikipedia.org\/wiki\/ASCII\" target=\"_blank\" rel=\"noopener\">https:\/\/en.wikipedia.org\/wiki\/ASCII<\/a><br \/>\nIn the subroutine, you have different state :<br \/>\nState 0: We open and listen to the serial port A1.<br \/>\nState 1: We check if any message arrives. If nothing arrives after &#8220;<strong>MyTimer<\/strong>&#8220;, we reopen the serial port (State 0).<br \/>\nState 2: The message from A1 port is already in <strong>ReceivedArray<\/strong>. We create the new message and send it to the A2 serial port.<br \/>\nIn this example bellow, the new message sent (<strong>SendArray<\/strong>) contains fixe values and values from the <strong>ReceivedArray<\/strong>.<br \/>\n<img decoding=\"async\" class=\"alignnone size-full wp-image-4023\" src=\"http:\/\/aceautomation.eu\/wp-content\/uploads\/copy_array.png\" alt=\"\" width=\"282\" height=\"183\" \/><br \/>\nState 3: Once the message is sent to the A2 serial port, we increment the number of messages received and we return to listen (State 0)<\/p>\n<p>Result:<br \/>\nIn this image bellow, we can see the value &#8220;+1234567&#8221; form\u00a0<strong>ReceivedArray<\/strong> copied to <strong>SendArray<\/strong><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-17599\" src=\"https:\/\/aceautomation.eu\/wp-content\/uploads\/array_serial1.png\" alt=\"\" width=\"265\" height=\"153\" \/><\/p>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p><div class=\"et_pb_row et_pb_row_0 et_pb_row_empty\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div> How to use Ace PLCs with 2 serial ports as a serial Gateway The Ace with 2 serial ports can be used as a serial gateway. If you want for example to convert a serial message from an equipment which include data to another serial equipment with the same data. This can be used [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","_et_pb_use_builder":"on","_et_pb_old_content":"<div>The <strong>Ace with 2 serial ports<\/strong> can be used as a serial gateway. If you want for example to convert a serial message from an equipment which include data to another serial equipment with the same data. This can be used with different speeds and parities parameters.<\/div><div>\u00a0<\/div><div>For this operation you must have an Ace PLC with 2 RS232 or RS485 port.<\/div><div>\u00a0<\/div><div>You must <strong>link each serial port to your devices.<br \/><\/strong><\/div><div style=\"text-align: justify;\"><table style=\"height: 59px;\" width=\"393\"><tbody><tr style=\"height: 84px;\"><td style=\"width: 188.5px; height: 84px;\">RX to TX<br \/>TX to RX<br \/>GND to GND<\/td><td style=\"width: 188.5px; height: 84px;\"><img class=\"alignnone size-full wp-image-2897\" src=\"http:\/\/aceautomation.eu\/wp-content\/uploads\/serial-port_ace_plc.jpg.png\" alt=\"\" width=\"213\" height=\"64\" \/><\/td><\/tr><\/tbody><\/table><\/div><p>Upload [ilink url=\"http:\/\/aceautomation.eu\/wp-content\/uploads\/GatewaySerialSub.zip\" style=\"download\"]GatewaySerialSub[\/ilink] program to your Ace with vBuilder (Unzip the file before)<br \/>This program is for Ace 7096x version. Check the version in the \"Setup Hardware\". Change it if needed.<br \/>You must also configure the serial port as <strong>Custom type<\/strong> and all other parameters depending of your equipments configurations.<\/p><table style=\"height: 48px; width: 560.65px;\"><tbody><tr><td style=\"width: 94px;\"><img class=\"wp-image-2459 aligncenter\" src=\"http:\/\/aceautomation.eu\/wp-content\/uploads\/SetupHardware-button.png\" alt=\"\" width=\"67\" height=\"68\" \/><\/td><td style=\"width: 15px; text-align: center;\">or<\/td><td style=\"width: 96px;\"><img class=\"wp-image-2898 aligncenter\" src=\"http:\/\/aceautomation.eu\/wp-content\/uploads\/setup_3090.png\" alt=\"\" width=\"69\" height=\"70\" \/><\/td><td style=\"width: 531.65px;\"><img class=\"alignnone size-full wp-image-2889\" src=\"http:\/\/aceautomation.eu\/wp-content\/uploads\/serial_port_custom.jpg\" alt=\"\" width=\"365\" height=\"58\" \/><\/td><\/tr><\/tbody><\/table><p>How\u00a0<span id=\"result_box\" class=\"short_text\" lang=\"en\"><span class=\"\">does <\/span><\/span> the program work ?<\/p><p>The program is a subroutine called \"SerialA1toA2\".<\/p><p>In the main program, we call this subroutine at each program cycle.<br \/><strong>NbMess.Processed<\/strong> (in the main program)<strong> and NbMessagReceived <\/strong>(in the subroutine) is the number of messages processed. This is just for information.<\/p><p><span id=\"result_box\" class=\"\" lang=\"en\" tabindex=\"-1\"><span class=\"\">In our case here, the length of the received message is 14. The length of the message sent is 42. You must adjust these values for your application according to the length of your messages.<\/span><\/span><br \/>The tags <strong>ReceivedArray<\/strong> and <strong>SendArray<\/strong> are arrays of size respectivley 14 and 42.<br \/>The values in the array tags must be in decimal. See [ilink url=\"https:\/\/en.wikipedia.org\/wiki\/ASCII\" style=\"tick\"]ASCII table[\/ilink].<br \/>In the subroutine, you have different state :<br \/>State 0: We open and listen to the serial port A1.<br \/>State 1: We check if any message arrives. If nothing arrives after \"<strong>MyTimer<\/strong>\", we reopen the serial port (State 0).<br \/>State 2: The message from A1 port is already in <strong>ReceivedArray<\/strong>. We create the new message and send it to the A2 serial port.<br \/>In this example bellow, the new message sent (<strong>SendArray<\/strong>) contains fixe values and values from the <strong>ReceivedArray<\/strong>.<br \/><img class=\"alignnone size-full wp-image-4023\" src=\"http:\/\/aceautomation.eu\/wp-content\/uploads\/copy_array.png\" alt=\"\" width=\"282\" height=\"183\" \/><br \/>State 3: Once the message is sent to the A2 serial port, we increment the number of messages received and we return to listen (State 0)<\/p><p>Result:<br \/>In this image bellow, we can see the value \"+1234567\" form\u00a0<strong>ReceivedArray<\/strong> copied to <strong>SendArray<\/strong><\/p><p><img class=\"alignnone size-full wp-image-4031\" src=\"http:\/\/aceautomation.eu\/wp-content\/uploads\/array_serial.png\" alt=\"\" width=\"265\" height=\"153\" \/><\/p>","_et_gb_content_width":"","footnotes":""},"class_list":["post-7282","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/aceautomation.eu\/it\/wp-json\/wp\/v2\/pages\/7282","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aceautomation.eu\/it\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/aceautomation.eu\/it\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/aceautomation.eu\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aceautomation.eu\/it\/wp-json\/wp\/v2\/comments?post=7282"}],"version-history":[{"count":3,"href":"https:\/\/aceautomation.eu\/it\/wp-json\/wp\/v2\/pages\/7282\/revisions"}],"predecessor-version":[{"id":17626,"href":"https:\/\/aceautomation.eu\/it\/wp-json\/wp\/v2\/pages\/7282\/revisions\/17626"}],"wp:attachment":[{"href":"https:\/\/aceautomation.eu\/it\/wp-json\/wp\/v2\/media?parent=7282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}