Input Devices

This week is about input devices.On wednesday Neil took lecture on input devices ,in lecture he told about various sensors which act as input devices.What are the functions of input sensor ,how it sense the data.These all things covered by Neil.On next day our instructor Suhas Sir and Arundhati Ma'am gave brief about assignment .They told about various sensors ,how to make board and how to test it.

Please refer group assignment here:

Group Assignment:Probe an input device's analog levels and digital signals .

Individual Assignment: Measure something: add a sensor to a microcontroller board that you have to designed and read it.

Individual Assignment:

In individual assignment we have to make new microcontroller board which contain input devices.I decided to work on my final project.I required ultrasonic sensor as input device to measure water level.So I started designing of new board .I want to test my input sensor ,so I thought I will use attiny45 IC.

Input Devices:

An input device is a peripheral used to provide data and control signals to a computer. Input devices allow us to enter raw data for processing.Sensors are input devices that record data about the physical environment around it. Sensors send data to a microcontroller.They do not make judgements, decisions or control any output devices.

As my project is automated water management system,to sense the water level I required some input sensor .I decided to use ultrasonic sensor to sense the water level.It has four pins VCC,GND,ECHO,TRIGGER.It transmit and receive the data.

Ultrasonic Sensor:

The ultrasonic sensor (or transducer) works on the same principles as a radar system.An ultrasonic sensor can convert electrical energy into acoustic waves and vice versa.The acoustic wave signal is an ultrasonic wave travelling at a frequency above 18kHz. The famous HC SR04 ultrasonic sensor generates ultrasonic waves at 40kHz frequency.Typically, a microcontroller is used for communication with an ultrasonic sensor.To begin measuring the distance, the microcontroller sends a trigger signal to the ultrasonic sensor.The duty cycle of this trigger signal is 10µS for the HC-SR04 ultrasonic sensor.When triggered, the ultrasonic sensor generates eight acoustic (ultrasonic) wave bursts and initiates a time counter.As soon as the reflected (echo) signal is received, the timer stops. The output of the ultrasonic sensor is a high pulse with the same duration as the time difference between transmitted ultrasonic bursts and the received echo signal.

Ultrasonic Sensor

How ultrasonic sensor works:

The ultrasonic sensor (or transducer) works on the same principles as a radar system. An ultrasonic sensor can convert electrical energy into acoustic waves and vice versa. The acoustic wave signal is an ultrasonic wave traveling at a frequency above 18kHz. The famous HC SR04 ultrasonic sensor generates ultrasonic waves at 40kHz frequency.

Typically, a microcontroller is used for communication with an ultrasonic sensor. To begin measuring the distance, the microcontroller sends a trigger signal to the ultrasonic sensor. The duty cycle of this trigger signal is 10µS for the HC-SR04 ultrasonic sensor. When triggered, the ultrasonic sensor generates eight acoustic (ultrasonic) wave bursts and initiates a time counter. As soon as the reflected (echo) signal is received, the timer stops. The output of the ultrasonic sensor is a high pulse with the same duration as the time difference between transmitted ultrasonic bursts and the received echo signal.

Theoretically, the distance can be calculated using the TRD (time/rate/distance) measurement formula. Since the calculated distance is the distance traveled from the ultrasonic transducer to the object—and back to the transducer—it is a two-way trip. By dividing this distance by 2, you can determine the actual distance from the transducer to the object. Ultrasonic waves travel at the speed of sound (343 m/s at 20°C). The distance between the object and the sensor is half of the distance traveled by the sound wave.

The following equation calculates the distance to an object placed in front of an ultrasonic sensor:

I started working on PCB designing.I used Eagle to design my board.I used ATTINY45 IC for my board.Because I required only 4 pins for my sensor.So attiny45 is feasible for me so I used.I used PB3 and PB4 pin for ECHO and Trigger of sensor.

Pinout

As I started working on pcb schematic ,I required 4 pin header for sensor.Fab library dont have 4 pin header.I searched for other library .I found Sparkfun library for eagle.I downloaded zip folder and unzipped that folder and added connector library to eagle library.

Schematic

After schematic I checked ERC errors and make it zero.Then I shifted to pcb board.I placed components neatly and started manual routing.Routed whole board and checked DRC errors.During routing you have to keep in mind that add clearance and take trace width as 16 mil.

Routing

After routing save the files.You have to save two files.One is trace file and other is cut file.Export file as image and save it as monochrome image.Set resolution as 1000dpi.SRM-20 Required .rml file.To make .rml file png image is required.Rml file is made using MODS.




After this I used SRM-20 machine to mill my board.I followed all instructions which I learned in electronic design week.After milling I got pcb board like

Milled board

Now its time to solder all components.I took all components from Fab inventory.First I applied flux on my board.Then one by one I soldered all components.Components required are attiny45,resistor,capacitor,pin header.

Soldered board

Programming:

After soldering I started working on programming.I used PB3 and PB4 pin as input pin .I interfaced my board with Fabisp.Because I am using ISP as programmer to program my board.When I completed code I compiled it but it showing error as Serial was not declared in this scope.I searched on google and then I got to know something is missing in my code.

Error

I got to know that I havent defined RX and TX pin in code.Other important thing is arduino contain software serial library but Attiny45 dont have that library thats why I need to add that library first.I added library and defined RX and TX pin .Now my code is ready to compile.

Solution

Other important thing is I want to see reading on serial monitor ,for that FTDI cable is required .I connected FTDI cable to my board but its now working .I thought there are some problem in connection .I checked all connection its proper.Problem is in cable,cable is not working.So I thinking about second option .I searched on google how arduino used as FTDI.I connected arduino TX,RX,VCC,GND pin to my board.I compiled code and uploaded to my board.This take to much time to debug the error.It took two days for me to remove all errors.Finally I got output.When you got output after too much efforts it feels very happy.It requires lots off patience.

Also I tried different sensors on Tinkercad software.This software is new for me.I learned this and I started design of circuit.I tried LDR sensor,Temperature sensor ,switch.Also seen output on serial monitor and using serial plotter I have seen waveforms.

Learning Outcome:

From this week I learned how sensor works.I tested my project input sensor.Also I learned how to do serial communication.In this week I debugged all errors.From that errors I learned lots of things.Also I learned how communication happens.

Creative Commons License
Fab Lab by Snehal Gawali is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.