Renjith M S

Week 13:Input Devices

Assignment:

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

This week I decided to make ATMEGA 328 board.

ATMEGA 328

Some of the Features of ATMEGA 328 are

  • 1.8-5.5V operating range
  • Up to 20MHz
  • 32kB Flash program memory
  • 1kB EEPROM
  • 2kB Internal SRAM
  • Two 8-bit Timer/Counters
  • One 16-bit Timer/Counter
  • RTC with separate oscillator
  • 6 PWM Channels
  • 8 Channel 10-bit ADC
  • Serial USART
  • Master/Slave SPI interface
  • 2-wire (I2C) interface
  • Watchdog timer
  • Analog comparator
  • Data retention: 20 years at 85C/ 100 years at 25C
  • 23 IO lines

PCB DESIGNING

I designed ATMEGA 328 board in EAGLE. The design files are available here

The schematic diagram of the circuit is given below

Image

In the fab library in EAGLE there is no ATMEGA 328 IC . So I used ATMEGA 88 having same pin configuration as that of ATMEGA 328

Image

This is for the first time I manually routed my board . The traces of the board near the ATMEGA 328 pin are made 14 mil instead of 16 mil in order to optimize the clearance. But this procedure made my pcb soldering very very difficult. But I was having no other option.

The mill trace and cut trace are given here

Image

After milling only I could realize the problems in my board routing . The main problem is the ground and vcc lines are very much close. Next time I have to be more careful.

Image
Image

I edited the cut trace in gimp.

PCB MILLING

Roland MDX 20 Milling Machine is used for milling . The screen shots are given below

Image

I used 0.4 mm bit for milling. So I selected 1/64 trace.

Image

I used 0.8 mm bit for cutting. For that I selected 1/32 cut trace

Image

The final milled pcb is obtained,but holes were not made by machine because the diameter of the holes which I designed were less than 0.8mm ie 1/32 mil.

Image

The Soldering process was difficult because the traces were minute,next time I decided to go for a better design.

Breakout board for PIR sensor

In order to connect an LED and PIR sensor I have designed a breakout board which has red led and 499 ohm resistor

my photo
my photo

The schematic and board screenshots are provided above.It can be seen that there is a provision for led,resistor,pin header thats all.This circuit makes the job simpler.

my photo
my photo

The mill trace and cut trace of the breakout board is given above. The Design files for Breakout board for PIR sensor are available here

my photo
my photo

Finally it has been milled in modella machine ,the screenshots for milling process and cutting process is given above.

my photo
my photo

milling and soldering process for the breakout board is finished.

Programming

Blinking RGB LED

In order to ensure that my board is working properly I just wrote a program to blink an LED(I used RGB LED).

Image

open the terminal window from the folder containing the blink file and the make file .Run the command
$ make
$ make program-usbtiny
The make file is given in the figure below

Image

The output obtained is given below.

Interfacing PIR sensor with ATMEGA328

I have written a program which will detect the presence of motion and turn on the RGB led.

PIR SENSOR working

There are multiple variables that affecting the Pyro Motion Detector input and output.The PIR sensor itself has two slots in it, each slot is made of a special material that is sensitive to IR. The lens used here is not really doing much and so we see that the two slots can 'see' out past some distance (basically the sensitivity of the sensor). When the sensor is idle, both slots detect the same amount of IR, the ambient amount radiated from the room or walls or outdoors. When a warm body like a human or animal passes by, it first intercepts one half of the PIR sensor, which causes a positive differential change between the two halves. When the warm body leaves the sensing area, the reverse happens, whereby the sensor generates a negative differential change. These change pulses are what is detected.

Image

PIR sensor detect only bodies (hot materials and living objects) in motions not the static ones. This sensor uses Infra red beam to detect the motion and only covers a certain space based on the sensor model, This sensor module gives only two output states that is logic High 1 which is equivalent to 3.3 V and logic low 0 equivalent to 0 V.So connect the output of the PIR sensor to a digital input pin,and connect GND and VCC to the microcontrollers GND and VCC respectively.For more details visit the page here

Programming

The programming concept I used is simple ,digital pin PC0 is connected to the output of PIR sensor and PD3 is connected to the RGB led .When a motion is detected PCO pin will be high,which in turn will turn on the LED.

Image

The program and the make file used are

Image

The connections are made using the breakout board and the hero shot is provided in the figure below.

Image

Finally when the motion is detected the LED is turned on and if no motion it will be off.

Top