Fab Academy 2018
Fab Lab Khairpur operated by Sukkur IBA University
Input Devices
Tasks of the week
Group Assignment
Individual Assignment.
Group Task
In group assignment of this week, we have to measure analog levels and digital signals in an input device.
Measuring Analog Levels of Phototransistor
SFH 320 Silicon NPN Phototransistor is used by one of our group member in individual task in which the circuit is detecting light and displays result of light intensity on bar using python. So as the group assignment we measured the resistance of this component which is changed when we increase or decrease the intensity of lights on it. The resistance is measured by Digital Multimeter. We observe that at one instance when we increase the intensity of light resistance decreases and when we decrease intensity of light resistance increases.
Detecting Digital Signals in UltraSonic Sensor
HC SR-04 Ultrasonic sensor is used by one of our group member in his individual task of this week. We detect the change in digital signal in Oscilloscope using arduino UNO. A sensor is connected with arduino and the pin of Echo is connected with Oscilloscope. Arduino is program to detect obstacle in front of Ultrasonic sensor (a code is attached with files), when an obstacle is present in front of Ultrasonic sensor we found change in wave in oscilloscope.
Individual Task
For Input devices, I choose to use ultrasonic sensor. Ultrasonic sensor is a device which is used to measure distance to an object.
This works by sending out a wave which comes back by striking an object, it measure the time elapsed from generating of the wave to bounce back.
This way it measures distance from the origin position of the sensor to the object. It follows the given below formula to calculate the distance.
Distance = [{(Speed of sound)*(Time taken)}/2]
For more about ultrasonic sensor, refer this site.
I sketched its pin diagram on a page shown below, I connected basic necessary components to the IC, like:
- pin 01 VCC
- pin 02 XTAL1 connected to one side of 20MHz resonator.
- pin 03 XTAL2 connected to other side of 20MHz resonator, and center pin of resonator connected to ground.
- pin 04 10K pull up resistor, and, to RST.Other terminal of the resistor connected to VCC
- pin 05 LED I connected an LED to this pin, cathode of the LED connected with a current limiting resistor of 499 Ohm .
- pin 06 Not Connected (NC).
- pin 07 MOSI/SDA connected to ISP header as MOSI, and also connected to pin no.5 of FTDI header as a SDA .
- pin 08 MOSI connected to ISP header as MISO.
- pin 09 SCK/SCL connected to ISP header as SCK, and also connected to pin no.4 of FTDI header as a SCL.
- pin 10 TRIG Connected to trig pin of Ultrasonic sensor.
- pin 11 ECHO Connected to echo pin of Ultrasonic.
- pin 12 connected to 2 pin header for future useI connected this wire to simply on a header, may be we use it for any other purpose.
- pin 13 connected to 2 pin header for future useI connected this wire to simply on a header, may be we use it for any other purpose.
- pin 14 Ground
At reset pin (pin no.4 of attiny44), we have to use a pull up resistor of 10K to 20K ohm as mentioned in the datasheet of attiny44. I used 10K ohm value resistor for this purpose. Below snapshot is for further clarification about pull up resistor.
Then, I designed it on 'eagle', added and connected required components on 'schematic' part, and, in 'board' part I shape it to its final look.
Generating .rml files from Fab Modules.
After complete soldering of the components to the board, the next step is to up the circuit by burning bootloader through an ISP programmer. So, here I did it successfully.
Here is the code, which uploaded and then sensor gives value in serial monitor as I changed the object distance from the sensor. The unit of distance is in centimeters here in this case.
#include "SoftwareSerial.h"
// defines pins numbers
SoftwareSerial mySerial(4, 6); /* RX:D3, TX:D2 */
const int trigPin = 2;
const int echoPin = 3;
// defines variables
long duration;
int distance;
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
mySerial.begin(9600); // Starts the serial communication
}
void loop() {
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(100);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(200);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance= duration*0.039/2; // Here the displayed distance is in centimeters cm
// Prints the distance on the Serial Monitor
mySerial.print("Distance: ");
mySerial.println(distance);
}
Download all files from here
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.