LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RS485 serial read

Hi,

 

I am using the product NI USB-485 2 port (http://sine.ni.com/nips/cds/view/p/lang/en/nid/14584) in order to receive data from a PIC microcontroller. I am using RS485 in order to transmit data from the PIC24FV16KM202 through RS485 through the USB to 485 box to labview. I am using the VISA palette to configure the serial port and to read the serial port. Although I can see the LED of the port (of NI USB/485) flickering, which signifies that data is being read, no data appears in the indicator on the front panel. 

 

I've attached the VI i'm using. I took some ideas from other posts and tried the ready-made NI examples but still nothing worked! It's as if the data is really being read but not being displayed at all.

 

Please help!

0 Kudos
Message 1 of 15
(9,090 Views)

Why closing VISA session

 

In your code, you're closing the VISA session, before the While loop finishes iteration (detects no data available). LabVIEW is based on DATA FLOW, which means, any node (function or block or structure) on the Block Diagram will execute on after it receives all of the wired inputs... now if you see the VISA close node (encircled in Red) will execute immediately after Write Mode property will execute...!! Force the execution (of VISA close) such that it should run only after While loop finishes its execution (consider connecting as shown by Green wire).


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


Message 2 of 15
(9,077 Views)

Thanks, I tried that but still it doesn't work.

 

What I'm getting is the data is being received and read because the NI USB/485 shows a flickering LED while the data should be read. the only problem is that it is not being displayed on labview and hence I cannot access it.

0 Kudos
Message 3 of 15
(9,064 Views)

I don't know if this is part of my problem but when I opened NI MAX and tried the Input/Output function on my port, I tried the 'Read' button and got this:

0 Kudos
Message 4 of 15
(9,060 Views)

Are you sure, that this third party hardware responds to *IDN? command. Is manual available for this third party hardware??


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 5 of 15
(9,046 Views)

I have tried the 'write' command and I wrote *IDN. no error was given. I do not suppose it responds to it in reality because when I write it, I have nothing in the strings received box, that is, I get nothing back for writing the *IDN command. Moreover, I do not understand exactly what the *IDN command is and how am I supposed to recognise whether the device responds to it or not.

 

I have a manual for this device, however it only includes how the different serial installations should be done.

0 Kudos
Message 6 of 15
(9,021 Views)

@racdar92 wrote:

I have tried the 'write' command and I wrote *IDN. no error was given.


Writing to (most of the) instruments (over RS232) will not throw any error and you can write anything...!!

 


@racdar92 wrote:

I do not understand exactly what the *IDN command is and how am I supposed to recognise whether the device responds to it or not.


It is a Standard Commands for Programmable Instruments (SCPI), mostly available for GPIB instruments. The two ways to check, whether or not, the instrument will respond to *IDN? are:
a. Go through the manual (programming).

b. Test it by sending this command and reading it back, you should receive data if the instrument supports or will experience TIMEOUT error.

 


@racdar92 wrote:

I have a manual for this device, however it only includes how the different serial installations should be done.


Which instrument are you using, have you tried contacting the vendor (or technical support) of this instrument OR have you tried searching online if any example code is available.


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 7 of 15
(9,017 Views)

I have tried several code examples I found online, particularly in NI forum. Still with all the codes I've tried, I cannot seem to be able to display the 'read buffer'. I will try writing that command and read it back and then I'll get back to you about what happens. You're saying that if a TIMEOUT error occurs (which I do get several times when I perform serial read), that means that my device should be able to support *idn command?

 

I am using NI USB to RS485 converter (having two ports).

0 Kudos
Message 8 of 15
(9,014 Views)

@racdar92 wrote:

You're saying that if a TIMEOUT error occurs (which I do get several times when I perform serial read), that means that my device should be able to support *idn command?


No, its otherwise...!!

Okay lemme try explain...!!

you either use just WRITE function (to set some parameter or to configure) OR

you use WRITE followed with a READ function (with small delay, say 50ms between two).. this is when you want to read some data. Now if there is a TIMEOUT error occuring, that means the instrument is not responding to the command that you had sent using WRITE and while you were expecting and waiting to READ (response), you will receive nothing and TIMEOUT will occur (usually after 10sec, which is default and is settable).

 

Check this link, might help.


@racdar92 wrote:

I am using NI USB to RS485 converter (having two ports).


I was asking what instrument is connected with NI USB RS-485???

 

Edited: link included.


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 9 of 15
(9,008 Views)

One more link:

 

Instrument Control Fundamentals: Main Page


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 10 of 15
(9,006 Views)