Hi,

See attachments for examples to control the IOIO OTG using Matlab and Gnu 
Octave. You'll also need the jar files for purejavacomm, jna and a jar of 
the ioiolib.
This allows me to experiment with my IOIO OTG board with an interpreted 
high level language without any java compilation! It may also be possible 
to make Simulink blocks this way.

For octave, make sure you have the java package installed. I've used this 
version to test the script:
http://sourceforge.net/projects/octave/files/Octave%20Windows%20binaries/Octave%203.6.4%20for%20Windows%20Microsoft%20Visual%20Studio/

To whom it may concern: Thanks for creating this nice little board and it's 
accompanying software! I hope it will become very successful. I thing the 
price could come down quite a bit when production volumes increase.

Kind regards,

Ronald



-- 
You received this message because you are subscribed to the Google Groups 
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.
%This is my "Hello World" for talking to the IOIO-OTG board using Gnu Octave
%Make sure you enter the right COM port. Look for it in the Windows
%device-manager
%
%By Ronald van der Meer

comport='COM4';

pkg load java
javaaddpath('purejavacomm-0.0.11.jar')
javaaddpath('jna-3.5.1.jar')
javaaddpath('ioiolib-0330.jar')

%It may also work if this is omitted by auto-probing all ports
javaMethod('setProperty', 'java.lang.System', 'ioio.SerialPorts', comport); 
 
javaMethod('addBootstraps', 'ioio.lib.util.IOIOConnectionRegistry', {'ioio.lib.pc.SerialPortIOIOConnectionBootstrap'});
ioio=javaMethod('create', 'ioio.lib.api.IOIOFactory');
ioio.waitForConnect(); %TODO: Handle it nicely when connect fails
ledpin=java_get( 'ioio.lib.api.IOIO', 'LED_PIN');
led=ioio.openDigitalOutput(ledpin,true);

%Let's blink
for i=1:10
  led.write(0); %LED on
  pause(0.1)
  led.write(1); %LED off
  pause(0.1)
end

led.close;
clear led 
ioio.disconnect();
clear ioio
%This is my "Hello World" for talking to the IOIO-OTG board using Matlab
%Make sure you enter the right COM port. Look for it in the Windows
%device-manager
%
%By Ronald van der Meer

comport='COM4';

javaaddpath('purejavacomm-0.0.11.jar')
javaaddpath('jna-3.5.1.jar')
javaaddpath('ioiolib-0330.jar')

%It may also work if this is omitted by auto-probing all ports
java.lang.System.setProperty('ioio.SerialPorts',comport');

% imports need to be done in an eval function or in a separate file, or else the interpreter gives an error when the "javaaddpath" commands are not yet executed
% see http://www.mathworks.com/matlabcentral/answers/48233-how-come-javaaddpath-import-do-not-work-in-a-script-function
% a workaround for this seems to be to enclose the 'import' command in an
% 'eval' function.
eval('import ioio.lib.util.IOIOConnectionRegistry')
eval('import ioio.lib.api.IOIOFactory')
eval('import ioio.lib.api.IOIO')

ioio.lib.util.IOIOConnectionRegistry.addBootstraps('ioio.lib.pc.SerialPortIOIOConnectionBootstrap')
ioio=ioio.lib.api.IOIOFactory.create();
ioio.waitForConnect() %TODO: Handle it nicely when connect fails
led=ioio.openDigitalOutput(IOIO.LED_PIN,true);

%Let's blink
for i=1:10
  led.write(0) %LED on
  pause(0.1)
  led.write(1) %LED off
  pause(0.1)
end

led.close
clear led 
ioio.disconnect()
clear ioio

Reply via email to