combination between pr11 and pr16

LED Blinking, Walking with Cytron Servo, Displaying RFID, Multi-function Mobile Robot......

combination between pr11 and pr16

Postby kembaralalu » Thu Apr 15, 2010 9:20 am

ive combine between pr11 and pr 16.however,i have change the program..n my circuit didnt function at all..if i do seperately,2 circuit function.. please2 help me out
kembaralalu
Freshie
 
Posts: 6
Joined: Thu Apr 15, 2010 9:09 am

Re: combination between pr11 and pr16

Postby A380 » Thu Apr 15, 2010 1:42 pm

kembaralalu, how you combine your both PR? can you elaborate more about your project?
User avatar
A380
Discoverer
 
Posts: 120
Joined: Tue May 19, 2009 2:44 pm
Location: Malaysia

Re: combination between pr11 and pr16

Postby kembaralalu » Thu Apr 15, 2010 4:39 pm

this is rx program.
i just want the lm35dz using wired and wireless..

CODE: SELECT_ALL_CODE
#include <pic.h>
//===================================================================================
__CONFIG (0x3F32);
//   define
//===================================================================================
//#define   inc_button   RA1
//#define dec_button    RA2
#define   send_button   RA3
#define      lcd         PORTB
#define      RS         RA2
#define      E         RA5
#define      CHANNEL0   0b10000001   // AN0
#define      ledA      RB2
#define      fanA      RB4
#define      buzzer      RB5


//   function prototype
//===================================================================================
void uart_send(unsigned char data);
void read_adc(void);
void lcd_goto(unsigned char data);
void dis_num(unsigned long data);
void send_char(unsigned char data);
void send_config(unsigned char data);
unsigned short read_temp(void);
void lcd_clr(void);
void increment(unsigned long data);

//   main function
//===================================================================================
//assign variable
   
   unsigned short result;
   unsigned short temp,no;
   unsigned short read_temp(void);

void main(void)
{

ADRESH=0;               //clear A/D result
PORTA=0;
   
      {
         //sensor A
      ADCON0=CHANNEL0;            //CHANNEL1=0b10001001
   //   lcd_goto(8);
            
      read_adc();

      temp=read_temp();
   //   dis_num(temp/10);
   //   send_char('.');
   //   dis_num(temp%10);
   //   send_char(0b10001001);
   //   send_char('C');
   //   send_char(' ');
   //   send_char(' ');
      
      temp=temp;
      }

// display
   ADCON0= 0b10001001;            //configure PortA as digital I/O

   TRISA = 0b111111;         //configure PORTA input
   TRISB = 0b00000000;         //configure PORTB as output
   
//setup USART
   BRGH = 0;               //baud rate low speed option
   SPBRG = 255;            //set boud rate to 1200bps for 20Mhz crystal
   TX9 = 0;               //8-bit transmission
   TXEN = 1;               //enable transmission
   SYNC = 0;               //asynchronous
   
   SPEN = 1;               //enable serial port
   
   
   temp=temp;

   while(1)                  //infinity loop
   {
      if((temp>400))      //   *****************************************
            {                        //   *   LED A and Fan A activated only for    *
               ledA=1;                  //   *   temperature A greater than 40'C      *
                                 //   *   and temperature B less than 35'C   *
               fanA=1;                  //   *****************************************
               
               buzzer=1;
            }   

         else if((temp<400))    //   *****************************************
            {                        //   *   LED B and Fan B activated only for    *
               ledA=0;                  //   *   temperature A less than 40'C and   *
                                 //   *   temperature B greater than 35'C      *
               fanA=0;                  //   *****************************************
               
               buzzer=0;
            }   
         
         else if(send_button==0)      //send the desired number   
         no=temp;

         uart_send(no);            //continuous send data
   
//      delay(2000);
   
      }
   }
   
//==================subroutine ADC=========================

void read_adc(void)
{
   unsigned short i;
   unsigned long result_temp=0;
   for(i=2000;i>0;i-=1)         //looping 2000 times for getting average value
   {
      ADGO = 1;               //ADGO is the bit 2 of the ADCON0 register
      while(ADGO==1);            //ADC start, ADGO=0 after finish ADC progress
      result=ADRESH;
      result=result<<8;         //shift to left for 8 bit
      result=result|ADRESL;      //10 bit result from ADC

      result_temp+=result;      
   }
   result = result_temp/2000;      //getting average value

}

unsigned short read_temp(void)
{
   unsigned short temp;
   temp=result;
   return temp;

}      
      
//   functions
//===================================================================================
void uart_send(unsigned char data)
{   
   while(TXIF==0);            //only send the new data after
   TXREG=temp;               //the previous data finish sent
}



this is tx program
#include <pic.h>
//===================================================================================
__CONFIG (0x3F32);
//   define
//===================================================================================
//#define   inc_button   RA1
//#define dec_button    RA2
#define   send_button   RA3
#define      lcd         PORTB
#define      RS         RA2
#define      E         RA5
#define      CHANNEL0   0b10000001   // AN0
#define      ledA      RB2
#define      fanA      RB4
#define      buzzer      RB5


//   function prototype
//===================================================================================
void uart_send(unsigned char data);
void read_adc(void);
void lcd_goto(unsigned char data);
void dis_num(unsigned long data);
void send_char(unsigned char data);
void send_config(unsigned char data);
unsigned short read_temp(void);
void lcd_clr(void);
void increment(unsigned long data);

//   main function
//===================================================================================
//assign variable
   
   unsigned short result;
   unsigned short temp,no;
   unsigned short read_temp(void);

void main(void)
{

ADRESH=0;               //clear A/D result
PORTA=0;
   
      {
         //sensor A
      ADCON0=CHANNEL0;            //CHANNEL1=0b10001001
   //   lcd_goto(8);
            
      read_adc();

      temp=read_temp();
   //   dis_num(temp/10);
   //   send_char('.');
   //   dis_num(temp%10);
   //   send_char(0b10001001);
   //   send_char('C');
   //   send_char(' ');
   //   send_char(' ');
      
      temp=temp;
      }

// display
   ADCON0= 0b10001001;            //configure PortA as digital I/O

   TRISA = 0b111111;         //configure PORTA input
   TRISB = 0b00000000;         //configure PORTB as output
   
//setup USART
   BRGH = 0;               //baud rate low speed option
   SPBRG = 255;            //set boud rate to 1200bps for 20Mhz crystal
   TX9 = 0;               //8-bit transmission
   TXEN = 1;               //enable transmission
   SYNC = 0;               //asynchronous
   
   SPEN = 1;               //enable serial port
   
   
   temp=temp;

   while(1)                  //infinity loop
   {
      if((temp>400))      //   *****************************************
            {                        //   *   LED A and Fan A activated only for    *
               ledA=1;                  //   *   temperature A greater than 40'C      *
                                 //   *   and temperature B less than 35'C   *
               fanA=1;                  //   *****************************************
               
               buzzer=1;
            }   

         else if((temp<400))    //   *****************************************
            {                        //   *   LED B and Fan B activated only for    *
               ledA=0;                  //   *   temperature A less than 40'C and   *
                                 //   *   temperature B greater than 35'C      *
               fanA=0;                  //   *****************************************
               
               buzzer=0;
            }   
         
         else if(send_button==0)      //send the desired number   
         no=temp;

         uart_send(no);            //continuous send data
   
//      delay(2000);
   
      }
   }
   
//==================subroutine ADC=========================

void read_adc(void)
{
   unsigned short i;
   unsigned long result_temp=0;
   for(i=2000;i>0;i-=1)         //looping 2000 times for getting average value
   {
      ADGO = 1;               //ADGO is the bit 2 of the ADCON0 register
      while(ADGO==1);            //ADC start, ADGO=0 after finish ADC progress
      result=ADRESH;
      result=result<<8;         //shift to left for 8 bit
      result=result|ADRESL;      //10 bit result from ADC

      result_temp+=result;      
   }
   result = result_temp/2000;      //getting average value

}

unsigned short read_temp(void)
{
   unsigned short temp;
   temp=result;
   return temp;

}      
      
//   functions
//===================================================================================
void uart_send(unsigned char data)
{   
   while(TXIF==0);            //only send the new data after
   TXREG=temp;               //the previous data finish sent
}
 


and between pr11 and pr16,i change 7segment and connect it to lcd..is wrong?
kembaralalu
Freshie
 
Posts: 6
Joined: Thu Apr 15, 2010 9:09 am

Re: combination between pr11 and pr16

Postby kembaralalu » Thu Apr 15, 2010 4:45 pm

i've combine between pr11,which wired LM35DZ (a) and LM35DZ (b) wireless.so the data will be sending using rf module.in pic16f876a for RX and TX.But after i burn program,the project output is noise after i connected with power supply.
kembaralalu
Freshie
 
Posts: 6
Joined: Thu Apr 15, 2010 9:09 am

Re: combination between pr11 and pr16

Postby ober » Thu Apr 15, 2010 5:07 pm

1. please share your source code properly as shown.
2. It might be hardware problem. how is your wireless temperature sensor works? how is the data being transmitted? How is the wireless data being received? Please eleborate in more details.
3. It might be your source code, we cannot go through every every source code being post by forumer as there are hundreds and thousands of lines. Try to get the error out from your code and discuss.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: combination between pr11 and pr16

Postby kembaralalu » Thu Apr 15, 2010 5:36 pm

tq, :oops:
kembaralalu
Freshie
 
Posts: 6
Joined: Thu Apr 15, 2010 9:09 am

Re: combination between pr11 and pr16

Postby kembaralalu » Thu Apr 15, 2010 7:20 pm

Build C:\Documents and Settings\Asus\Desktop\WIRELESSKU1\WIRELESSKU for device 16F876A
Using driver C:\Program Files\HI-TECH Software\PICC\PRO\9.60\bin\picc.exe

Executing: "C:\Program Files\HI-TECH Software\PICC\PRO\9.60\bin\picc.exe" --pass1 "C:\Documents and Settings\Asus\Desktop\baya\tx.c" --chip=16F876A -P -q -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Executing: "C:\Program Files\HI-TECH Software\PICC\PRO\9.60\bin\picc.exe" -oWIRELESSKU.cof -mWIRELESSKU.map tx.p1 --chip=16F876A -P -q -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"

Memory Summary:
Program space used 173h ( 371) of 2000h words ( 4.5%)
Data space used 1Eh ( 30) of 170h bytes ( 8.2%)
EEPROM space used 0h ( 0) of 100h bytes ( 0.0%)
Configuration bits used 1h ( 1) of 1h word (100.0%)
ID Location space used 0h ( 0) of 4h bytes ( 0.0%)

Running this compiler in PRO mode, with Omniscient Code Generation enabled,
produces code which is typically 52% smaller than in Lite mode.
The HI-TECH C PRO compiler output for this code could be 192 words smaller.
See http://microchip.htsoft.com/portal/pic_pro for more information.

Loaded C:\Documents and Settings\Asus\Desktop\WIRELESSKU1\WIRELESSKU.cof.

WHAT IS THIS MEAN?WHAT SHOULD I DO?
kembaralalu
Freshie
 
Posts: 6
Joined: Thu Apr 15, 2010 9:09 am

Re: combination between pr11 and pr16

Postby kembaralalu » Thu Apr 15, 2010 7:30 pm

this is another error

Error [237] D:\dr pendrive\fypp\ok fyp\Source Code\PR11.c; 43. function "_main" redefined
Error [237] D:\dr pendrive\fypp\ok fyp\Source Code\PR11.c; 295. function "_read_adc" redefined
Error [237] D:\dr pendrive\fypp\ok fyp\Source Code\PR11.c; 313. function "_read_temp" redefined
kembaralalu
Freshie
 
Posts: 6
Joined: Thu Apr 15, 2010 9:09 am

Re: combination between pr11 and pr16

Postby ober » Fri Apr 16, 2010 8:34 am

can you print screen your project window and share it here? Show us what is the files being include under source code and header.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm


Return to DIY Project Set

Who is online

Users browsing this forum: No registered users and 18 guests

cron