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:

Cableguy

Expert
Licensed User
Longtime User
Hi, @kolbe

I have bought an ioio board a few months ago but never even powered it on...
May I challenge you to create a "firsts steps with ioio" tutorial?
I plan to create a simple 4 legged walker/cube... But I am kinda lost in all the info orgy!
 

kolbe

Active Member
Licensed User
Longtime User
Good idea. I'll see what I can do. I'm thinking perhaps an up to date list of links and links to posts that can get you started without having to scan through this rather long thread.

Hi, @kolbe

I have bought an ioio board a few months ago but never even powered it on...
May I challenge you to create a "firsts steps with ioio" tutorial?
I plan to create a simple 4 legged walker/cube... But I am kinda lost in all the info orgy!
 

Cableguy

Expert
Licensed User
Longtime User
Good idea. I'll see what I can do. I'm thinking perhaps an up to date list of links and links to posts that can get you started without having to scan through this rather long thread.
That would be an awsome Christmass gift!!
 

James Costello

Member
Licensed User
Longtime User
Not exactly a thorough guide but the steps that I finally used to get my thinking working:

1. Download the latest IOIO library (currently 2.04 at time of posting - extract, and make sure the files are named as "ioio 20.jar" and "ioio20.xml" if not rename them
2. Download and extract the IOIO Workbench (currently 2.32 at time of posting, i think), that has demo`s for just about all the inputs and outputs you`ll want. You should be able to reverse engineer stuff from there...

Couple of other things I had to update the firmware on my IOIO board to work with the latest library, it shipped with Version 3, you need version 5. This link should help with that https://github.com/ytai/ioio/wiki/IOIO-OTG-Bootloader-and-IOIODude

Lastly to make troubleshooting easier I installed a app from the Play Store called 'IOIO Hardware Tester' which helped my confirm BT connections etc.

Sorry, as my application was only controlling some LED`s with PWM output.

James
 

Cableguy

Expert
Licensed User
Longtime User
Thanks James, all good reading!
 

Cableguy

Expert
Licensed User
Longtime User
@James Costello

I went through the steps mentioned on the page you provided the link for, and updated my firmware from 3.3 to 5.
I know there are a few issues with bluetooth dongles not working... do you have any suggestions for this?
now I just have to wait for my servos and control board to start codding my robot cube
 

kolbe

Active Member
Licensed User
Longtime User
Here's a user created list of BT adapters that should work. I think however this problem is smaller than before with the latest firmware and application.

I use this one without any problems. It's not the newest or cheapest but it is a class I and has good range.

So did you get the IOIO to work?

@James Costello

I went through the steps mentioned on the page you provided the link for, and updated my firmware from 3.3 to 5.
I know there are a few issues with bluetooth dongles not working... do you have any suggestions for this?
now I just have to wait for my servos and control board to start codding my robot cube
 
Last edited:

kolbe

Active Member
Licensed User
Longtime User
Not exactly a thorough guide but the steps that I finally used to get my thinking working:

1. Download the latest IOIO library (currently 2.04 at time of posting - extract, and make sure the files are named as "ioio 20.jar" and "ioio20.xml" if not rename them
2. Download and extract the IOIO Workbench (currently 2.32 at time of posting, i think), that has demo`s for just about all the inputs and outputs you`ll want. You should be able to reverse engineer stuff from there...

Couple of other things I had to update the firmware on my IOIO board to work with the latest library, it shipped with Version 3, you need version 5. This link should help with that https://github.com/ytai/ioio/wiki/IOIO-OTG-Bootloader-and-IOIODude

Lastly to make troubleshooting easier I installed a app from the Play Store called 'IOIO Hardware Tester' which helped my confirm BT connections etc.

Sorry, as my application was only controlling some LED`s with PWM output.

James

I'll add to that Ytai's Github page and the users group for general information.

When you download the ioio library and workbench app just make sure the workbench app is referencing the latest ioio library version, check the library version in the B4A IDE library tab.
 
Last edited:

Cableguy

Expert
Licensed User
Longtime User
For now I'm just glad that it didn't just explode on me... I'm waiting on a few servos and a control board to arrive to continue experimenting
 

Cableguy

Expert
Licensed User
Longtime User
Hi guys

So I finally got my servos and searched the store on ready to use apps to test them...
sure enough, all use the BT connection and I am still waiting for my BT dongle to arrive...
so I started creating my own solution to test them...
all went quite well, and I was almost finished... all that was left to do was to do the pwm out logic.
today... my test app wont even connect to the board.. it claims it can't find the "sub IOIO1_connected"..
I haven't changed my code, and all is based on the workbench example, which still can connect to my board, so no hardware issues here... can anyone tell me whats wrong??


[EDIT:]

Found my error after going a bit back in the thread... it seems that the latest lib does not like uppercase declared events.
So now I've restarted my app and am almost done... I'll post it on the my creations as soon as finished and tested.
 

Attachments

  • IOIOTest.zip
    8.5 KB · Views: 244
Last edited:

Cableguy

Expert
Licensed User
Longtime User
Hi again...
I can't seem to be able to catch or fire the pulsewidth_done event, any thoughts on this one?
 

kolbe

Active Member
Licensed User
Longtime User
Hi again...
I can't seem to be able to catch or fire the pulsewidth_done event, any thoughts on this one?

The done event is optional, so you don't need to use it unless you want to know when the method has finished running.

But... you seem to have discovered a bug in the library. I don't seem to raise an done event if there are no exceptions thrown in this and other methods where the done event is optional. It will however raise the done event if an exception is thrown. I'll try to get that fixed soon. The method works but you just never will get a done event.

Also when you open a pulseoutput pin it will not start to output until you do a pulsewidth to define what kind of pulse you want.
 

Cableguy

Expert
Licensed User
Longtime User
The done event is optional, so you don't need to use it unless you want to know when the method has finished running.

But... you seem to have discovered a bug in the library. I don't seem to raise an done event if there are no exceptions thrown in this and other methods where the done event is optional. It will however raise the done event if an exception is thrown. I'll try to get that fixed soon. The method works but you just never will get a done event.

Also when you open a pulseoutput pin it will not start to output until you do a pulsewidth to define what kind of pulse you want.
Happy new year! Glad you're back!
I have no problems making the output as I need it and the servo runs fine.
I need to know when pulse width is finished in order to liberate the pin so that I can then change the servo direction... Or just change its angle
 

kolbe

Active Member
Licensed User
Longtime User
Happy new year! Glad you're back!
I have no problems making the output as I need it and the servo runs fine.
I need to know when pulse width is finished in order to liberate the pin so that I can then change the servo direction... Or just change its angle

Thank you and like wise.

By liberate do you mean open and close the pin? I just leave the pin open and call pulsewidth again with a different value, 1500 for middle, 1000 full left, 2000 full right.
 

Cableguy

Expert
Licensed User
Longtime User
When controlling a servo, in my trials, I have found that if you "misfire" the pulse width while it has not ended, then the next movement becomes erratic. So I took the route of disabling touch on the buttons during pulse width action and used a timer as time out... It works, but different angles have different time duration (real time from one point to another) so sometimes the servo was in a kind of overdrive and the arm kinda trembles... If done event can be caught then I can close the pin for each individual movement, and this way save battery.
 

kolbe

Active Member
Licensed User
Longtime User
When controlling a servo, in my trials, I have found that if you "misfire" the pulse width while it has not ended, then the next movement becomes erratic. So I took the route of disabling touch on the buttons during pulse width action and used a timer as time out... It works, but different angles have different time duration (real time from one point to another) so sometimes the servo was in a kind of overdrive and the arm kinda trembles... If done event can be caught then I can close the pin for each individual movement, and this way save battery.

I see. Well give me a day or two but while waiting try using ioio.synch before and after calls to pulsewidth, this might help.

I've seen the trembling servos too but thought it just might be the cheap servos I was using. I do know that over-driving the servo beyond the 2000 or below the 1500 gives unreliable results. I wonder if digital servos show this behavior.
 

Cableguy

Expert
Licensed User
Longtime User
Digital servos, afaik, do not suffer from this as they stop at a precise encoder position. The user can even set the current encoder position to be 0, 90, or -90... But the software side remains unchanged for normal control.
 

Cableguy

Expert
Licensed User
Longtime User
[ IOIO - I2C ]

So, my 16 channel PWM I2C Driver has finally arrived.
Does anyone have an example about using I2C?
I plan to control up to 10 Tower 9g servos, but I have no clue on even how to start.
 

kolbe

Active Member
Licensed User
Longtime User
These examples are getting dated but the I2C one should be correct... well you have to add the eventname and sub. You basically need the know the address of the chip and then how to manipulate the registers to do what you want. Most chip datasheets go into all kinds of signal details that with the IOIO you don't really care about b/c the IOIO does that for you. Most of the time you just need to send byte/s to some register/s and then read byte/s. Sometimes you have to wait for the data to be ready which can be tricky. I use a number of I2C devices and their use is all quite different, with some you need to do a onetime read of parameters to make your calculations, other require setting a bunch of register during a setup procedure, etc. Typically the writebyte array will first have the register address and then the data you want to write to it. The readbyte array has the number of bytes your expect back. This is done at once with the writeread method. You will have to use bit level arithmetic and bit masking sometimes to create for example a 12 bit value from two separate bytes. Figuring out what bytes are signed and which aren't is fun. Use value=Bit.AND(bytes(0),0xFF) to make sure the 8th bit is not regarded as a sign bit by android.

On the hardware side of things the I2C bus requires a pullup resistor so make sure to add one to the clock and data unless it is already on your breakout board.
 
Last edited:

kolbe

Active Member
Licensed User
Longtime User
@Cableguy

Here's a test ioio library that should raise success events for pulsewidth. For now I'll put it here b/c I haven't tested it much. Let me know how it goes. I'll move it to the release post once I'm sure I haven't broken anything.

EDIT: removed the library to avoid duplicates.
 
Last edited:
Top