B4A Library IOIO board library

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

  1. kolbe

    kolbe Active Member Licensed User

    I am repeating myself but if you use the workbench app as is it will compile fine against the latest library regardless of API version. Other problems may occur later but it will at the very least compile.

    Can you compile any applications at all? It's a wild guess but is the error above because you don't have the right version of Java installed?

    Sorry but I'm going to have to give up on trying to help you. I don't know enough about what you are actually doing. Each error you have posted is different and seemingly unrelated. I have little idea of what you are doing or what you have changed and I get the feeling you are changing many things. I fear this is going nowhere. The language barrier doesn't help either... I saw you posting in the German forum as well.

    My advice at this point is for you to start very simple and familiarize yourself with B4A first (use the examples in the tutorial) only after that start with other libraries. When you feel comfortable with the way libraries work ask again here if you are still having IOIO problems. If B4A is correctly setup and working it really isn't that difficult to get the IOIO library to work.
     
  2. luigi.crocella

    luigi.crocella Member Licensed User

    Thanks Kolbe,
    1) Yes, Other applications I can compile normally
    2) Yes, I can see in the tab: ioio library 2.02

    What happens? I hope you can help me.
     
  3. kolbe

    kolbe Active Member Licensed User

    @Fossil
    @luigi.crocella

    Try compiling this app. It simply connects when the application is created and then with a button you can turn on the onboard led. You need to choose the correct connection type.

    Edit: Fossil see Erel's post below.
     

    Attached Files:

    Last edited: May 18, 2014
  4. Erel

    Erel Administrator Staff Member Licensed User

    This error means that Java JDK is not installed correctly. Make sure that the correct javac is referenced under Tools - Configure Paths.
     
  5. kolbe

    kolbe Active Member Licensed User

  6. Erel

    Erel Administrator Staff Member Licensed User

    I referred to this error:

    Exception in thread "main" Could not find the main class: com.sun.tools.javac.Main. Program will exit.
     
  7. luigi.crocella

    luigi.crocella Member Licensed User

    Thanks Kolbe.
    I tried the simple ioio. When I compile I get the error:
    ----------------------------------------------------------
    Parsing code. 0.05
    Compiling code. Error
    Generata eccezione di tipo 'System.OutOfMemoryException'.
    -----------------------------------------------------------

    I had a doubt: I have not updated my B4A later versions and I'm working with the B4A 3.00.
    Could this be causing my problem?
     
  8. kolbe

    kolbe Active Member Licensed User

    Perhaps try to copy just the code text into a project you create. Maybe as you said a B4A v3.5 project is not compatible with a 3.0

    Other than that I'm at a loss for ideas. The error doesn't give you much to go on, no line number, etc. Perhaps ask Erel for some help. What is parsing code 0.05?
     
  9. Kevin L. Johnson

    Kevin L. Johnson Member Licensed User

    Apparently Samsung Galaxy S2's and S3's (others?) have some sort of issue with communicating properly with the IOIO via the usb port ... my Samsung Galaxy S3 is doing the same thing, while my older Android phone has no problem communicating with the same board via usb.
     
  10. Kevin L. Johnson

    Kevin L. Johnson Member Licensed User

    I've just recently purchased an IOIO inventors kit from Sparkfun, but am not able to access it via my Samsung Galaxy S3 running Android 4.3. I can however, access it via an older android phone.

    My questions are ... Since the IOIO Lib now includes Open Accesorry ...
    1.) Does this mean that we can now access the IOIO via open accessory (even for Android 4.1 and above)?
    2.) If so, what are the requirements, (currently am using two IOIO lib files "IOIO" (version 1.40) and "IOIOLib" (version 3.20)
    3.) What firmware might I need on my IOIO board?

    My apologies for an earlier incorrect posting in the "Libraries" thread ... Thanks for the heads-up NJDude!

    Thanks again, this product, community and dedicated individuals are all fantastic!
     
  11. kolbe

    kolbe Active Member Licensed User

    Sorry I've been away for a few weeks.

    Yes open accessory works with the latest ioiolib as does device mode. Open Accessory started with sdk 10 or android 2.3.3 or GINGERBREAD_MR1.

    You will need the IOIO application firmware v5.xx to use the latest ioiolib v2.02

    I have a samsung s3 mini. I'll give the library a try on that and see if there are any issues.

    I hope to post ioiolib 2.04 with all the latest fixes from Ytai soon.
     
    Last edited: Jul 13, 2014
  12. Kevin L. Johnson

    Kevin L. Johnson Member Licensed User


    Glad to have you back! Thanks for all your efforts ...

    Q1: Do you have a rough order of magnitude (days, weeks, months) on when you're hoping to post ioiolib v2.04? If not, I can certainly understand.
    Q2: After I update the firmware of my ioio board. Do I need to do anything special to use Open Accessory or do I just disable "USB debugging" in my Androids Developer options?

    Thanks again!
     
  13. kolbe

    kolbe Active Member Licensed User

    Next few days.
    Download v2.02 of the library and use the workbench app as an example. On the device side disable debugging an you said.
     
  14. Jiemde

    Jiemde Member Licensed User

    Hi Kolbe,
    I'm new in B4A, I try to work with the IOIO OTG board and see in this forum that you publish an "simple.ioio" zip file.
    I've deszipped this file and open it in the B4A.
    First I receive an error : library ioio 20 is missing.

    IN the Sub Button1_Down and Button1_Up I have an error with the "WriteWait" who is not recognized ( I use the IOIO lib 2.02 and the IOIOBT lib 1.61 ) ?
    Can you make an short overview of the last lib necessary for working well with the IOIO board ?
    Have you an idea about this problem

    Best regards
     
  15. luc primeau

    luc primeau Member Licensed User

     
  16. Kevin L. Johnson

    Kevin L. Johnson Member Licensed User

    I am trying to get my IOIO to drive a servo motor.

    I am running KitKat on my Samsung Galaxy S3
    I have upgraded all my firmware and Libs to the latest etc. and disabled USB debugging in the Developer options
    Therefore I am running an Open_Accessory connection ..

    I can run the simple IOIO example that blinks the yellow status light from my Basic4Andriod IDE and phone.

    Next I started with Kolbes PWM code snippet and rolled it into the simple IOIO as a template (removing the code to blink the Yellow status LED)
    therefore this short bit of code only tries to drive a PWM Servo...

    THE PROBLEM:
    It doesn't yet drive the PWM Servo AND I am getting an illogical error of "Sub aPwmOut_open was not found" as if the IDE or Libs are struggling to resolve something.

    Code:
    Sub Process_Globals
      
    'These global variables will be declared once when the application starts.
      'These variables can be accessed from all modules.
      Dim yoyo As IOIO
      
    Dim servo As PwmOutput
    End Sub

    Sub Globals
      
    'These global variables will be redeclared each time the activity is created.
      'These variables can only be accessed from this module.
      Dim SeekBar1 As SeekBar
      
    Dim Label1 As Label
    End Sub

    Sub Activity_Create(FirstTime As Boolean)

      
    Activity.LoadLayout("main1")

      yoyo.Initialize()
       yoyo.ReceiverRegister 
    'only for open accesory connection
       yoyo.Connect("yoyo",yoyo.CONN_OPEN_ACC,1,0'change connection type as desired

       yoyo.OpenPwmOutput(
    "aPwmOut",5,servo.OP_NORMAL,50)

      SeekBar1.Max=
    2000 ' no more than 2 ms

    End Sub

    Sub Activity_Resume

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

    '   yoyo.ReceiverUnregister 'only for open accesory connection
    '   yoyo.Disconnect
    '   ExitApplication

    End Sub

    Public Sub aPwmOut_open (noerror As Boolean, result As Object)

       
    If noerror Then
        
    'assign instance
        servo=result
         
    If servo.IsInitialized Then Log("Servo is Initialized")
       
    Else
        
    Dim trouble As Exception
        trouble=
    LastException
        
    Msgbox("trouble.message","Exception")
       
    End If

    End Sub

    Sub SeekBar1_ValueChanged (Value As Int, UserChanged As Boolean)

       
    Dim fltValue As Float

       
    If Value < 1000 Then Value=1000 'do not allow less than 1 ms

       Label1.Text=Value
       fltValue = Value /
    1000.0
       
    Log (fltValue)

       
    If servo.IsInitialized Then
        
    Log("Servo Initialized")
        servo.PulseWidth(fltValue,
    1'in microseconds, 1.0 to 2.0 ms for a servo
       Else
        
    Log("Servo is NOT Initialized")
       
    End If

    End Sub

    Sub yoyo_connected(noerror As Boolean)

       
    If noerror Then
         
    ToastMessageShow("ioio connected",True)
         
    Activity.Title="IOIO Connected"
         
    'yoyo.OpenDigitalOutput("pin0",0,pin0.OP_NORMAL,True) 'for led true is ON and false is OFF
       Else
           
    ToastMessageShow("ioio error",True)
       
    End If

    End Sub
    UPDATE: I've deleted the previously attached non-working example file because there is a working and improved V2 example found below
     
    Last edited: Sep 4, 2014
  17. luc primeau

    luc primeau Member Licensed User

    You should wait for yoyo connected
    and then openpwm

    Sub yoyo_connected(noerror As Boolean)

    If noerror Then
    ToastMessageShow("ioio connected",True)
    Activity.Title="IOIO Connected"
    yoyo_OpenPwmOutput("aPwmOut",5,servo_OP_NORMAL,50)
    Else
    ToastMessageShow("ioio error",True)
    End If

    End Sub
     
  18. Kevin L. Johnson

    Kevin L. Johnson Member Licensed User

    Thanks luc primeau ... I could not see the forest for the trees but, thanks to your input, IT NOW WORKS FOR SINGLE SERVO .

    OK, Now I am at a point where I need to trial and error / test a few things.
    AND In order to save me a bit of time I have two more questions that I hope someone has the answers to or at least some insight into the issue...

    1 - Does anyone have any best practices or architecture for robust connection, communication and operations using the IOIO (I am currently using it hardwired through my phones USB port, but could go to a mushroom like USB Bluetooth dongle if there were additional benefits like simplicity or robustness of communication or operation with the IOIO).

    I am having to do a lot of disconnecting and reconnecting of the usb cables to get the ioio to connect etc.

    AND Secondly,

    2 - Now I need to mod the PWM Servo code for two servos ( one for Azimuth servo of Gimbal, and one for Elevation servo of Gimbal). My lesson learned above was to wait for completion events regarding connecting to the IOIO and opening the PWM Output etc. But I'm wondering how best to handle this overall and especially now that I'm coding and waiting for two servos (perhaps through boolean variables or ???) This is where I'm down to trial and error methods at the moment.

    I need to clean up my single servo code and will post it after doing so.

    Any ideas ... And Thanks in advance
    Kevin
     
  19. luc primeau

    luc primeau Member Licensed User

    http://www.robotshop.com/en/bluetooth-usb-adapter-mini.html
    they sell the usb bluetooth that work well

    First : how do you connect to your ioio
    this is the way i connect and work fine but i'll explain later some issue

    Try

    YOYO.Initialize
    YOYO.ReceiverRegister

    If openacc then
    ' open accesory
    YOYO.connect("yoyo",YOYO.CONN_OPEN_ACC,0,10 )

    ' dont forget to put in your activity_resume

    if openacc then
    YOYO.ReceiverUnregister

    end if





    Else
    ' open Bluetooth
    YOYO.connect("yoyo",YOYO.CONN_BT ,1,10 )
    End If

    Catch
    Msgbox("Error ioio","Error")

    End Try


    Note : When we open ioio in USB mode we have to be sure to close everything ( pvm,serial ,etc) and then close activity
    Of course when the application stop for any reason the usb port is still block ( this is in accessory mode not in Bluetooth)


    We been developing apps with ioio and b4a and this is a very good match :)

    We just finish an beverage control system with RFID reader and 4 serial port , all with ioio included in our on pcb

    Erel did the best programming language on the market
     
  20. Kevin L. Johnson

    Kevin L. Johnson Member Licensed User

    Thanks ...
    I purchased two today!

    I have been using the Open Accessory connection

    Did you mean 'don't forget to put in your activity_pause'?

    OK, close everything on startup (just in case?) or before shutting down. What does this look like and where does this code go

    the only thing i'm doing in my Activity_Pause is ...
    Code:
    yoyo.Disconnect

      
    ExitApplication
    I am not currently closing my PWM output which could be my biggest problem (the reason why I keep needing to unplug and then plug in my IOIO usb cable during each run.

    Is there any way to prevent this when using OPEN_ACC because this may be part of my issue as well.

    Yes, I agree wholeheartedly!

    UPDATE: As promised ... here is my best practices attempt at an example of using an IOIO OTG via USB and Open Accessory to drive a single R/C Hobby Servo using PWM.


    Thanks for all the help too!
    Kevin
     

    Attached Files:

    Last edited: Sep 4, 2014
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