February 27, 2012

Reading Accelerometer Data with Microcontroller

Reading Accelerometer with microcontroller can bring your project to life after reading this post you will be able to interface your accelerometer easily with microcontrollers.


After reading a bit about accelerometer  and accelerometer pins you are good to go with accelerometer interfacing with your microcontroller I have interfaced accelerometer with my Atmega 8535 microcontroller (it is easy to use because its having built in ADC).
According to me the easiest way to know any sensor is transmit its data to hyper terminal via COM port and then analyze data in real-time. So as soon as I got accelerometer I wrote a piece of code to transmit the data serially and started analyzing them on my PC.

Here is the code which I wrote in AVR-BASCOM
-----------------------------------------------------------------------------------------------------
$regfile = "m8535.dat"                                      ' specify the used micro
$crystal = 16000000                                         ' used crystal frequency
$baud = 9600                                                ' use baud rate

Dim X As Integer , Y As Integer , Z As Integer
Dim Channel As Word

Config Adc = Single, Prescaler = Auto

Ddra.0 = 1
Porta.0 = 1                                                 'pin 1 in output mode high(vcc)
Ddra.1 = 1                                                  'pin 2 in op mode low(gnd)
Porta.1 = 0
Ddra.2 = 0
Porta.2 = 1                                                 'x axis adc ip mode
Ddra.3 = 0
Porta.3 = 1                                                 'y axis adc ip mode
Ddra.4 = 0
Porta.4 = 1                                                 'z axis in ip mode
Ddra.5 = 1
Porta.5 = 0                                                 'g select pin op high
Ddra.6 = 1                                                  'self test pin op low
Porta.6 = 0

Do
X = Getadc(3)                                  'read x axis
Y = Getadc(4)                                   'read y axis
Z = Getadc(5)                                   'read z axis
Waitms 100
Print " X " ; Getadc(3) ; " Y " ; Getadc(4) ; " Z " ; Getadc(5) ;  'display on COM port
Print
Loop
End
---------------------------------------------------------------------------------------
 And finally what i got is this 
accelerometer interfacing with microcontroller
Accelerometer interfacing with microcontroller
and then you are ready to see instant data on your hyper terminal.
So you can analyze your movement or just create a look-up table for further references. 

or manually decide what values you want to use for application.
 

                  Guys keep waiting for further posts  what are about how to utilize this accelerometer data to control any game like NFS Most wanted or Counter strike with just a tilt of hand or to make your own WII like gaming console.






Read more ...

February 14, 2012

Interfacing Accelerometer

         Using accelerometer for any application may make the things easy and life simple for end user. Interfacing accelerometer with microcontroller is not a difficult thing.
         Starting with the pins of accelerometer

                        1) Vcc : to power up accelerometer

                        2) Gnd : ground

                        3) X : analog value of voltage representing tilt in X direction

                        4) Y : analog value of voltage representing tilt in Y direction

                        5) Z : analog value of voltage representing tilt in Z direction

                        6) sleep (optional) : for sleep mode of accelerometer

                        7) 3V3: output from accelerometer module for ARef value

                        8)0g (free fall) : this pin can be used to detect free fall user can connect this pin to an interrupt  pin so when the sensor  experiences free fall microcontroller can be acknowledged.

                        9) GSel: this is optional pin for selecting 1.5G or 6G.
                                               
                   
                        10) Self test : name is self  explanatory
                       
Read more ...

AVR Software UART (Proteus simulation)

What is software UART?

             Software UART is the method of creating serial asynchronous transmission and reception  pins on almost every pins of your avr microcontroller.

Why Software UART?

              Whenever you are in need of more UART pins than given on your microcontroller chip you can use software UART. You can configure every I/O pin as serial transmission and reception pin.

Demo of software UART:

          Here in this demo I have created one software UART on each i.e. on PORTA.1 , PORTB.1 , PORTC.1, and one hardware UART on PORTD.1


         
            when you run the demo code given below all three software uart and one hardware uart will start working as shown below.








I have used BASCOM for AVR to program my avr-8535 microcontroller.

Here is source code for AVR 8535 and simulation files of Proteus ISIS.
Read more ...

February 10, 2012

Accelerometer

What is an accelerometer?

                    An accelerometer is an electromechanical device that will measure acceleration forces. These forces may be static, like the constant force of gravity pulling at your feet, or they could be dynamic - caused by moving or vibrating the accelerometer.



What is accelerometer used for? 


                     By measuring the amount of static acceleration due to gravity, you can find out the angle the device is tilted at with respect to the earth.
                     In the computing world, IBM and Apple have recently started using accelerometers in their laptops to protect hard drives from damage. If you accidentally drop the laptop, the accelerometer detects the sudden free fall, and switches the hard drive off so the heads don't crash on the platters. In a similar fashion, high g accelerometers are the industry standard way of detecting car crashes and deploying airbags at just the right time.



How accelerometer works?
 
                    You might be thinking that how with pure electronics we can measure tilt of any sensor but that is not true with accelerometer because accelerometer are made with Micro electromechanical system (MEMS). so with movement of accelerometer the micro particles move that create either capacitive change between the plates or voltage difference according to the tilt.  





Types of accelerometer: 

     1) Piezoelectric Accelerometer : 

                                       They contain microscopic crystal structures that get stressed by acceleration forces, which causes a voltage to be generated.

     2)Capacitive accelerometer :

                                     They contain microscopic metallic structures placed near to each other so that any movement between them produce capacitance change

 




Read more ...
Related Posts Plugin for WordPress, Blogger...