ATMEGA32 and Bluetooth Module

Literature review
Hey yeah, here is the literature Review (Theory) of a project we have made using AVR and bluetooth module. Before jump into any project any project you need to know the project so here it is.


Atmega32

Atmega32 is low- power CMOS 8-bit microcontroller based on Atmel's AVR microcontroller family. The device is manufactured using Atmel’s high density nonvolatile memory technology. It is a 40-pin IC having 32 programmable I/O lines .It is based on advanced RISC architecture. It has 32 general puropose working register which are directly connected to Airthmetic logic unit(ALU), allowing two independent registers to be accessed in one single instruction executed in one clock cycle. The resulting architecture is more code efficient while achieving throughputs up to ten times faster than conventional CISC microcontrollers. It has 32kbytes of flash program memory, 1024 Bytes EEPROM memory and 10,000 write/erase cycle  for flash memory and 100,000 write/erase cycle for EEPROM. for system programming on atmega32. There is a On-chip ISP Flash which allows the program memory to be reprogrammed in-system through an SPI serial interface There is 8-bit, 16-bit timer and a special programmable Watchdog timer for exceptional hardware or software failure.It has a JTAG interface for Boundary-scan for the peripherials connected to AVR. It can be operate from 0-16 MHz frequency. It has very less power consumption of 3V at 1MHz, 25*C. It has 3 modes of operation
Active mode , It consumes current of 0.6 mA.
Idle mode, It consumes current of 0.2 mA. . The Idle mode stops the CPU while allowing the USART, Two-wire interface, A/D Converter, SRAM, Timer/Counters, SPI port, and interrupt system to continue functioning.
Power-down mode, It consumes current of less than 1 uAThe Power-down mode saves the register contents but freezes the Oscillator, disabling all other chip functions until the next External Interrupt or Hardware Reset.


http://www.atmel.com/images/atmel-8155-8-bit-microcontroller-avr-atmega32a_datasheet.pdf

Relay 

Relay is simple electrical switch which on the principle of electromagnetic induction. The main operation of a relay comes in places where only a low-power signal can be used to control a circuit needed with high power components. It consist of 4 pins 2 for input and 2 for output. The input pins are connected to electromagnet of relay which energized the relay thus it make connection to the circuit.  
Transformer 

A transformer operates on the principals of “electromagnetic induction”, in the form of  Mutual Induction.Mutual induction is the process by which a coil of wire magnetically induces a voltage into another coil located in close proximity to it.The main use of transformer is to convert the voltage supply and regulate the volatage using other voltage regulator to different component of circuit

Bluetooth module 

Bluetooth is a license-free 2.4 GHz frequency band, usually with an integrated antenna, having data-rates up to 3 Mbps (for Bluetooth v2.0), can pass through walls, has easy setup, and optional data-encryption. Multiple links can be established concurrently with different Bluetooth devices because of automated frequency hopping (Frequency Hopping Spread Spectrum, or FHSS). This is comparable to the creation of a virtual RS485-type bus allowing several devices to communicate at the same time. 
Classes of Bluetooth 
Bluetooth comes in three classes. Transmitting range cannot be explicitly stated for each device class; every environment is slightly different, and affects the signal in different ways. The best way to compare a devices' operating range is by comparing Output Power. A higher output power means a longer range.
Class 1 - Long Range
Maximum Output Power of 100mW (20dBm) up to 100 meter range

Class 2 - Medium Range (the most common)
Maximum Output Power of 2.5mW (4dBm) up to 10 meter range

Class 3 - Short Range (very rare)
Maximum Output Power of 1mW (0dBm) up to ~1 meter range

Devices equipped with Bluetooth technology support wireless point-to-point connections, as well as wireless access to LAN, mobile phone network, the Ethernet and home networking. The connectivity between two Bluetooth equipped devices is carried out as serial communication. Bluetooth technology delivers the received data and receives the data to be transmitted to and from a host system through a host controller interface (HCI). The most popular host controller interface today is either a UART or a USB link.

Now, even though we can use USB or UART, the most commonly used HCI is UART because of following reasons:

◦If UART is used software overhead is very less
◦Its highly cost effective.

UART for interfacing Bluetooth
A Universal Asynchronous Receiver and Transmitter (UART) is used for communication with serial input and serial output devices. Serial transmission reduces the cost and complexity of the wirings at the expense of speed, and for many applications this is a desired trade-off. The UART takes bytes of data and transmits the individual bits in a sequential fashion. At the destination, a second UART re-assembles the bits into complete bytes. Synchronization for the serial data stream is accomplished by adding start and stop bits to the transmit data to form a data character. Data integrity is insured by attaching a parity bit to the data character. The parity bit is checked by the receiver for any transmission bit errors.
To a host system, the UART appears as an 8-bit input and output port that it can read from and write to. Whenever the host has data to be sent, it just sends these data to the UART in byte format (8-bit wide), whenever the UART receives data from another serial device it will buffer these data in its FIFO (again 8-bit wide), then it will indicate the availability of these data to the host through an internal register bit, or through a hardware interrupt signal.

Above is the block diagram of SC16C650B UART. Functions of UART are explained below using these blocks in brief manner.
Register Select is used to decode the address of register which the host wants to access. Data Bus and Control Logic is how the host transmits and receive data to/from UART. There are several registers in UART. Some of them are TransmitHoldRegister (THR), Receive Hold Register (RHR) – both as name suggests is used to hold Transmitting and Receiving data. Then there is Interrupt Enable register used to enable/disable different kinds of Interrupts supported by UART. There are other registers used to control FIFO, Modem, Data format, etc. The Shift Registers are used to break the byte information for sequential transfer OR assemble the bits using FIFO to form Byte data.
The host controller sends the data using D[7-0] channel and address using A[0-2] channel. The UART chip receives these data and using shift registers and FIFO , it converts into serial data. These serial bits will be then sent to Bluetooth Controller (Rx,Tx,CTS,RTS) and then transmitted via RF channel.

http://ajkamath.blogspot.com/2010/12/how-uart-works-and-its-interface-with.html

EEPROM 
Most of the AVRs in Atmel's product line contain at least some internal EEPROM memory. EEPROM, short for Electronically Erasable Read-Only memory, is a form of non-volatile memory with a reasonably long lifespan. Because it is non-volatile, it will retain its information during periods of no AVR power and thus is a great place for storing sparingly changing data such as device parameters.
The AVR internal EEPROM memory has a limited lifespan of 100,000 writes - reads are unlimited. They are available up to 128KB in size. Atmega's internal EEPROM is accessed  via special registers inside the AVR, which control the address to be written to (EEPROM  uses byte addressing), the data to be written (or the data which has been read) as well as the flags to instruct the EEPROM controller to perform a write or a read.





http://www.avrfreaks.net/forum/tut-c-using-eeprom-memory-avr-gcc?page=all

dimmER CIRCUIT
Switching an AC load with an AVR has done by using either a mechanical relay or a solid state relay with an optically isolated Triac. If we wants to dim a mains AC lamp by just limiting the current through the bulb e.g. a transistor is not really possible to draw such current due to the large power, the transistor then will need to dissipate, resulting in much heat and it is also not efficient from an energy use point of view. So, such method will not be adopted and the following method can be used for dimming the AC bulb.


Phase cutting
when it is connected to power supply then the Triac is fully opened, but only during a part of the Sine AC wave. This is called leading edge cutting.
We could let an AVR just open the Triac for a number of microseconds, but that has the problem that it is unpredictable during what part of the sinus wave the triac opens and therefore the dimming level is unpredictable. One needs a reference point in the sinus wave.
For that a zero crossing detector is necessary. This is a circuit that tells the AVR (or another micro controller) when the sinus-wave goes through zero and therefore gives a defined point on that sinus wave.
Opening the Triac after a number of microseconds delay starting from the zero crossing therefore gives a predictable level of dimming.
Note: Zero Crossing detector in alternating current, the zero-crossing is the instantaneous point at which there is no voltage present. In a sine wave or other simple wave form, this normally occurs twice during each cycle. The zero-crossing is important for systems which send digital data over AC circuits, such as modems, X10 home automation control systems, and Digital Command Control type systems for Lionel and other AC model trains.



Circuit of Zero crossing 

zero-crossing detector using an 8 pin DIP unit 311 IC is shown in the figure below. The output of the 311 op-amp IC is connected to an open collector NPN transistor. A 20 kilo ohm load resistor is connected to the output of the transistor. For a positive input signal, that is, for an input sine wave above 0 volt, the output of the op-amp sets the transistor OFF, and the output of the transistor goes HIGH. The low condition resembles a -10 volt in the circuit and a HIGH condition resembles -10 volt in the circuit.
The output of the transistor indicates whether the input is more than or less than 0 volt. In short, if the input signal is a positive voltage, the output of the transistor will be LOW. If the input signal is a negative voltage, the output of the transistor will be HIGH.





Methodology












Time and cost 
Time

S.N. Name of the Material Quantity Price 
1 AVR 1 350
2 PCB circuit board 1 200
3 ULN 2003 2 60
4 5V 8 channel Relay 1 900
5 Triac driven opt coupler 2 80
6 Triac Bt138 500V 4 A 2 60
7. AC bulb 2 200
8. Bluetooth Module 1 1500
9. Miscellaneous 1000
4350

Reference  for team member 
http://www.slideshare.net/AbhishekNeb/thesis-voice-control-home-automation
http://brigada-diverse-4u.blogspot.com/2013/02/varying-bulb-luminosity-using-atmega16.html 
http://www.ermicro.com/blog/?p=744
http://www.embedds.com/programming-avr-i2c-interface/
http://ajkamath.blogspot.com/2010/12/how-uart-works-and-its-interface-with.html
http://maxembedded.com/2013/09/the-usart-of-the-avr/

Comments

Popular Posts