10-09-2009 05:50 AM
Hi there,
I have already successfully managed to communicate between LabVIEW 7.1 and my PIC18F2450, currently Im just using standard VISA Read and VISA write functions. I send a request to the microcontroller and immediately afterwards it sends me back around 10-20 bytes of data. That all works fine,
but now I would like to setup a more advanced system. I would like to sample a sine wave with the PIC's A/D converter and display this data real-time in a LabVIEW VI.
Now I have two ideas on how to do this. I can either send packets of around 100 bytes at a time frequently, or else I can continuously send single bytes immediately after I have sampled the A/D, which one is the better solution and which is the most suitable VISA Control to handle this kind of interrupt ?
If anyone has any suggestions I'd be glad to hear about them.
10-12-2009 04:22 AM
Hi eoin87,
Glad to hear you've got the initial communication working between the PIC and your VI. If you are looking to sample sine waves using this method, the optimisation would be dependant on the frequency of the input. For higher frequencies, you should send packets of bytes at a time like you say, but for very low frequencies continuously sending single bytes will be fine, considering LabVIEW would be able to finish all the background processes without losing data.
You can read the input of the transmission into a shift register. For example, if you are sending packets of 100 bytes, you may want to have your shift register hold 1000 bytes before you start updating the display. This is where your display may be off-real-time. However, if you want to update your display closer to real-time, you must either use a small packet size, or send single bytes. If you have to include a header with every transmission, sending single bytes or small packets may not suit the application though. The best method is to try some scenarios to find the optimal packet size for transmitting.
In the NI Example Finder (Help menu -> Find Examples) search for serial, and you will find Basic Serial Write and Read.vi. This example is very good for showing the basics of communication using VISA, and the VI is set up so that you can customise the following settings: baud rate, data bits, parity, stop bits, flow control, and delay.
I hope that my input is helpful to you.
Regards,
Imtiaz Chowdhury
Project Manager
Green Running / Austin Consultants
06-17-2011 06:52 AM
06-17-2011 06:52 AM