Conversion from GPIB to visadev : BusManagementStatus

2 Ansichten (letzte 30 Tage)
Théophane Dimier
Théophane Dimier am 24 Feb. 2023
Dear Matlab community,
I was using the "traditional" gpib interface (see https://ch.mathworks.com/help/instrument/gpib.html) to communicate with a measurement device. After having seen the warning that this approach would soon be removed, I decided to modify my code to use the visadev based approach, following the recomandations given here. Everything works well apart from the BusManagementStatus that has been removed without giving a straight forward alternative.
My code was performing the following loop to wait for the device to be ready:
while ~strcmp(inst.BusManagementStatus.ServiceRequest,'on')
pause(0.25);
end
Where inst is the instrument as returned by gpib function.
Following the description of the visastatus function (see https://ch.mathworks.com/help/instrument/visadev.visastatus.html?s_tid=doc_ta), I have modified my code to (inst is now returned by visadev):
[status_bit,status_flag]=visastatus(inst);
while ~status_bit
pause(0.2);
[status_bit,status_flag]=visastatus(inst);
end
But this does not result in the same behaviour as the original code (the loop is never executed or only once). I then decided to use the second output argument of the visastatus function to look specifically at the RSQ bit (bit number 6 according to the documentation of visastatus, hence the masking with 64=0x44=0b01000000):
[status_bit,status_flag]=visastatus(inst);
while ~bitand(uint8(status_flag),uint8(64))==64 %test if RQS bit is at 1
pause(0.2);
[status_bit,status_flag]=visastatus(obj.inst);
end
But this still does not work. Using the software GPIB Analyzer by NI, I could see live the status of the RSQ bit which was sometimes different from what visastatus was returning. Is there any documentation on how to convert the behaviour of BusManagementStatus into the visadev approach?
Thanks in advance for the help

Antworten (1)

Nikhilesh
Nikhilesh am 9 Mär. 2023
There isn't a direct equivalent to the BusManagementStatus function in the visadev approach. The visadev approach uses the VISA standard for communication, which is different from the GPIB standard used by gpib.
However, you can use the visastatus function to check the status of the instrument. The visastatus function returns a status bit vector and a status flag, which indicate the status of the instrument.
  1 Kommentar
Théophane Dimier
Théophane Dimier am 9 Mär. 2023
Thanks for taking the time to answer my question, nevertheless visastatus does not work, as mentionned in my original message. It seems that the mapping between the status bit vector and the actual status of the bus is not correct.
I used a workaround for my problem by using a try-catch structure with a tentative read with a short timeout, at least I could get the desired behaviour even if it is a bit "dirty"...

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Instrument Control Toolbox Supported Hardware finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by