caramoan tour package

caramoan tour package

Author Topic: pakilagyan naman po ng comment each line ng mikroC prog n ito  (Read 371 times)

Offline spelter

  • CR2032 Battery
  • **
  • Posts: 26
  • Pogi/Ganda Points: 0
  • Gender: Male
pakilagyan naman po ng comment each line ng mikroC prog n ito
« on: February 12, 2012, 10:16:48 PM »
volatile bit rx_event;
volatile bit sw_u;
volatile bit sw_d;
volatile bit btnSW;

char RxDat[10];
char tmp[7];

#define LswD PORTA.B0
#define LswU PORTA.B1
#define Proxity PORTA.B2

#define TraRED PORTB.B6
#define TraGREEN PORTB.B0

#define MotorDn PORTB.B2
#define MotorUp PORTA.B3

void RxStatus() {               //data receive part
    char *res;
    res = strpbrk("U",RxDat);
    if(res > 0) { sw_d=0; sw_u=1; }
    res = strpbrk("D",RxDat);
    if(res > 0) { sw_u=0; sw_d=1; }
   
    res = strpbrk("R",RxDat);
    if(res > 0) { TraRED = 1; TraGREEN = 0; }
    res = strpbrk("G",RxDat);
    if(res > 0) { TraRED = 0; TraGREEN = 1; }
    res = strpbrk("S",RxDat);
    if(res > 0) { TraRED = 0; TraGREEN = 0; }

}
void main() {
    rx_event=0;
    sw_u=0;
    sw_d=0;
    btnSW=0;
   
    PORTA = 0;
    PORTB = 0;
    TRISA = 0b00000111;
    TRISB = 0b00110010;
    ADCON1 = 0b11111111;
   
    UART1_Init(9600);    //initialize baud rate 9600
    Delay_ms(100);
    PIR1.RCIF = 0;       //?
    PIE1.RCIE = 1;       //?
    RCSTA.SPEN = 1;      //?
    INTCON.PEIE = 1;     //?
    INTCON.GIE = 1;      //?
   
    PWM1_Init(255);      //?
    Delay_ms(100);
    PWM1_Set_Duty(130);  //?
    PWM1_Start();        //?
    Delay_ms(1000);      //?

    while(1) {

       if(rx_event) { rx_event=0; RxStatus(); }
       if(PORTB.B5 == 0) {
          Delay_ms(20);
          if(PORTB.B5 == 1) {
             if(LswU == 0) sw_d=1;
             else if(LswD == 0) sw_u=1;
          }
       }
       
       if(Proxity == 0) {
          Delay_ms(15);
          if(Proxity == 1) {
             Delay_ms(1000);
             if(LswU == 0) sw_d=1;
             UART1_Write_Text("PASS");
          }
       }
       
       if(sw_u) {
          PWM1_Set_Duty(150);
          MotorDn = 0;
          MotorUp = 1;
          sw_u=0;
       }
       if(sw_d) {
          PWM1_Set_Duty(80);
          MotorUp = 0;
          MotorDn = 1;
          sw_d=0;
       }
       if(LswU == 0) MotorUp = 0;
       if(LswD == 0) MotorDn = 0;
       
    }

}
void interrupt(void) {
    if(PIR1.RCIF) {
       UART1_Read_Text(RxDat, "\n", 10);       // "\n"?
       rx_event=1;
    }
}

Philippine Electronics Forum

pakilagyan naman po ng comment each line ng mikroC prog n ito
« on: February 12, 2012, 10:16:48 PM »

Offline Kaizer03

  • Nuclear Reactor
  • ****
  • Posts: 4847
  • Pogi/Ganda Points: 225
  • C#<-->Android<-->Java
    • PhilRobotics
Re: pakilagyan naman po ng comment each line ng mikroC prog n ito
« Reply #1 on: February 12, 2012, 10:20:43 PM »
^

read mikroC manual as well as its MCU's Datasheet...

Lend a hand for those who are in need!=)

Stop Hijacking!=) More Technical Posts!=)
 ;)

Kaizer Killer EX Pre-Alpha

Philippine Electronics Forum

Re: pakilagyan naman po ng comment each line ng mikroC prog n ito
« Reply #1 on: February 12, 2012, 10:20:43 PM »

Offline rdpzycho

  • Technical People
  • Solar Power Satellite
  • *****
  • Posts: 10732
  • Pogi/Ganda Points: 632
  • Gender: Male
  • Respect Begets Respect
    • rdpzycho
Re: pakilagyan naman po ng comment each line ng mikroC prog n ito
« Reply #2 on: February 12, 2012, 10:31:39 PM »
volatile bit rx_event;
volatile bit sw_u;
volatile bit sw_d;
volatile bit btnSW;

char RxDat[10];
char tmp[7];

#define LswD PORTA.B0
#define LswU PORTA.B1
#define Proxity PORTA.B2

#define TraRED PORTB.B6
#define TraGREEN PORTB.B0

#define MotorDn PORTB.B2
#define MotorUp PORTA.B3

void RxStatus() {               //data receive part
    char *res;
    res = strpbrk("U",RxDat);
    if(res > 0) { sw_d=0; sw_u=1; }
    res = strpbrk("D",RxDat);
    if(res > 0) { sw_u=0; sw_d=1; }
   
    res = strpbrk("R",RxDat);
    if(res > 0) { TraRED = 1; TraGREEN = 0; }
    res = strpbrk("G",RxDat);
    if(res > 0) { TraRED = 0; TraGREEN = 1; }
    res = strpbrk("S",RxDat);
    if(res > 0) { TraRED = 0; TraGREEN = 0; }

}
void main() {
    rx_event=0;
    sw_u=0;
    sw_d=0;
    btnSW=0;
   
    PORTA = 0;
    PORTB = 0;
    TRISA = 0b00000111;
    TRISB = 0b00110010;
    ADCON1 = 0b11111111;
   
    UART1_Init(9600);    //initialize baud rate 9600
    Delay_ms(100);     // delay by 100ms
    PIR1.RCIF = 0;       //?
    PIE1.RCIE = 1;       //?
    RCSTA.SPEN = 1;      //?
    INTCON.PEIE = 1;     //?
    INTCON.GIE = 1;      //?
   
    PWM1_Init(255);      //?
    Delay_ms(100);  // delay by 100ms
    PWM1_Set_Duty(130);  //?
    PWM1_Start();        //?
    Delay_ms(1000); // delay by 1000ms

    while(1) {  // loop forever

       if(rx_event) { rx_event=0; RxStatus(); }
       if(PORTB.B5 == 0) {
          Delay_ms(20); // delay by 20ms
          if(PORTB.B5 == 1) {
             if(LswU == 0) sw_d=1;
             else if(LswD == 0) sw_u=1;
          }
       }
       
       if(Proxity == 0) {
          Delay_ms(15); // delay by 15ms
          if(Proxity == 1) {
             Delay_ms(1000); // delay by 1000ms
             if(LswU == 0) sw_d=1;
             UART1_Write_Text("PASS");
          }
       }
       
       if(sw_u) {
          PWM1_Set_Duty(150);
          MotorDn = 0;
          MotorUp = 1;
          sw_u=0;
       }
       if(sw_d) {
          PWM1_Set_Duty(80);
          MotorUp = 0;
          MotorDn = 1;
          sw_d=0;
       }
       if(LswU == 0) MotorUp = 0;
       if(LswD == 0) MotorDn = 0;
       
    }

}
void interrupt(void) {
    if(PIR1.RCIF) {
       UART1_Read_Text(RxDat, "\n", 10);       // "\n"?
       rx_event=1;
    }
}

eto na contribution ko. ;D
‎"Divide each difficulty into as many parts as is feasible and necessary to resolve it."
- Rene Descartes

"For every difficult problem there is always a simple answer and most of them are wrong."
- Clayton Paul

Philippine Electronics Forum

Re: pakilagyan naman po ng comment each line ng mikroC prog n ito
« Reply #2 on: February 12, 2012, 10:31:39 PM »

Offline spelter

  • CR2032 Battery
  • **
  • Posts: 26
  • Pogi/Ganda Points: 0
  • Gender: Male
Re: pakilagyan naman po ng comment each line ng mikroC prog n ito
« Reply #3 on: February 12, 2012, 10:48:33 PM »
salamat po
more details pa po ung sa mga complicated parts naman :)

Philippine Electronics Forum

Re: pakilagyan naman po ng comment each line ng mikroC prog n ito
« Reply #3 on: February 12, 2012, 10:48:33 PM »

Offline spelter

  • CR2032 Battery
  • **
  • Posts: 26
  • Pogi/Ganda Points: 0
  • Gender: Male
Re: pakilagyan naman po ng comment each line ng mikroC prog n ito
« Reply #4 on: February 12, 2012, 10:49:25 PM »
PIC18F1220 pala ginamit ko dito

Philippine Electronics Forum

Re: pakilagyan naman po ng comment each line ng mikroC prog n ito
« Reply #4 on: February 12, 2012, 10:49:25 PM »

Offline gwapa

  • CR2032 Battery
  • **
  • Posts: 39
  • Pogi/Ganda Points: 0
Re: pakilagyan naman po ng comment each line ng mikroC prog n ito
« Reply #5 on: February 12, 2012, 11:57:37 PM »
Read the manual, use google.



is this your homework?

Offline kmb36td

  • Size AAA Battery
  • ***
  • Posts: 82
  • Pogi/Ganda Points: 5
Re: pakilagyan naman po ng comment each line ng mikroC prog n ito
« Reply #6 on: February 13, 2012, 12:27:06 AM »
very bad code.....

happy troubleshooting... hehehe

Offline motion55

  • Technical People
  • Diesel Generator
  • *****
  • Posts: 1882
  • Pogi/Ganda Points: 244
  • Gender: Male
  • Been at this longer than you've been alive.
Re: pakilagyan naman po ng comment each line ng mikroC prog n ito
« Reply #7 on: February 13, 2012, 05:55:47 AM »
Quote
    PIR1.RCIF = 0;       //?
    PIE1.RCIE = 1;       //?
    RCSTA.SPEN = 1;      //?
    INTCON.PEIE = 1;     //?
    INTCON.GIE = 1;      //?
   

Quote
PIC18F1220 pala ginamit ko dito

Pwede ko i-bigay sayo ang sagot pero di mo matutunan paano hanapin. Ituro ko na lang paano hanapin.

Download the PIC18F1220 datasheet. Sa PDF reader, search mo ang RCIF, RCIE, SPEN, PEIE, at GEIE. Makukuha mo ang explanation with a little common sense.


"Set your mind free!"

Offline dummy_c

  • Diesel Generator
  • *
  • Posts: 1588
  • Pogi/Ganda Points: 162
  • Gender: Male
  • If I die 2nyt, 8's bcoz maimai is not at my side!
Re: pakilagyan naman po ng comment each line ng mikroC prog n ito
« Reply #8 on: February 13, 2012, 07:12:21 AM »
Yah nasa data sheet lang yan TS.

    PWM1_Init(255);      //?
    PWM1_Set_Duty(130);  //?
    PWM1_Start();        //?
Ito naman makikita mo ito sa mikroc's PWM example. Or tingin ka lang sa help ng mikroC then search mo PWM.
The world's technology is always changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Offline spelter

  • CR2032 Battery
  • **
  • Posts: 26
  • Pogi/Ganda Points: 0
  • Gender: Male
Re: pakilagyan naman po ng comment each line ng mikroC prog n ito
« Reply #9 on: February 13, 2012, 09:12:22 AM »
salamat.. i'll try :D

Offline dummy_c

  • Diesel Generator
  • *
  • Posts: 1588
  • Pogi/Ganda Points: 162
  • Gender: Male
  • If I die 2nyt, 8's bcoz maimai is not at my side!
Re: pakilagyan naman po ng comment each line ng mikroC prog n ito
« Reply #10 on: February 13, 2012, 09:24:35 AM »
salamat.. i'll try :D

You'll try?? You're funny. ;D ;D ;D ;D ;D ;D
The world's technology is always changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Offline spelter

  • CR2032 Battery
  • **
  • Posts: 26
  • Pogi/Ganda Points: 0
  • Gender: Male
Re: pakilagyan naman po ng comment each line ng mikroC prog n ito
« Reply #11 on: February 13, 2012, 10:25:23 AM »
i saw all the codes but it's a bit hard to understand

Offline dummy_c

  • Diesel Generator
  • *
  • Posts: 1588
  • Pogi/Ganda Points: 162
  • Gender: Male
  • If I die 2nyt, 8's bcoz maimai is not at my side!
Re: pakilagyan naman po ng comment each line ng mikroC prog n ito
« Reply #12 on: February 13, 2012, 04:19:38 PM »
That is why kailangan mo basahin ang datasheet at help file ng mikroC TS.
Huwag na i-try pa. Kasi kailangan talaga eh, kailangan, kailangan. ;D ;D ;D

Trust me if babasahin mo datasheet makikita mo yan. Search mo lang sa datasheet.
Yang PWM nasa mikroC help yan. Search mo lang din.
The world's technology is always changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Philippine Electronics Forum

Re: pakilagyan naman po ng comment each line ng mikroC prog n ito
« Reply #12 on: February 13, 2012, 04:19:38 PM »

 

Privacy Policy

Contact Us: elabph@yahoo.com