LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronizing RS-232 Reception and DAQ acquisition .

Dear all,

Thanks for taking the time to read my post.

I am using Labview 8 on Win XP CPU 3.4, 2GB RAM PC.

I am using a microcontroller PIC24 (on the Explorer 16 development board), which I have programmed to acquire two AC signals at a rate of 400 point per 50Hz cycle (i.e. 20kHz sampling rate but only 400 per second). The PIC24 uses a 16-bit ADC to acquire the data and then transmits via RS-232 to my PC running Labview.

In order to send the acquired value to my PCs serial port (Remember UART = 8-bits of data only) I divide the 16 bit word into MSB and LSB. I then send the MSB and LSB 8-bit value one after the other.

The transmission format is format I use is:
Channel_1_ADC_High = d15-d14-d13-d12-d11-d10- d9-d8
Channel_1_ADC_LOW = d7-d6-d5-d4-d3-d2-d1-d0
Channel_2_ADC_High = d15-d14-d13-d12-d11-d10- d9-d8
Channel_2_ADC_LOW = d7-d6-d5-d4-d3-d2-d1-d0

To make things a bit more clear, the PIC has a small, 4-bytes Hardware buffer and I have implemented a 2049-byte software buffer before that. I should point out that the PIC is sending its acquired data in uncontrolled chunks of data.

The serial settings for the PIC and my Labview program are 460800, 8 data bits, no parity, 1 stop bit.

I am using a producer-consumer approach to receiving (and processing) the data.

I would now like to add two DAQ channels to my code. I am using a PCI-6220 DAQ which I would like to acquire data at a rate of 400 points per 50Hz cycle (i.e. 20kHz sampling rate but only 400 per second). I should point out here that I am measuring a power line signal (i.e. at European 50Hz frequency).

My idea was to try and get labview to receive the data from the serial port and once this happens, to trigger the DAQ to measure the two signals. As I am only receiving 800 point per second (400 points* two channels), I am under the impression that their should me more than enough time to measure two signals using the DAQ, before new data arrive.

I have tried quite a few things and I never seem to get what I need. My understanding is that I only measure one point via the DAQ for every 400 points I receive via the serial port.

I have added my VI’s below and I would greatly appreciate any advice.

I am not certain whether I should be going down the time loop approach or not?

Please remember I am using LV 8.

Thank you.

Regards
Alex
Message Edited by bogiasac on 08-24-2008 09:49 AM
0 Kudos
Message 1 of 15
(3,840 Views)

Could not seem to add more that 3 attachments....

0 Kudos
Message 2 of 15
(3,838 Views)

Hi Alex,

 

Just to clarify, you're looking to acquire 400 samples at 20kHz once per second - is that correct?

 

Do you have a hardware trigger you can use for this operation, or is software timing sufficient? Either way is possible, although hardware would be more reliable.

 

Regards,

Tom

Applications Engineering, NI UK
0 Kudos
Message 3 of 15
(3,779 Views)

y newbie my nane is Emerson 

y need to tryng the same project please help-me i live in brasil y use pic16f877a ,max232 cristal 4mhz

my pic send strig this form

channel a

channel b

or

100

200

100

200

 

100 is the value to channel a

200 is the value to channel b

please help-me

Message Edited by magnoedu on 01-29-2009 05:10 PM
0 Kudos
Message 4 of 15
(3,628 Views)

magnoedu wrote:

y newbie my nane is Emerson 

y need to tryng the same project please help-me i live in brasil y use pic16f877a ,max232 cristal 4mhz

my pic send strig this form

channel a

channel b

or

100

200

100

200

 

100 is the value to channel a

200 is the value to channel b

please help-me

Message Edited by magnoedu on 01-29-2009 05:10 PM

 

You should have started a new thread rather than adding onto someone else's.

Your English is very unclear.  And you want help, but you don't ask any question.  What do you need help with?

0 Kudos
Message 5 of 15
(3,617 Views)
and sorry my English is horrible , I did not want to bring inconvenience to you, I would do the same project of the friend, but the examples are separated are not in one VI, I am new to LabVIEW, my problem and how the reading of two strings sent by the microcontroller.
I changed one VI to read an analogue channel but I need two channels,
I have no problems with microcontroller only with LabVIEW
Download All
0 Kudos
Message 6 of 15
(3,607 Views)

You have the termination character enabled, which means the VISA read will read up until the termination character is detected which is set for hexA or decimal 10, which is ASCII character new line.

 

I would recommend putting two consecutive reads in the For loop, the results from the first read will go to one channel, the second read to the second channel.  That way ever loop iteration will be able to read each data point of the interlaced data.

 

One problem you'll have is that with your data stream, there is no guarantee the first data point it reads will be channel A and the 2nd channel B.  If you start the program at just the wrong time with this continuously streaming data, you could wind up with channel B first, and there would be no way to programatically know this.

0 Kudos
Message 7 of 15
(3,588 Views)
friend you could do an example for me to see please
0 Kudos
Message 8 of 15
(3,581 Views)
0 Kudos
Message 9 of 15
(3,562 Views)
but friend his example and the same , that I sent you must read two different strings and different values to two meters
0 Kudos
Message 10 of 15
(3,555 Views)