From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ADC signal formating problem!!

Solved!
Go to solution

hi NI staff.

iam having problems trying to measuring voltages from the adc port of an PIC-18F4550 through Labview.

the fact is that iam such a newbie in G-programing, and i don't know how to converse the string that iam getting of the VISA READ module, and therefore iam not getting the data in the correct form.

iam using a 8bit adc, so i pretend to read 255 when iam at FS; but iam getting something like '48', as you can see in the screenshot attached.

0 Kudos
Message 1 of 9
(2,962 Views)

What do you mean that you "pretend to read" 255?

 

Your string indicator from your VISA read shows a character of "0".  That is the ASCII character for a value of 48.  So the byte you read is a value of 48.  And by typecasting that to a U8, you get a numeric value of 48.

0 Kudos
Message 2 of 9
(2,947 Views)

i mean, that when the ad is set at full scale, i want to get directly the amount of bits that represent it. 

but you are right, iam getting the ascii code. how can i convert it???

0 Kudos
Message 3 of 9
(2,943 Views)

You need to do that with the programming in your device.  If you want it to send a byte of 255, then you need to program your device to do that.  Right now your LabVIEW code on the PC side looks like it would work alright to convert a byte value of 255 to a numerical value of 255.

0 Kudos
Message 4 of 9
(2,935 Views)

but mi pic is doing it! in fact, when it first fail to represent what i wanted to, i connected it to the serial monitor of the CCS, and there it worked fine. iam in fact -checked by this method- sending a 255 byte, but my VI, cant convert it properly.

0 Kudos
Message 5 of 9
(2,930 Views)

No, you can't be sending a byte of 255.  Your VI shows you are sending a byte value of 48 because that is what is being read by the VISA read.

 

Are you sure your program isn't sending other bytes as well?  Is it sending data continuously?  Perhaps your VI is reading stale data, the first byte in a buffer.

0 Kudos
Message 6 of 9
(2,927 Views)
Solution
Accepted by topic author opium

i've figured it out. i dont know precisely why but it seems that the number indicator, and all the typecast conversion takes only a part of what im sending. 

it worked simply by attaching a string indicator to the outpin of the VISA-READ. it was the first option that i thought the first time, but it didnt work that time.

sorry for stealing your time and thanks for the help!! 🙂 

0 Kudos
Message 7 of 9
(2,918 Views)

So are you actually sending multiple bytes?  So if you are sending the value 255 you are actually sending the characters "2" "5" and "5"?

0 Kudos
Message 8 of 9
(2,911 Views)

no. as logically, if i send an 8 bit byte, i am receiving an 8bit byte. but, when i first started that didint worked out, so i tryed to solve it by adding numer conversion objetcs. in that point was when i started to receive data in a wrong format. 

0 Kudos
Message 9 of 9
(2,886 Views)