10. E-Textiles and Wearables II

This week is a contiuation to wearables class and is aimed to explore mainly to use different actuators or output devices.

Inspiration

  • Interactive Wearables

  • Smart T-Shirts for Vital Signs Monitoring

Introduction

Actuators are output devices that transform an electrical signal into a physical action in the real world. Very common examples of actuators could be motors, LEDs, LCD screens, etc.

Usually actuators are coupled with input devices or sensors especially in interactive projects where actuators are activated by electronic signals that is usually acquired from sensors and processed by a micro-controller. In embedded systems, the relation between input and output devices being interfaced with the Micro-Controller Unit (MCU) is analogoeus to the relation between sensory cells and muscle cells in human body.

Diagrams designed by Tasneem Hussain(2020).

It is very interesting to see how the idea of a microprocessor or micro-controller is inspired by the functioning concept of the human nervoues system.

This link explains how output devices are interfaced with micro-controller boards in different projects.

I have made the following simple video for beginners with Arduino programming as a part of the online workshops we hosted at QBIC Fab Lab for Arduino Day 2020.

The Assignemnt of the Week

This week we are expected to learn how to design a swatch and then integrate it with Attiny as a small programming IC. Also to test at least two actuators using Attiny or Arduino as a controller.

The Used Equipment, Tools and Software

  • Arduino IDE Software
  • Arduino LilyPad board
  • Attiny 44 IC
  • Neopixel LED strip
  • Piezo buzzer
  • TinkerCAD
  • Roland MDX-50 milling machine
  • FabModules software

Project #1: Safety Scarf for Kids

For this project I have used three actuators; neopixel LED strip, piezo buzzer and viberation motor.

I have got the inspiration from a project made by SparkFun which is a safety winter scarf that has an LED strip which can be powered to light up using On/OFF switch.

I have modified this design using neopixel LED strip coupled with light sensor (LDR) that is programmed to send activtion signal to the LED strip when it is dark. Also, a piezo buzzer will be activated and a nice melody will play. When the ambient light is bright, the LED strip and the buzzer will automatically stop.

  • Understanding how to interface actuators with a controller

To interface sensors and actuators with a micro-controller, you should first read the datasheet of the component. The datasheet has all technical specifications related to the any component, most importantly the operating voltage and the control signal (Read more here).

For the circuit I want to design, I am using a photocell or LDR as a light sensor, Adafruit neoplixel LED strip and piezo buzzer.

  • Designing the circuit using TinkerCAD

I have used TinkerCAD to design the simple circuit and to simulate the Arduino code before practical implementation.

After wiring the circuit, I have added the code so that I can simulate the whole system.

To simulate the code and circuit the ambient brightness can be varied, the LDR will continously be sensing the ambient light brightness. When it is dark outside, LED will light up and the buzzer will play the melody. However, when in is dark LED strip and the buzzer will automatically turn off.

Since this is designed for kids, I will add one more feature to notify the kid to remove the scarf when it is hot. This can be achieved using a temperature sensor and a small viberation motor that will be active when the temperature is at room temperature or more (>= 25 degree C).

  • Writing the Arduino code
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

//Initializing variables

const int ldrPin = A2; // LDR is connected to analog pin A2
int Do = 262, Re = 294 , Mi = 330 , Fa = 349 , Sol = 392 , La = 440 , Si = 494, Do2 = 524; //initializing the melody notes
int buzz = 10; //Piezo buzzer is connected to digital pin 10
int wait = 0;

#define PIN  9 // the Neopixel is connected to pin 9
#define NUMPIXELS 8 // the number of NeoPixels attached to the Arduino

// When setting up the NeoPixel library, we tell it how many pixels,and which pin to use to send signals. Note that for older NeoPixel strips you might need to change the third parameter -- see the strandtest example for more information on possible values.

Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

#define DELAYVAL 100 // Time (in milliseconds) to pause between pixels

void setup() {

  pinMode(ldrPin, INPUT);
  pinMode(buzz, OUTPUT);

  // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
  // Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
#endif
  // END of Trinket-specific code.

  pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
}

void loop() {

  int ldrStatus = analogRead(ldrPin); // acquiring the reading from the light sensor
  pixels.clear(); // Set all pixel colors to 'off'

  // The first NeoPixel in a strand is #0, second is 1, all the way up
  // to the count of pixels minus one.
  for(int i=0; i<NUMPIXELS; i++) { // For each pixel...

    // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
    // Here we're using a moderately bright green color:
    if (ldrStatus <= 200) {

    pixels.setPixelColor(i, pixels.Color(150, 150, 150)); // by setting the colors at the same level red, green and blue will be on together which will give white color 

  wait = 300;

  // Playing the notes on the piezo buzzer

  tone(buzz, Do, wait);
  delay(400);
  tone(buzz, Re, wait);
  delay(400);
  tone(buzz, Mi, wait);
  delay(400);
  tone(buzz, Fa, wait);   //this note might sound too sharp
  delay(400);
  tone(buzz, Sol, wait);
  delay(400);
  tone(buzz, La, wait);
  delay(400);
  tone(buzz, Si, wait);
  delay(400);
  tone(buzz, Do2, wait);
  delay(400);
  noTone(buzz);

 pixels.show();   // Send the updated pixel colors to the hardware.

  }
  else {

    pixels.setPixelColor(i, pixels.Color(0, 0, 0));
    pixels.show();   // Send the updated pixel colors to the hardware.

}
}
    delay(DELAYVAL); // Pause before next pass through loop
}
  • Implementing the circuit using Arduino LilyPad

I have reproduced the circuit using Arduino LilyPad and tested the system.

  • Power Management

When shifting from Arduino to LilyPad board, power management needs to be considered. Arduino board can supply +5V which can operate the LED strip; however, LilyPad can only supply +3.3V. To obtain +5V from LilyPad, I have used a small voltage step up converter.

Since the regulator that I am using can supply an output current of 1A, this was enough to turn on 8-9 neopixels. This is due to the fact that each pixel in the Adafruit neopixel strip requires around 60mA of current to turn on all the colors together (i.e. to give white color).

Refer to the link to invistigate how to power the neopixel strip.

  • Sewing the circuit

Final step will be to embed the circuit as a wearable electronics using conductive thread and conductive nylon tape in felt. I have designed a simple PCB using Eagle software to solder piezo buzzer and LDR in a sewable PCB.

1- Eagle schematics design and board.

2- I have then prepared the tool path for the PCB using FabModules open source software.

3- Then I used Roland MDX-50 to mill the PCB, to drill the holes and to cut the board outline.

4- After milling, I soldered the piezo buzzer, LDR and resistor over the small board.

5- Finally, I have sewed the whole circuit using conductive thread and conductive nylon tape. I have used multimeter to check the continuety after stitching each component.

6- Testing the circuit was the last step before embedding it onto a scarf. Unfortunatly, the LED strip was not responding as desired.

This could be due to the fact that I am using two different conductive materials (nylon tape and conductive thread)or different conductivities and properties.

Project #2: Touch Sensor Using Attiny

  • Programming the Attiny 44:

For this project I wanted to test simple circuit using Attiny 44 IC as a controller. Attiny 44 is a microprocessor Integrated Circuit (IC) or “computer chip” which typically contains the Central Processing Unit (CPU) or “brain” of the laptops, tablets and smartphones we all use. Typically these chips rely on external Random Access Memory (RAM), Read-Only Memory (ROM), and other peripherals that work together as part of a larger computer system. Attiny 44 is categorized as an IC under AVR family of microprocessors/ micro-controllers. The AVR microprocessors are preferred for having quite cheap cost, having an excellent real time performance, they are available in different scales of packages from small to bigger with a nice range of peripherals, and due to the fact that they support great open-source software.

Before starting with Attiny 44, I have opened its datasheet which is quite lengthy! However, I just focused on simple information that I need to serve my purpose. The pinout of the Attiny 44 is one of the most important things to understand.

In order to use Attiny 44 as a controller, it should be programmed. However, as it is an IC it does not have a platform to burn the bootloader to excute the code (Refer to the link and tutorial). Therefore, it needs a programmer board such as Arduino to be programmed and reprogrammed. I refered to this tutorial to understand how to connect the Attiny44 with Arduino board.

Arduino +5V ---> ATtiny Pin 1 (VCC)

Arduino Ground ---> ATtiny Pin 14 (GND)

Arduino Pin 10 ---> ATtiny Pin 4 (RESET)

Arduino Pin 11 ---> ATtiny Pin 7 (MOSI)

Arduino Pin 12 ---> ATtiny Pin 8 (MISO)

Arduino Pin 13 ---> ATtiny Pin 9 (SCK)

Then I followed this document on how to program Attiny 45 and I have applied the same steps to program the Attiny 44 IC using Arduino IDE. It is very important to download the boards for Attiny family first before working with Arduino IDE (Refer to Step 2 in the tutorial for more details).

Burning the bootloader is done only once; however, the connectioncs of the pins should be wired the same everytime the Attiny44 is programmed.

I have done a simple test to construct a circuit with Attiny44 and blinking LED.

After the program is uploaded, the serial connections with Arduino can be removed and the Attiny board can be powered externally from any DC power source (VCC should be between 1.8 and 5.5V). I have tried powering from DC power supply set at +3V and it is working perfectly!!

  • Building the Capacitive Touch Sensor to Control LED:

To make a touch sensor with Arduino, you need to download a special library called CapacitiveSensor.

I referred to the tutorial and the video below to understand how to use a capacitive touch sensor.

Then I constructed my own circuit and tested the folloing code with an Arduino board and it was working.

#include <CapacitiveSensor.h>
CapacitiveSensor Sensor = CapacitiveSensor(4, 6);
long val;
int pos;
int LED = 13;

void setup()
{
//Serial.begin(9600);
pinMode(LED, OUTPUT);
}

void loop()
{

val = Sensor.capacitiveSensor(30);
//Serial.println(val);
if (val >= 1000 && pos == 0)
{
digitalWrite(LED, HIGH);
pos = 1;
delay(500);
}

else if (val >= 1000 && pos == 1)
{
digitalWrite(LED, LOW);
pos = 0;
delay(500);
}

delay(10);
}
  • Do the Same using Attiny 44

I edited the pin for the LED to be pin 0 or lead 13 in the Attiny44 IC using the following circuit connection.

For uploading the code, I connected again pins for SCK, MISO, MOSI and RST with pins 13, 12, 11 and 10 respectively on the Arduino. I have uploaded the code the same way as I did earlier byt it did not work unfortunatly :'(

I am still troubleshooting and trying to understand why the code can not be uploaded to the microcontroller IC.

- Alternative Solution!! Use Attiny 85 Development Board

After failing to use Attiny 44, I decided to use Attiny85 development board as it is avaliable locally. This board looks as follows, it has Attiny85 IC embedded onto it and has a USB connector to enable direct programming without the need to burn bootloader or to couple the Attiny85 with Arduino.

Before using this development board it is very important to download the driver for the shield and to install the Digistump boards in Arduino IDE. I refered to the following video to understand how to program Attiny85 development board using Arduino IDE.

The link to download the board's driver zip file here and the json URL link to install the boards to Arduino IDE is "http://digistump.com/package_digistump_index.json".

I designed the following simple circuit using Fritzing to embed within my hand embroidered design.

Instead of the connection with USB, I have soldered a 2x coin cell battery (CR2032) holder to Vin and GND pins of the Attiny85 development board as shown in the image below for the embedded electronics.

Finished with my hand embroidered Fabricademy Logo.

Getting the electronics ready.

Embedding the electronics using hard-soft connections. Please note that I am using the conductive nylon tape as the capacitive sensor, but any other conductive fabric can be used to do the same job. Check the tutorial by Adafruit Inductries to make wearable capacitive touch sensor.

I have modified the code a bit to suit the new connections.

#include <CapacitiveSensor.h>
CapacitiveSensor Sensor = CapacitiveSensor(1, 2);
long val;
int pos;
int LED = 0;

void setup()
{
//Serial.begin(9600);
pinMode(LED, OUTPUT);
}

void loop()
{

val = Sensor.capacitiveSensor(30);
//Serial.println(val);
if (val >= 1000 && pos == 0)
{
digitalWrite(LED, HIGH);
pos = 1;
delay(500);
}

else if (val >= 1000 && pos == 1)
{
digitalWrite(LED, LOW);
pos = 0;
delay(500);
}

delay(10);
}

Finally its working perfectly :)

Project #3: Textile Speaker

  • Making the Speaker

The speaker is nothing but a coil and a magnet.

Now my 5 Ohm textile speaker is ready for testing!!

  • The Circuit

In order to improve the loudness of the sound and to regulate the delivery of sufficient amount of electric current to the speaker, I have used an audio power amplifier using LM4861. Using the datasheet, I have implemented the design below of the audio amplifier.

I started by testing the circuit on a breadboard.

The music was barely coming out but it was working and vibrating :)

  • PCB Design

I have used Eagle software to design the audio amplifier PCB layout. Unfortunatly, I could not find the OP Amp LM4861 in Eagle; however, I created my own LM4861. I refered to this video to understand how to create a new device (i.e. IC chip) in Eagle. After creating the compnent, I have designed the following Eagle schematics and PCB layout.

I milled the PCB using Roland MDX50 milling machine as mentioned above in project#1.

Testing the speaker with PCB.

Project #4: Steps Tracker (Pedometer)

Refer to Skin Electronics Assignment.

Project #5: Interactive Loomed Fabric

During COVID19 period I have done a workshop on interactive loomed fabric to build interesting projects for sound generation circuits.

The following slides represent the main content of the workshop.

Files

Check the Drive folder to access the files for the electronics design.