LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview serial communication with RS 232

Solved!
Go to solution

Hello all

 

I am currently doing a project for a wireless data logger and I have been asked, by my project supervisor, to use labview to be the data logger software.  However I am not very familiar with this software.  I am using a simple read, write program that i obtained from the examples of the NI Development zone. I am attaching the program.  While testing with labview 7.0, it gives error which I have attached.  The DAQ card that is available is NI DAQ 6024e and I have NI_CB_68LP connector block.  Can serial communication be done with this card or with the connector block? Is it important to have a NI hardware to perform the serial read ?

 

I am relying completely on your kind consideration to help me out of this.

 

Kind regards

 

Pravish

Download All
0 Kudos
Message 1 of 56
(11,823 Views)

Hi Pravish

 

I have no idea about  the DAQ Card. But I assume you have a COM port available on you PC as can be implied from the error message. I see on your task bar  that you have a mikroBasic for PIC  program open on your PC. By any chance do you use the COM port for programming the PIC controller. If you are using the COM port(COM 2) for programming the maybe you will have to close the application(mikroBasic for PIC  ) and try the NI example.

 

You do not require addtional hardware for serial communication if your PC has a working COM port

 

Regards

 

Javed

Message 2 of 56
(11,814 Views)

Try sending the commands using Max (Measurement & Automation eXplorer in your start menu). In there it shows what devices it can see and there's a test panel, where you can try sending commands and seeing responses. If you can send the commands using that, you should be able to do the same in your code and it'll show you what VISA string the device is known as. Hope that helps, Duncan

0 Kudos
Message 3 of 56
(11,797 Views)

The error that you got is due to the handshaking problem. As other pointed already about additional hardware and exactly you don't need any additional hardware for communication via SERIAL. Just plug the USB to PC and send the required commands to the slave side. Hopefully, that will give information. If your slave don't have SERIAL option means then you need a additional hardware acts like bridge between labVIEW and your end device. Here, the bridge device is used convert the SERIAL data into the your slave or end device understanding format.

 

If you want to get rid of the error that you are currently posted, Try to put a Millisecond time delay between WRITE VISA and READ VISA. That is it.

Message 4 of 56
(11,785 Views)

Thanks for the reply Javed.

 

In fact it was not reading due to I was making the mikrobasic read at the same time.  It worked for only once though and then it didn't re-run when I pressed the run again.  It tells me time out error.  Do you think I should include a continuous loop?

 

Thanks for your help Javed once again. 

 

Kind regards

 

Kunal

0 Kudos
Message 5 of 56
(11,745 Views)

Hi Kunal

 

 

Great to know that I could help you.

 

The VI which you had provided in you initial post is a one time read-write process.

 

You should have your VISA write/Read in a loop if you want to write/read continuously.

 

The Time-out error maybe because you are not recieving any data on your COM port.

 

Regards

 

Javed

0 Kudos
Message 6 of 56
(11,721 Views)

Thanks everyone for your views and advices.  Infact I figured out the problem which was I initially did not configured the port I was doing serial read in MAX (Measurement and Automaiton Explorer) and also due to this I could not configured the port in the VISA serial configuration.  That's why I was getting the run arrow broken. 

 

Sorting all these out made the program run arrow ok.  However another issue crop up and i again need your help and advices dear all.  I am attaching a picture of the error I am getting. 

 

However I wrote another program to do only serial read which I am also attaching and with this one too there is an error being generated.  Its saying that "NI-488:  Command requires GPIB Controller to be Controller in Charge".  Is it due to I need to use the serial cable sold by NI instruments only?

 

Relying on your kind help and usual cooperation, dear all.

 

Thanks in anticipation

 

Kind regards

 

 

Kunal

Download All
0 Kudos
Message 7 of 56
(11,640 Views)

The error 1 jpeg means you are trying to set a setting on your serial port that is invalid.  It is happening at argument 1, but without seeing the block diagram for the VI, I don't know what your exactg error is.

 

Your erro2 jpeg, you are confused about what it says.  The GPIB error message is an alternate error message that because a GPIB error uses the same error numbers as other LabVIEW errors.  Since you are not using GPIB, it doesn't apply.  Look at the first error which is "An input parameter is invalid".  Whatever data you are receiving from your serial port cannot be formatted properly in the Scan from String function with the %f format code.  Perhaps the string is empty, or has some invalid characters in it.  Put an indicator on your pink string wire to see what data is being read.

0 Kudos
Message 8 of 56
(11,636 Views)

Thanks for the fast reply.  I will attach the VI file for the error 1.

 

I will take your advices into considerations and get back to you with the results.

 

Kind regards

 

Kunal

0 Kudos
Message 9 of 56
(11,633 Views)

Hi Ravens

 

As per your suggestion i put an indicator.  However i removed the scan from string and it seemed that the program is reading although in form of binary pulse signals.  However upon connecting the scan from string, there is error again. 

 

Infact what i am trying to do is converting voltage to digital form via a PIC 16f877 and then sending the data over a serial cable and then using a serial to usb converter, i am entering the data in the usb port of my laptop which is recognised as a com port in VISA. 

 

I am attaching the modifications together with the results of the program.

 

Thanks for the guidance though.

 

Kind regards

 

Kunal

0 Kudos
Message 10 of 56
(11,628 Views)