Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing different measurments to a PIC

I have been working with recieving serial data via uart to labview parsing that data to reconstruct a AC signal then doing analysis on that signal to get amp and phase. The phase is incorrect cause of no time reference im working on that so for now im just using the tone measurment function to get a phase from my data. Then after that i want to write these measurments back to my PIC. My micro expects the values to be formated as follow.

 

A123P123

 

when my micro detects an "A" it knows the amplitude, and "P" for phase so im using the "format into string" to append the "A" and "P" to the amplitude and phase values.

 

My question is can i use the visa write in the consumer loop like the attached picture of my code while i have the visa read in the producer. Also will the format into string work.

Download All
0 Kudos
Message 1 of 12
(4,362 Views)

For what I am seeing in your code you are getting data (that you need to analyze) and then write it to your PIC, if so, then I do not think that what you are doing is wrong. You are reading your data enqueuing the data, then you analize and write that analized data to you PIC usign VISA Write (with a strig due VISA write needs a string as a write buffer). 

I am adding some links for you about P/C architectures that you can use as example to help you with yours:

http://www.ni.com/white-paper/3023/en/ (Producer/Consumer design)

https://decibel.ni.com/content/docs/DOC-22047

https://decibel.ni.com/content/docs/DOC-2431 (this eventhoug is used with DAQmx it has pretty much the same thinking as yours: Read then write)

ftp://ftp.ni.com/pub/events/labview_dev_ed/2009/labview.pdf (info)

 

Hope this will help you

0 Kudos
Message 2 of 12
(4,322 Views)

I cant seem to get the correct values for the Frequency, amplitude, and phase. I am just getting bits of a number for some reason. The result string seems to be in the format i expect but not the correct values. You can see in the image the result string and actual values i expect to write to uart.

0 Kudos
Message 3 of 12
(4,292 Views)
You've obviously changed the code from your original post. Why haven't you shown what the change is?
0 Kudos
Message 4 of 12
(4,274 Views)

sorry i added the frequency as well so the micro expects the following order of the data.

 

P#F#V#               where # is the number not any special character.

 

When micro dectects P it knows the phase

F = frequency

V = Voltage.

 

I just have the wrong wires going into the wrong spot then the picture the Phase and Frequency are mixed up that why i arranged the frequency then phase, and voltage under the result string so the P is actually getting the frequency and so on. Not anything that messing up the code. I also cut numbers after decimal. So the string should be getting the numbers underneath but is not i dont know if its the format to string function or if i shouldnt being wiring the components of of extract tone function the way i am into the format string function.

 

 

Download All
0 Kudos
Message 5 of 12
(4,259 Views)

You aren't cutting any decimals in this version. What did you do with the version that shows the numeric results and the string? Does the micro expect a termination character? You aren't sending one.

0 Kudos
Message 6 of 12
(4,245 Views)

Here is that verison.   the micro sends data then labview analyzes it and then sends it back and the micro waits for the interrupt to display the voltage,freq,phase on the lcd it wont release data again until the interrupt is enabled each time

 

When i use constants on the format string for some reason the micro likes that and will display it and work as i like.

Download All
0 Kudos
Message 7 of 12
(4,232 Views)
0 Kudos
Message 8 of 12
(4,227 Views)
The blue wires and the I32 inputs of the Format Into String mean you are converting to integers. Why? Your other code does not do that? You are getting exactly what you programmed it to do. If you want to limit the number of decimal places, that can be done in the format string where you are converting orange wires. For example %.3f will give you 3 decimal places.
0 Kudos
Message 9 of 12
(4,222 Views)

okay but besides that either way when i am sending those measurment back to my micro,they wont show and my micro wont recognize it. Although if intead of wiring the components from the "Amp-freq single tone function"  to the "format string function" just use constants on the "format string function" my micro detects that and writes that to the lcd.

 

My question is why doesnt the values from the amp-freq single to the "format string" function go through to the micro and the constant do.

 

Does that make sense???

0 Kudos
Message 10 of 12
(4,215 Views)