Week 10

Output Devices

This was a week of experiments for me. I wanted to end up with a circuit which would output on LCD and control a relay for my final project - this meant I had to make a modified Satsha Kit board. It would be used to represent the water left inside a tank, based on the data fed by the distance sensor or But based on the concept of Circular development, I decided to start simple with a Charlieplexed LED circuit, and then graduate to designing and modifying the SatshaKit.

Charlieplexing

This was a fairly straight exercise, with me taking the traces and components file off from the class website. The soldering was also a fairly straight off process. Tapan suggested I have fun and change the LED colors, so I did that.

Starting sodlering the charlieplexing board

The programming was done through the Arduino, which I programmed as ISP at first using the "Arduino as ISP" example code under the Files menu. In this, I had to make 1 change, on line 81, I uncommented Use Old wiring as shown in the image below and uploaded the code into the Arduino Uno. Using the Uno as the device to program my Attiny44 circuit, I used this wiring to wire my arduino to the circuit and completed the code upload to get this output

hero from Gautam Prakash on Vimeo.


LCD via I2C

The I2C driver soldered on to the LCD screen

This was done after the Input Devices week, as a step closer to my final assignment. The PinToo board is my design based on the SatshaKit . The SatshaKit is available on Github. More documentation of this is in input week. The next challenge I took up was to attach an LCD to my Pintoo board - a board based on the SatshaKit, using an AtMega 328P to power it. Since I wanted to conserve the number of wires lost in connecting an LCD to the PinToo, I decided to use the I2C bus to power it. Reading up the datasheet for 328P, I was able to identify which pins the SDA and SCL were mapped to.

I²C (Inter-Integrated Circuit), pronounced I-squared-C or I-two-C, is a multi-master, multi-slave, packet switched, single-ended, serial computer bus invented by Philips Semiconductor (now NXP Semiconductors). It is typically used for attaching lower-speed peripheral ICs to processors and microcontrollers in short-distance, intra-board communication. I²C uses only two bidirectional open-drain lines, Serial Data Line (SDA) and Serial Clock Line (SCL), pulled up with resistors. Typical voltages used are +5 V or +3.3 V, although systems with other voltages are permitted. The maximal number of nodes is limited by the address space and also by the total bus capacitance of 400 pF, which restricts practical communication distances to a few meters. The relatively high impedance and low noise immunity requires a common ground potential, which again restricts practical use to communication within the same PC board or small system of boards. - Wikipedia

There are boards made already with a PCF8574 IC to enable this connection with just the Analog 4 (SCL) and 5 (SDA) pins. I took that and soldered it to an Blue background 16 x 2 LCD. To ease coding, I chose to use an Library in Arduino IDE called "LiquidCrystal_PCF8574". With this code, I was able to show the water flow data on the LCD screen.

Steps taken to integrate the LCD code in the Flow meter code

Install this library in the Library Manager, found under menu item "Sketch>Include Library
Include library and define its I2C address
Include the lcd.begin and the following lines below it
Include the highlighted lines in Void Loop
How to customise any code to display output on an LCD if using this library
1. Include the Library and line "LiquidCrystal_PCF8574 lcd(0x27);" The value 27 is an address, which can be changed to 3F or the correct address which can be found using I2C scanner code on Arduino website
2. In void setup, include these lines "lcd.begin(16, 2);" where 16 indicates charecters in 1 line and 2 indicates number of lines. So if your using a 20x4 screen, change them to "20, 4".
"lcd.setBacklight(255);" sets the backlight to high, with 255 being highest brightness and 0 being lowest.
"lcd.home();" sets the 0,0 values as home
"lcd.clear();" sets the LCD to a clear screen
3. In void loop, print any line you want on the screen by setting the line as "lcd.setCursor(0, 0);" - sets cursor to first charecter on line 1 (remember counting starts with 0, not 1)
"lcd.print("*** first line.");" prints the charecters inside the double quotes in line one
"lcd.setCursor(0, 1);" sets cursor to line 2, charecter 1. If you change the 0 to lest say, 10, the text printed on the screen will come from charecter 11
"lcd.print("*** second line.");" prints charecters in the double quotes on line 2.

There were 2 issues I faced in this exercise.

  1. White boxes appeared on the screen and not any charecters. After diagnosis, I realised i Had inverted wires from the PinToo to the driver - SDA wire connected to SCL and viceversa
  2. the last few charecters were not clearing from the LCD. This can be rectified by introducing a "lcd.clear();" after each run of the "lcd.print..." command.

There was a success after these 2 fixes,

Link to the PinToo board schematic and board can be found in the links. The


Relay

A relay is a output device, which controls based on the 5v power supplied by any pin from the PinToo/4 board, an electrical appliance drawing 240v upto 10A of current. This means that I can now control any water pump or irrigation system based on a pump, or even control water drawn by appliances in the laundry section of a home.

Week 10: Pin4 board and a Relay from Gautam Prakash on Vimeo.

Conclusion

Output devices was completed in 2 phases - 1 with a charlieplexed LED array and 2 with an LCD outputting flow data on an LCD screen.(Updated) I also got the board to control a relay, which could control a device drawing 240V and 10A of electricity.