LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous Reading of a string

Hi

I am reading values from an ultrasonic sensor serially using VISA from a microconroller.The values are of the time that the signal takes to travel from and to the sensor and is in ASCII say 22223333 and so on giving 2 bits in 0.5 sec continously.I created a VI where i take the first 2 bits 22 and convert to hex 32 32 and using a subset i give offset of 4 and then convert this to decimal so that i can put the formula to calculate the distance travelled.The conversion works but the problem is after first two bits 22 i want to keep calculating for the other bits continously and plot it in a graph.Eg. for 2233 first 22 gives 0.5 m then for 33 gives 0.6 m and so on..Can anyone suggest ideas as to how i should keep reading from the ASCII string and keep calculating and plotting aswell??
Thanks in advance 

0 Kudos
Message 1 of 8
(4,180 Views)

Please attach your VI instead of a picture. for example we cannot tell the datatpye of your diagram constants. Also whatever you are doing looks highly convoluted.

 

In any case, you need to put this in a loop for continuous reading.

0 Kudos
Message 2 of 8
(4,175 Views)

I did try putting it in a loop but i am missing something.i'll attatch both vis.please have a look.

Thank you

Download All
0 Kudos
Message 3 of 8
(4,173 Views)

Hi Simon,

 

try this:

check.png

Btw. "22" results in 0.53, "33" gives you 0.54!

 

You really should read the manual of your sensor and give better explanations on that conversion routine...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 8
(4,163 Views)

Yes you are right its 0.53 and 0.54 , i just din remeber the answers coz i did this in my lab and nt at home.The speed of signal is 330m/s so i'm just using D=S*T and by 2 coz its the time for a round trip.The formua is rite trust me.And this is just for the first 2 bits what should i do for the remaining??And i figured that i might have to use arrays to save the answers if i am to plot in a graph.Could you send me a vi instead of the image pls.

Thank you

 

P.S i've seen many solutions of yours and i must tell you are amazing Smiley Very Happy

0 Kudos
Message 5 of 8
(4,154 Views)

Hi Simon,

 

that "image" is actually a snippet, you can use it in LabVIEW. (Just search the help for "snippet".)

 

Btw. English isn't my first language, so reading your message is really hard with all those abbrevations and 'slang'. Could you please write proper English?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 8
(4,150 Views)

Hi GerdW

 

i tried out your code and its perfect i must say thank you.If i need to plot this in graph with x axis as time and y axis as amplitude what should i do?I simply gave a clock and the result into the XY graph but it did not work.And if i am using the serial read-write VI and i constantly get values while reading, will your code work for simultaneous conversion??

0 Kudos
Message 7 of 8
(4,139 Views)

Hi GerdW

 

I am attatching the the serail read write VI along with your code.I just wanted to know that when i am constantly reading values from the sensor will i be able to plot it simultaneously aswell ??

Thank you

0 Kudos
Message 8 of 8
(4,125 Views)