B4A Library IOIO board library

The request in this thread here introduced me to a product called IOIO that seems to have been designed by some Google engineers in the 20% of time that Google gives them to pursue their own interests,

The blog of the main mover of the project is at Microcontrollers, Electronics & Robotics: Meet IOIO - I/O for Android

The board will be available soon from here IOIO for Android - SparkFun Electronics

As the software has just been released I took a look at it and wrapped it in a couple of libraries for use with Basic4android. I obviously cannot test it as I have no board but the Basic4android library is a very thin veneer on top of the normal Android library so, typos and idiot errors aside, it should work with no problems and the software documentation should be pretty much applicable. I have copied a lot of the library help from the software documention so a B4A help viewer should give you a good grounding in how to use it.

I don't yet know if the board will be available this side of the pond - if anyone wants to ship me one for testing .... :)

EDIT :- Version 1.1 posted with INTERNET permission. See post #11 for details.

EDIT :- Version 1.2 posted with PulseInput. See post #37 for details.

EDIT :- Version 1.2 reposted with XML error fixed. See post #39 for details.

EDIT :- Version 1.3 posted with SPI and I2C support. See post #40 for details.

EDIT :- Version 1.3a posted with IOIOlib 3.2 included. See post #42 for details.

EDIT :- Version 1.4 posted. See post #47 for details.

EDIT :- IOIOlibBT 3.10 posted. See post#58 for details.

EDIT:- IOIOBT1.4 posted See post #63 for details

EDIT:- IOIOBT1.5 posted See post #77 for details.

THESE ATTACHMENTS ARE NOW OBSOLETE. SEE POST #105 FOR THE LATEST VERSIONS BY KOLBE: http://www.b4x.com/android/forum/threads/ioio-board-library.8942/page-6#post-90731
 

Attachments

  • IOIOBT1.5.zip
    102.3 KB · Views: 2,322
  • IOIO1.4.zip
    100.5 KB · Views: 1,758
Last edited by a moderator:

John D.

Member
Licensed User
Longtime User
Thank you for all the work you've done on this, kolbe. I'm watching with interest. I can use this (if newer tablets can communicate over USB).
 

lornetw

Member
Licensed User
Longtime User
Hi. I'm really glad to see that Ytai's new library has been released ! (waiting since last year - I realize that Ytai is a very busy person). I will be watching for your B4A library with bated breath.

I am a teacher in an adult trade school. I teach CNC programming and machining on CNC machines. We have about 17 CNC machines.

I am going to build a small 3D printer, based on the Bukito printer (http://deezmaker.com/bukito-portable-3d-printer/). Bukito's makers have said that it will be open source, so I am waiting for the drawings to be available. In the mean time I have been able to start on my version of their printer because they are using a lot of parts from http://openbuildspartstore.com/ and they have drawings of most of their parts on their site. Since I teach MasterCAM, I used MasterCAMx7 to design my version of Bukito in 3D (see .PNG file attached). I don't have the open source drawings for the Z axis (to make the head go up and down), so that is missing in my drawing.

I would like to explore using the IOIO board for testing the steppers and maybe developing various functions. Ideally, I would like to use the IOIO board to receive the CNC program (G-codes) and be the controller for the actual 3D printing but I think, for now, this is a big stretch. 1) I don't think the IOIO board will be fast enough - the latency times might be too long. 2) A G-code interpreter (that would take the G-code and control the stepper motors) doesn't yet exist (at least I haven't found one) - maybe someone will now develop one, seeing that the new library is out.

Thank you for all your work and looking forward to your B4A library
 
Last edited:

John D.

Member
Licensed User
Longtime User
Lornetw,

The stepper library already addresses your concerns about latency. See the wiki for implementation details. As long as your app can push the commands into the queue faster than the machine moves, accurate motion should be possible. Ytai's X-Y plotter is a good demonstration of this.

A G-code interpreter should be pretty easy to make, if you limit it to the simplest command set. On the other hand, the optimizations and tweaks that need to be made to tune ANY controller to ANY actual machine usually (always) get complicated quite quickly. It might be attractive to be able to hack a $100 tablet and use it as both touch screen interface and machine controller (like I am doing now for something else) .... but to get all the bells and whistles of a package like linuxcnc ported over to Android would be a huge undertaking. Still ... if the 3d printer can operate on simple moves ... tantalizing thought.

Edit: Full disclosure -- I have a Tormach, I used to own a 'real' cnc, and I've done motion control with about half a dozen PLC brands (I build special machines). Ytai's stepper library actually looks like it is more capable than many PLC motion cards (a lot of them require a stop at the end of every move, so you can't program it to change speed in the middle of a path).

This looks interesting for access to cheap boards for interfacing to real-world circuits, maybe.
 
Last edited:

kolbe

Active Member
Licensed User
Longtime User
I've got the motor control working but still need to clean it up, test and write the javadocs. Need to add to the workbench app examples of how to use it as well. This firmware does seem to be more stable. A few problems I noticed with v4 have disappeared. I also verified that all works on the IOIO OTG which I had never done before.

No help needed at the moment. Once it's released I'll need feedback. The motor control is more complex that the other functionality but now you are able to generate precise signals which is a huge improvement. I'll probably release this and then work on the OpenAccess unless of course I quickly stumble on the fix for that.
 

mrodriguez

Member
Licensed User
Longtime User
I've got the motor control working but still need to clean it up, test and write the javadocs. Need to add to the workbench app examples of how to use it as well. This firmware does seem to be more stable. A few problems I noticed with v4 have disappeared. I also verified that all works on the IOIO OTG which I had never done before.

No help needed at the moment. Once it's released I'll need feedback. The motor control is more complex that the other functionality but now you are able to generate precise signals which is a huge improvement. I'll probably release this and then work on the OpenAccess unless of course I quickly stumble on the fix for that.
Ok just let me know when you need a tester. I can test digital/analog, pwm, capacitive, etc
 

lornetw

Member
Licensed User
Longtime User
Lornetw,

The stepper library already addresses your concerns about latency. See the wiki for implementation details. As long as your app can push the commands into the queue faster than the machine moves, accurate motion should be possible. Ytai's X-Y plotter is a good demonstration of this.

A G-code interpreter should be pretty easy to make, if you limit it to the simplest command set. On the other hand, the optimizations and tweaks that need to be made to tune ANY controller to ANY actual machine usually (always) get complicated quite quickly. It might be attractive to be able to hack a $100 tablet and use it as both touch screen interface and machine controller (like I am doing now for something else) .... but to get all the bells and whistles of a package like linuxcnc ported over to Android would be a huge undertaking. Still ... if the 3d printer can operate on simple moves ... tantalizing thought.

Edit: Full disclosure -- I have a Tormach, I used to own a 'real' cnc, and I've done motion control with about half a dozen PLC brands (I build special machines). Ytai's stepper library actually looks like it is more capable than many PLC motion cards (a lot of them require a stop at the end of every move, so you can't program it to change speed in the middle of a path).

This looks interesting for access to cheap boards for interfacing to real-world circuits, maybe.
John, Thanks for your reply and info. As for latency times, it will be interesting so see if the overhead of running the Basic4Android code will slow down the latency times. I'm looking forward to playing with this.

Kolbe, count me in as a tester. I'll do my best, though I'm not an advanced user of Basic4Android.
 

kolbe

Active Member
Licensed User
Longtime User
Well it took me the better part of the weekend but I managed to get OpenAccessory working!!! Funny how things aren't that complicated once you understand them.

As for latency etc... I set up a little test that generates opposite pulses on two pins. With BT I could only get 20ms pulses without stalling the buffer but with OA it had no problem with 5ms pulses. This gives you some idea of latency because you have to push cues to the buffer faster than they are used, that means read the buffer available and the push the required cues before the buffer stalls. Might even be able to do better than 5ms, didn't really test the limit. The only hard limit I guess is the timer in B4A because the min is 1ms. Now that I think about it, might be able to do even better with a library method running on a separate thread.

I'll work on getting the library posted sometime this week. There have been a few changes to the way you connect so your current apps will have to be updated.
 

John D.

Member
Licensed User
Longtime User
The latency will be something to test and calculate before trying to interpolate circles with steppers on a CNC.
 

lornetw

Member
Licensed User
Longtime User
Hi. I was just cruising through the other posts in this topic and I found in post #105 that we will have to communicate only through Bluetooth. Am I understanding this properly ? It seems to me that to be able to communicate in a real-time fashion (because we are trying to control real-world steppers, etc) we need to be able control everything while wired up through the USB cable, no? From what I gather about Bluetooth, it is not as fast nor as reliable as a USB connection would be. Won't Bluetooth be a bottle-neck for communications? If Bluetooth drops bits every once and awhile (while controlling steppers), precision will be not as good. Any thoughts ?
 

kolbe

Active Member
Licensed User
Longtime User
Hi. I was just cruising through the other posts in this topic and I found in post #105 that we will have to communicate only through Bluetooth. Am I understanding this properly ? It seems to me that to be able to communicate in a real-time fashion (because we are trying to control real-world steppers, etc) we need to be able control everything while wired up through the USB cable, no? From what I gather about Bluetooth, it is not as fast nor as reliable as a USB connection would be. Won't Bluetooth be a bottle-neck for communications? If Bluetooth drops bits every once and awhile (while controlling steppers), precision will be not as good. Any thoughts ?

As you see above, just posted version 2.0 which means that now you can connect via Open Accessory. That said you could always connect via ADB but only up to Android 4.1 (SDK 16). What you said was only true for devices with Android 4.2 and above. Bluetooth is still the only option if you have a device that has Android 4.2 and above and does not support Open Accessory.

I've don't lots with BT and the IOIO and find it works very well but you are not going to be able to build a self-balancing robot. I've even connected a UART camera to the IOIO that can send back low res pics at 1-2 fps via BT. One real plus with BT is that reconnecting when things go wrong can be done with just code. I find USB connections require the physical unplugging and replug at times. So I guess they both have their merits and you need to pick the right one for the project.
 

lornetw

Member
Licensed User
Longtime User
Thank you kolbe for all your work. Would you happen to have a simple example in B4A of using your library to control a stepper. I'm starting at absolute zero with this. I've never even used my IOIO board yet (I'm going to start out at the very beginning, of course).

Lorne
 

kolbe

Active Member
Licensed User
Longtime User
Thank you kolbe for all your work. Would you happen to have a simple example in B4A of using your library to control a stepper. I'm starting at absolute zero with this. I've never even used my IOIO board yet (I'm going to start out at the very beginning, of course).

For a stepper you need a driver circuit, something like this. You can't drive one directly from the IOIO! You then control the direction, step, and stepsize with the digitalout pins connected to the stepper driver. If you need more explanation google arduino and steppers. There all kinds of arduino guides out there. For the b4a code just use a togglebutton to set the digitalpin HIGH or LOW depending on the state you want like in the workbench example.
 

gmilias

Member
Licensed User
Longtime User
Kolbe,

Thank you for the amazing work with ioio library and open accessory protocol. It will be very useful to me.
I have a usb host capable phone (Moto G, Android 4.4) and I would like to know whether I can use your latest version of library with usb_device mode in order to avoid external power supply to ioio. Ytai says that since version 5.00 of ioio otg firmware (release notes) there is "Support for Android working in host mode." I have already updated my ioio otg, but I couldn't connect through workbench (selection:accessory). Are there some modifications of manifest file necessary for this in order to connect?

Thanks in advance for your help,
George
 

kolbe

Active Member
Licensed User
Longtime User
Kolbe,

Thank you for the amazing work with ioio library and open accessory protocol. It will be very useful to me.
I have a usb host capable phone (Moto G, Android 4.4) and I would like to know whether I can use your latest version of library with usb_device mode in order to avoid external power supply to ioio. Ytai says that since version 5.00 of ioio otg firmware (release notes) there is "Support for Android working in host mode." I have already updated my ioio otg, but I couldn't connect through workbench (selection:accessory). Are there some modifications of manifest file necessary for this in order to connect?

Thanks in advance for your help,
George

Yes there are essential manifest changes. However if you are running the workbench project that is already there. For other projects there is a text file in the library zip called "add to manifest". In the B4A IDE use the manifest editor to add that text to the bottom of the manifest file.

Make sure your IOIO is running the v5 firmware. Also host capable doesn't automatically mean Open Accessory as far as I know.

Actually I have device mode working as well but just didn't release it yet. I was waiting to see if Ytai had any other minor updates. I guess now that you asked I'll go ahead and update. I agree it's nice to be able to power the IOIO from the Android device.

I've also started a library for B4J but so far it's not working. The purejavacom library it uses doesn't seem to recognize the serial ports. I want to see if I can somehow use the serial library Erel has already made for B4J.
 

mrodriguez

Member
Licensed User
Longtime User
Yes there are essential manifest changes. However if you are running the workbench project that is already there. For other projects there is a text file in the library zip called "add to manifest". In the B4A IDE use the manifest editor to add that text to the bottom of the manifest file.

Make sure your IOIO is running the v5 firmware. Also host capable doesn't automatically mean Open Accessory as far as I know.

Actually I have device mode working as well but just didn't release it yet. I was waiting to see if Ytai had any other minor updates. I guess now that you asked I'll go ahead and update. I agree it's nice to be able to power the IOIO from the Android device.

I've also started a library for B4J but so far it's not working. The purejavacom library it uses doesn't seem to recognize the serial ports. I want to see if I can somehow use the serial library Erel has already made for B4J.

Kolbe, I use Erel serial library with FTDI chip for comunication with Xbee module. It works perfect. You can buy a usb—FTDI serial module on Sparkfun. I use it over galaxy s4 and rikomagic IV.

FTDI Basic Breakout - 3.3V 15usd
 
Last edited:

gmilias

Member
Licensed User
Longtime User
Yes there are essential manifest changes. However if you are running the workbench project that is already there. For other projects there is a text file in the library zip called "add to manifest". In the B4A IDE use the manifest editor to add that text to the bottom of the manifest file.

Make sure your IOIO is running the v5 firmware. Also host capable doesn't automatically mean Open Accessory as far as I know.

Actually I have device mode working as well but just didn't release it yet. I was waiting to see if Ytai had any other minor updates. I guess now that you asked I'll go ahead and update. I agree it's nice to be able to power the IOIO from the Android device.

I've also started a library for B4J but so far it's not working. The purejavacom library it uses doesn't seem to recognize the serial ports. I want to see if I can somehow use the serial library Erel has already made for B4J.
Kolbe,
Thanks for your reply. I am very happy that you have already device mode working. I will be waiting to release your updated version! :)
 
Top