Home | Weekly assignments | Final project

week10:Input devices


*assignment

-individual assignment:

measure something: add a sensor to a microcontroller board that you have designed and read it

-group assignment:

measure the analog levels and digital signals in an input device

1.Learning what input device is and how it works(procedure)

From the start, I didn't know what input devices are and how they work.
So I had to learn and understand.
I'll explain what I learned about this week until I understand before showing my assignment.

Input devices

As far as I understand, I can define 'Input' as to accept the value which is from outside the MCU.
Because computer can understand only 0,1. They process all the values with those 2(0,1).
So We need Input devices.
There are so many types of Input devices.
(Among them, I chose to make 'Step response'.)

ADC(Analog to Digital Converter)

I think this is the main conception in this week.
I'll compare ADC and not ADC(I don't know exact word and conception...! anyway keep going.)
Let's see
echo hello-world board(week6_electronic_design). We added 'button' and 'led' to Echo hello-world board.
Here, 'button' is the thing can control (0,1).
They have only 2 values. So computer doesn't have problem.
This is not ADC.
There is no Analog signal.

touchpad
But compared to it, like Touchpad that was the example of Neil.
(And you can see touchpad on your laptop.)
Our touch is the input value and analog signal.(Actually our touch means our inner resistance. I'll explain later.)
But it's not just 0 or 1.
It contains so many values which are unstable.
So this Analog is needed to be converted to Digital, so that computer can read it.
That's why we need ADC.

2.Step response(capacitance)

I chose to make 'Step response'.
But actually I didn't get it exactly so I decied to just follow Neil's board from the first.
There are two types of Step response boards.
One is 'loading' and the other is 'transmit-receive'.
At the first time, seeing Neil's videos, I saw the difference that 'loading' needs just one input but 'transmit-receive' needs two(both sides).
I understood 'transmit-receive' but I didn't understand 'loading' yet.
So I wanted to try 'loading'.

Learning how it works

Actually I just milled and got it.
But honestly until this week I didn't get it perfectly(about the components and the conceptions).
So this time I decided to study more!

Analyzing three boards I've made until this week.

ISPloadtouchpad
Brian's ISP board, Hello-load board, Hello txrx board in order.
I analyzed all the components.(what they are, personality) in these three boards.

*important conceptions

-SPI: Serial Peripheral interface (used in Atmel for inputting and reading program or data)
-MOSI: Master Output, Slave Input (output from master) --> to give output
-MISO: Master Inout, Slave Output (output from slave) -->to accept input
-SCK: Serial Clock(Clock means special signal to get programs activate)
-ADC: Analog to digital converter (translating analog to digital)
-AVCC: The Analog Supply Voltage pin for Port F and the A/D converter.
-AREF: Voltage Reference that the chip will use to know the range of voltage.(Pin which is the standard for analog VCC)
-PDIP/SOIC : PDIP(Dual in-line package, through hole package), SOIC(Small-outLine integrated circuit)
-EEPROM (128/256/512 Bytes of In-System Programmable EEPROM) : Electrically Erasable Programmable Read-Only Memory, Non-volatile memory.
used in computers and other electronic devices to store small amounts of data that must be saved when power is removed
-Tx:Trasmit
-Rx:Receive


Symbols

symbols
These are the symbols in electrical network.
I barely know of these things though I learned of it when I was in high school.



1.Trying with arduino board

youtube
First I learned from youtube.
Because I don't know what to do.
So I searched 'capacitive sensor' on youtube.
This lecture was really helpful for me to understand.
As Neil said, our body becomes one resistor.
So the resistence difference is the point in this week.


capacitive
I followed 'Capsense' on arduino libraries website.
And everything Ok.

Code

capacitive
Here is my code with capacitive arduino.

#include

CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2); //

void setup()
{
cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example
Serial.begin(9600);
}

void loop()
{
long start = millis();
long total1 = cs_4_2.capacitiveSensor(30);


Serial.print(millis() - start); // check on performance in milliseconds
Serial.print("\t"); // tab character for debug windown spacing

Serial.println(total1); // print sensor output 1


delay(100); // arbitrary delay to limit data to serial port
}

Result


Here is the video.

2.CapacitiveSensor with my board

schematicboard
Schematic and Board on Eagle.

Assemble

components
Components
assemble
I got milling and soldering.
Now it's not that difficult.
assemble
And I made touchpad.
Cooper and 1ohm resistor and 2 connected pin.
assemble
1 pin should be connected to 1ohm resistor like this with soldering.
assembleassemble
Touchpad and board joined like this.
(PB4 and PB3 used for input)
my board
I tried same step including same code with my board.
But I met 2 failures.

1)Comfort error

comfort error
The error message is "avrdude ser_open() can't open device . com3"
I searched and solved this problem.

How to solve

comfort solve
It's very easy and basic.
I just forgot.

2)Serial error

serial error
The error message is "Serial was not decalred in this scope."

This was quite tough part for me.
I didn't know how to solve it.
And that time I remembered Seunghee's 11week also tried capacitive sensor(even though her trying 'transmit-receive').
So I referred to her code.
From that I could find the key.

How to solve

serial solve
The point is the 'code'.
I used the same code as arduino.
What I changed
1.Including SoftwareSerial library.
2.Including SendonlySoftwareSerial.
3.Changing from 'SoftwareSerial Serial' to 'SoftwareSerial mySerial'.
4.Changing all 'Serial' to 'mySerial'

Code

#include #include #include CapacitiveSensor cs_4_2 = CapacitiveSensor(A3,A2);
SoftwareSerial mySerial(3,2);

void setup()
{
cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF);
mySerial.begin(9600);
}

void loop()
{
long start = millis();
long total1 = cs_4_2.capacitiveSensor(30);

mySerial.print("millis() - start"); // check on performance in milliseconds
mySerial.print(""); // tab character for debug windown spacing

mySerial.println(total1); // print sensor output 1

delay(1000); // arbitrary delay to limit data to serial port
}


Result


Finally I succeeded!!

Downloads

Code
capacitive arduino ino file
capacitive board ino file
softwareserial library link
sendonly softwareserial library link
Schematic and board
Schematic file
Board file

Home | Weekly assignments | Final project