LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

pic rs232 interface with labview

Hi All

 

I would like to send a 8 bit ADC value from PIC to Labview by rs232 to show the digital value of ADC.

I have wrote a program in C# to communicate with PIC and it is working fine.

Please someone explain how labview communicate with PIC via rs232.

 

Please send me VI if possisble.

 

Regards

 

Ananth

0 Kudos
Message 1 of 22
(7,029 Views)

You already have an example VI. Click on Help/Find Examples and search for RS-232. If you do a search there are lots of threads on this forum related to just this. The examples that ship with LabVIEW are a greatly underutilized resource.

 

Since you can communicate using C# you are off to a great start. You know that the cable is good and you know the communications settings. If you try something in LabVIEW and have problems then just post back your specific questions.

=====================
LabVIEW 2012


0 Kudos
Message 2 of 22
(7,025 Views)

Here is a small example to read ADC from pic and display on labview. Everything was okay untill i add the serial write and delay in the code. After i add this, reading from pic and writing to pic is not working.

 

Could you please advise me

 

regards

 

ananth

0 Kudos
Message 3 of 22
(6,942 Views)

Are you just trying to do a serial write of "*IDN?" Also, rather than trying write and read at the same time, I'd recommend one step at a time. For example, connect an output pin on your PIC to an LED, and then try to use a simple program with just a Serial Write to set that output pin High. This way you can eliminate potential timing issues. Once you're sure you're succcessfully writing, then try a full Read/Write Query.

 

 

Product Support Engineer
National Instruments
0 Kudos
Message 4 of 22
(6,913 Views)

Dear James

 

I used the simple serial read and write example in LV. The LED connected at portA.0 is ON/OFF when it is getting ASCII code "a" and "b" from LV.

 

It is working but very slow. After i write "a" to the port, the LED is ON after a long delay.  sometime it doesn't receive the value. How i can make write and read separately. Can you please give me an example

 

Thank you

 

Ananth

0 Kudos
Message 5 of 22
(6,894 Views)

This is just a variation of your code.  The delay is still there, but part of your case structure.  Use the Bytes at Serial Port function to detect receive bytes.

Another variation would be to put the Visa receive case struction inside a while loop.  I never use a sequential operation for serial data transfer because it relies to heavily on a delay between operations (never good programming practice in any language).  Using a while loop enhances the code and you can control when it receives the data, which is dependent on the incoming data steam not on a timer.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 6 of 22
(6,881 Views)

@neomax wrote:

Hi All

 

I would like to send a 8 bit ADC value from PIC to Labview by rs232 to show the digital value of ADC.

I have wrote a program in C# to communicate with PIC and it is working fine.

Please someone explain how labview communicate with PIC via rs232.

 

Please send me VI if possisble.

 

Regards

 

Ananth


If I am not very wrong your ADC in the PIC MCU is 10 bit and not 8. It is no problem to send these 10 bits as two bytes using the serial port. In fact fact you can send what ever you want over a RS232 communication line. You just have to break it into bytes in one end. And rebuild the data to the correct format in the other end.



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 7 of 22
(6,865 Views)

Hi

 

I have tested with your VI file. Still i have the same delay problem. My PIC MCU is receiving 8 bit data from the serial port and decoding to various functions like "a" for LED ON "b" for LED OFF so and so. so i want to send variable 8bit data to serial port. Could you please advise me.

 

Regards

 

Ananth

0 Kudos
Message 8 of 22
(6,858 Views)

Dear Coq

 

Yes the PIC is sending 10 bit ADC resolution by two bytes. I am getting the values and it displays properly on the LV as you will see from the previously attached VI. Now my problem is writing to serial port. I want to write 8 bit variable data to serial port. PIC will read this value and do the variable task.

 

Please advise me.

 

Reggards

 

Ananth 

0 Kudos
Message 9 of 22
(6,857 Views)

You already have the VISA Write in your example. You don't need anything else except to make sure you are sending the correct data.

0 Kudos
Message 10 of 22
(6,844 Views)