LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

My packet along with command to sensor get decoded !why?

my sensor is connected through serial port and i'm using labview 7.
I'm trying to send a configuration packet which is j (command) + 32byte (packet).
here are the the steps I did:
1) create an array of (configpacket)
2) convert it to desimal string
3) concatinate it with command.
4) using write serial send it to senesor.
Correct packet should be:
j00110005050505050011255000000
before i use write.vi it seems to be fine. but some how it gets converted to ASCII (i think) becuase in my sensor i get like
41414059...
i've attached a part of the code.
I would really appreciate you hel.p
0 Kudos
Message 1 of 6
(2,875 Views)
Hello Farzad,

If I understand your intention correctly, you want to get one String with 33 characters in it?!
I think, the fault lies in the conversion from your Array to the "configpacket"-String.
If you convert an Array of numbers to a String, you will get an Array of Strings.
I have written a small VI, that converts an Array to ONE String using a for-loop.

If that should not solve your problem, please ask again.

Regards

Peter Weber
NI Germany
0 Kudos
Message 2 of 6
(2,875 Views)
Hello Peter,
Thank you for your reply.
I believe the packet and j command concatinated in
a right way cause i have an indicator that gives
shows the result.
the problem lies where i'm using Write to serial
port. it seems at that time my elements in the
packet that are numbers (as they should be) get
converted to ASCII code and ascii code goes to my
sensor, instead.
it is mainly because "Write" serial accepts only
string. if i could find a way to write to serial
port the binary it would work.

Regards,
Farzad.
0 Kudos
Message 3 of 6
(2,875 Views)
Hi Farzad,

To convert an integer with an ASCII code into its corresponding ASCII character (string output):
Make sure the code is wired into the left-hand input of the Type Cast VI (Advanced>>Data Manipulation palette), and make sure that its format is U8 (a single ASCII character or code occupies only a single byte's worth of information). The output of the Type Cast VI will be the desired ASCII character. You can incorporate this character into an instrument command string using the String Concatenate VI, etc. See attached file

Hope this helps.

Regards,
Luca
Regards,
Luca
Message 4 of 6
(2,875 Views)
Hello Farzad,

I think, Luca is right with his answer.
The "number to String VI" will cast f.e. a 86 to "86", but you want to have the binary code, which is (in this case) a 'V' in ASCII.
The VI, I attached, should finally solve your problem.

Best Regards,

Peter Weber
NI Germany
0 Kudos
Message 5 of 6
(2,875 Views)
I would like to Thank you all and special thanks to Peter.
0 Kudos
Message 6 of 6
(2,875 Views)