Conversion from GPIB to visadev : BusManagementStatus

조회 수: 2 (최근 30일)
Théophane Dimier
Théophane Dimier 2023년 2월 24일
댓글: Théophane Dimier 2023년 3월 9일
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

답변 (1개)

Nikhilesh
Nikhilesh 2023년 3월 9일
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
Théophane Dimier
Théophane Dimier 2023년 3월 9일
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"...

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Instrument Control Toolbox Supported Hardware에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by