NPEDUCATIONS, Electronic circuits development, electronics tutorials, microcontroller tutorials and projects, advanced microcontroller (ARM) based tutorials and projects, Embedded c development, Embedded c for ARM cortex M, Intel IoT based projects, IoT projects, CC3200 launch pad projects, MSP430 Launchpad tutorials and projects, Tiva C launch pad tutorials and projects, 8051 tutorials and projects, sensor interfacing with microcontroller tutorials, data communications and networking tutorials, peripheral interfacing with microcontroller, led message scrolling display, arduino based tutorials and projects, intel galileo based tutorials and project, ADC interfacing tutorials, LED Blinking, LCD interfacing, Embedded System tutorials and projects, projects, projects, online Embedded C training

Visitor Counter using IR sensors and MSP430 launch pad

Microcontroller based Visitor counter project is useful in so many areas like railway stations, holy places, banks, etc. I was implemented this project by using Texas instruments MSP430 launch pad and IR sensor technology. But ultra sonic sensors will best suitable for this application because the effect of sunlight is more on IR based sensor module than ultra sonic sensors. But the ultra-sonic sensor modules are more costly that IR sensor modules and easy to implement.

IR sensor Modules:
This IR sensor Module is just same as obstacle sensor circuit. In this I have connected a 10k resistor to the inverting terminal of the opamp LM358 which is single supply opamp and the photo diode (D2) is connected to the positive terminal of the opamp. The IR diode is connected between the Vcc and Gnd via resistor R5 (330ohms). When the IR rays falls on the photodiode, a voltage is generated at the positive terminal of the opamp. Then the opamp will generate a high or low at the output and this is fed to MCU interrupt pins. Here i have designed the circuit diagram with eagle cad software.

IR sensor Module circuit diagram

Circuit Diagram:
Circuit for object or visitor counter project

In the above circuit diagram, I have connected two IR sensor modules (with two separate opamps 1A and 1B) to the MSP430 microcontroller port pins P1.2 and P2.3. A power on reset circuit (resistor and capacitor) is connected to the RST pin of thee microcontroller. A 16x2 character LCD is connected to port2 of the MSP430 microcontroller. A tutorial on the interfacing the 16x2 LCD to MSP430 is described here.
Simple Steps to Build Algorithm using MSP430 interrupts:
  1. If a person crosses the first sensor (1A) and then second (1B), then the count will increment. Check out the video shown below.
   2.  If a person crosses the second sensor (1B) and then first (1A), then the count will decrement.


#include  "msp430g2553.h"
#include  "stdio.h"
#include  "string.h"
#include "stdlib.h"
#include "MSP430_LCD.h"

void IntToString(int);
void strrev(char *);

#define delay_value 500
char LCD_Data = '';
char Template[50] = "\0";
char Temp_Array[5]="\0",Temp_Array1[5]="\0";
unsigned char Flag = 0,Temp=0;
static unsigned char i=0, j=0, status = 0, Button_Press=0;
static int COUNT = 0x00;
unsigned int Temp_Flag=0;

void main(void)
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  BCSCTL1 = CALBC1_1MHZ;                    // Set DCO
  BCSCTL2 &= ~(DIVS_3); //This line of code ensures that the SMCLK divider is 0, so we have SMCLK=DCO=1MHz (in fact if we are to have a /8 divider, it should be   BCSCTL2 |= DIVS_3;).

 // P1DIR = 0xFF;
  P2DIR = 0xFF;

  P1SEL  = BIT1 + BIT2;                     // P1.1 = RXD, P1.2=TXD, P1.6 = LCD_RS, P1.7 = LCD_EN
  P1SEL2 = BIT1 + BIT2;                     // P1.1 = RXD, P1.2=TXD

  P2SEL = 0;
  P2SEL2 = 0;

 P1DIR = 0xC1;                             // P1.0 output, else input
    P1OUT |= BIT0+ BIT3 + BIT4 + BIT5;                            // P1.4 set, else reset

    P1IE |= 0x38;                             // P1.3 interrupt enabled
    P1IES |= 0x38;                            // P1.3 Hi/lo edge
    P1REN |= 0x38;                            // P1.3 pullup
    P1OUT |= 0x38;       // Pull Up Resistor at 1.3
    P1IFG &= ~0x38;                           // P1. IFG cleared

       P1IFG &= ~0x38;                           // P1. IFG cleared
       P1OUT &= ~BIT0;

  LCD_Init(); // LCD initialization

       send_cmd(0x01);  // clear display
       send_cmd(0x81);  // clear display
       send_string("Visitor Counter:");
       send_cmd(0x01);  // clear display

    send_cmd(0x81);  // clear display

    send_cmd(0xC0);  // clear display

    if(COUNT != 0)
     P1OUT |= BIT0;


    for(Temp=0;Temp<5 data-blogger-escaped-0x01="" data-blogger-escaped-0x08="" data-blogger-escaped-0x10="" data-blogger-escaped-0x20="" data-blogger-escaped-10="" data-blogger-escaped-1="" data-blogger-escaped-__interrupt="" data-blogger-escaped-bit3="" data-blogger-escaped-button_press="1;" data-blogger-escaped-char="" data-blogger-escaped-cleared="" data-blogger-escaped-count--="" data-blogger-escaped-count="" data-blogger-escaped-edge="" data-blogger-escaped-else="" data-blogger-escaped-emp="" data-blogger-escaped-empvalue="" data-blogger-escaped-end="" data-blogger-escaped-for="" data-blogger-escaped-if="" data-blogger-escaped-ifg="" data-blogger-escaped-int="" data-blogger-escaped-interrupt="" data-blogger-escaped-interrupt_flag1="0;" data-blogger-escaped-interrupt_flag2="1;" data-blogger-escaped-inttostring="" data-blogger-escaped-k="" data-blogger-escaped-main="" data-blogger-escaped-nterrupt_flag1="=" data-blogger-escaped-nterrupt_flag2="=" data-blogger-escaped-of="" data-blogger-escaped-p1.0="toggle" data-blogger-escaped-p1.3="" data-blogger-escaped-p1.4="" data-blogger-escaped-p1="str," data-blogger-escaped-p1ifg="" data-blogger-escaped-p2="" data-blogger-escaped-pina="" data-blogger-escaped-port="" data-blogger-escaped-port_1="" data-blogger-escaped-pragma="" data-blogger-escaped-return="" data-blogger-escaped-routine="" data-blogger-escaped-service="" data-blogger-escaped-static="" data-blogger-escaped-str="" data-blogger-escaped-strrev="" data-blogger-escaped-temp_array="" data-blogger-escaped-tempvalue="(value" data-blogger-escaped-th="" data-blogger-escaped-the="" data-blogger-escaped-toggle="" data-blogger-escaped-value="value/10;" data-blogger-escaped-vector="PORT1_VECTOR" data-blogger-escaped-void="" data-blogger-escaped-while="" data-blogger-escaped-x08="" data-blogger-escaped-x10="" data-blogger-escaped-x20="" data-blogger-escaped-x30="">p1; ++p1,--p2)
  *p1 ^= *p2;
  *p2 ^= *p1;
  *p1 ^= *p2;



//return str;


1 comment :

Thanks for visiting NPEDUCATIONS. We will contact you soon


musase said...
This comment has been removed by the author.

Post a Comment

Thanks for visiting NPEDUCATIONS. We will contact you soon

If you really like this tutorial, Don't forget to give the comment or please subscribe to the RSS feed by submitting your E-mail or like our Facebook page.

Powered by Blogger