From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RS485

I´m not sure if i´m right with my question.

I want to test a device with RS485 and need an example for the command

 

Command Frame Image 

DMY/STX/ID/Command data/EXT/BCC

 

DMY: Dummy data: 7Fh

STX : Start text: 02h

ID: Slave ID [2bytes]: (ASCII)

Command data: Variable length data: (ASCII)

EXT: End text: 03h

BCC: BCC error detection between ID and EXT (1 Byte)

 

Command Code  example "03" for INQUIRY (Reading)

 

Communication with Standard RS232 devices is no Problem for me. But These are clear ASCII commands. 

What for a string must i build for a INQUIRY command?

 

Thank you very much in advance

 

0 Kudos
Message 1 of 14
(3,429 Views)

Hi Moby,

 

are you related with NGHIA?

Apparently you want to use the very same communication protocol…

 

Read the manual attached by NGHIA, it describes the strings quite nicely. All you need to add is to put that DMY byte in front of the remaining string…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 14
(3,425 Views)

I answered in wrong topic.

I'm Not related to the other User.

But it's a japanese device,too.

I will Check. For the Moment in need a rs485 USB Adapter. I only have rs232 connectors and Adapter.

 

Must i build an String with Hex values?

0 Kudos
Message 3 of 14
(3,400 Views)

Hi Moby,

 

you can build your string using hex values. Or you use string constants set to hex or \-code display mode...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 14
(3,395 Views)

RS232 to RS485 converters are pretty common in our lab.  It would probably be more reliable to get a dedicated RS485 device, but we've used a couple converters like this one, and this one.  One works without power, just requiring two wires somehow.  The other I found needed a 12V adapter, but both work well for our low speed environmental chamber control.

0 Kudos
Message 5 of 14
(3,364 Views)

I´m sorry for late Reply. I was ill and some other things to do.

Now i tryed to get a simple command:

 

inquiry--->command code "03" It´s reading command

My adress is 01

But i don´t get back any feedback. I think something is wrong in command string?

 

 

0 Kudos
Message 6 of 14
(3,299 Views)

Hi Dicker,

 

I made the display style indicator visible for all string constants (as suggested before!):

check.png

Do you see the difference between them?

 

I think something is wrong in command string?

Yes, you are right!

- You need to set the string constants to hex display to be able to input correct values…

- you need to calculate the correct BCC value, trying to append an empty string is plain wrong!

- there are no error wires in your VI!

- using the default TermChar is wrong for this kind of communication…

- are you sure you need to read 20 bytes from your device?

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 14
(3,295 Views)

Hello Gerd,

 

yes i see the different in style and i read it before. But this versionw as wanted (seems to be wrong) 

According to my Manual ID and command data are ASCII  and not hex values. Now i don´t know how to handle.

Error wires are now connected. Cluster constant at Input and a Display output at visa read.

I reduced the reading buffer to 4 (Manual)

About term char: I had no Information in Manual. So i didn´t Change it. Now i set it to false.

BCC is also difficult to understand: It´s calculated in the Response between/including "ID" "RES" "DATA" "EXT"

-->ID=2bytes

-->RES=2bytes

-->data (for inquiry command) = 4bytes

-->EXT= no Information 

Now i´m thinking i must add "8" as string?

My error out is "-1073807339"  It´s meaning time out at "reading"

Best regards 

 

0 Kudos
Message 8 of 14
(3,289 Views)

Hi Dicker,

 

Now i´m thinking i must add "8" as string?

Why do you think so? Just because there are 8 bytes???

There should be a description in your manual telling you how to calculate the BCC. (Sometimes they just XOR all bytes…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 14
(3,287 Views)

Good afternoon Gerd,

I will Check the calculation again.

If i will mit find any Information i will ask manufacturer in Japan.

For the Moment i only counted the Bytes.

What's about my String Hex Problem?

Is PDF Upload here possible, 2-4pages?

Best regards

0 Kudos
Message 10 of 14
(3,282 Views)