B4A Library IOIO board library

Discussion in 'Additional libraries, classes and official updates' started by agraham, Apr 30, 2011.

  1. Cableguy

    Cableguy Expert Licensed 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!
  2. kolbe

    kolbe Active Member Licensed 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.

    Cableguy likes this.
  3. Cableguy

    Cableguy Expert Licensed User

    That would be an awsome Christmass gift!!
  4. James Costello

    James Costello Member Licensed 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.

    Cableguy likes this.
  5. Cableguy

    Cableguy Expert Licensed User

    Thanks James, all good reading!
  6. Cableguy

    Cableguy Expert Licensed 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
  7. kolbe

    kolbe Active Member Licensed 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?

    Last edited: Dec 24, 2014
  8. kolbe

    kolbe Active Member Licensed User

    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: Dec 24, 2014
  9. Cableguy

    Cableguy Expert Licensed 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
  10. Cableguy

    Cableguy Expert Licensed 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??


    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.

    Attached Files:

    Last edited: Jan 3, 2015
  11. Cableguy

    Cableguy Expert Licensed User

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

    kolbe Active Member Licensed 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.
    Cableguy likes this.
  13. Cableguy

    Cableguy Expert Licensed 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
  14. kolbe

    kolbe Active Member Licensed User

    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.
  15. Cableguy

    Cableguy Expert Licensed 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.
  16. kolbe

    kolbe Active Member Licensed User

    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.
  17. Cableguy

    Cableguy Expert Licensed 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.
  18. Cableguy

    Cableguy Expert Licensed 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.
  19. kolbe

    kolbe Active Member Licensed 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: Jan 13, 2015
  20. kolbe

    kolbe Active Member Licensed User


    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: Mar 5, 2015
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice