Store PLCnext CommunityPLCnext on LinkedInPLCnext on Instagram  PLCnext on YouTube Github PLCnext CommunityStore PLCnext Community

  1. rizky
  2. PLCnext Engineer
  3. Tuesday, 14 September 2021
Hi Phoenix Contact Team,
Currently, I am working to read data from GPS. I see some example and the configuration was only available on AXL F RSUNI.
Can I use AXL SE RS485 to read data from GPS?
Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo
Yes, if the GPS unit has an RS485 interface, and if the required comms settings (baud rate etc) can be matched between the GPS unit and the serial module.
Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support
rizky Accepted Answer Pending Moderation
0
Votes
Undo
Thank you.
Yes, it is. The configuration can be matched between the GPS Unit and the serial module.
I am using AXL Com Serial Function Block to read the data. As you know, the GPS Module transmit in the NMEA 0813 standard.
In the AXL SE RS485 config settings, I cannot config the Transmission type (Transparent, end to end) and CR LF as the delimiters.
Also on the arrRcvData variable was in the BYTE type, how can I convert it to char as the messages from GPS?
If you dont mind, the example project from you will be helpful.

Thanks Martin.
Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo
In the AXL SE RS485 config settings, I cannot config the Transmission type (Transparent, end to end) and CR LF as the delimiters.
That's right, these options don't exist for the SE module, which is a lower-cost alternative to the RS UNI without all the same features. You can only get the raw data from the SE module, so you will need to implement protocol features (like message delimiters) in your code.

on the arrRcvData variable was in the BYTE type, how can I convert it to char
You can use the BUF_TO_STRING function block to convert a byte array to a String variable. There is information on how to use this FB in the PLCnext Engineer help pages.

Please let us know if you need any more information.
Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support
  1. one week ago
  2. PLCnext Engineer
  3. # 3
rizky Accepted Answer Pending Moderation
0
Votes
Undo
You can only get the raw data from the SE module, so you will need to implement protocol features (like message delimiters) in your code.


Can you explain more about this?

You can use the BUF_TO_STRING function block to convert a byte array to a String variable. There is information on how to use this FB in the PLCnext Engineer help pages.


Yes, I've tried to use BUF_TO_STRING function block to convert byte array to STRING Variable.
But the messages that appear is like below picture.
Can you give more explanation?

Thanks Martin
Attachments (1)
  1. one week ago
  2. PLCnext Engineer
  3. # 4
Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo
The data read from the SE module will include all the raw data sent by the transmitting device. For example, if the device transmits "Hello World<CR><LF>", then you will receive 13 bytes of data from the SE module, and if you want to look for the CR LF delimiters in the message then you will need to parse the raw data in your code, looking for successive bytes with the values BYTE#16#D and BYTE#16#A. With an RS UNI module, you can set the module to look for delimiters like this, and it will automatically filter out these delimiter chars from the data you read from the module. So if "Hello World<CR><LF>" is transmitted from the partner device to an RS UNI, you would only receive 11 bytes of data.

The BUF_TO_STRING function is useful when the byte array contains data representing ASCII codes. You mentioned that you wanted to convert the bytes to "char" data, so I assumed this was the case. If the data you are receiving from the partner device is ASCII, then it looks like it is sending all sorts of non-printable ASCII codes. So, perhaps the device is not sending ASCII codes at all. The data sheet for the partner device should tell you exactly what each byte in a transmitted message represents.

If you would like more help with this specific project, you can get personal support from the local Phoenix Contact office in your country. If you would like someone to contact you directly, please let me know.
Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support
  1. one week ago
  2. PLCnext Engineer
  3. # 5
rizky Accepted Answer Pending Moderation
0
Votes
Undo
The BUF_TO_STRING function is useful when the byte array contains data representing ASCII codes. You mentioned that you wanted to convert the bytes to "char" data, so I assumed this was the case. If the data you are receiving from the partner device is ASCII, then it looks like it is sending all sorts of non-printable ASCII codes. So, perhaps the device is not sending ASCII codes at all. The data sheet for the partner device should tell you exactly what each byte in a transmitted message represents.

I tried to read the GPS data using another PLC with its serial module and I was able to receive the data in STRING. All the configuration was the same.
  1. one week ago
  2. PLCnext Engineer
  3. # 6
Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo
Can you give an example of a (short) message that is transmitted by the GPS device?
When that message is received by the PLCnext Control device (via the SE module) into a byte array, what are the data values in each of the array elements (in hexadecimal or decimal)?

e.g.
Message transmitted by the GPS device: Hello World<CR><LF>
Bytes received by the PLC (hex): 48 65 6c 6c 6f 20 57 6f 72 6c 64 0d 0a

This will tell us if the problem is in the byte array, or in the BUF_TO_STRING conversion.
Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support
  1. one week ago
  2. PLCnext Engineer
  3. # 7
rizky Accepted Answer Pending Moderation
0
Votes
Undo
Attached picture for the received data in hexadecimal.

I check the BYTE value and convert each bytes to character and I think yes it was the problem on the BYTE array value.
It show unique character when I convert the BYTE value.
Do you have any idea what cause this?
I just can do parse the raw data after confirm the GPS messages received correctly on the SE module.
Attachments (1)
  1. one week ago
  2. PLCnext Engineer
  3. # 8
Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo
OK, so the data received from the SE module seems to contain "garbage" ASCII codes.
There could be a few reasons for this, related to the hardware and/or the software setup.
With your permission, someone can contact you (on the email address you used to register on this forum), to go through the specifics of your setup, and help find the source of the problem.
Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support
  1. one week ago
  2. PLCnext Engineer
  3. # 9
rizky Accepted Answer Pending Moderation
0
Votes
Undo
With your permission, someone can contact you (on the email address you used to register on this forum), to go through the specifics of your setup, and help find the source of the problem.

Yes, please.
Thanks for your help Martin.
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.