Android communications

Started by Tinine, July 01, 2023, 16:44:33

Previous topic - Next topic

chrisws

My board arrived and I've been experimenting with a few things.

I've hit an issue where the HelloConsole program doesn't work on my Ubuntu 22.04 machine.

It stops at "waiting for handshake" (works fine on Windows 10)

Most of the forum messages seem to be related to much older Ubuntu versions, so I've run out of things to try for now.

Tinine

I have been checking regularly for confirmation that Santa came through for you  :D

Craig

chrisws

I managed to get around my issue and have a made a little bit of progress. 

Tinine

Quote from: chrisws on January 08, 2024, 04:45:14I managed to get around my issue and have a made a little bit of progress.
My hero  8)

Coupled with something like this and we'll have a serious industrial controller. I currently use the RT5 model but I'll be switching to the RT7 shortly.

Craig

Edit: Oh but are you focused on the PC version?
 

chrisws

Quote from: Tinine on January 08, 2024, 05:53:04
Quote from: chrisws on January 08, 2024, 04:45:14I managed to get around my issue and have a made a little bit of progress.

Edit: Oh but are you focused on the PC version?

I'm working on a PC "module" first because that's much simpler than dealing with Android development.
Once it's (hopefully) working, it can then be transplanted into the android side.
Also, if you have linux, you could test out a few things on the way.

chrisws

Interesting little project. I made some progress of sorts, hooking in AnalogInput, PulseInput, DigitalInput, DigitalOutput, CapSense and PwmOutput modules.

So far I've only tested DigitalOutput to blink the built-in LED on pin 0.

The board seem pretty old and no-longer-for-sale on various stores which seems a shame. Is it still "a thing" ?

I'd like to try hooking up an LED matrix I previously used for an arduino project, not sure how to go about this.

Tinine

Quote from: chrisws on January 25, 2024, 11:27:49Interesting little project. I made some progress of sorts, hooking in AnalogInput, PulseInput, DigitalInput, DigitalOutput, CapSense and PwmOutput modules.

So far I've only tested DigitalOutput to blink the built-in LED on pin 0.

The board seem pretty old and no-longer-for-sale on various stores which seems a shame. Is it still "a thing" ?

I'd like to try hooking up an LED matrix I previously used for an arduino project, not sure how to go about this.
In terms of off-the-shelf, Sparkfun seem to be keeping it updated. The problem is that there has never been an easy way to get Android to talk to it. 
The project is open-source and there are those who have the required programming skills that are having their own boards made to suit their product.

In the microcontroller world, people are using miniature touchscreen displays which are slow, hog resources, low resolution, usually open-frame, etc.
The low cost Android device is the perfect front-end for a controller but the problem has always been talking to hardware via USB.
If we get to the point where SB can handle it, I for one will be designing my own version of the IOIO. We'll have a lot of interest from the Arduino camp because that stuff is such a PITA.  :D

Craig



J7M

I checked where to buy in Germany and unfortunately the only shops are digikey and mouser. Both have it on stock in US. Good thing is, that they have a lot of them and I can pay in Euro. Only the delivery costs is a little bit higher.
There is always the risk, that Sparkfun will discontinue the IOIO board but at least at the moment it doesn't look like that. Also IOIO at Github is still active. Continue with development of the plugin depends on the expected effort. If it is straight forward to get the digital in- and output, PWM and analog input working on PC and Android then it is maybe worth doing it. More complicated protocols like UART, SPI or I2C can be implemented later, if there is good feedback by the users.

chrisws

The ioio-otg board does seem to be a unique product and I can see how a SB module could add value.
What kinds of devices did you have in mind for this? 

chrisws

I hooked up an arduino slider pot and it worked fine!

Here is my test program:


Quoteimport ioio

analogIn = ioio.openAnalogInput(46)
ioio.waitForConnect()

while 1
  print analogIn.read()
  delay 10
wend

This prints a range of readings as the pot is moved.

There are three separate threads that run here:

1. The SB thread
2. The looper thread
3. The connection handling thread

2+3 will cause high CPU usage if there are no Thread.sleep() calls. But any sleeps will affect latency. I will try adding an argument to ioio.waitForConnect() so you can specify the desired latency for the usage tradeoff.





Tinine

Quote from: chrisws on January 27, 2024, 01:54:44The ioio-otg board does seem to be a unique product and I can see how a SB module could add value.
What kinds of devices did you have in mind for this?

Machine automation. I was labeled "young fool engineer" by Dick Morley (father of the Programmable Logic Controller, aka:PLC) for having the audacity of sticking and original IBM PC (complete with beige box) on a huge machine that formed the first robot-welded car seat frames for the GM Minivan.
I had no option at the time because it was the only system that I could program and the ISA bus accepted the real-time hardware that I needed for 5-axis servo control.

Today, all the big-boys have a PC front-end to their industrial controllers. 
I never took to Windows because even with sophisticated power conditioning all electronics were vulnerable and if we ever had to do a system restore, it rarely went smoothly.

For the past 11 years, I have been using ruggedized Android tablets for the front-end and communicating with microcontrollers. This works really well. 
However, this is only data-in/out, not control because I don't want to rely on BT/WiFi for machine movements.

Now, with a direct USB/IOIO wired connection, all is possible and with the huge benefit of the programming language built-in.

The big-guys, like Allen Bradley, Siemens, Beckhoff are totally screwing-over their customers. Heck a do-nothing 10" touch monitor is like $3K and then there's the problem of supply. Of course, the real cost is a dead production line.

Android devices are ubiquitous and inexpensive. I routinely access a customers systems, worldwide via TeamViewer or Real VNC for machine diagnostic purposes. Android tablets are already equipped for this.

Tablets are making their way, more and more to the factory floor. I am currently using Oukitels but there are many alternatives. If it gets damaged, grab any cheap tablet or someone's Android phone, install the app and the equipment is back online.  8)

I am in a customer's facility as I type this. All their systems are running a (free) ftp server which means that they can access the tablet's entire file-structure from any networked PC. THIS is the absolute best way of controlling machinery IMO  :D

Craig




chrisws

I finally got my arduino 8x8 led to display something. My unit has an integrated MAX7219 ic which is controlled via SPI.
Here's the code:
import ioio

' mosi = master-in slave-out (miso is unused here)
const mosiPin = 2
const misoPin = 6
const csPin = 3
const clkPin = 4

spi = ioio.openSpiMaster(misoPin, mosiPin, clkPin, csPin)
ioio.waitForConnect(10)

spi.write(0x09, 0x00)  ' Decode mode: no decode for digits 0-7
spi.write(0x0A, 0x01)  ' Intensity: maximum intensity 0x0 -> 0x0F
spi.write(0x0B, 0x07)  ' Scan limit: all digits
spi.write(0x0C, 0x01)  ' Shutdown: normal operation

while 1
  for i = 1 to 8
    spi.write(i, 0x35)
  next
  delay 1000
wend

Those four spi.write lines are maybe a bit sketchy. I got the details from that annoying liar chatgpt.

J7M

I have ordered a board. I want to try to get some I2C sensors to work. I hope I can build the plugin, haven't tried it yet. If everything works fine, I will write a  little tutorial.

J7M

The board is working using the example by IOIO (I can toggle the LED). I built the SmallBASIC plugin, but when running led.bas I got the following error message:

Exception in thread "main" java.lang.NoClassDefFoundError: net/sourceforge/smallbasic/ioio/IOIOImpl

Caused by: java.lang.ClassNotFoundException: net.sourceforge.smallbasic.ioio.IOIOImpl
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
Failed to IOIOTask
 * RTE-ERROR AT led.bas:0 *  
Description:
LIB: IOIO->sblib_init(), failed

I'm a little bit lost. In the source code of the plugin in main.cpp, there is the line

options[0].optionString = (char *)"-Djava.class.path=./target/ioio-1.0-jar-with-dependencies.jar";

Do I need this file? Where can I get it?

I tried as written in the Makefile:

/usr/lib/jvm/java-21-openjdk/bin/javap -s -p -cp t target/ioio-1.0.jar 'net.sourceforge.smallbasic.ioio.AnalogInputImpl'
but it gives the error

Error: class not found: net.sourceforge.smallbasic.ioio.AnalogInputImpl

chrisws

You need to install maven to build the jar

Then run the command:

$mvn clean package

If you like I can just add the jar to the release area to save you the hassle.

The javap command was for working out the required jni signatures. I've gotten past all that now.

I've just ordered a couple of i2c sensors for testing TwiMaster. There's still a few missing details so calling ioio.openTwiMaster() won't do anything yet.

Did you have any issues getting the USB connection working? It still doesn't work on my desktop, but on my laptop it connects after pluging/unplugging the usb a few times.

Hopefully this won't be an issue with android.