Probe an input device's analog levels and digital signals.
Individual Assignment
Measure something: add a sensor to a microcontroller board that you have designed and read it.
This week is for the input devices. For input devices we uses various type of sensor which read the atmospheric condition and give
the signal to the microcontroller. This signal is in the form of of analog signal or digital. Microcontroller read both the signal.
So for this week we have to designed a new board which is used for reading the data or signal from input devices.
What is of sensors ?
Sensors are the device which sense the respective quantity (for eample temperarture sensor measure the temperature) and convert this quantity into a electrical signal.
This electrical signal may be in the form of digital or analog signal. This signal is read by microcontroller and then it give a value respective to that measure quantity.
How sensor works ?
Every sensor have three parts in it-
1. Sensing section- This is the section where the sensor is there. This sensor are chosed to sense the magnitude of respective things which we want to measure.
2. Electronic circuit - Its second section are convert this measured values into electrical form. Means it convert the respective data into mV.
3.Output to microcontroller- The last part is transmite this measured data to the microcontroller in the form of digital or analog signal.
Analog to Digital Conversion
Mostly microcontroller support only digital signal. But our sensor output are in analog signal. So we have to convert this analog signal into digital signal.
We used a Analog to digital convertor in microcontroller board by which microcontroller read the digital signal. At present most of the sensor have this convertor
on their output signal board by which we obtained both type of Analog and Digital signal.
Type of Sensors
Sensors are define in variou types according to their performance. Some of types are given below-
1.Active and passive sensors
Active sensor
Active sensor are does not required any power or signal to operate. They also called generators. For example if we talk about thermocouple, it have only two wires
does not have a power supply wire or connection. When the temperature become high or low, the voltage across these two wire changes. the voltage in the form of mV and
it transmiited in the form of anolog signal to microcontroller.
Passive sensor
Passive sensor are required external power supply or extrenal signal to perform the operation. For example if we talk about the Potentiometer
and load cell, they both come in category of passive device. They produced voltage and we read this voltage by microcontroller
2.Analog and Digital sensors
Analog sensor
The sensor which give output in the form of analog (which varries) are called analog sensor. The value of this analog sensor continously
changes with respect to measuring quantity like temoerature , humidity etc.
Digital sensor
The sensor which give the output in the form zero or one are called digital sensor.The value of this sensors are fixed ther give output of
either one or zero. example digital temperarure sensor.
3.Scaler and Vector sensor
Scaler sensor
The sensor which sense the quantity not direction are called scaler sensor. For example Temperature and gases measurement. We dont need any direction
for measure this.
Vector Sensor
The sensor which magnitude depends on the direction called Vector sensor. For Example Triple axis accelerometer which measure the magnitude
of the direction.
Attiny 1614
This time I selected Attiny 1614 for PCB Board. This is the 14 pin ic which is new series of Attiny Family. This IC is come with 8 bit AVR processor.
This processor running at 20MHz. It have 16KB of flash memory, 2KB of SRAM memory and 128B EEPROM.
It require Minimum voltage of 1.4 V and maximum voltage of 5.5V for the operations. It work in the temperature range between -40 C to 105 C.
This Microcontroller have 14 Pins-
Board Design
For this week we have to design a new board for the input devices. Firstly I make the planing for which sensor I have to test with my microcontroller. According to it
I designe my PCB. So I designed the PCB according to the sensor pins. I decided to test ultrasonic sensor, LDR sensor, PIR motion detector and Step response sensor
Now according to My sensor pin requirements I select the pin header.
I select Three Pin header for the UPDI,VCC and GND and connect the UPDI pin to IC's Updi. Then I select 2 pin header of 4 pins. The one is used for the led display
and another is used for the ultrasonic sensor. So I used SDA, SCL and Rx and Tx pin and then provide supply of GND and VCC to the both pin header.
I also chosed another 3 pin header and connect its one pin to the 8 no. analog pin of Ic and provided supply of VCC and GND. I also used a LED by which I can understand about
my board working or not. After that I change the schematic into board and arrange all the component in the proper manner.
After arranging I Export the png files of that board.
Then I generate the gcode for the my pcb board by usind MODs CE platform.
For the milling of traces-
For the Border Cutting Process
After that I open the v panel and and start milling my board. there is the image of My design board .
Soldering Process
Component used-
1. Attiny 1614
2. 1206 package 1K resistor and a LED
3. 4 Pin header *2
4. 3 Pin header *2
After soldeing all this component the on the board. then it is completed
Programming
The most difficult part for me this week is to programme attiny 1614. We used its UPID pin for programming. So we need To a programmer which communicate between
USB serial monitor and UPDI. So I mill the board which is provided in embeded programming week. This board have a FT230x Ic .
We modify this board by adding an extra pin for the VCC.
First time board was not run but after several trial We will able to prograame our board. We found that the board having gap between usb ports pins thats why it
not connect with the laptop. So I stick a paper tape behind the board. After this its port visible.
Now we have to add library of Attiny in the arduino ide. To add library follow the steps-
Go to file >> Preference >> and past the given link in url section.
Link to paste- "http://drazzy.com/package_drazzy.com_index.json"
After that go to board manager and search "MegaTinycore" And install it. After that go to the tool option and select the mega tiny core and then select the attiny 1614 IC
After that select chip as Attiny1614. Now go to the programmer and select "SerialUPDI Slow:57600 Baud".
NOTE- I also facing issue with arduino ide newer version. so I download the older version of Arduino Ide and it work.
Ultrasonic Sensor
Ultrasonic sensor are used to measure the distance. It have two parts in module in which one part transmit the signal and another recieve the signal.
It emits the frequency of 40KHz then this frequncy travel with the speed of sound and strike on the object and then return back to the reciver at module.
It have four pin ECHO, TRIG, VCC, GND. When we send the signal, the firstly trig pin high for some time then it become low and send the signal. When the module send the signal
the echo pin become high and when we get the reflected signal the echo pine become low. Now we have to calculate the time for the ehigh value of echo pin. It can be
easily undersatand by the following diagram
Now we have to define how the sensor measure the distance. We know that the speed of sound is 340m/sec. we convert this speed in cm per microsecond and become 0.034cm/us.
we know that Speed = distnace / time and the Time = Distance/Speed.
speed= speed of sound
Then Time= Distance/speed of sound
Distance= Time *speed of sound
now at this time it give the distace of total signal travel. We have to measure only the distance between the module and striking object. so we divided the Speed by 2.
Distance = Time* Speed of sound/2 is the formula used to measure the distance.The same formula we used in arduino code.
Now we connect the ultasonic to my PCB board.
I Short the Trig and echo pin and connect this pin to board pin (PB2) digital pin5. Then I go to example and take the ultrasonic ping code
Then I modified the code by adding the code for oled and then after selecting port of UPDI Programmer and upload it.
and connect oled display to the board to see the result.