Editing Instrument control package
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
Instrument-Control is a package for interfacing the outside world of hardware via Serial, i2c or Parallel interfaces. It is currently under development by Andrius Sutas | Instrument-Control is a package for interfacing the outside world of hardware via Serial, i2c or Parallel interfaces. It is currently under development by Andrius Sutas, you can browse the SVN [http://svn.code.sf.net/p/octave/code/trunk/octave-forge/main/instrument-control/ repository here] and download the package [http://octave.sourceforge.net/instrument-control/index.html here]. | ||
= Compatibility = | = Compatibility = | ||
Line 7: | Line 7: | ||
{| class="wikitable" style="text-align:center" | {| class="wikitable" style="text-align:center" | ||
|- | |- | ||
! !! Linux | ! !! Linux !! Windows (Cygwin) !! FreeBSD !! Mac OS X | ||
|- | |- | ||
! Serial | ! Serial | ||
| bgcolor="green" | v0.1.0 || bgcolor=" | | bgcolor="green" | v0.1.0 || bgcolor="yellow" | WIP || bgcolor="yellow" | WIP || bgcolor="yellow" | WIP | ||
|- | |- | ||
! Parallel | ! Parallel | ||
| bgcolor="green" | v0.1.0 || - | | bgcolor="green" | v0.1.0 || - || bgcolor="yellow" | WIP || - | ||
|- | |- | ||
! i2c | ! i2c | ||
| bgcolor="green" | v0.1.0 || - | | bgcolor="green" | v0.1.0 || - || bgcolor="yellow" | WIP || - | ||
|- | |- | ||
! TCP | ! TCP | ||
| bgcolor=" | | bgcolor="yellow" | WIP || bgcolor="yellow" | WIP || - || - | ||
|- | |||
|- | |- | ||
! USBTMC | ! USBTMC | ||
| bgcolor=" | | bgcolor="yellow" | WIP || - || - || - | ||
|- | |- | ||
! GPIB | ! GPIB | ||
| bgcolor=" | | bgcolor="yellow" | WIP || - || - || - | ||
|- | |- | ||
! VXI11 | ! VXI11 | ||
| bgcolor=" | | bgcolor="yellow" | WIP || bgcolor="yellow" | WIP || - || - | ||
|} | |} | ||
Where: <span style="background:green">(VER)</span> - Included since VER version; <span style="background:yellow">(WIP)</span> - Work In Progress and will probably be included in next release | Where: <span style="background:green">(VER)</span> - Included since VER version; <span style="background:yellow">(WIP)</span> - Work In Progress and will probably be included in next release; (-) - Not supported / Untested. | ||
You might see errors while doing "pkg install", which mean that package is unable to support related interface on your platform (e.g. due to missing header files), therefore one should <b>always</b> check for the supported interfaces before trying to use them: | You might see errors while doing "pkg install", which mean that package is unable to support related interface on your platform (e.g. due to missing header files), therefore one should <b>always</b> check for the supported interfaces before trying to use them: | ||
Line 46: | Line 37: | ||
{{Code|Check for interface support|<syntaxhighlight lang="octave" style="font-size:13px"> | {{Code|Check for interface support|<syntaxhighlight lang="octave" style="font-size:13px"> | ||
pkg load instrument-control | pkg load instrument-control | ||
if | if (exist("serial") == 3) | ||
disp("Serial: Supported") | disp("Serial: Supported") | ||
else | else | ||
Line 55: | Line 45: | ||
#similarly with: | #similarly with: | ||
# | #exist("parallel") == 3 | ||
# | #exist("i2c") == 3 | ||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||
= Examples = | = Examples = | ||
Line 143: | Line 69: | ||
Here is a simple example to get started with the serial package. It tests the RxD and TxD lines. Make sure you have defined a loopback or connected the pins of your adapter. | Here is a simple example to get started with the serial package. It tests the RxD and TxD lines. Make sure you have defined a loopback or connected the pins of your adapter. | ||
{{Code|Serial port example|<syntaxhighlight lang="octave" style="font-size:13px"> | {{Code|Serial port example|<syntaxhighlight lang="octave" style="font-size:13px"> | ||
# Open default serial port ttyUSB0 in default configuration of 115200, 8-N-1 | |||
s0 = serial() | |||
# Opens serial port ttyUSB1 with baudrate of 115200 (config defaults to 8-N-1) | # Opens serial port ttyUSB1 with baudrate of 115200 (config defaults to 8-N-1) | ||
s1 = serial("/dev/ttyUSB1", 115200) | s1 = serial("/dev/ttyUSB1", 115200) | ||
Line 156: | Line 84: | ||
}} | }} | ||
Chaging some configurations is simple done by calling helper functions | |||
{{Code|Serial port example: helper functions|<syntaxhighlight lang="octave" style="font-size:13px"> | {{Code|Serial port example: helper functions|<syntaxhighlight lang="octave" style="font-size:13px"> | ||
srl_baudrate(s1, 9600) # Change baudrate | |||
srl_bytesize(s1, 5) # Change byte size (config becomes 5-N-1) | |||
srl_parity(s1, "E") # Changes parity checking (config becomes 5-E-1), | |||
# possible values [E]ven, [O]dd, [N]one. | |||
srl_stopbits(s1, 2) # Changes stop bits (config becomes 5-E-2), possible | |||
# values 1, 2. | |||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | }} | ||
Line 180: | Line 103: | ||
Do not forget to close the ports when you are done! | Do not forget to close the ports when you are done! | ||
{{Code||<syntaxhighlight lang="octave" style="font-size:13px"> | {{Code||<syntaxhighlight lang="octave" style="font-size:13px"> | ||
srl_close(s0) # Closes and releases file descriptor | |||
srl_close(s1) # Closes and releases file descriptor | |||
srl_close(s2) # Closes and releases file descriptor | |||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | }} | ||
Line 367: | Line 283: | ||
== i2c == | == i2c == | ||
i2c | |||
== TCP == | == TCP == | ||
Line 471: | Line 347: | ||
# Convert uint8 array to string, | # Convert uint8 array to string, | ||
char(data) | char(data) | ||
# close | # close usbtmc session | ||
vxi11_close(t0) | vxi11_close(t0) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | }} | ||
=== Limitations === | === Limitations === | ||
For now, | For now, | ||
* it's not possible to connect more than one instrument per IP address (e.g. VXI11-GPIB gateways) | * it's not possible to connect more than one instrument per IP address (e.g. VXI11-GPIB gateways) | ||
* only instrument | * only instrument _inst0_ can be connected | ||
== GPIB == | == GPIB == | ||
Line 500: | Line 374: | ||
}} | }} | ||
=== Limitations === | === Limitations === | ||
* | * setting minor, sad, send_eoi and eos_mode not implemented yet | ||
[[Category: | [[Category:OctaveForge]] | ||
[[Category:Packages]] |