THE WAKE UP CHANNEL
Go to bottomPage: 12
TOPIC:
#924
Re:direction of motion 1 Year, 5 Months ago Karma: 0
Tom Ormiston wrote:

Jacob
The line is in the wrong place.
Here is the entire ISR routine from the demo with the new line added:


Code:


///////////////////////////////////////////////////////////
//Interrupt routine for Timer 0 End of Count (50ms)
///////////////////////////////////////////////////////////
void interrupt isrTimer0(void)
{
if(cMDDelay > 0) // If the LED is still activated
{
cMDDelay--; // Decrement the LED activation time
if(cMDDelay == 0) // If the LED activation time has expired
{
LED_OFF; // Turn off the LED Output port
ePIR_SC0 &= ~SC0_MOTION_DETECTED; // Clear engine Motion detected flag
}
}
if(cMDCheck > 0) // When it hits 0, we check the MD bit in the main loop
{
cMDCheck--; // Decrement the MD check counter

#if (VERBOSE == 1)
ePIR_ASC0 &= ~ASC0_TRANSIENT_DETECTED;
ePIR_ASC0 &= ~ASC0_NOISE_DETECTED;
#endif
}
c50mSecond++; // Increment the 50 ms counter
//1 second tick area
if (c50mSecond >= DELAY_1SEC) // If we have reached one second...
{
c50mSecond = 0; // Reset the 50 ms counter
c1Second++; // Increment the one second counter
cSecondCount++; // Increment the continuous 1 second counter
ePIR_SC1 |= SC1_ENGINE_TIMER_TICK; // Pass the one second tick to the ePIR engine

#if (VERBOSE == 1)
if(SysStatus1 & PIR_STABLE)
{
if(ePIR_ASC0 & ASC0_WHITE_LIGHT_DETECTED)
{
ePIR_ASC0 &= ~ASC0_WHITE_LIGHT_DETECTED;
SysStatus1 |= WHITE_LIGHT_EVENT;
}
if(ePIR_ASC0 & ASC0_TRANSIENT_DETECTED)
{
ePIR_ASC0 &= ~ASC0_TRANSIENT_DETECTED;
SysStatus1 |= TRANSIENT_EVENT;
}
if(ePIR_ASC0 & ASC0_NOISE_DETECTED)
{
ePIR_ASC0 &= ~ASC0_NOISE_DETECTED;
SysStatus1 |= NOISE_EVENT;
}
}
#endif
// 1 minute tick area
if (c1Second >= 60) // If we have reached one minute...
{
c1Second = 0; // Clear the one second counter
}
}
///////////////////////////////////////////////////////////
// Check for PIR sensor stability after power up
///////////////////////////////////////////////////////////
if(!(SysStatus1 & PIR_STABLE))
{
if(!(SysStatus1 & PIR_PRE_STABLE)) // If we have not seen engine stability after power up...
{
if (ePIR_SC0 & SC0_PIR_STABLE) // If the PIR sensor has become stable...
{
SysStatus1 |= PIR_PRE_STABLE; // Indicate that the system has stabilized after powerup
cMDCheck = DELAY_5SEC; // Add some extra time to pyro stablization - just to be sure
}
}
else
{
if(cMDCheck == 0)
{
SysStatus1 |= PIR_STABLE; // Indicate that the system has stabilized after powerup
LED_OFF; // Turn off LED to show we are ready

// Set up the White Light detection registers and enable (Defines are in main.h)
ePIR_ASC0 |= WHITE_LIGHT_ANTI_JAM_DEF << 5; // Configure White Light Anti-Jam
ePIR_ASC1 = WHITE_LIGHT_SCAN_RATE_DEF + (WHITE_LIGHT_DEBOUNCE_DEF << 4);
ePIR_SC2 += (WHITE_LIGHT_THRESH_DEF << 3); // Set up the white light detection threshold and enable

#if (VERBOSE == 1)
// Clear out any status from before the pyro was stable
ePIR_ASC0 &= ~ASC0_WHITE_LIGHT_DETECTED;
ePIR_ASC0 &= ~ASC0_TRANSIENT_DETECTED;
ePIR_ASC0 &= ~ASC0_NOISE_DETECTED;
SysStatus1 &= ~(TRANSIENT_EVENT + NOISE_EVENT + WHITE_LIGHT_EVENT);
#endif
SysStatus1 |= SEND_STABLE; // Send the "Stable" message from main
}
}
}

///////////////////////////////////////////////////////////
// Check for motion detected and update the output as needed
///////////////////////////////////////////////////////////
else if((ePIR_SC0 & SC0_MOTION_DETECTED) && !cMDCheck) // If the engine indicates a motion event
{
LED_ON; // Turn on the LED Output port (turned off in T0 int)
cMDDelay = cMDDelayTime; // Initiate LED ON time
cMDCheck = DELAY_1SEC; // Wait 1 second before checking for motion again (allows Engine to re-stablize)

cDirection = ((ePIR_SCO & SC0_MOTION_DIRECTION) ? 1 : 0); //New line to get direction of movement

if(ePIR_ASC0 & ASC0_MD_ORIGIN) // Which Engine reported the motion event?
{
SysStatus1 |= TX_EXTENDED; // Set Extended flag if motion was sensed by Extended Detector
cEDCount++; // Increment the Extended Detection counts
TxMotionCount = cEDCount; // Set the Extended Detection Counts to be transmitted in main()
}
else
{
SysStatus1 |= TX_NORMAL; // Set Normal flag if motion was sensed by Extended Detector
cMDCount++; // Increment the Normal Detection counts
TxMotionCount = cMDCount; // Set the Normal Detection Counts to be transmitted in main()
}
TxSecondCount = cSecondCount; // Save the time stamp - transmitted in main()
}
}





Just in case, here is the entire main() application loop with the new line added:


Code:


///////////////////////////////////////////////////////////
// This is the main application loop - we never exit
///////////////////////////////////////////////////////////
while(1)
{
Z8_WDT; // Kick the watchdog
Z8_HALT; // Halt to conserve power. ADC and T0 Interrupt pull CPU out of Halt
// Is there anything to do?
if(SysStatus1 & (WHITE_LIGHT_EVENT | TRANSIENT_EVENT | NOISE_EVENT | SEND_STABLE | TX_EXTENDED | TX_NORMAL))
{
#if (VERBOSE == 1)
if(SysStatus1 & WHITE_LIGHT_EVENT)
{
TxQueue('W');
SysStatus1 &= ~WHITE_LIGHT_EVENT;
}
if(SysStatus1 & TRANSIENT_EVENT)
{
TxQueue('T');
SysStatus1 &= ~TRANSIENT_EVENT;
}
if(SysStatus1 & NOISE_EVENT)
{
TxQueue('N');
SysStatus1 &= ~NOISE_EVENT;
}
#endif
if(SysStatus1 & SEND_STABLE)
{
TxQueue('S'); // Send out 'S' to indicate we are stable
TxCRLF();
SysStatus1 &= ~SEND_STABLE;
}
// The T0 interrupt sets TX_EXTENDED or TX_NORMAL when a motion event is detected
// We send out a message with a count of events and a time stamp
if(SysStatus1 & (TX_EXTENDED | TX_NORMAL))
{
if(SysStatus1 & TX_EXTENDED)
{
SysStatus1 &= ~TX_EXTENDED;
TxQueue('E'); // Send an 'E' if motion was sensed by Extended Detector
}
else
{
SysStatus1 &= ~TX_NORMAL;
TxQueue('M'); // Send an 'M' if motion was sensed by Normal Detector
}
TxQueue(' ');
TxCharAsDecimal(TxMotionCount); // Send out the count of detections
TxString(" @ ");
TxIntAsDecimal(TxSecondCount); // Send out the time stamp
TxString(" D: ");
TxCharAsDecimal(cDirection); 
TxCRLF();
}
}
} // End of main application loop
like your modification of your headfile is correct:





It looks
EPIR_SC0_DEF 0x48

Let me know if this helps.
Tom Ormiston
jd (User)
Fresh Boarder
Posts: 6
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#925
Re:direction of motion 1 Year, 5 Months ago Karma: 0
Dear Tom,
i inserted the code as you said, but the code does not build. It says an error appears at the serial map.
I zip the src so you can have a look.

Other question:
how can i put the zmotion detection module on the board that came with the intrusion package?
I see no header, is there some instruction or should i go buying the detection devkit??
File Attachment:
File Name: src.zip
File Size: 11670
jd (User)
Fresh Boarder
Posts: 6
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#930
Re:direction of motion 1 Year, 4 Months ago Karma: 0
Dear Tom,
still no result. After i followed your latest instructions, the build reports a problem at the serial driver. No details.
Shall i send you the SRC or can you give me more insight on which files to open and start from?
Thanks,
Jacob
jd (User)
Fresh Boarder
Posts: 6
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 12