Instrument control package: Difference between revisions
Jump to navigation
Jump to search
no edit summary
No edit summary |
No edit summary |
||
Line 313: | Line 313: | ||
# the timeout can be overwritten for single read call, in this case 1000ms | # the timeout can be overwritten for single read call, in this case 1000ms | ||
data = tcp_read(t0, 12, 1000) | data = tcp_read(t0, 12, 1000) | ||
# close tcp session | |||
tcp_close(t0) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | }} | ||
== USBTMC == | |||
=== Configuring interface === | |||
Recent linux kernels support USBTMC out of the box. Connect your instrument and check if /dev/usbtmc* exists. Set appropriate permissions to /dev/usbtmc* | |||
=== Example: basic use === | |||
{{Code|USBTMC example|<syntaxhighlight lang="octave" style="font-size:13px"> | |||
# Open interface to USB instrument | |||
t0 = usbtmc('/dev/usbtmc0') | |||
# write to listener | |||
usbtmc_write(t0, '*IDN?') | |||
# Blocking read call, returns uint8 array | |||
data = usbtmc_read(t0, 10000) | |||
# Convert uint8 array to string, | |||
char(data) | |||
# close usbtmc session | |||
usbtmc_close(t0) | |||
</syntaxhighlight> | |||
}} | |||
== VXI11 == | |||
=== Example: basic use === | |||
{{Code|VXI11 example|<syntaxhighlight lang="octave" style="font-size:13px"> | |||
# Open VXI11 connection to 192.168.100.100 | |||
t0 = vxi11('192.168.100.100') | |||
# write to listener | |||
vxi11_write(t0, '*IDN?') | |||
# read from instrument, returns uint8 array | |||
data = vxi11_read(t0, 10000) | |||
# Convert uint8 array to string, | |||
char(data) | |||
# close usbtmc session | |||
vxi11_close(t0) | |||
</syntaxhighlight> | |||
}} | |||
=== Limitations === | |||
For now, | |||
* it's not possible to connect more than one instrument per IP address (e.g. VXI11-GPIB gateways) | |||
* only instrument _inst0_ can be connected | |||
== GPIB == | |||
=== Configuring interface === | |||
For using GPIB you need to install and configure the linux-gpib kernel modules and libraries. | |||
=== Example: basic use === | |||
{{Code|GPIB example|<syntaxhighlight lang="octave" style="font-size:13px"> | |||
# Open GPIB instrument with ID 7 and set timeout to 1 second (see ibtmo / NI-488.2 Function Reference) | |||
t0 = gpib(7,11) | |||
# write to listener | |||
gpib_write(t0, '*IDN?') | |||
# read from instrument, returns uint8 array | |||
data = gpib_read(t0, 10000) | |||
# Convert uint8 array to string, | |||
char(data) | |||
# close usbtmc session | |||
gpib_close(t0) | |||
</syntaxhighlight> | |||
}} | |||
=== Limitations === | |||
* setting minor, sad, send_eoi and eos_mode not implemented yet | |||
[[Category:OctaveForge]] | [[Category:OctaveForge]] | ||
[[Category:Packages]] | [[Category:Packages]] |