Performance tests in case of rs485 failure

In my home automation project with Arduino and Android I always paid special attention to communication failures. These might happens for many reasons and the system has to deal with them.

In particular, in the following video I was interested to show you some test I made in order to assess whether the information presented by the touchscreen panel will be displayed whenever available.

The red led indicates that the Arduino is processing a modbus request. As you can see, it stops blinking when the bus 485 is interrupted and immediately after the connection has been restored, it restart to work. Indeed, take look at the bulb icons in the monitor. When the bus is restored, the bulb status will be updated.

The description of the project and the source code are also available. Take a look!

As usual, comments are well appreciated! :)

Android App and Modbus RTU

We made a small and simple application for our well Ltouch panels to allow users to configure and subsequently communicate with all Modbus RTU devices.

Biemme Config, will be installed as standard on all our touch, so make it easier to configure the Modbus RTU devices.

In a few simple steps we can write and read using the Modbus RTU functions 03 and 16.

We prepare communication; We connect via a three-wire cable on Modbus device and Ltouch.

The Modbus RS485 port is positioned in the side of a connector DB9 and uses these pins:

  • 2 – A
  • 3 – B
  • 5 – GND

Set the speed of communications (thanks to our Libreria the app supports speeds up to 115200) and the timeout.

The Function 03:

Node Id: corresponds to the slave to read.

Start Register : corresponds to the first register for the Modbus read

Number Registers: Corresponds how many registers I want to read

Once configured these three fields we can, using the three buttons, perform the read request.

Single reading: Ltouch will perform a read-only and represents the values read on the screen.

Continuous cycle reading: Ltouch will perform the readings at intervals of a second in a cyclic mode. The values will be shown on screen.

FUNCTION 16:

With this feature we can write the integer values:

Node ID: It corresponds to the address of the slave in which I am going to write

Start Register: It is the first register in which I am going to write

Number Registers: It represents the number of consecutive registers in which I will write the value.

Value: It represents the value that will write.

To close the application just press over the Biemme logo

Android Arduino Communication through Modbus and Rs485

In this post I’d like to describe you a project I’m working on that consists of connecting an Android multi touch panel to one (or more) Arduino slave(s) using modbus protocol and RS485.
Even though the idea of this project could be applied in many fields, I chose to contextualize it in a typical smart home context: a touch display that dims lights, shows temperatures and bulbs statuses.


The nice feature of the Android multi touch panel I used is that it has many interfaces such as Ethernet, RS485, RS32 and I²C as well.
I expressly selected RS485 because Arduino-based microcontrollers are not ready for Ethernet yet (even though some examples still exist but without great success). Indeed, RS485 is a well known standard that has been widely used in the indus­trial con­text and in building automa­tion appli­ca­tions. It is a half-duplex, 2-wires, low noise bus that allows high speeds and remote devices connection (up to 1200 meters).
Furthermore, modbus is a serial communication protocol, developed for industrial applications, open and easy to deploy and maintain. I used modbus RTU, but other variations of the protocol still exist though. Continue reading

Using Bundle Android to Exchange Data between Threads

The question that I want to answer with this post is the following: How bundle Android works for exchanging data from a running thread to the main UI?

This is a fairly common situation in Android projects and very simple to figure it out. The context might be the following:

  1. An Android activity that creates a thread running some work
  2. The created thread has to exchange some data with the main UI thread

This situation can be handled by using a combination of Android bundles and messages. Continue reading

How to configure an Android Vnc Server

android vnc server from android clientIn this post I would like to show you the steps required to set up an Android Vnc Server to remotely control Android devices. This walkthrough has been tested with the Ltouch Android panels, but with simple modifications this tutorial can be used with any other Android devices.

Prerequisites:
The only requirement for this would be to have a rooted device (the Ltouch is already rooted). A basic knowledge of linux terminal commands could speed up the setup process. Continue reading

The Pltouch I/O Library as the PLC: An Example

In one of the first blog posts of the Pltouch series, we anticipated that the I/O library can be used in a way the PLC developers are familiar with (but it is not the only way of course).

PLC developers are accustomed to have a big infinite loop in which the code is executed sequentially. Conversely, in PC programs and in apps as well, this is not the case, there is no infinite loop and in mobile apps there are even many entry points. 

Based on those assumptions, the learning curve of PLC developers that want to embrace the Android/Java world might be steep. In order to smooth the steepness of this learning curve, the Pltouch I/O library allows users to continue to use the PLC-style  way of doing things even in the context of Android apps. 

Continue reading

How to set the Android network interface using shell commands

android network configurationIn this post, I’d like to tell you how to set the Android network preferences on Android devices, that is, IP Address, Netmask, Gateway and DNS. This process can be easily done using the Android GUI, specifically in the Settings/Ethernet menu configuration. However, sometimes it is useful to know the shell commands in order to add them in boot scripts. The commands that you’ll find below, has been tested with the Android Ltouch F multi-touch, but I’m confident that there settings should work also with other devices too.

Continue reading

Android IO library for the BieMme Pltouch

In a previous article we introduced the Pltouch, a brand new Android-based HMI with an additional set of I/O pins addressable directly from the Java source code. 

In this post, we would like to explain the rationale behind the Android IO library that is provided free of charge in every Pltouch. This Android Java library acts as a bridge between the Android world and the low level I/O pins.

Once the library has been imported in an Eclipse workspace there are two ways in order to structure your app’s code. In both cases you have to

  • Create an instance of the Android IO library
  • Store this reference in the activity class (like for instance using private/public class field)
  • Call the initialization method

Let’s go through every point and expand each one with examples.

Continue reading

How to configure Android adb without using the mini-usb

android serial lines debugAs presented in an earlier blog post, the Android adb daemon (in the host device) can be set to listen for requests coming from wifi or ethernet instead of the default usb. This process is common for the majority of Android smartphone/tablets and in order to achieve it, the host device must receive at least a set of initialisation commands sent throughout the mini-usb connector.

The mini-usb is a very good connector but when you have to disconnect and reconnect it many times, it may fail or broke. As a consequence, having a mini-usb connector that does not work, means that you can not upload your apks, debug and in general manage your Android device. Continue reading

How to create an Android System App with the Ltouch Panels

Android software stackThe topic we would like to tell you today is how to create an Android System App with the any of the touch panels/tablets Ltouch F, FW (Wifi) or development boards Ltouch S and SW (Wifi). An Android system app is a special kind of application that has higher privileges and does not live in normal user application sandbox.

Example of tasks that can be performed with system apps are:

  • Install and remove other apps
  • Execute commands in super user mode with the Java command: Runtime.getRuntime.exec
  • Low level permission for interacting with the platform
  • Full access to device’s resources

Continue reading