Search This Blog

Friday, 15 June 2012

Surface level measurement using LIS302DL-MEMS Accelerometer

Bingo! I want to write a program for LIS302DL(MEMS Accelerometer) by my self since I've bought STM32F4 Discovery. After few days of working and learning, I've just finish my programming few minutes ago and it is working perfectly well.

So, the program is written to keep the discovery board's surface level at zero, means if the surface is tilted on which the Board is placed, the led(s) will glow such that it indicate the direction at which the surface should be tilted to balance the level.

STM32F4 Discovery also came with the same program, but it is too complex to understand. In their Demo, TIMER4 is used. Instead of using timer I've used only simple led on-off command. It is too simple to understand then using timer.

Here are some photos:

It isn't possible for me to tilt the whole table. So, I just tilted the board!Bad PJ, isn't it?





Here's the video of Acceleromter and STM32F4 in action:




The program used one special type of interrupt Sys_Tick. This interrupt generates at every 1ms in my program. You can change if you want. So, at every 1ms we check the resisters of LIS302DL and compare it with our logic to blink led according to the direction. I don't want to say that we should not use TIMx in programming, but what I mean is why to use complex programming method when the simplest form of programming is available. The main advantage of not using TIM4 is that the time require to handle TIM4 interrupt is saved in case of using simple GPIO On-Off command.


Friday, 8 June 2012

Learn ARM Cortex-M programming by STM32

I am writing this post after a long time. Oh man! right now I am enjoying my vacation. I wish this vacation lasts forever. 

Anyway I was thinking to do something interesting in the summer vacation and I have vacation of almost two months. So, I have plenty of time to learn something interesting. When I was learning about microcontrollers, I've always a keen to know about ARM architecture and want to learn it's programming.

I mean when I heard about the project based on ARM or watch youtube videos about ARM projects, I was like man! I want to learn this stuff! After checking few manufacturer's development board I found them too costly and even their programmer costs a fortune!! Yeah! you can say that because a programmer alone cost you 200$!

Few days ago, I was checking ST microelectronics website and found their new development board. Believe me this board is awesome. It costs you just 22$(1400 INR). 
Isn't is amazing? I mean these all features cost at least 100-150 usd and you've ARM Cortex-M series microprocessor for developing in just 22$!

I bought STM32F4DISCOVERY development board by ST Microelectronics just a few days before through kits and spares. Believe me or not no other development board is good as it is. I've spent couple of hundred just to learn simple microcontroller programming. I've used development boards from Microchip, Atmel , Texas Instruments, but I've never seen anything like STM32F4DISCOVERY. Take a glance at it.


STM32F4DISCOVERY BOARD

 If you're still feeling that the board isn't worth that much than here're some of its features:


● STM32F407VGT6 microcontroller featuring 1 MB of Flash memory, 192 KB of RAM
and LQFP100 package
● On-board ST-LINK/V2 with selection mode switch to use the kit as a standalone
ST-LINK/V2 (with SWD connector for programming and debugging)
● Board power supply: through USB bus or from an external 5V supply voltage
● External application power supply: 3V and 5V
● LIS302DL, ST MEMS motion sensor, 3-axis digital output accelerometer
● MP45DT02, ST MEMS audio sensor, omnidirectional digital microphone
● CS43L22, audio DAC with integrated class D speaker driver
● Eight LEDs:
– LD1 (red/green) for USB communication
– LD2 (red) for 3.3V power on
– Four user LEDs, LD3 (orange), LD4 (green), LD5 (red) and LD6 (blue)
– 2 USB OTG LEDs LD7 (green) VBus and LD8 (red) over-current
● Two pushbuttons (user and reset)
● USB OTG with micro-AB connector
● Extension header for LQFP100 I/Os for quick connection to prototyping board and easy
probing


Now you can say OMG! WOW! All these features in just 22$! Why to spend thousands of rupees on microcontroller or microprocessor that isn't based on ARM and you've full support and ease of learning at affordable price.

In the beginning I thought the programming of at least one architecture must be done to learn ARM programming, but I was completely wrong. If you know some basic thing about 8085 or 8086 or any other microcontroller, you can learn ARM architecture and to program ARM. Even if you doesn't know how to program a microcontroller!- it is okay. Besides STM32F4 has maximum clock upto 168 MHz at 210DMIPS and DSP features. The best performance any another microcontroller like 8085, Microchip and Atmel can give is like 80-120 MIPS.

ARM CORTEX-M4 gives freedom to develop real time embedded application easily, with great support of community and of course at affordable cost. You can expand the limitation faced by any other microcontroller. You can develop application based on speech, image,etc with its DSP core. I will post some tutorials about how to use STM32F4DISCOVERY and program it.

Some useful links:
STM32F4DISCOVERY official website: http://www.st.com/internet/evalboard/product/252419.jsp
Kits and Spare by Element 14                : http://kitsnspares.com/user1/buyproduct.asp


Sunday, 22 April 2012

Object Counter using PIC16F877

Hey,
This blog is about the circuit that I've designed for my college project.
I've designed Object counter using PIC16F877 and used Op-Amp as comparator-LM324.
The circuit diagram and simulation is as under:


1).Sensor Circuit.

 Working of Sensor:


  • Resistance of LDR when light falls on it=7.8k
  • Resistance of LDR when light is blocked=19k
  •  Voltage drop across R2 when light falls on LDR=1.42V
  • Voltage drop across R2 when light is blocked by an object=0.7V
  • Voltage given to comparator by potentiometer=1.38V
  • Output Voltage from Comparator=2.17V
          As you can see from the circuit that when light is blocked by an object the resistance of the LDR increases hence voltage drop across R2 is decrease. We've given this decreased voltage to the negative terminal of Op-Amp. Hence difference between reference voltage and sensor output will be amplified.


 2).Microcontroller Programming and Proteus Simulation:


I've done simulation in proteus. I couldn't find a way to give input from sensor to microcontroller for simulation. So, I've skipped that part and simulate only initialization of 16x2 LCD.
Programming is done in MPLAB using HI-Tech C Compiler. I've made my own library to use 16x2 LCD.I've made a simple mistake while programming that skips the counts of 10,20,30....etc.
So, whenever count reaches to 8,18,28..... it skips 9,19,29,..... and shows 10,20,30....etc.

The recording was done before I can edit my program.I made some modification after that and now the circuit works fine. So, hope you'll bear me for this video that was recorded before I can find my mistake.

Bill Of Materials

U1            PIC16F877                                                           
U2            LM324                                                               
X1            4MHz Quartz Crystal                                       
2              15pF Capacitor
1              16x2 JHD162A LCD
2              150 resistors
2              1k  resistors
2              IC Sockets
1              Yello LED in white
2              10k POT
1              LDR
1              9V Battery

 Some Photos







PS: To get proteus file or MPLAB coding file mail me or write your e-mail address in comment.