LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RS 485 communication between RIO and PC

Solved!
Go to solution

Hi, I'm trying to set connection from PC to cRIO9030, by USB->RS232->RS485 converters. When I'm sending data from PC on RT I'm getting invalid values, for example when i'm sending 65 number, I'm getting 57B7, 0 gives me F8F7 etc...

Download All
0 Kudos
Message 1 of 11
(3,594 Views)

First, you don't need to set the Wire mode on every iteration of the loop.  Do it once before the loop. 

 

Second,  all I see you doing is writing out the character zero in the VISA Write in the sending from PC VI.  If you are sending other data, your VI doesn't show it.

 

Third, hook up the error wires.

 

If you are getting odd data, run your VI's so that you have data in your controls and indicators.  Do Edit > Make Current Values Default.  ave and attach.

0 Kudos
Message 2 of 11
(3,584 Views)

Thanks for your reply, but that problem is still here 

Download All
0 Kudos
Message 3 of 11
(3,580 Views)

What I was saying wasn't going to solve the problem.  It was so we could see some evidence to help determine what the problem might be.

 

But the VI's you attached still don't contain any data.

 

1.  Run your VI's.

2.  Stop them.

3.  Go to the EDIT menu on each VI and pick "Make Current Values Default".

4.  Save your VI's.  (Make sure "Receiving" is spelled correctly.  Smiley Wink)

5.  Attach those VI's to your next message.

0 Kudos
Message 4 of 11
(3,577 Views)

Now it should be better 🙂

Download All
0 Kudos
Message 5 of 11
(3,571 Views)
Solution
Accepted by topic author wojtek432

Yes.  That is better.

 

It is very strange.  I don't see anything obviously wrong in LabVIEW with the way you are handling data.  Though one thing you should do is add a small wait function into your sending VI.  Right now, it is sending data as fast as it can.  Though I think it would be more likely to give you buffer overrun errors rather than data corruption.

 

One more thing, put an error indicator on your wire in the receive VI so you can see if you are getting any parity or other serial errors there.

 

I took the values being sent and received and looked at their hex and binary values to see if there is any pattern there, and I don't. Though it is "almost" inverted 0's to 1's and 1's to 0's.

 

 

I would double check your wiring.  Make sure you didn't swap the polarity of the RS-485 wires.  Though I think if that happened, you'd likely see a lot of framing errors.

 

See if you can swap out any equipment, like if you have another RIO, or another RS-485 port on the same RIO.  Or if the RIO has an RS-232 port try doing an RS-232 to RS-232 with a null modem cable.  That would at least confirm which parts (such as LabVIEW code) are operating correctly.

0 Kudos
Message 6 of 11
(3,550 Views)

I'm currently working with a serial port implementation that has a "Invert Polarity" option, and switching that fixed a similar problem (I'd receive the right number of bytes but the wrong characters), so I think RavensFan's suggestion of checking your wiring sounds promising.

0 Kudos
Message 7 of 11
(3,540 Views)

I double checked it. I had switched it to RS232, and there was similiar behaviour. I checked cabels, converters etc...Error indicator on sending VI shows nothing, receiving VI shows error -1073807339, when I'm not sending anthing, and warning 1073676294, when there is data sending.  Have you got any ideas where to look for answer next?

0 Kudos
Message 8 of 11
(3,522 Views)

I found something interesting. I'm never reading numbers. I tried all signs from my keyboard

0 Kudos
Message 9 of 11
(3,514 Views)

The error is a timeout error.  It could be a sign of one system not sending data, or could be caused by some basic programmer errors such as not configuring termination characters properly or not reading the correct number of bytes.  The warning is not an issue and is generally a good sign because it is only telling you that you got exactly the number of bytes you asked for.

 

"I tried all signs from my keyboard".  I have no idea what that means.  What is a "sign" from your keyboard?

 

I was hoping that using RS-232 would change things up just enough to indicate the problem is with the port or wiring because it would be a different port on your RIO.  And the wiring would be different.  Are you sure you used the correct type of cable for RS-232?  I would assume you'd need a null modem cable since it would look like two PC's talking to each other.  But you could try a straight through cable as well.

 

Are you using a USB to RS-232 adapter?  What chipset is it using (Prolific or FTDI)?  People tend to have more issues with the adapters build on the Prolific chipset.

Did you try a different RS-232 adapter?  Different USB port?  Different PC?

 

 

0 Kudos
Message 10 of 11
(3,506 Views)