um regarding the while(1) in manual mode, i need that to display my times in a cycle 10 seconds>20 seconds>30seconds>etc>10seconds again. without it, it's not looping around it.
#include <pic.h>
__CONFIG (0x3F32);
#define led1 RB1
#define led2 RB2
unsigned int varinc;
unsigned long counter;
void main(void)
{ TRISB = 0b00000000;
TMR1H = 11; // preset for timer1 MSB register
TMR1L = 220; // preset for timer1 LSB register
counter = 0;
T1CKPS1 = 1; // bits 5-4 Prescaler Rate Select bits
T1CKPS0 = 1; // bit 4
T1OSCEN = 0; // bit 3 Timer1 Oscillator Enable Control bit 1 = on
T1SYNC = 1; // bit 2 Timer1 External Clock Input Synchronization Control bit...1 = Do not synchronize external clock input
TMR1CS = 0; // bit 1 Timer1 Clock Source Select bit...0 = Internal clock (FOSC/4)
TMR1IE = 1; // enable Timer1 interrupts
PEIE = 1; // bit6 Peripheral Interrupt Enable bit...1 = Enables all unmasked peripheral interrupts
GIE = 1; // bit7 global interrupt enable
TMR1ON = 1; // bit 0 enables timer
while(1);
}
void interrupt ISR(void)
{
if(TMR1IF)
{
varinc++;
led1=~led1;
if(varinc==10)
{
counter++;
led2=~led2;
varinc = 0;
}
TMR1IF=0;
TMR1H=11;
TMR1L=220;
}
}
void tenminutes(void)
{
TMR1ON=1;
while(counter<10)
{
motor_1 = 1;
motor_speed = 115;
lcd_clr(); // clear LCD screen
lcd_goto(0) ; // set the position of message to be displayed
send_string("Drying In "); // send message to be displayed
lcd_goto(20); // set the position of message to be displayed
send_string("Process. ");
if(counter>=10)
{
motor_1 = 0;
motor_speed = 0;
lcd_clr() ; // clear LCD screen
lcd_goto(0) ; // set the position of message to be displayed
send_string("Drying Is "); // send message to be displayed
lcd_goto(20); // set the position of message to be displayed
send_string("Complete! ");
}
}
}
@stan4, if i don't happen to see you today, i want to ask, can i turn on my motor while my interrupts are working?
i tried just now with this code:
Code:void tenminutes(void) { TMR1ON=1; while(counter<10) { motor_1 = 1; motor_speed = 115; lcd_clr(); // clear LCD screen lcd_goto(0) ; // set the position of message to be displayed send_string("Drying In "); // send message to be displayed lcd_goto(20); // set the position of message to be displayed send_string("Process. "); if(counter>=10) { motor_1 = 0; motor_speed = 0; lcd_clr() ; // clear LCD screen lcd_goto(0) ; // set the position of message to be displayed send_string("Drying Is "); // send message to be displayed lcd_goto(20); // set the position of message to be displayed send_string("Complete! "); } } }
and the result isn't so good: when i select the time i want, the motor only moved for like 0.1ms, stopped, and resets itself to main menu where i have to select manual or auto mode again.
i kept trying by selecting time and run it till it came to a point where my LCD displayed alot of rubbish characters, but my motor still won't turn, and kept resetting to main menu. there was once where my motor turned vigorously like mad and stop. that's just it. and it never ran for 10 seconds :\
what do you think i can do? btw timer1 interrupt is working fine. i think i should demonstrate my LCD + PIC on a PCB now.. breadboard's a little unstable. gonna sleep now it's 2.15am
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?