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

    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.?
     
  2. Cableguy

    Cableguy Expert Licensed User

    This is what I got... at least there is something being trown at b4a
    Code:
    An error occurred:
    (Line: 
    0null
    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: Jan 13, 2015
  3. kolbe

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

    kolbe Active Member Licensed User

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

    Cableguy Expert Licensed 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: Jan 15, 2015
  6. Cableguy

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

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

    Cableguy Expert Licensed User

    Yes I did.

    I have no idea. My bt dongle is unbranded.

    Yes, it takes an eternity to pair but it does seem to pair. My firmware is on 5.03 I think.

    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.
     
  9. kolbe

    kolbe Active Member Licensed User

    @firestormer

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

    Attached Files:

    Last edited: Mar 16, 2015
    Cableguy likes this.
  10. Cableguy

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

    kolbe Active Member Licensed User

  12. bluedude

    bluedude Well-Known Member Licensed User

  13. JTKEK

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

    kolbe Active Member Licensed User

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

    JTKEK Member Licensed User

    [​IMG][/url][/IMG] The picture below show original IOIO default bluetooth name
    [​IMG]

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

    [​IMG]

    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
     
  16. JTKEK

    JTKEK Member Licensed User

    anyone has twi working example
    can you share with me
     
  17. kolbe

    kolbe Active Member Licensed User

    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.

    Code:
    Sub humid_temp

        
    Try
            
    'get inside temp from humid sensor
            Dim readbyte(2As Byte
            
    Dim writebyte(1As 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(2As Byte
                
    Dim writebyte(1As 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: Oct 3, 2015
    JTKEK likes this.
  18. kolbe

    kolbe Active Member Licensed 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 likes this.
  19. JTKEK

    JTKEK Member Licensed User

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

    Reyes5 Member Licensed 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 !
     
Loading...
  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