B4A Library IOIO board library

diego

Member
Licensed User
Thank you all for sharing, I've successfully tried DigitalInput with two cables and a resistor :sign0025:
(I know nothing about electronics, so I was jumping for joy :) )



Some doubts:

- the IOIOBT lib is the same as IOIO? if so, it's possible to establish connection by BT or USB with same code just changing Initialize to True or False.

- what is the minimum value for the Timer to avoid losing data in digitalInput.Read ? can I set it to 1 msec?

- The two dongles in the photo don't seem to work, I get an error "Bluetooth device named 'IOIO' not found". Wrong dongles, perhaps?
 

pinoy_ako

Member
Licensed User
diego.
you have to pair with it first in your bluetooth settings. if you are asked for a password, use "4545".
great pos. now i learn how to post pics.:D



I'm I think there's something wrong with my analog input syntax.
i dont remember i had problems with AI. i tried it with LM35 before.
 

kolbe

Active Member
Licensed User
FYI. Andrew will no longer be supporting this library.

http://www.basic4ppc.com/forum/bugs-wishlist/8774-wish-ioio-support.html#post90055

I'll post the new libraries here. It seems like it is better this way than to have two threads on the forum for the same library.

Version: v2.07 (use this one)

This uses the latest java IOIOlib from Ytai. It includes all the latest bug fixes. Look at the IOIO wiki release notes for more information. There is no new functionality in this version. Your IOIO should be using version 5.06 application firmware. Use the latest bootloader as well.

The IOIO has become a solid platform. It offers a unique functionality still today and does what it was designed to do well. Although there isn't a lot of activity it is still being supported by Ytai and I intend to here at B4A as well.

In the zip file I include files needed for OpenAcc and Device connections.

Please place any IOIO related questions in this thread.​

Version: v2.05 (for reference only)

This version brings heaps of long awaited features. You can now finally connect the IOIO in four ways.​

USB ADB: Possible only on SDK 16 and below. After this release Goggle secured ADB and no support for this connection exists in newer Android versions.

BLUETOOTH: This works on almost all versions of Android that have Bluetooth.

USB OPEN ACCESSORY: This works on SDK 10 and above. Your Android device must however support Open Accessory. Most newer devices do have support. For this to work you need to add items to the manifest file of your app. It also requires a two extra commands in your app to register and unregister a broadcast receiver.

USB DEVICE: Connects the IOIO to your Andorid device as a device. This requires that your Android supports Open_Accessory and OTG. In this mode your Android device powers the IOIO. Make sure the IOIO-OTG is set to Auto and not HOST mode.

There is now a Motor Control Sequencer (aka waveform/pwm sequencer). This is a very cool addition made by Ytai. You need application firmware v5 for this functionality.

There is now a synch() command that allows managing the multi-threaded nature of the Android OS with the synchronous nature of the IOIO.

IOIO.Initialize is now required. It also returns a string indicating which connection types are supported by the Andorid device. This only test software support, your device may still lack the required hardware.

Add the changes to your manifest file with the changes in "add this with manifest editor.txt".

Works with both the original IOIO and the IOIO-OTG.

This version requires that your IOIO be running application firmware v5!

This version is built on Ytai's IOIOlib v5.04

Remaining Issues

The sequencer has trouble closing and reopening if done too rapidly. I don't think this is an b4a library issue but an IOIOlib issue. If you try to reopen and an exception is thrown you will need to unplug and plug back in the IOIO to reconnect unless you are using BT of course.

Finally

Enjoy. Since this takes a dedicated effort to maintain I wouldn't mind hearing about your projects. Also... please study the workbench 2.32 code before posting "how to" questions. I kept the code as simple as possible and you have basic examples on how to do use just about all the functionality of the IOIO.​

Version: v1.9 (for reference only)

Only two noteworthy changes in this version.

Capacitive sensing functionality. A cap-sense input pin can be used to measure capacitance, typically in touch sensing applications. Note that not every pin can be used as cap-sense.

The PulseWidthSweep method. Changes the pulsewidth from pulseWidthStart to pulseWidthEnd by step with a msPause in ms b/w each loop. Step should always be positive. Just make start greater than end to count backwards.
This method is usefull for better control of servos.

Note that this version is built on Ytai's IOIOlib v4.0. This means that the IOIO firmware app needs to be v4.0 too.

Judging from the download there seems to be a least 50 or so of you using the library.​

Version: v1.8 (for reference only)

Many things have changed in this version so be sure to read everything to avoid questions on the forum that are answered in the documentation. Be sure to read the documentation that Ytai provides for the IOIO on github. The latest B4A library is based on the Ytai's 3.26 version.

https://github.com/ytai/ioio/wiki/IOIOLib-Basics

Changes/Improvements

The library now supports connections to multiple IOIOs simultaneously. See the IOIO Workbench app for an example.
Most of the methods are now threaded so it all works with SDK > 9, no more NetworkOnMainThread exceptions.
Documentation improved, examples for most methods.
An IOIO Workbench app to verify most IOIO functionality.
Uses latest code from Ytai, so other bug fixes.

Remaining Issues

Starting with Android 4.1 Google has added encryption to the ADB interface that IOIO uses to communicate when connected through USB. Ytai doesn't have any plans to support this change. Because this version of the library doesn't support OpenAcc, the only way to connect to Android devices 4.1 and higher is via Bluetooth.​

Note:
IOIO Test is for v1.7 of the library
IOIO Workbench 2.0 is for v1.8 of the library
IOIO Workbench 2.1 is for v1.9 of the library
IOIO Workbench 2.32 is for v2.07 of the library

For IOIO Workbench you will need to adapt your screen layout for your device.
 

Attachments

Last edited:

Ph1lJ

Member
Licensed User
Hi Kolbe

I see from previous entries that you have done some stuff with the ioio Pulse-in, could you post an example of this ?

I was trying all day yesterday - just don't seem to get it.

Was able to get most other ioio functions to work, but not this one

Here's hoping you can help

Cheers

Ph1lJ
 
Last edited:

kolbe

Active Member
Licensed User
The light sensor is this one.

http://www.sparkfun.com/datasheets/Sensors/Imaging/TSL235R-LF.pdf


The humidity sensor is this one.

http://www.sparkfun.com/datasheets/Sensors/Temperature/HH10D.pdf


The sample rate is overkill for the humidity sensor but it works.

B4X:
Dim yoyo As IOIOBT

Dim hfreq As PulseInput
Dim lfreq As PulseInput

hfreq = yoyo.OpenPulseInput(6,hfreq.IP_FLOATING,hfreq.RATE_2MHZ,hfreq.FREQ_SCALE_16,True)
lfreq = yoyo.OpenPulseInput(31,lfreq.IP_FLOATING,lfreq.RATE_2MHZ,lfreq.FREQ_SCALE_16,True)

humid= Round2((7665-hfreq.Frequency)*(380/4096),2)
lux= Round(lfreq.Frequency)
If your pulse is not 3.3v then you will have to make some changes to this. The output is connected directly to the IOIO pin. Make sure the wires aren't too long, < 12"
 

jransom2

Member
Licensed User
PWM Output

Does anyone have a pwm input and output example that I can use for controlling a servo using the ioio library?

The servo is in open drain mode and all I want to do is control the rotation.

For some reason this is not coming to me as easily as it should.....

Thanks in advance
 

kolbe

Active Member
Licensed User
This code works for me. Connect the signal directly to pin 7. Make sure you have the connections correct! Should you connect the motor +/- to the IOIO it will probably damage the board. You could use a 220ohm resistor on the signal just to protect the pin from motor malfunction. This is controlling the motor with 3.3v which works for me but I guess 5v is what is really expected. In that case you change to open drain mode. In the long run this is probably the better way to go.

B4X:
Activity module
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("main")
   yoyo.Initialize(True)
   yoyo.WaitForConnect
   servo=yoyo.OpenPwmOutput(7,servo.OP_NORMAL,50)
   SeekBar1.Max=2000 ' no more than 2 ms
End Sub

Sub SeekBar1_ValueChanged (Value As Int, UserChanged As Boolean)
   If Value < 1000 Then Value=1000 'do not allow less than 1 ms
   Label1.Text=Value
   servo.PulseWidth=Value 'in microseconds, 1.0 to 2.0 ms for a servo
End Sub
 

microbox

Active Member
Licensed User
Trouble on IOIO demo program

Hi everyone, I'm new to B4A and want to try to run a sample program using IOIO board. This IOIOB4ADemoBT program is from Tonghl, I have the files into the libraries folder (ioioBT1.61) here is the code I'm using...
B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   '
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim YOYO As IOIOBT
   Dim led As DigitalOutput
    '
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 btn_Exit As Button
   
   Dim btn_LED As ToggleButton
   Dim Label1 As Label
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
    '
   Activity.LoadLayout("frm_Main")
   '
   If FirstTime Then
      YOYO.Initialize (True)
      YOYO.WaitForConnect()
      led = YOYO.OpenDigitalOutput( 0,led.OP_NORMAL ,True) ' Enable LED_PIN for output
   End If
   '
End Sub

Sub Activity_Resume
    Label1.Text =Label1.Text & ". LIB Ver: " & YOYO.GetIOIOVersion(YOYO.VER_IOIOLIB)
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    If UserClosed Then
      led.Close
      YOYO.disconnect()
   End If
End Sub

Sub btn_LED_CheckedChange(Checked As Boolean)
   'led_.write(!button_.isChecked());
   led.Write(Not (btn_LED.Checked)) ' Turn on/off stat LED, active LOW
End Sub

Sub btn_Exit_Click
   ExitApplication
End Sub
Unfortunately when I run the simulator and in real device I got an error, please see attached file...can anyone point out what I'm missing in the process?

Thanks in advance,
microbox
 

Attachments

microbox

Active Member
Licensed User
Hi sorry but I can not resist to try the IOIO demo supplied by agraham without the Bluetooth yet..this demo consist supposedly of a button to toggle led.. But on the sim and real device I don't see the button appear...can anyone guide me on this please..:sign0104:


microbox
 

Attachments

kolbe

Active Member
Licensed User
Microbox,

First off, with the IOIO you can't use the simulator. You need a real IOIO connected. So nothing will work unless you have the program running on a real device with the IOIO connected.

Second, does your program work if you use the USB connection? This will eliminate possible problems.

If USB works then we will see about the Bluetooth connection. It can be tricky because not all BT dongles work with the IOIO. Some devices have problems too.

As for the IOIO demo program, if are not connecting it will block at yoyo.waitforconnect and then you may never see the button.

I'll try in the next few days to post a better test program that will help debug these connection problems. I have one already but I need to clean it up a bit.
 

microbox

Active Member
Licensed User
Hi Kolbe, thanks for responding. I tried to use the USB only before but there is no button displaying. I will try it again as soon as I get back home...and post here my results. I'm also looking forward for your update..it will be a great help for beginners like me.

Thanks in advance,
microbox
 

kolbe

Active Member
Licensed User
Here is a test app that I hope makes getting started with the IOIO easier. It allows to test the connection to the IOIO and gather basic information. It also allows you to quickly see the logcat in order to debug any problems. I'm using a newer version on the B4A IOIO library so if you try build against older libraries it won't find the new ioio.connect method. Once I finish the documentation I'll post the new library as well. I'm also not sure how this application will look on smaller screens.

Edit: The new library is posted here. The IOIOtest app will only compile with v1.7 of the IOIO library.
 

Attachments

Last edited:

jransom2

Member
Licensed User
What Libraries do I need?

Kolbe -

I installed the new libraries that you have so graciously provided. I then downloaded your new test app. When compile and send app to phone I get and error parsing the "yoyo.connect" the error is below:


Compiling code. Error
Error compiling program.
Error description: Unknown member: connect
Occurred on line: 88
yoyo.connect("yoyo",BtnBT.Checked)
Word: connect


I have the following libraries installed and checked:
ioio (version 1.4)
ioiobbt (version 1.6)

What do I need To do?

Thanks
Jim
 

kolbe

Active Member
Licensed User
I'm using a newer version on the B4A IOIO library so if you try build against older libraries it won't find the new ioio.connect method. Once I finish the documentation I'll post the new library as well. I'm also not sure how this application will look on smaller screens.
You should be able to use the apk no problems however. You can also just comment out the ioio.connect part and use library 1.61. Also change the ioio object name back to ioiobt and not ioio.

Read the readme.txt too. You don't need the ioio.connect to connect. It is a new method I'm experimenting with. You can still do the original ioio.initialize then ioio.waitforconnect. This works with all libraries.
 

microbox

Active Member
Licensed User
@Kobe :icon_clap:
I want thank you very much for the wonderful code. Your program works for me on my galaxy tab. But unfortunately, I tried many times but the status of my ioio is DEAD...:( so that means I need to wait until I get a new ioio. I can't wait to get me ioio (hope before June)...thanks for the effort on the files and sharing it...

Kind regards,
microbox
 

kolbe

Active Member
Licensed User
DEAD doesn't mean the IOIO is dead, it just means the connection has been broken and you need to reinitialize and then waitforconnect. When you disconnect the state goes to DEAD for example. Are you saying you never get a CONNECTED state? When you press Init it should go to INIT state, after waitforconnect to CONNECTED and after disconnect to DEAD. What does the logcat say?
 
Top