B4J Library IOIO library for B4J

Here is a library that allows you to use the IOIO board with B4J! It's about the easiest way you'll find to access a microcontroller from your PC. Check out he wiki here.

Version: v2.07

This uses the latest java IOIOlib from Ytai. It includes all the latest bug fixes. Look at the IOIO wiki release notes for more information. There is no new functionality in this version. Your IOIO should be using version 5.06 application firmware. Use the latest bootloader as well.

The IOIO has become a solid platform. It offers a unique functionality still today and does what it was designed to do well. Although there isn't a lot of activity it is still being supported by Ytai and I intend to here at B4A as well.

Make sure you read the readme.txt

I've decided to start with version number 2.07 as it will be less confusing with the B4A version of this library if the both have the same version number.

Note:

The jna-4.2.2.jar is too big to upload to the forum. You can download it here.

The workbench is an app that demonstrate how to use the library. Check it out first before posting "How to" questions please.

Please place any B4J IOIO related questions in this thread. There is an ongoing thread for the B4A library here.
 

Attachments

  • workbench-1.0.zip
    9.7 KB · Views: 359
  • ioio 207.zip
    420.4 KB · Views: 367
Last edited:

Cableguy

Expert
Licensed User
Longtime User
So finally I can control my io-io from my PC with Bluetooth !!
 

pivar

Member
Licensed User
Longtime User
Here is a library that allows you to use the IOIO board with B4J! It's about the easiest way you'll find to access a microcontroller from your PC. Check out he wiki here.

Version: v2.07

This uses the latest java IOIOlib from Ytai. It includes all the latest bug fixes. Look at the IOIO wiki release notes for more information. There is no new functionality in this version. Your IOIO should be using version 5.06 application firmware. Use the latest bootloader as well.

The IOIO has become a solid platform. It offers a unique functionality still today and does what it was designed to do well. Although there isn't a lot of activity it is still being supported by Ytai and I intend to here at B4A as well.

Make sure you read the readme.txt

I've decided to start with version number 2.07 as it will be less confusing with the B4A version of this library if the both have the same version number.

Note:

The jna-4.2.2.jar is too big to upload to the forum. You can download it here.

The workbench is an app that demonstrate how to use the library. Check it out first before posting "How to" questions please.

Please place any B4J IOIO related questions in this thread. There is an ongoing thread for the B4A library here.
 

pivar

Member
Licensed User
Longtime User
So with the good examples of workbench I will try to use IOIO (drive a small mechanism for laboratories ) ; I will use usb connection ;how to know which com is used in the PC ? or do I try the different COM to find this used in PC ?
Thanks to Kolbe
 

Cableguy

Expert
Licensed User
Longtime User
usually, upon connection of the board to the PC using the USB cable, the driver should show which COM he's using in the device manager
 

pivar

Member
Licensed User
Longtime User
usually, upon connection of the board to the PC using the USB cable, the driver should show which COM he's using in the device manager
Well , but the Customer has only to plug , choose my app ,and the soft has to find the COM ; I will begin with trying the different COM , but it's not smart
 

Cableguy

Expert
Licensed User
Longtime User
you can try to cycle the coms while sending a byte into the board and have it returning it

If the b4J works the same way as the B4A version, you should get a Connected event fired, so you can use that to figure out the com
 

kolbe

Active Member
Licensed User
Longtime User
Well , but the Customer has only to plug , choose my app ,and the soft has to find the COM ; I will begin with trying the different COM , but it's not smart

I see your point. You need to know what com port the driver has selected. You can always cycle through the com port and try each one until one connects. Alternatively you can look into capturing from windows what comm ports are active and determine which one is connected to the IOIO. I'm sure there is a way to do this I just haven't looked into it. Start maybe here with com port arbiter. It at least tells you how to find out the comm port info from windows registry.
 

pivar

Member
Licensed User
Longtime User
I'm not strong enough to look in the bowels of window ; but based on workbench , after a failed connection , the port is increased up to find or limited by the number port maxi ; with usb , timer1 of 800 ms is enough (on weak computer) ; no need to try 5 times ; ... not deeply all understood , particulary :If ioio1.IsInitialized Then ioio1.Disconnect
 

kolbe

Active Member
Licensed User
Longtime User
I'm not strong enough to look in the bowels of window ; but based on workbench , after a failed connection , the port is increased up to find or limited by the number port maxi ; with usb , timer1 of 800 ms is enough (on weak computer) ; no need to try 5 times ; ... not deeply all understood , particulary :If ioio1.IsInitialized Then ioio1.Disconnect

B4X:
If Checked Then
    timer1.Enabled=True 'start connection timer
    ioio1.Connect("ioio1",ComboBox2.Items.Get(ComboBox2.SelectedIndex),0)
    comments.Append("Attempting connection to IOIO1"&CRLF&CRLF)
Else
    timer1.Enabled=False
    If ioio1.IsInitialized Then ioio1.Disconnect
    comments.Append("IOIO1 Disconnected"&CRLF&CRLF)
    toggle(False)
    togglebutton1.Text="CONNECT"
End If

If you try to disconnect and ioio was never initialized it will throw an exception. This is just a robustness check and not really needed.
 

pivar

Member
Licensed User
Longtime User
B4X:
If Checked Then
    timer1.Enabled=True 'start connection timer
    ioio1.Connect("ioio1",ComboBox2.Items.Get(ComboBox2.SelectedIndex),0)
    comments.Append("Attempting connection to IOIO1"&CRLF&CRLF)
Else
    timer1.Enabled=False
    If ioio1.IsInitialized Then ioio1.Disconnect
    comments.Append("IOIO1 Disconnected"&CRLF&CRLF)
    toggle(False)
    togglebutton1.Text="CONNECT"
End If

If you try to disconnect and ioio was never initialized it will throw an exception. This is just a robustness check and not really needed.
 

pivar

Member
Licensed User
Longtime User
Understood ;...
I will drive a stepper motor (and switches,inputs) ; with timer and pin false/true, I can have up to 600 steps/sec ; not totaly regular but enough for me ; better were if I could have 1000 steps:sec , and so I must use sequencer , but I'm afraid headaches ; I will try to understand what is in workbench
 

pivar

Member
Licensed User
Longtime User
So , the soft for the machine is finished ; the prototype runs well and what I tested on ioio is:
-for the stepper motor :
send steps with writeWait "hight-event_done-low_event done" allowed maxi speed 200 steps/sec (on release , and it's half on debug)
send steps with pin.Pulse , maxi speed ~500-600 steps/sec
send steps with sequencer ( sent 5 steps-stall-resend 5 steps ( it's to control the move)) ,maxi speed ~500-600 steps/sec
send steps with sequencer and refill the cue with timer : never runs well , steps are lost

and if there a pin to read , always use event_done (for me gives direction of move)
And I'm always happy to work with B4J........
 

kolbe

Active Member
Licensed User
Longtime User
So , the soft for the machine is finished ; the prototype runs well and what I tested on ioio is:
-for the stepper motor :
send steps with writeWait "hight-event_done-low_event done" allowed maxi speed 200 steps/sec (on release , and it's half on debug)
send steps with pin.Pulse , maxi speed ~500-600 steps/sec
send steps with sequencer ( sent 5 steps-stall-resend 5 steps ( it's to control the move)) ,maxi speed ~500-600 steps/sec
send steps with sequencer and refill the cue with timer : never runs well , steps are lost

and if there a pin to read , always use event_done (for me gives direction of move)
And I'm always happy to work with B4J........

Glad to hear the library has been useful.
 
Top