Requirements: Computer loaded with XOD and board driver, Rich UNO R3 board, 16x2 LCD display, 4-digit 7 segment display from the Biomaker Starter Kit, internet access to XOD libraries.
Cesar Sosa has created useful libraries for controlling the Rich UNO R3 board. In particular, you should download the XOD libraries:
cesars/rich-uno-r3 and cesars/0-all-examples
The cesars/rich-uno-r3 library contains a number of useful nodes that support the use of on-board hardware - such as the 4-digit display, buzzer, LM75 temperature sensor and touch buttons. These are ideal for experimenting with hardware control and the mixing of different software nodes. The cesars/0-all-examples library contains a series of examples that can be examined and modified.
The board has a built-in clock and back-up battery. This is based on a DS1307 high-precision real-time clock module with I2C serial interface, and address 68h. Many sensors and modules talk to a host board using the I²C bus also known as TWI (Two Wire Interface). This interface uses a single line (SDA) to transfer data serially and another line (SCL) to push clock pulses which define the initiation and rates of communication events. Devices on the serial bus have separate addresses, which allows many to share the same bus. XOD can support low-level I²C communication with nodes available in xod/i2c
., which allows a programmer to build support for new devices. There is information about this more technical topic at: https://xod.show/docs/guide/i2c/
However XOD provides direct support for some I2C hardware, including a range of real time clocks based on DS1307 chips and its relatives, and nodes and examples are provided for (i) setting the time, (ii) reading the time, and (iii) formating the year, month, day, date, hour, minute and second for processing or display. Direct XOD support for the real time clock can be found at: xod-dev/ds-rtc
There is an excellent tutorial and guide to building and using the real time clock module at: https://xod.io/docs/guide/rtc-example/. The guide works through an example for 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 will be able to create a simple digital clock based on a DS1307 I2C RTC module and I2C LCD display.
An LM75 temperature sensor is mounted on the board next to the real time clock (RTC). The microcontroller communicates with it via an I2C interface, at the address 48h. The temperature sensor is internally calibrated and measures to ~0.1 degree C accuracy. The temperature is output as a number that can be operated on or displayed. The LM75a-temp-sensor node can be found in the gst/lm75atempsensor XOD library - and allows simple access to the on-board sensor. Numerical output from the lm75a-temp-sensor node can be reformatted using the format-number node. This allows the user to define the number of significant digits. The output of this node is in string format. This can be fed to a join node, which allows addition of defined text to the string, and this can be sent to a display. In a simple example, the cesars/0-all-examples/0006-rich-lm75 patch collects the output from the onboard temperature sensor and sends this to a 4-digit display (make sure that you use the D10 and D11 addresses for CLK and DIO if you want to use the onboard display). To extend this - try to format the output for display on an external LCD screen using the text-lcd-16x2-i2c node. Also display the time...
4-digit displayObjectives: (i) Install external library for communication with the display, (ii) Implement nodes in XOD, (iii) Design numerical input and display, (iv) Implement external 4-digit display.
In order to drive the 4-digit 7-segment display on the Rich UNO R3, install the cesars/rich-uno-r3 and cesars/0-all-examples libraries from Cesar Sosa. These supply a number of nodes that can be used to control the display through the TM1637 support chip, and are based on an earlier library cesars/tm1637.
Note: you can download XOD code examples to drive the 4-digit display in the Tutorial 4 package. You may also find it useful to connect the external 4-digit display supplied in the Starter kit.
Node tm1637-dev accepts parameters for the clock and data pins, these are D10 and D11, respectively, for the onboard display.
Node bright-tm1637 can be connected to the above node and used to turn on, and regulate brightness of the display. The parameter “brightness” can be set to number from 0 (lowes brightness) to 7 (highest brightness). The parameter “on” is used to set the state of the display.
The library also provides several nodes for formatting the display. num-dec-tm1637 allows decimal display. The node num-decex-1637 allows display of numbers with decimal points, while num-hexex-1637 is used to display in hex format. The nodes accept parameters: “Number”, the value to be displayed; “Zeros”, For displays with dots between each digit: 1 = * 000.0, 2 = * 00.00, 3 = * 0.000, 4 = * 0.0.0.0 - and for displays with just a colon: 2 = * 00:00; “Length”, the number of digits to be displayed, and “Position”, the position from which to start the modification (0 - leftmost, 3 - rightmost)
The onboard display contains 4 digits, separated by a colon (ideal for display of time). The Starter Kit pack also contains an external device where the digits are separated by decimal points that can be activated as required. The external display can be easily wired to the board, using the expansion shield provided, and two suitable digital ports. It may be necessary to use the DIP switch to turn off the use of these ports, to avoid conflict with onboard devices. In the patch provided in the training library, the onboard potentiometer was used to provide a variable signal that can be used for input numbers.
Datasheet for TM1637:CMOS chip to support (8 segment*6 bit common anode LED) display. Keyboard scan (8×2bit), Luminance adjustment circuit, two-wire serial interface (CLK, DIO), built-in RC oscillator, built-in power-on reset circuit, automatic blanking circuit. Download datasheet
Suggested experiments:
Hook up 4-digit display to the onboard real time clock (RTC), and use for timer, clock or stopwatch display.
Use to display parameter values for other devices contained in the Starter Kit.
Comments