How can I send a square wave to the Tektronix AFG 3022B function generator and change its amplitude using a "To Instrument" block in Simulink?
조회 수: 2 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2019년 6월 18일
편집: MathWorks Support Team
2020년 3월 11일
How can I send a square wave to the Tektronix AFG 3022B function generator and change its amplitude using a "To Instrument" block in Simulink?
채택된 답변
MathWorks Support Team
2020년 3월 11일
편집: MathWorks Support Team
2020년 3월 11일
You can use the following settings in the "To Instrument" block in order to achieve this in Simulink:
1) In the "Hardware Configuration" tab, you can specify the interface or use the object from the MATLAB workspace.
2) In the "Instrument Initialization" tab, select "Execute function" and provide a function (for example: configureInstrument).
3) Create a MATLAB function with one input argument (the VISA object), for example:
function configureInstrument(v)
fprintf(v, '*RST');
fprintf(v, 'SOURCE1:FUNCTION SQUARE');
fprintf(v, 'SOURCE1:FREQUENCY 10E3');
fprintf(v, 'SOURCE1:VOLTAGE:AMPLITUDE 1.00');
fprintf(v, 'SOURCE1:VOLTAGE:OFFSET 0.00');
fprintf(v, 'SOURCE1:PHASE:ADJUST 0DEG');
fprintf(v, 'OUTPUT1:STATE ON');
end
4) In the "Send" tab set:
a) Command: 'SOURCE1:VOLTAGE:AMPLITUDE ' (with single quotes, the space at the end is important)
b) Output format: ASCII
c) ASCII format string: '%.2f\n'
With this configuration, at every simulation timestep the command sent to the instrument is going to look like this: 'SOURCE1:VOLTAGE:AMPLITUDE 1.94' (for an amplitude of 1.94). The amplitude value corresponds to the value of the signal at the input port of the "To Instrument" block.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Instrument Connection and Communication에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!