Jump to content
Sign in to follow this  
username

simple laser security system

Recommended Posts

Made a basic laser security system with the msp430 launchpad.

 

Video here:

 

 

Going to use this for a school design project so i'll have to add some flashey features such as a nice loud alarm, a laser deactivation code and 2 layer pcb +enclosure to pretty it all up.

Share this post


Link to post
Share on other sites

Nice Innovative use of LEDs. In the video you stated that you were buffering the output from the LED. Is that to boost the voltage given out by the LED?

 

I'm just interested if the MSP's inbuilt ADC could detect that voltage itself. OR if the inbuilt comparator of the MSP430G2211 could detect the small voltage change.

Share this post


Link to post
Share on other sites

Hi username, could you please post some info circuitry or schematic. I am interested in the amplifier for the sensor and your use of the ADC, but am stuck in the conceptual phase.

 

thanks. KB

Share this post


Link to post
Share on other sites

Sending an analog transmission via a laser would be a rather large pain in the butt... would require some careful calibration of the LED head. Or you could PWM the laser and have a RC filter on the output... that would equally be painful.

 

Anyhow, for my project I just used a digital signal as observed in the youtube clip. Here is a schematic representation of my input + the laser.

 

*(note the fun site is clipping my image :( .. link below to full image )

 

post-4818-135135511598_thumb.png

Share this post


Link to post
Share on other sites

thanks user. I already have had some luck using your code. I am using it as a simple photo detector- in hopes of making a differential light detector. I cannot however get the code to work with 2 sensors. Any ideas. I tried posting this in the code section, but I havent got much feedback yet :cry:

 

thanks.

 

/* LED as Photo-Sensor2
/ KB, interpreted from: Gustavo J. Fiorenza 
*/

#include "msp430g2452.h"	// Change the header to "msp430x20x2.h" if you're using the default MCU bundled with the LaunchPad.

#define LED_SENSEL INCH_0 	// Left sensor	
#define LED_SENSER INCH_3 	// Right sensor

unsigned int adcvalL = 0;   // Left value register
unsigned int adcvalR = 0;   //Right value resgister

unsigned int analogRead(unsigned int pin) {

 ADC10CTL0 = ADC10ON + ADC10SHT_2 + SREF_1 + REFON + REF2_5V;
 ADC10CTL1 = ADC10SSEL_0 + pin;

 ADC10CTL0 |= ENC + ADC10SC;

 while (1) {
   if ((ADC10CTL1 ^ ADC10BUSY) & ((ADC10CTL0 & ADC10IFG)==ADC10IFG)) {
     ADC10CTL0 &= ~(ADC10IFG + ENC);
     break;
   }
 }
 return ADC10MEM;
}

void main(void) {
unsigned int i, delay;

WDTCTL = WDTPW + WDTHOLD;	// Hold the watchdog.
P1DIR |= BIT6; // L LED indicator
	P1DIR |= BIT7; // R LED indicator
	P1REN = BIT1|BIT2|BIT4|BIT5|BIT6|BIT7;

while (1){


	// Multi-sampling (8 samples with delay for stability).
	adcvalL = 0;
	adcvalR = 0;

	for ( i=0; i < 8; i++ ) {
		adcvalL += analogRead( LED_SENSEL );	// Read the analog input.
		delay = 100;
		while (--delay);
	}
	adcvalL >>= 3; // division by 8

		for ( i=0; i < 8; i++ ) {
		adcvalR += analogRead( LED_SENSER );	// Read the analog input.
		delay = 100;
		while (--delay);
	}
	adcvalR >>= 3; // division by 8

	// Interpret the result
	if ( adcvalL < 900 ){
		P1OUT |= BIT6;	// Turn on the left Green LED.

	}else if ( adcvalR < 900 ){
		P1OUT |= BIT7;	// Turn on the right LED.
	}else{
		P1OUT = 0x00;	// Turn off the entire Port 1, thus turning off the LED as well.
	}

}

}

Share this post


Link to post
Share on other sites

Remember i'm rather new with the MSP430... and i'm still a student. I haven't even done a project with the ADC yet. Not quite sure why your trying to use a ADC. Just amplify your LED signal and feed it to a digital input. Heres my code... little bloated right now... all i'm doing is PWMing based on delays and reading a input and comparing it versus the output.

 

// Laser Based SS
// Nathan Zimmerman
// 9/11/11


#include 

#define 	GLED		BIT6 // Green LED saying that SS is good and active
#define		RLED		BIT0 // Red LED saying that SS has been breached and alarm is high
#define		ALARM		BIT1 // Output to drive alarm
#define		TXD			BIT2 // Serial Output
#define		RXD			BIT4 // Serial Input
#define		DIS_ALARM	BIT5 // Disable SS
#define		BUTTON		BIT3 // Disable SS
volatile unsigned int test = 0;
volatile unsigned int i=1;


void TXD_RXD(void); // Prototype TXD Function
void dis_alarm(void);


void main(void)
{

WDTCTL = WDTPW + WDTHOLD; // Turns WD OFF

if (CALBC1_1MHZ == 0xFF || CALDCO_1MHZ == 0xFF) //
{
while(1);	 // No idea what this does but I think it makes me happy
}	//End While

BCSCTL1 = CALBC1_1MHZ; // 
DCOCTL = CALDCO_1MHZ;  // Sets DCO to 1MHZ

P1IE |= BUTTON; // P1.3 interrupt enabled
P1IFG &= ~BUTTON; // P1.3 IFG cleared
__enable_interrupt(); // enable all interrupts


P1DIR |= ( GLED + RLED + ALARM + TXD); // All outputs except DIS_ALARM and RXD
P1OUT &= ~(GLED + RLED + ALARM +TXD); // All bits set high initally, need to set all bits low. 
P1OUT |= GLED; // Turns Green LED ON

__delay_cycles(1000000);

TXD_RXD(); // Should always stay in this state unless TXD != RXD 	

P1OUT = 0;
P1OUT |= (RLED + ALARM);

} // End Main

void TXD_RXD(void)
{
while(i < 10)
{

P1OUT |= TXD;
__delay_cycles(20);
if((RXD & P1IN)==0)
{ 
	i++;
}
P1OUT &= ~TXD;
__delay_cycles(40);
if((RXD & P1IN)==1)
{
	i++;
}

} // End While
} // End Function 

void dis_alarm(void)
{

P1OUT &= ~TXD;	
volatile unsigned int j=0; 
int x = 0; 
if((RLED & P1OUT) ==1)
{
x=20;	
}
else
{
x=100;	
}
while(j		{
	P1OUT ^= GLED;
	__delay_cycles(100000);
	j++;
	}// End While 
	__delay_cycles(100);
	WDTCTL = WDT_MRST_32 + ~WDTHOLD;    
}

// Port 1 interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
dis_alarm();
P1IFG &= ~BUTTON; // P1.3 IFG cleared


} // End ISR





/* Low Power Mode Code

P1OUT |= TXD; 
//__delay_cycles(1);
if((RXD & P1IN)==0)
{ 
	i++;
}

//__delay_cycles(2);
P1OUT &= ~TXD;
__delay_cycles(10);
if((RXD & P1IN)==1)
{
	i++;
}

__delay_cycles(150);


*/ // Low Power Mode





Share this post


Link to post
Share on other sites

I could be wrong, but the reason to use the ADC is to get a reliable estimate of the strength of the signal being generated by the sensor. This would mean, the higher the light level, the greater the adcval, and vice versa. I dont think this could be achieved in such a simplistic way, using digital inputs.

 

Thanks. KB

Share this post


Link to post
Share on other sites
I could be wrong, but the reason to use the ADC is to get a reliable estimate of the strength of the signal being generated by the sensor. This would mean, the higher the light level, the greater the adcval, and vice versa. I dont think this could be achieved in such a simplistic way, using digital inputs.

 

Thanks. KB

 

Ahh okay yea, I see what your saying. For my application it was simply a 1 or 0 type of application. Either the laser was tripped or it wasn't. I didn't really care about the strength of the beam. Hence why I used digital inputs. I doubt my circuit would work very well for analog based transmissions.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...