interrupt problem

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

Re: Regard about my project

Postby shahrul » Wed Jul 13, 2011 4:24 pm

ho2000 WROTE:to let pic capture the feedback from motor i only can use timer1 to do it?

Yes, only use any 1 timer.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: Regard about my project

Postby ho2000 » Wed Jul 13, 2011 4:31 pm

use any 1timer?mean i can use timer 0, timer 1 or timer 2.or just timer1 can capture the feedback?
ho2000
Freshie
 
Posts: 7
Joined: Wed Jun 29, 2011 6:54 pm

Re: Regard about my project

Postby shahrul » Wed Jul 13, 2011 4:36 pm

ho2000 WROTE:use any 1timer?mean i can use timer 0, timer 1 or timer 2.or just timer1 can capture the feedback?

can use Timer0 or Timer1 or Timer2. Normally I use Timer0.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: Regard about my project

Postby ho2000 » Sun Jul 17, 2011 12:37 am

I running the dc motor with encoder using pic16f690 as below is the interrupt code.Do anyone can help me to check on it see whether the interrupt code working well or not in real time testing as i simulate on the isis protest, 7 segmant dun show any value. for more information, the pulse is the square pulse and feedback from the motor.
while (1)
{
if (RA2 == 0)
{
pulse = pulse++;
}
hundred = rpm/100;
ten = (rpm-100*hundred)/10;
one = rpm-ten*10-100*hundred;
PORTC = LEDs [hundred];
PORTB = 0xEF;
__delay_ms(10);
PORTC = LEDs [ten];
PORTB = 0xDF;
__delay_ms(10);
PORTC = LEDs [one];
PORTB = 0xBF;
__delay_ms (10);
}

static void interrupt
isr(void)
{
if (T0IE && T0IF)
{
count = count ++;
}
if (count == 16)
{
rpm = 20*pulse; //formula to calculate the rpm but i thk this formula got problem one
count = 0;
pulse = 0;
}
T0IF=0;
}
ho2000
Freshie
 
Posts: 7
Joined: Wed Jun 29, 2011 6:54 pm

Re: interrupt problem

Postby silveroblado » Mon Aug 15, 2011 2:53 am

I m doing kind of similar project, but what i want to do is that, when my IR sensor detects any obstacle, my dc motor should stop and the value from the encoder should be stored inside the PIC, after overcoming the obstacle my dc motor with encoder starts, again when obstacle comes, my PIC 16f877a should store the value from the encoder (number of pulses or counts) from the start.

When the robot reaches its final destination, the LCD should be able to display the values stored in PIC (counts from encoder), the positions where obstacles were found (straight line).

And the last question I want to ask is why is the name of video of quadrature encoder by cytron been named PID control when they are using PIC, without PID controller!!?

Please give me some hints so that i can start programming.......Till now I can only show the values of the complete journey of my robot using the LCD.....but whats the way of storing the values when it stops at various points!!

I put this question here, because i saw the video!!
silveroblado
Apprentice
 
Posts: 32
Joined: Mon Aug 15, 2011 2:30 am
Location: Kuala Lumpur

Re: interrupt problem

Postby robosang » Mon Aug 15, 2011 10:10 pm

Basically you just use a few registers to record the value of encoder when the IR sensor sensed obstacle and at the end display all those value from registers on LCD one by one. Might also use array.

Actually I did not study what the video about, but PID control is a software algorithm, it can apply in any system. You don need a PID controller(hardware) to apply PID :lol:
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Previous

Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 1 guest

cron