ni.com is currently experiencing unexpected issues.

Some services may be unavailable at this time.

取消
显示结果 
搜索替代 
您的意思是: 

ADC signal formating problem!!

已解决!
转到解答

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 项奖励
1 条消息(共 9 条)
3,944 次查看

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 项奖励
2 条消息(共 9 条)
3,929 次查看

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 项奖励
3 条消息(共 9 条)
3,925 次查看

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 项奖励
4 条消息(共 9 条)
3,917 次查看

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 项奖励
5 条消息(共 9 条)
3,912 次查看

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 项奖励
6 条消息(共 9 条)
3,909 次查看
解答
接受人 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 项奖励
7 条消息(共 9 条)
3,900 次查看

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 项奖励
8 条消息(共 9 条)
3,893 次查看

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 项奖励
9 条消息(共 9 条)
3,868 次查看