CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

wireless communication...

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
luna



Joined: 11 Aug 2010
Posts: 3
Location: MALAYSIA

View user's profile Send private message

wireless communication...
PostPosted: Wed Nov 24, 2010 5:07 am     Reply with quote

Hye…
I'm trying to make software UART work that received data from several sensors through Zigbee (XBee OEM RF) wireless comm. In my project, I have one master and one slave. …at the slave have two sensors that are magnetic sensor and pir sensor (both are digital sensor).
If any one of the sensor nodes is triggered, it will send an alert signal to the main controller (master). But the problem here, the system is not looping.

The problem:
After I Press Switch 1 it will display “zone 1 detect and so on”…then I try to press switch 2… but it did not show at LCD “zone 2 detect and so on”. Suppose it will clear zone 1 detect and replace with the zone 2 detect…
Plzz… I really appreciate who can help me..

Here I post my coding.

program at master
Code:

#include <18F4550.h>
#fuses HS,NOLVP,NOWDT,NOPROTECT
#define use_portb_kbd TRUE
#use delay(clock=20000000) // 20 MHz crystal on PCB
#use rs232(baud=9600, UART1) // hardware uart much better; uses RC6/TX and RC7/RX

#include <stdlib.h>
#include "flex_LCD1.c"

#DEFINE LED_0 PIN_D0
#DEFINE LED_1 PIN_D1
#DEFINE LED_2 PIN_D2
#DEFINE BUZZER PIN_C0

void panic_button (void); //define a function
char x;

void main()
{
/*initialize*/
output_low(BUZZER);
output_low(LED_0);
output_low(LED_1);
output_low(LED_2);

lcd_init(); // initilize lcd
printf(lcd_putc,"\f HOME SECURITY");
printf(lcd_putc,"\n WYSAS'10");
delay_ms(100);
printf("!");

while (true)
{
panic_button();

if (kbhit())
{
x = getc();

if (x=='a')
{
output_high(LED_0);
output_low(LED_1);
output_low(LED_2);
output_high(BUZZER);
printf(lcd_putc,"\f ZONE 1 DETECT");
printf(lcd_putc,"\n ENTER PASSWORD");
delay_ms(500);
}

if (x=='b')
{
printf(lcd_putc,"\f ZONE 2 DETECT");
printf(lcd_putc,"\n ENTER PASSWORD");
output_high(LED_1);
output_low(LED_0);
output_low(LED_2);
output_high(BUZZER);
delay_ms(500);
}

}
}
}


void panic_button (void) //define a function
{

if(input(pin_a1)==1)
{
printf(lcd_putc,"\fINTRUDER DETECT");
printf(lcd_putc,"\nENTER PASSWORD");
output_high(LED_0);
output_high(LED_1);
output_high(LED_2);
output_high(BUZZER);
delay_ms(500);
}

}


prgrm at slave
Code:

#include <16f628a.h>
#fuses HS,NOLVP,NOWDT,NOPROTECT
#use delay(clock=20000000) // 20 MHz crystal on PCB
#use rs232(baud=9600, UART1)

#include <stdlib.h>

#define LED_0 PIN_B4

void main()
{
set_tris_a(0b01111111);
set_tris_b(0b00000000);

while (TRUE)
  {
   if (input(PIN_A2)==1)
    {
     output_high(LED_0);
     printf("b"); //sends signal b
    }

  if (input(PIN_A1)==1)
   {
    output_high(LED_0);
    printf("a"); //sends signal b
   }
  else if(input(PIN_A2)==0|input(PIN_A1)==0)
   {
    output_low(LED_0);
   }
 }
}
pmuldoon



Joined: 26 Sep 2003
Posts: 218
Location: Northern Indiana

View user's profile Send private message

PostPosted: Wed Nov 24, 2010 11:19 am     Reply with quote

Just a quick observation:

Your UART may be hanging up on an error.

add ERRORS to your UART setups:
Code:

#use rs232(baud=9600, UART1, ERRORS)



I assume your LEDs are responding properly on the slave?
luna



Joined: 11 Aug 2010
Posts: 3
Location: MALAYSIA

View user's profile Send private message

PostPosted: Wed Nov 24, 2010 2:45 pm     Reply with quote

Thanks a lot for your response.
Finally, its working like I want. tq...
Very Happy Very Happy
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group