B4A Library IOIO board library

Cableguy

Expert
Licensed User
Longtime User
I'll have this a go later on after diner. Thanks for the time...

IYHO, if you were to controle up to 10 servos, would you go the I2C way using only 2 wires or connect the data in directly to the ioio board thus using 10 wires... I mean, what are the real advantages in using the complex i2c scheme to the simplicity of code using individual output pins.?
 

Cableguy

Expert
Licensed User
Longtime User
This is what I got... at least there is something being trown at b4a
B4X:
An error occurred:
(Line: 0) null
java.lang.Exception: Sub pulsewidth_done signature does not match expected signature.
public static anywheresoftware.b4a.pc.RemoteObject b4a.example.main_subs_0._pulsewidth_done() throws java.lang.Exception

all I have in the done event is a log statement

[EDIT] I didn't notice at first that the event declaration had changed. In the popup help, the declaraion tells that success is a String, when in fact it expects a Boolean.
The event fires as expected, but I have yet to grasp the mechanics of servo motion. If I close the pin inside the done event, then the rotation does not reach its end... So I added a timer, and set a flag inside the done event in order to not close the pin before the rotation had ended.
It all seems to work quite well now.

Thank you @kolbe, for all you effort in this thread... hopefully, I'll become a servo expert and will pick after you, LOL
 
Last edited:

kolbe

Active Member
Licensed User
Longtime User

I think the I2C way may give you better control and be more robust. One thing I always feared is what if the servo goes bad and somehow sends back 5v to the IOIO pin... this is why I always use the 5v tolerant pins. Should the servo short to ground that would probably kill the IOIO, a current limiting resistor here might be a good idea. Your I2C chip may be more robust in these respects and even protect the IOIO should disaster strike. You are also offloading some work off the IOIO pic by using another chip. The IOIO is actually generating in real time the 10 square waves. If you are planning to do analog sampling on the IOIO at the same time or using inputpwm this might make a difference. I also noticed that when connecting to the IOIO the servos go nuts as the IOIO initializes, by default the pins are floating. You probably don't have this problem with the I2C chip as long as it has power.
 

kolbe

Active Member
Licensed User
Longtime User

Good to hear it's working. I'll correct the javadocs.
 

Cableguy

Expert
Licensed User
Longtime User
Thanks for your input about the I2C. I' ll start messing with that next weekend.
Thanks for the updated lib. Please update the event declaration (change string to boolean )
 
Last edited:

Cableguy

Expert
Licensed User
Longtime User
[Bluetooth ]

Só I got my BT dongle and rushed to get it connected to my ioio... no luck..
it pairs ok with my Asus tablet, though it takes a while to pair, but it pairs...
in the workbench I can even see it listed.. but connection fails over and over again.
the best I got was state init. I have already turned the voltage trim all the way in each direction.
Any suggestions?

( I already have a new bundle ioio+otg cable+BT dongle in the mail )
 

kolbe

Active Member
Licensed User
Longtime User

Did you see post #347? Is it a BT dongle that others have shown to work? Did you pair using code 4545? Are you using the latest firmware and application on the IOIO?

Also try the IOIO hello app you can download from Ytai's github downloads page.
 

Cableguy

Expert
Licensed User
Longtime User
Did you see post #347?
Yes I did.

Is it a BT dongle that others have shown to work?
I have no idea. My bt dongle is unbranded.

Did you pair using code 4545? Are you using the latest firmware and application on the IOIO?
Yes, it takes an eternity to pair but it does seem to pair. My firmware is on 5.03 I think.

Also try the IOIO hello app you can download from Ytai's github downloads page.
I didn't try that yet... will do over the weekend.

To be on the safe side, as I said, I have already ordered a second board bundling a bt dongle.
 

kolbe

Active Member
Licensed User
Longtime User
@firestormer

Here's the library version for your 100 pin ioio.
 

Attachments

  • ioio 205 100pin.zip
    412.5 KB · Views: 286
Last edited:

Cableguy

Expert
Licensed User
Longtime User
Hi guys...

I created a small tool for us IOIO enthusiasts to easily find the address of a dubious I2C chip/module

You can find it Here, I hope you find it useful.
 

JTKEK

Member
Licensed User
Longtime User
Kolbe i just change the default bluetooth name ioio to other name
can you update the library, which is can connect to custom name
 

kolbe

Active Member
Licensed User
Longtime User
Kolbe i just change the default bluetooth name ioio to other name
can you update the library, which is can connect to custom name

I don't understand the question. Maybe post an example.
 

JTKEK

Member
Licensed User
Longtime User
[/url][/IMG] The picture below show original IOIO default bluetooth name


[/url][/IMG] The picture below show modifed IOIO bluetooth name



i just modified, the name of IOIO bluetooth
the existing library is search for IOIO (original name)

can you make an update, so that the library can work with any IOIO bluetooth name
 

kolbe

Active Member
Licensed User
Longtime User
anyone has twi working example
can you share with me

Here is some working code. The hard part is figuring out how the chip you have works, the registers to use, order to access, what to send it and understanding the data you get back. You figure this out reading the spec sheets.

Below the chip address is 64. I first access register e3 and expect a 2 byte return. The done event returns the 2 bytes. I then do the same for register e5. I don't show the done event.

B4X:
Sub humid_temp

    Try
        'get inside temp from humid sensor
        Dim readbyte(2) As Byte
        Dim writebyte(1) As Byte
 
        writebyte(0)=0xe3 'read temp register

        'chip address,7bit,write,bytes,result,bytes,pause)
        Main.twi.WriteRead("htemp",64,False,writebyte,1,readbyte,3,0)

    Catch
        common.note_trouble("Sensors  humid_temp")
        get_temp
    End Try

    If Main.parms.logs Then Log("humid temp end")
End Sub

Sub htemp_done(noerror As Boolean, success As Boolean, writebyte() As Byte, readbyte() As Byte)

    If noerror Then
        If success Then
            Dim partial=(Bit.ShiftLeft(Bit.And(readbyte(0),0xff),8)+Bit.And(readbyte(1),0xfc)) As Int
            temp2=NumberFormat2(-46.85+(175.72*(partial/65536)),1,2,2,False)
     
            'get humidity from humid sensor
            Dim readbyte(2) As Byte
            Dim writebyte(1) As Byte
     
            writebyte(0)=0xe5 'read temp register
            Main.twi.WriteRead("hhumid",64,False,writebyte,1,readbyte,3,0)
        Else
            Log("htemp_done error "&noerror&" "&success)
            get_temp
        End If
    Else
        common.note_trouble("Sensors htemp_done ERROR ")
        get_temp
    End If

    If Main.parms.logs Then Log("htemp_done end")
End Sub
 
Last edited:

kolbe

Active Member
Licensed User
Longtime User

Sorry life has been keeping me busy with other things. What you ask is possible but it requires changing the library I get from Ytai. I don't really care to do that because of the extra maintenance then for each release.
 

JTKEK

Member
Licensed User
Longtime User

sorry for my question
what is main variable? i means main.twi
 

Reyes5

Member
Licensed User
Longtime User
Hello all,

For a new project, I need 40 digital outputs and 80 digital inputs. My idea is to have 3 IOIO boards attached to a tablet. I could find somewhere on the net it should be possible to work with multiple IOIO boards together. Has anyone experience with multiple IOIO boards connected to 1 tablet? And if yes, do you think or know it is possible over USB, using a USB HUB ? My customer is afraid of connecting over BT and realy wants a wired connection, no radio.
Has anyone got experience to share about this ?
Thanks a lot for your kind reply !
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…