LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

urgent inquiry: how to read value from a register using VISA read?

Solved!
Go to solution

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)

.Untitled.png

 

0 Kudos
Message 1 of 9
(3,528 Views)

this is the snippet:
11111.png

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

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.

Message 3 of 9
(3,512 Views)

Hi, so I should write 0 to register 0*41, and then use VISA read, and AND the last 2 bytes with 0*ff?

0 Kudos
Message 4 of 9
(3,501 Views)

Never mind.

0 Kudos
Message 5 of 9
(3,494 Views)

Hi, but how to pull the message of the last two bytes?

0 Kudos
Message 6 of 9
(3,488 Views)

String subset.

0 Kudos
Message 7 of 9
(3,483 Views)

I wrote 0 to 0*41, but in the read buffer is D841 0000, it didn't give the value in that register.

0 Kudos
Message 8 of 9
(3,480 Views)
Solution
Accepted by cantata2014

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.

Message 9 of 9
(3,452 Views)