Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

GPIB-USB and Matlab

Hi!

 

Thanks for your help. I was about to send this command:

 

REM on\r\n

 

and the remote switched to ON!

 

But I cannot turn it off with REM off\r\n in the same instance? I have to close the "communicate with device" window and re-open it to send REM off\r\n for it to turn off. Why is this?

0 Kudos
Message 41 of 51
(3,369 Views)

Are you able to send any commands at all (such as a *IDN?), or are all of your commands invalid until you close and re-open the session?

 

Ryan

Applications Engineer
National Instruments
0 Kudos
Message 42 of 51
(3,348 Views)

I am unable to send ANY commands until I close and reopen it.

0 Kudos
Message 43 of 51
(3,346 Views)

Hi Tnguyen628,

 

Do you mean you are unable to send commands or the device does not respond to commands at this point?  Also did you write your REM ON command using a WRITE operation or a QUERY operation?  The WRITE operation sends the command without waiting for a response.  The QUERY operation send the command and then waits for a response.  It does not sounds like this is an issue with the USB-GPIB-HS, rather it is an issue with not sending the proper commands and getting proper responses from the device.  You should consult the manual for this device and read some material to become more familiar with how GPIB communication works.  Looking at page 109 of that device manual it looks like you should be receiving a reply after using the REM command in the following format: [ on | off ] <CR> <LF and EOI>.

Justin D
Applications Engineer
National Instruments
http://www.ni.com/support/
0 Kudos
Message 44 of 51
(3,317 Views)

 


@JD_war_eagle wrote:

Hi Tnguyen628,

 

Do you mean you are unable to send commands or the device does not respond to commands at this point?  Also did you write your REM ON command using a WRITE operation or a QUERY operation?  The WRITE operation sends the command without waiting for a response.  The QUERY operation send the command and then waits for a response.  It does not sounds like this is an issue with the USB-GPIB-HS, rather it is an issue with not sending the proper commands and getting proper responses from the device.  You should consult the manual for this device and read some material to become more familiar with how GPIB communication works.  Looking at page 109 of that device manual it looks like you should be receiving a reply after using the REM command in the following format: [ on | off ] <CR> <LF and EOI>.


I did a WRITE operation with REM on\r\n - the instrument will turn on.

 

But when I do REM off\r\n the instrument will NOT turn off.

 

I have to restart "Communicate with instrument" in order to do REM off\r\n

 

0 Kudos
Message 45 of 51
(3,300 Views)

Hi Tnguyen628,

 

It states in the manual for the device that when sending the REM ON command, the device will reply with a result string.  Which means after you have written this command you will need to read the data off the lines from the device.  So try using a QUERY when writing the REM ON command or perform a WRITE of the REM ON command and then a READ to read the response from the instrument.

Justin D
Applications Engineer
National Instruments
http://www.ni.com/support/
0 Kudos
Message 46 of 51
(3,287 Views)

Hello,

 

I have the following problem:

I try to communicate through Matlab with the device (Anritsu pulse-pattern generator) using GPIB connection.

Here is the code: 

 

ppg_addr='GPIB0::16::INSTR';
v = visa('ni',ppg_addr);

fopen(vtek);

fprintf(vtek,'*IDN?\n')

fscan(vtek);

fclose(vtek);

 

I have the Instr. control toolbox and the 488.2 drivers installed.

The "fopen" command sucessfully establishes communication (also, the GPIB remote led indicator lights up on the device).

However, during the execution of "fscan" (also if I replace it by "query" or "fgets") I get the timeout error.

Also using some command such as, for instance, "fprintf(vtek,'LGC 1\n')" that is supposed to set pattern logic I have the same result. 

When I use the NI Visa interactive control, for the same menemonics, the communication is fine, I put these commands in viWrite and they are recognized OK by the device.

I also tried to work without \n in Matlab, but the result is the same.

Is there some configuration that Interactive control sets that I have to add in Matlab?

 

Any help is appreciated

Tnx 

 

 

 

0 Kudos
Message 47 of 51
(3,138 Views)

In the previous post the object name is vtek and not v 🙂

 

Also, some more information that might help: The get command results in:

 

out = get(vtek)

out =

Alias: ''
BoardIndex: 0
ByteOrder: 'littleEndian'
BytesAvailable: 0
BytesAvailableFcn: ''
BytesAvailableFcnCount: 48
BytesAvailableFcnMode: 'eosCharCode'
BytesToOutput: 0
EOIMode: 'on'
EOSCharCode: 'LF'
EOSMode: 'none'
ErrorFcn: ''
InputBufferSize: 512
Name: 'VISA-GPIB0-16'
ObjectVisibility: 'on'
OutputBufferSize: 512
OutputEmptyFcn: ''
PrimaryAddress: 16
RecordDetail: 'compact'
RecordMode: 'overwrite'
RecordName: 'record.txt'
RecordStatus: 'off'
RsrcName: 'GPIB0::16::0::INSTR'
SecondaryAddress: 0
Status: 'open'
Tag: ''
Timeout: 10
TimerFcn: ''
TimerPeriod: 1
TransferStatus: 'idle'
Type: 'visa-gpib'
UserData&colon; []
ValuesReceived: 0
ValuesSent: 0

0 Kudos
Message 48 of 51
(3,137 Views)

In the previous post the object name is vtek and not v 🙂

 

Also, some more information that might help: The get command results in:

 

out = get(vtek)

out =

Alias: ''
BoardIndex: 0
ByteOrder: 'littleEndian'
BytesAvailable: 0
BytesAvailableFcn: ''
BytesAvailableFcnCount: 48
BytesAvailableFcnMode: 'eosCharCode'
BytesToOutput: 0
EOIMode: 'on'
EOSCharCode: 'LF'
EOSMode: 'none'
ErrorFcn: ''
InputBufferSize: 512
Name: 'VISA-GPIB0-16'
ObjectVisibility: 'on'
OutputBufferSize: 512
OutputEmptyFcn: ''
PrimaryAddress: 16
RecordDetail: 'compact'
RecordMode: 'overwrite'
RecordName: 'record.txt'
RecordStatus: 'off'
RsrcName: 'GPIB0::16::0::INSTR'
SecondaryAddress: 0
Status: 'open'
Tag: ''
Timeout: 10
TimerFcn: ''
TimerPeriod: 1
TransferStatus: 'idle'
Type: 'visa-gpib'
UserData&colon; []
ValuesReceived: 0
ValuesSent: 0

 

If I run from Matlab's test & measurement tool, i get: "an error occured while communicating with the instrument". 

0 Kudos
Message 49 of 51
(3,129 Views)

I think you need to contact Mathworks. NI's hardware and software are working just fine.

0 Kudos
Message 50 of 51
(3,126 Views)