10-27-2014 08:17 PM
Hi everyone,
it's a very urgent inquiry. can anyone please help me?? Thanks very much!!
I wrote some commands into several registers using VISA write. now I want to read the value from another register.
But the bytes returned are just the commands I written before, and some other commands which I don't know what they are for.
this is the command format, and I have attached the datasheet.. I want to read the value from register (0*41)
.
Solved! Go to Solution.
10-27-2014 08:19 PM
this is the snippet:
10-27-2014 08:30 PM
Have you tried sending a 4byte message
0000 0000 0x00
0100 0001 0x41
0000 0000 0x00
0000 0000 0x00
Then read the message and pull the message from the last two bytes?
AND
0x00
0x00
0xFF
0xFF
This will give you the value in the 16 bit register without the rest of the data included in the message. You can always check the rest to make sure you get good data.
10-27-2014 08:38 PM - edited 10-27-2014 08:42 PM
Hi, so I should write 0 to register 0*41, and then use VISA read, and AND the last 2 bytes with 0*ff?
10-27-2014 08:43 PM - edited 10-27-2014 08:44 PM
Never mind.
10-27-2014 08:45 PM
Hi, but how to pull the message of the last two bytes?
10-27-2014 08:53 PM
String subset.
10-27-2014 08:55 PM
I wrote 0 to 0*41, but in the read buffer is D841 0000, it didn't give the value in that register.
10-27-2014 09:47 PM
Ravens, if you've got something more than me, don't nevermind it at all 😃
The command you posted has several components:
The grey area the transport layer uses for a checksum
several bits set to 0.
a single bit to define if it's a read/write op
a byte to determine the register of interest.
two bytes for data.
With what you've provided, there's only three things that we need to worry about:
1) Set the R/W bit to 0 to signify we're reading rather than writing.
2) Set the second byte to 0x41 so we focus on the register of interest.
3) With a read, I can't imagine the last two bytes matter. They're likely ignored. The documentation you provided offers nothing to explain this. The most logical thing I can think of is these two bits contain the data you pass to the register if you set the R/W bit to 1.
There's two parts to this communication. The first part is a VISA Write to send the device this command. It's likely you'll need to terminate the message. You'll need to know how to do this.
The device should reply with the message you quoted in the original post. Ravens is right. It'll come back as a string. You can use string subset to separate it into the parts defined by the standard. You can use those parts to determine if the data is legitimate and then do whatever you want with the data.