07-13-2023 07:48 AM - edited 07-13-2023 07:54 AM
Running into an issue I haven't been able to solve yet. Trying to communicate with a Sierra Instruments flowmeter. The flow meter has no issue communicating with its intended software, so I know it is not a driver or cable issue. I have attached a reference on the command overview. Also attached is my VI and screenshots. My comm settings are correct.
Solved! Go to Solution.
07-13-2023 08:02 AM - edited 07-13-2023 08:03 AM
07-13-2023 08:05 AM
Hi Rapheal,
According to the datasheet, each command has a length of 2 bytes. The response to the command is also 2
bytes. The low byte is always transmitted/received first followed by the high byte.
Thanks!
07-13-2023 08:27 AM
Hi derek,
why do you think you could use ScanFromString here?
@parker300 wrote:
According to the datasheet, each command has a length of 2 bytes. The response to the command is also 2
bytes. The low byte is always transmitted/received first followed by the high byte.
Use StringToU8Array, index the bytes as needed and do whatever you want to do with them…
07-13-2023 08:28 AM - edited 07-13-2023 08:30 AM
This device is using hex/binary/raw data formats. So...
1. You need to turn the Termination Character OFF
2. The Scan From String will not work. Use Unflatten From String instead.
The Scan From String is expecting ASCII text. But your device is sending the data in its raw format.
07-13-2023 08:35 AM - edited 07-13-2023 08:56 AM
For future readers, here is the part of the datasheet that describes the command and answer:
crossrulz 's solution implements that perfectly.
07-13-2023 09:24 AM - edited 07-13-2023 09:47 AM
Crossrulz,
Thanks for the help. When I copy your code, I get this error 74 message, saying my data is corrupted. Do you know the root of this?
07-13-2023 09:27 AM - edited 07-13-2023 09:44 AM
Regardless, setting a default data to littoral "%x", leaving the format specifier blank, (default specifier %f) then, passing in an hex codes string is just as wrong as you can be!
You could use Scan from String with a %x format specifier and a default value of 0 AS U16 or I16 then use swap bytes. However, the Unflatten From String is more scaleable.
07-13-2023 09:51 AM - edited 07-13-2023 10:03 AM
@parker300 wrote:
Crossrulz,
Thanks for the help. When I copy your code, I get this error. Do you know the root of this?
You tried to unflatten to an array of integers rather than a scalar integer. Worse, you are only getting two character on your read String and you might need to read 4 e.g "6209" equals 0d 2402
Probe the read string! Is it "6209" or "c\t" ,lowercase c horizontal tab,
Tim must be decaffeinated today.
07-13-2023 10:15 AM
@JÞB wrote:
@parker300 wrote:
Crossrulz,
Thanks for the help. When I copy your code, I get this error. Do you know the root of this?
You tried to unflatten to an array of integers rather than a scalar integer. Worse, you are only getting two character on your read String and you might need to read 4 e.g "6209" equals 0d 2402
Probe the read string! Is it "6209" or "c\t" ,lowercase c horizontal tab,
Tim must be decaffeinated today.
1. I don't drink coffee, so I'm always decaffeinated.
2. Look at the data sheet. It clearly states the response is 2 bytes. The example is showing the two bytes in hexadecimal, showing the combination, and what the decimal equivalent would be to make it more human readable. Further, in \ Codes it should show "b\t", a lower case b and a tab.
3. Looks like Jay is the one who needs coffee.