Question

Discuss PIC and electronic related things

Moderators: David Barker, Jerry Messina

Post Reply
CharlieM
Registered User
Registered User
Posts: 211
Joined: Wed Oct 10, 2007 12:05 am

Question

Post by CharlieM » Sat Mar 20, 2010 12:39 am

Hello All,

I want to control Timing of a 2 cycle engine. What would be the best way to go about this. I tried some ideas,but they don't seem to work very well. I need to controll timing down to < 200 RPM and up to 4000. I am going from 5 degrees BTDC to 28 to 30 BTDC. Thanks. I am aware that I will need at least one timer maybe two. Maybe CCP?
Running version 2.2.4.0 ICC 1.2.1.0
Regards CharlieM

CharlieM
Registered User
Registered User
Posts: 211
Joined: Wed Oct 10, 2007 12:05 am

Post by CharlieM » Sun Mar 21, 2010 12:05 pm

Hi everyone,

I have been reading up on CCP. http://ww1.microchip.com/downloads/en/D ... /ccpwm.pdf

I understand the capture part. Basically If I have the ccp pin to capture a falling edge every time the ccp pin sees a logic 0 the ccpL:ccpH register will be loaded with the timer1 value. Is this correct? The Compare mode is where I get a little lost. From what I am reading it seems that the ccp pin when timer1 value and ccpl:ccpH values match will toggle? Can I set up a interrupt on another pin? Using CCP seems the best way to go with this,but I am open to suggestions. :wink:
Running version 2.2.4.0 ICC 1.2.1.0
Regards CharlieM

MattH
Registered User
Registered User
Posts: 51
Joined: Mon Jan 01, 2007 8:03 pm
Location: Allentown, PA

Post by MattH » Sun Mar 21, 2010 1:05 pm

Hi Charlie,

You're on the right track. CCPM is the right way to do it.
You got the capture part right.
Is this correct?
Yes. That's correct.
For the compare part, you can use any pin (e.g. INT0, INT1) to create an interrupt. In your INT routine just enable the compare mode and start timer 1. At match, CCPx will toggle and also creates an interrupt.

Matt

CharlieM
Registered User
Registered User
Posts: 211
Joined: Wed Oct 10, 2007 12:05 am

Post by CharlieM » Sun Mar 21, 2010 4:25 pm

Thanks Matt. That is what I needed to know.
Running version 2.2.4.0 ICC 1.2.1.0
Regards CharlieM

Post Reply