CCP VS Regular I/O pin?
-
- Posts: 41
- Joined: Sun Dec 30, 2012 9:34 pm
- Has thanked: 5 times
- Been thanked: 4 times
- Contact:
CCP VS Regular I/O pin?
Hi. Well here's the deal. I have been using a pic12f675. I am able to decode PWM and light several leds depending on the PWM as to which ones light up (For radio controlled airplane lights). I also have a project that ramps a beacon (LED) up
and down to simulate a red beacon. It also flashes to bright white LEDS to simulate strobe lights. With the pic12f675, it seems impossible to do both on one chip? The project with the flashing LEDS uses a timer interrupt, while the PWM decoder uses polling (constant ). So, I have ordered some pic12f1840 chips which has a ccp module. I can find no good information on how to use it or WHY it is supposed to be better than a regular I/O pin. I have missed an entire week of excersise because I am consumed with learning this and I really need help. Also, I want to stay with an 8 pin chip for small size, at least for now. Keep it simple for me because I am starting to believe that I am retarded!
and down to simulate a red beacon. It also flashes to bright white LEDS to simulate strobe lights. With the pic12f675, it seems impossible to do both on one chip? The project with the flashing LEDS uses a timer interrupt, while the PWM decoder uses polling (constant ). So, I have ordered some pic12f1840 chips which has a ccp module. I can find no good information on how to use it or WHY it is supposed to be better than a regular I/O pin. I have missed an entire week of excersise because I am consumed with learning this and I really need help. Also, I want to stay with an 8 pin chip for small size, at least for now. Keep it simple for me because I am starting to believe that I am retarded!
-
- Posts: 1314
- Joined: Sun Jan 15, 2012 3:15 pm
- Has thanked: 474 times
- Been thanked: 458 times
- Contact:
Re: CCP VS Regular I/O pin?
Hi Drakkor
These links and pdf's might help, as they describe how it works(bit of heavy reading sorry )
http://www.mikroe.com/chapters/view/6/
http://nptel.iitm.ac.in/courses/Webcour ... me3_16.htm (need to have a search through the text)
http://www.electrosome.com/pwm-pic-microcontroller/ (a bit of text and a c file it may help)
Regards
Dazz
These links and pdf's might help, as they describe how it works(bit of heavy reading sorry )
http://www.mikroe.com/chapters/view/6/
http://nptel.iitm.ac.in/courses/Webcour ... me3_16.htm (need to have a search through the text)
http://www.electrosome.com/pwm-pic-microcontroller/ (a bit of text and a c file it may help)
Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php
-
- Posts: 41
- Joined: Sun Dec 30, 2012 9:34 pm
- Has thanked: 5 times
- Been thanked: 4 times
- Contact:
Re: CCP VS Regular I/O pin?
hi, this is no help as I have been there already . I really need a simple example if you could? Sometime it amazes me that information is so hard to find. I thought I was done using assembly but I wonder if that may be better than Flowcode sometimes?
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: CCP VS Regular I/O pin?
Hi Drakkor,
It's so much easier and quicker creating an embedded application using Flowcode instead of assembly, C & JAL etc
If you want I can take you though step by step on how to generate PWM.
But first can you give some more details.
E.g PWM frequency, osc speed of your target device, using internal and external osc etc.
Using built in PWM is much better than toggling a pin, especially if other factors like delays wait for inputs etc as these will alter the pwm frequency.
Whereas the inbuilt PWM duty or frequency will not be affected.
It's so much easier and quicker creating an embedded application using Flowcode instead of assembly, C & JAL etc
If you want I can take you though step by step on how to generate PWM.
But first can you give some more details.
E.g PWM frequency, osc speed of your target device, using internal and external osc etc.
Using built in PWM is much better than toggling a pin, especially if other factors like delays wait for inputs etc as these will alter the pwm frequency.
Whereas the inbuilt PWM duty or frequency will not be affected.
Martin
-
- Posts: 41
- Joined: Sun Dec 30, 2012 9:34 pm
- Has thanked: 5 times
- Been thanked: 4 times
- Contact:
Re: CCP VS Regular I/O pin?
Hi, I want to decode the pwm, not make it. I have done it by polling on an I/O pin but I want to see how it would be done on a chip with the built in ccp? I just can't find even the simplest of examples anywhere? Any help would be appreciated : )
-
- Flowcode v5 User
- Posts: 211
- Joined: Tue Feb 19, 2013 9:51 pm
- Has thanked: 72 times
- Been thanked: 177 times
- Contact:
Re: CCP VS Regular I/O pin?
Instructions for that are in Microchip's Compiled Tips ‘N Tricks Guide page 3-4. You can also use Flowcode's INT interrupt and achieve similar results. If you use Flowcode's interrupt you still will have to use some C code to enable a timer, to read the timer values and to reset the timer.
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: CCP VS Regular I/O pin?
Yes I understand that, But you wanted to:Drakkor wrote:I want to decode the pwm, not make it.
That's where the built in PWM will be very handy.Drakkor wrote:I also have a project that ramps a beacon (LED) up
and down to simulate a red beacon.
Thought you wanted to do this on one chip?
I was thinking of about 2KHz frequency, but was wondering what you had in mind?
Do you know the what the pulse width is that you want to measure?
I'm assuming the pulses have already been stripped from the RF carrier?
Martin
-
- Posts: 41
- Joined: Sun Dec 30, 2012 9:34 pm
- Has thanked: 5 times
- Been thanked: 4 times
- Contact:
Re: CCP VS Regular I/O pin?
Hi, Yes I do want to do both on one chip. I already have a working project with the leds using TMR0 but I want to be able to turn the beacon and strobes off with one switch on my Radio controlled a plane transmitter. I will be measuring between 1 and 2 ms
pulses. I want to turn it on say.....anywhere above 1.5ms pulse. I am able to figure the timing out myself as I have before but what I think (From the previous reply) Is that when I go to do this on the ccp pin, I will need to add some C-code? So far I have been using the Pic12f675. I ordered some Pic12(l)f1840 (I believe the number is right?) but they have the built in enhanced ccp. I know that I have to learn more C but when you can't simulate it, it makes it a lot of work for a newbie (Unpluging the chip, put in breadboard, etc.... : )
I wonder...does Flowcode 6 simulate C-code? It would sure make it easier for me to test out when I add the C-code? Also, still unsure of the order to assign a variable to a timer FCV_xxxxxx = xxxxxx After the FCV_ does the TIMRx go here or the variable name? Thanks in advance : )
pulses. I want to turn it on say.....anywhere above 1.5ms pulse. I am able to figure the timing out myself as I have before but what I think (From the previous reply) Is that when I go to do this on the ccp pin, I will need to add some C-code? So far I have been using the Pic12f675. I ordered some Pic12(l)f1840 (I believe the number is right?) but they have the built in enhanced ccp. I know that I have to learn more C but when you can't simulate it, it makes it a lot of work for a newbie (Unpluging the chip, put in breadboard, etc.... : )
I wonder...does Flowcode 6 simulate C-code? It would sure make it easier for me to test out when I add the C-code? Also, still unsure of the order to assign a variable to a timer FCV_xxxxxx = xxxxxx After the FCV_ does the TIMRx go here or the variable name? Thanks in advance : )
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: CCP VS Regular I/O pin?
Hi Drakko,
http://www.matrixmultimedia.com/mmforum ... 996#p51996
Won't be able to start on it until later this evening.
Martin
No unfortunately V6 does not simulate C-codeDrakkor wrote:I wonder...does Flowcode 6 simulate C-code?
Take a look at this:Drakkor wrote:still unsure of the order to assign a variable to a timer
http://www.matrixmultimedia.com/mmforum ... 996#p51996
I will see if I can make it easier for you by creating a flowchart that should help you.Drakkor wrote: I already have a working project with the leds using TMR0 but I want to be able to turn the beacon and strobes off with one switch on my Radio controlled a plane transmitter. I will be measuring between 1 and 2 ms
pulses. I want to turn it on say.....anywhere above 1.5ms pulse.
Won't be able to start on it until later this evening.
Martin
Martin
-
- Posts: 41
- Joined: Sun Dec 30, 2012 9:34 pm
- Has thanked: 5 times
- Been thanked: 4 times
- Contact:
Re: CCP VS Regular I/O pin?
Martin, Thank you so much. Once I see how it's done, I won't forget it : )
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: CCP VS Regular I/O pin?
Just working on one thing at a time.
I have created a pulse detector.
If pulse measured at RA5 is less than or = 1.2ms then pin RA0 will be 0V
If pulse measured at RA5 is greater then or = 1.3ms then pin RA0 will be 5V
Flowchart was created the way it was to minimize the C code, so it may not be the best way, but it should be the easiest way to understand how it works.
This is just for testing as I have not tested on actual hardware.
Once pulse detector is proven as working, I will then implement the the LED beacon itself.
Martin
I have created a pulse detector.
If pulse measured at RA5 is less than or = 1.2ms then pin RA0 will be 0V
If pulse measured at RA5 is greater then or = 1.3ms then pin RA0 will be 5V
Flowchart was created the way it was to minimize the C code, so it may not be the best way, but it should be the easiest way to understand how it works.
This is just for testing as I have not tested on actual hardware.
Once pulse detector is proven as working, I will then implement the the LED beacon itself.
Martin
- Attachments
-
- PWM Detector V1.fcf
- (16.25 KiB) Downloaded 269 times
Martin
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact: