erfan.khalilian69
Member level 4
- Joined
- Feb 7, 2011
- Messages
- 71
- Helped
- 3
- Reputation
- 6
- Reaction score
- 3
- Trophy points
- 1,288
- Location
- Kualalampur
- Activity points
- 1,916
exactly what type of motor is it and how is it interfaced?
how will you measure the 90degrees?
if (BUTTON1 != 0)
for(i=0;i<45*5; i++) // for 45 seconds
{
RC3 = 1;
__delay_ms(1.5); // delay for 2 milliseconds
CLRWDT();
RC3 = 0;
__delay_ms(18.5);
CLRWDT();
}
if (BUTTON1 != 0)
for(i=0;i<45*5; i++) // for 45 seconds
{
RC3 = 1;
__delay_ms(1.5); // delay for 2 milliseconds
CLRWDT();
RC3 = 0;
__delay_ms(18.5);
CLRWDT();
}
volatile int tenthMillSecCounter=0; // incremented every 10mSec
// Timer 0 is programmed to interrupt every 0.1mSeconds
// T0 clock is FOSC/4 = 200000
// with 1:2 prescaler decrements 2000000/2 times / second
// to get an interrupt every 0.1 mSec the calculation for TMR0 overflow from 0xFF to 0 is
// count = 255 - 1000000/10000 = 255 - 100
// i.e. for 0.1mSec counter is
#define tenthMillSec 155
static void interrupt isr(void)
{
if (T0IF) // A TMR0 interupt occurred
{
TMR0=tenthMillSec; // increment counters every .1 mSec
tenthMillSecCounter++;
}
T0IF=0; // clear TMR0 interrupt flag
}
// delay for count tenths of a second
void tenthMilliSecondDelay(int count)
{
tenthMillSecCounter=0; // zero counter
while( tenthMillSecCounter < count) ; // wait
}
// initalise clock, set port A for digital input, set up timer 0, etc
void systemInitialise(void)
{
OSCCON=0x70; // Fosc use oscillator 8MHz
ANSEL=0; // set digital inputs
OPTION=0x80; // TMR0 RATE 1:2
TMR0=tenthMillSec; // initialise timer 0 counter
T0IE = 1; // enable interrupt on TMR0 overflow from 0xFF to 0
GIE = 1; // Global interrupt enable
}
systemInitialise();
if (BUTTON1 != 0)
for(i=0;i<45*5; i++) // for 45 seconds
{
RC3 = 1;
tenthMilliSecondDelay(15); // delay for 1.5 milliseconds
CLRWDT();
RC3 = 0;
tenthMilliSecondDelay(185);
CLRWDT();
}
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?