Post a new topicPost a reply Page 1 of 2   [ 16 posts ]
Go to page 1, 2  Next
Author Message
 Post subject: Sensor Board Interruption problem
PostPosted: Sun Feb 05, 2012 12:50 pm 

Joined: Wed Jul 13, 2011 10:03 am
Posts: 24
I need ONLY interruptions caused by the PIR sensor, but qhen I enable the interrupts on SENS_INT, any of the sensor pppppppppproduce the interruption.

Is there any solution in order to have only the interruption of the PIR?

I need an interruption caused by the RTC or the PIR sensor, but not from other sensors.

Code:

SensorEvent.setBoardMode(SENS_ON);
SensorEvent.attachInt();

PWR.deepSleep("00:00:00:10",RTC_OFFSET,RTC_ALM1_MODE2,UART1_OFF | BAT_OFF | RTC_OFF);

      if( intFlag & RTC_INT )
        {
          intFlag &= ~(RTC_INT);
          XBee.println("RTC interrupt!!!");
        }
      else if(intFlag & SENS_INT)
      {
                        intFlag &= ~(SENS_INT);
              SensorEvent.loadInt();
         SensorEvent.detachInt();

         if(SensorEvent.intFlag & SENS_SOCKET7)
            XBee.println("PIR interrupt");
         else
            XBee.println("Other Sensor interrupt");

      }


Thanks in advance,
Iker.


Top
 Profile  
 
 Post subject: Re: Sensor Board Interruption problem
PostPosted: Mon Feb 06, 2012 10:42 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7516
Hello Iker,

Please read the Technical Guide for the Events Board: you can switch On/Off the (physical) switches on the Events Board in order to select which one(s) of them will trigger an interrupt.

Best regards


Top
 Profile  
 
 Post subject: Re: Sensor Board Interruption problem
PostPosted: Mon Feb 06, 2012 8:45 pm 

Joined: Wed Jul 13, 2011 10:03 am
Posts: 24
I know you can switch them on/off. The problem is that I need to have 5 sensors (such as light, temperature, etc) but i want only the presence one to produce the interrupt. Is it possible?

Iker.


Top
 Profile  
 
 Post subject: Re: Sensor Board Interruption problem
PostPosted: Tue Feb 07, 2012 9:46 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7516
Hi iker,

the way we use to disable interruptions from a given sensor is configuring its threshold to 3.3V in the case of positive comparator (for example, socket 5) or 0V for a negative comparator (like socket 2).

Regards.


Top
 Profile  
 
 Post subject: Re: Sensor Board Interruption problem
PostPosted: Sun Feb 12, 2012 5:44 pm 

Joined: Wed Jul 13, 2011 10:03 am
Posts: 24
I've tried what you recommend me, but it doesn't work fine.

I've set the thresolds, and the light and temp sensor does not produce interrupts. However, the aperture sensor, plugged in socket 2 is producing an interrupt, but in the SensorEvents intFlag it seems to be the PIR sensor.

I post here all my code:

Code:
#include "WProgram.h"

#define SENS_PRESION    SENS_SOCKET1 //entrada comparador positiva
#define SENS_LUZ       SENS_SOCKET3 //entrada comparador positiva
#define SENS_TEMP       SENS_SOCKET5 //enttrada comparador positiva
#define SENS_PRESENCIA   SENS_SOCKET7 //entrada digital
#define SENS_APERTURA   SENS_SOCKET2 //entrada comparador negativa

float leerPresion();
float leerLuz();
float leerTemp();
char leerPresencia();
char leerApertura();
void SensIntConf();

void float2stringNchar (float fl, char str[], int N); //modificación para obtener solo 4 caracteres (incluido el punto de separación de parte entera y decimal)


uint8_t extPanId[8]={1,2,3,4,5,6,7,8};
uint8_t destination[8];
packetXBee* paq_sent;
int8_t state = 0;
long previous = 0;
uint8_t i=0;
char myNwkAddr[4];
char data[20];



int main(void)
{
init();

setup();

for (;;)
loop();

return 0;
}


void setup()
{
USB.begin();

//Start Xbee in Zigbee, 2.4GHz, 2mW
xbeeZB.init(ZIGBEE, FREQ2_4G, NORMAL);
//Xbee power on
xbeeZB.ON();

delay(2000);
xbeeZB.getAssociationIndication();
delay(2000);// Check if creating process success
while (xbeeZB.associationIndication)
{
XBee.println("Imposible unirse a la red");
xbeeZB.getAssociationIndication();
delay(200);
}
XBee.println("Unido a la red!");

RTC.ON();

SensIntConf();


delay(1000);

}

void SensIntConf()
{

SensorEvent.setBoardMode(SENS_ON);

SensorEvent.attachInt();

SensorEvent.setThreshold(SENS_PRESION, 3.3);
SensorEvent.setThreshold(SENS_LUZ,3.3);
SensorEvent.setThreshold(SENS_TEMP,3.3);
SensorEvent.setThreshold(SENS_APERTURA,3.3);

}



void loop()
{
#define st "Estamos en el loop!!!"
XBee.println(st);

//A Dormir...
XBee.println("A dormir...");

PWR.deepSleep("00:00:00:10",RTC_OFFSET,RTC_ALM1_MODE2,UART1_OFF | BAT_OFF | RTC_OFF);

//Evaluacion de interrupcion

USB.begin();
RTC.ON();

char presencia='0';

if( intFlag & RTC_INT )
 {
   intFlag &= ~(RTC_INT); // Clear flag
  XBee.println("Interrupción de RTC");
 }
else if(intFlag & SENS_INT)
{
SensorEvent.loadInt();
if(SensorEvent.intFlag & SENS_PRESENCIA)
{
XBee.println("Interrupción de PIR");
presencia='1';
}

else
XBee.println("Interrupción de Otro sensor");

intFlag &= ~(SENS_INT);

}
else
{
XBee.println("Interrupción de otro sitio...");
}


//Lectura de datos

float presion= leerPresion();
char presionC[4];
float2stringNchar(presion,presionC,4);
strcpy(data,presionC);
XBee.print("Presion=");
XBee.println(presionC);

float luz= leerLuz();
char luzC[4];
float2stringNchar(luz,luzC,4);
strcat(data,luzC);
XBee.print("luz=");
XBee.println(luzC);

float temp=leerTemp();
char tempC[4];
float2stringNchar(temp,tempC,4);
strcat(data,tempC);
XBee.print("Temp=");
XBee.println(tempC);

char apertura=leerApertura();
XBee.print("Apertura=");
XBee.println(apertura);
data[12]=apertura;
XBee.print("Presencia=");
XBee.println(presencia);
data[13]=presencia;
data[14]='\0';

XBee.print("Datos a enviar = ");
XBee.println(data);


//enviamos datos...

paq_sent = (packetXBee*) calloc(1, sizeof(packetXBee));
paq_sent->mode = UNICAST;
paq_sent->MY_known = 0;
paq_sent->packetID = 0x52;
paq_sent->opt = 0;
xbeeZB.hops = 0;

xbeeZB.getOwnNetAddress();
Utils.hex2str(xbeeZB.sourceNA, myNwkAddr);
xbeeZB.setOriginParams(paq_sent, myNwkAddr, MY_TYPE);

//Opción de enviarla directamente al coord con nwkAddr=0x0000
char data2[20];
strcpy(data,data2);
xbeeZB.setDestinationParams(paq_sent, "0000",data2, MY_TYPE,DATA_ABSOLUTE);
xbeeZB.sendXBee(paq_sent);
if (!xbeeZB.error_TX) {
XBee.println("enviado OK");

} else {
XBee.print("error al enviar: ");
XBee.println(xbeeZB.error_TX);
}
free(paq_sent);
paq_sent = NULL;


delay(500);

}

float leerPresion()
{
//Socket1 R=560K - 1/R=valorLeido(560K*(3.3-valorLeido))
//1 lbs = 0.45359237 kg  --> 25 lbs= 11.34kg
float valorLeido=SensorEvent.readValue(SENS_PRESION);
float cond=valorLeido/(560*(3.3-valorLeido));
XBee.print("Conductancia=");
XBee.print(cond);
return cond;
}

float leerLuz()
{
//valor de luz en %
float valorLeido = SensorEvent.readValue(SENS_LUZ);
float luz = valorLeido/3.3*100;
return luz;
}

float leerTemp()
{
float valorLeido=SensorEvent.readValue(SENS_TEMP);

float temp=valorLeido*100-50; //0.5V = 0ªC , 1V = 50ºC

return temp;
}

char leerApertura()
{
float valorLeido=SensorEvent.readValue(SENS_APERTURA);
valorLeido=(int)valorLeido;
if(valorLeido>1)
return '1';
else
return '0';

}

void float2stringNchar (float fl, char str[], int N)
{
boolean neg = false;

if( fl<0 ){
neg = true;
fl*=-1;
}

float numeroFloat=fl;
int parteEntera[10];
int cifra;
long numero=(long)numeroFloat;
int size=0;

while(1){
size=size+1;
cifra=numero%10;
numero=numero/10;
parteEntera[size-1]=cifra;
if ((numero==0) || (size==N)){
break;
}
}


int indice=0;
if( neg ){
indice++;
str[0]='-';
}
for (int i=size-1; i>=0; i--)
{
str[indice]=parteEntera[i]+'0';
indice++;
}

if(size<N){
str[indice]='.';
size++;
indice++;


numeroFloat=(numeroFloat-(int)numeroFloat);
for (int i=1; i<=N-size ; i++)
{
numeroFloat=numeroFloat*10;
cifra= (long)numeroFloat;
numeroFloat=numeroFloat-cifra;
str[indice]=char(cifra)+48;
indice++;
}
}

str[indice]='\0';
}


If i switch on the waspmote, and dont touch anything, the RTC is waking up the board very 10 seconds.

If I pass my finger 3cm over the PIR sensor, it doesn't produce the interrupt always (neither in H or L position).

When the aperture sensor changes its value (from open to close, or viceversa) an interrupt is produced, but my code resolves it as a PIR interrup.

I've also plugged the Flexiforce sensor in socket 1. When I touch it anywhere (noy only in ), an interrupt is produced as another sensor interrup, or a PIR interrupt, or other interrupt which is not from RTC or SENS INT. The header is not very well, could it be the solder joints?


Is there something wrong in my code that I'm not seeing? I'm quite desperate.

Thanks for all.

Best regards,
Iker.


Top
 Profile  
 
 Post subject: Re: Sensor Board Interruption problem
PostPosted: Sun Feb 12, 2012 5:47 pm 

Joined: Wed Jul 13, 2011 10:03 am
Posts: 24
In the code, the thresold for SENS_APERTURA is 3.3V (although it is on sens_socket 2 - negative input in the comp). I've been doing tests with thresolds of 0V and 3.3V but it works the same way. It produces interrupt changing from open to close, and from close to open.

Iker.


Top
 Profile  
 
 Post subject: Re: Sensor Board Interruption problem
PostPosted: Mon Feb 13, 2012 1:09 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7516
Hi iker,

Two issues:

Regarding the threshold configuration, it is possible that with aperture sensors, such as the hall effect or the liquid level sensors, it may be surpassed, since they provide a direct connection to ground or 3V3, which may be very slightly higher than the threshold fixed by the potentiometer but enough to provide a positive comparison.

About interruptions processed as if produced by the PIR sensor, this is owed to the fact that the PIR is still activated, which means its flag will still be marked high. It is quite sensitive if you are moving around, try blocking it with a solid cover, like a cardboard box, to prevent it from retriggering again and again.

Best regards.


Top
 Profile  
 
 Post subject: Re: Sensor Board Interruption problem
PostPosted: Sat Feb 25, 2012 10:39 am 

Joined: Wed Jul 13, 2011 10:03 am
Posts: 24
Hi,

Maybe the hall effect sensor is producing interrupt because it exceeds the threshold, so I've removed it from my design.

When I pass my hand about 10 cm over the PIR sensor, it does not produce interruption. But, when I touch slightly the flexiforce sensor, the interruption is produced, sometimes resolved as PIR sensor, sometimes as another sensor interrupt. ¿Is it also exceeding the threshold?

I've removed the Flexiforce from my design (also switching off the power in the multiswitch).


Result: there is no interruption from PIR sensor. Only from the RTC. So, the PIR sensor may not be well. I've checked it with the jumper in L and H position, but it doesn't work.

Checking only the Flexiforce sensor in socket 1, with threshold 3.3V... It is also producing interrupts...

Any help?

Thanks,
Iker.


Top
 Profile  
 
 Post subject: Re: Sensor Board Interruption problem
PostPosted: Mon Feb 27, 2012 9:57 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7516
Hi iker,

it seems there is something wrong with your PIR, yes. Could you measure the output of the sensor at the output pin when triggering? Could you also post a picture of the sensor connected to the board so we can check if there is anything wrong with it?

Regards.


Top
 Profile  
 
 Post subject: Re: Sensor Board Interruption problem
PostPosted: Mon Feb 27, 2012 12:45 pm 

Joined: Wed Jul 13, 2011 10:03 am
Posts: 24
Ok, I'll measure it as soon as possible and post the picture.

What about the flexiforce performance?

Thanks,
Iker.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 2   [ 16 posts ]
Go to page 1, 2  Next


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use