Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

phasors measurments from serial data

Hello,

so i am sampling a voltage from a standard wall outlet, through the adc on my microcontroller, then the values are sent through uart to labview. I managed to get all the values and replicate the 120vac Sine wave.Im not to sure if i can do that. Also for the amplitude i made up my own formula that would give me 120Vrms. I heard something about resolution from my adc to get amplitude also. I am now wondering how would i calculate the frequency, i figured i can take the period to be peak to peak of the sine wave and then take 1/t to get the frequency. The frequency should be 60hz. Im not to sure if i can do that. Also would like to get phase angle. I have attached images of front and block panel of code.

0 Kudos
Message 1 of 11
(4,901 Views)

Everything depends on how you are sampling the signal in the microcontroller.  

 

The period is the separation of positive zerocrossings (or peaks) of the sine wave in samples multipiied by the sample period. Nothing in the images you posted gives any indication of what the sampling rate is.  The output of the Extract Tone Information VI will not have the correct frequency because you do not provide an accurate value for dt. It defaults to 1.

 

The phase angle can only be defined with respect to some kind of timing reference point. The only reference point you have available is the time you start the acquisition. But since that is completely random and arbitrary with respect to anything in the power system, phase is meaningless.

 

If you measure both voltage and current, then you can define a phase angle between them to obtain power factor.

 

Lynn

0 Kudos
Message 2 of 11
(4,870 Views)

the sample rate is at 3900 samples per second. Im sending sets of 512 numbers and have the byte count on visa read at 4650.see attached vi.

0 Kudos
Message 3 of 11
(4,831 Views)

so not to sure how to incorporte that still

0 Kudos
Message 4 of 11
(4,829 Views)

The image below shows how to insert the sample rate information into the waveform.

 

Lynn

 

Sample Rate.png

0 Kudos
Message 5 of 11
(4,810 Views)

Hey thanks for that it worked. Your awesome. I also had another question so i am also going to integrate a GPS reciever into my code on my pic so that way i can get the phase angle from the voltage. Basically each sample will be time stamp when sending the data through UART so as far as separation from data and time would i also create a "new visa read" to find the time and use spreadsheet string array again. Then have the ouput connected to ''T0" on wavform for start.

0 Kudos
Message 6 of 11
(4,765 Views)

I am not sure I fully understand what you are doing. 

 

I think I would create one string on the PIC which contains both the time stamp and the voltage data. Since you are already sending comma-separated data, just add the necessary element (or elements) for the timestamp at the beginning. This is probably easier than trying to keep track of two different strings from the same device.

 

Lynn

0 Kudos
Message 7 of 11
(4,743 Views)

Okay yes that the way i am writing the code for the microcontroller and i am about done, but when getting the data with voltage  and timestamp value how would i separate them, like im using the "spreadsheet string to array" to get voltage values and plot them, so not to sure how to separate timestamp and voltage and get  into the waveform and once i do separate them Would i just send the time stamp to the  "t0" on wave form and that would correspond to timestamp for each data to get phase angle. code snippet below

0 Kudos
Message 8 of 11
(4,657 Views)

Hi narlun2010,

 

The queue in your code is outputting sets of 512 numbers deliminated by commas, correct?

0 Kudos
Message 9 of 11
(4,571 Views)
Correct I just can't seem to separate the voltage values from the the gps time. I use a "scan from string" to get the time then have that output to the "to" of build waveform to time stamp voltage values then have the remaining string go into a spreadsheet to string to get the voltage voltage values and plot the sine wave
0 Kudos
Message 10 of 11
(4,530 Views)