Tutorials at the xod.io website

A XOD tutorial library with basic patches can be found at https://xod.io/docs/tutorial/ (some of these may require adjustment of parameters for use with the multifunction Rich UNO R3 board provided in the Biomaker Starter Kit).

In addition, an excellent collection of hands-on hardware-software tutorials that can be found at the XOD website (https://xod.io/docs/guide/). These are summarised below. The same web page also includes details of Interfaces and protocols: Controlling LEDs via UART — exchanging text-based data between two boards, I²C communication basics, IoT and Network communication: Quick setup of W5500 Ethernet Shield for Internet and LAN communication, Advanced setup of W5500, Connecting to Internet with ESP8266-based MCUs, Fetching data from web API’s with HTTP GET requests.

Digital clock

A tutorial that descibes the use of XOD nodes to conbine a real time clock (RTC) module and I2C 16x2 LCD text display to create a digital clock. The tutorial exercise is easily translated to the Rich UNO R3 board and Starter Kit, with access to the onboard RTC, expansion shield and external I2C 16x2 LCD display. The tutorial provides a detailed description of the software and hardware components - and is especially useful for its clear description of the way patched nodes can be encapsulated in a single new node with particular inputs and outputs - and embedded in another patch. This allows functions to be embedded in a modular and reusable way - and can shield users from underlying complexity.

This example describes how to use the datetime and ds-rtc libraries, format date and time values, and work with real-time clock (RTC) modules for Arduino. Upon the completion of the guide, you learn how to create a simple digital clock based on a DS1307 I2C RTC module and I2C LCD display.

In this example, the programming process consists of two steps:
(i) Making a program to write the current datetime to the memory of the RTC module. (ii) Making a program to read the current datetime from the RTC module and display it on the screen.

The instructions and code can be found at: https://xod.io/docs/guide/rtc-example/

Required hardware:
Arduino Uno board e.g. Rich UNO R3
I2C RTC breakout board based on the DS1307 microchip
I2C LCD 16x2 display
A battery to power the RTC module
Expansion shield or breadboard
Hook-up wires

(i) Reformat the time display
(ii) Direct the output to different displays, ie. the onboard 4-digit display or 4D Systems touchscreen display


Data logging

This tutorial describes how to store sensor data and process it on a computer. The example shows how to read environmental temperature and save the values on a microSD card. After this, the microSD card can be connected to a computer to analyze the measured sequence of temperature values.

The example employs a TMP36 based thermometer, but XOD also supports the LM75 temperature sensor that is installed on the Rich UNO R3 board. The LM75a-temp-sensor node can be found in the gst/lm75atempsensor XOD library, and can be added to the patch. The LM75 thermometer is connected via an I2C port.

Note: there is more information about use of the Rich UNO R3 RTC and LM75 devices in XOD in Tutorial 3.

The temperature readings are bound to timestamps when read, using a system-time node. This node outputs time in seconds passed since the program start. A count node is used to number each new record for the continuously updated data. We need to set a frequency of readings to limit the data volume and to give some time for the microSD board to flush the file after each record. The easiest way to do this is to use a clock node. 

With a potentially large volume of data, the stream can be formated as a table. Each row may represent a single record: the record number, record timestamp, and a temperature value read at that moment. To combine all data values and store them as a single string, use the join node. XOD provides an sd-log node to append text lines to the tail of the specified file stored on an SD card.

The program can be uploaded to the Arduino board and optionally powered by battery/solar cell. The program will be held in non-volatile memory, and the device will continute logging whenever powered, and despite any interruptions due to power loss. With the microSD card, you can store a significant amount of data that would not fit in the memory of the controller.

The instructions and code can be found at: https://xod.io/docs/guide/sd-log-example/

Required hardware:
Arduino Uno board
LM75 digital temperature sensor
microSD breakout board
Formatted microSD card
Hook-up wires

You can use any other sensor or even several different sensors to log and observe a processes of your choice.


Control of sequences: traffic light

A traffic light is a good example of a device which does its job sequentially. In its simplest form a traffic light has three states: Green — go, Yellow — stop if you can and Red — stop! Each state is active for some time interval and when done everything starts from the beginning and repeats again and again.

The tutorial describes the implementation a state machine. In this example there is one patch node per state and a patch that will wire the state nodes together. In this case: (i) state-green, (ii) state-yellow, (iii) state-red and (iv) main joining patch.

Drafts are crated for all state patches, the main patch is built, and then finalised. A mechanism is needed to allow patch nodes to talk to each other. A common mechanism is to send a pulse input to a state patch to enter that state, and add pulse outputs to notify about state completion. Therefore, each of the states has an input and output. We can wire them in a daisy chain so that when one state completes its job, it gives the control to the next state. 

What should a state do once entered? When should it exit? What should it do right before exit? In this case, when a state is entered, it should turn on the corresponding LED. Then it should wait few seconds, turn the LED off and then exit.

A pulse from a boot node is used to trigger entry into the first state, as we want our traffic light to start its job right when the device is powered up. However, the device suspends after the last state because nothing returns it back to the first state. We could link the last state DONE pulse to the first state SET pulse to complete the loop, but unfortunately, XOD does not allow this - to avoid possible deadlocks. Instead we can add a defer node. This can break any cycle and tell XOD to break off if a deadlock occurs. The first state-green node input is not allowed to have links from the boot and defer-pulse at the same time. We can easily solve it by adding an any node.

Doing things sequentially in XOD requires the following approach:
(i) Understand your sequence states
(ii) For each state make a patch node
(iii) On each state patch, use pulse inputs and outputs to enter and exit the state
(iv) Make a joining patch which wires all states together
(v) Define an entry pulse for the first state

The instructions and code can be found at: https://xod.io/docs/guide/simple-traffic-light/

Play with timeout values, try to start the sequence from another state, add three more LEDs to form a complementing traffic light. 

Required hardware:
Arduino Uno board
Onboard TMP75 I2C temperature sensor
microSD breakout board
Formatted microSD card
Hook-up wires

Marco Aita and Carlos Lugo have rewritten this for use with the shield and RGB LED.