Ni.com is currently experiencing issues that may cause some pages to fail.
Support teams are actively working on the resolution.
Ni.com is currently experiencing issues that may cause some pages to fail.
Support teams are actively working on the resolution.
06-11-2011 07:20 AM
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
06-11-2011 09:59 AM
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.
06-22-2011 02:37 PM
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
06-23-2011 11:35 AM
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.
06-23-2011 02:51 PM
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
06-23-2011 07:21 PM
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.
06-24-2011 08:05 AM
@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.
06-24-2011 08:42 AM
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
06-24-2011 08:50 AM
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
06-24-2011 09:47 AM
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.