PWM problem with 16f88

Moderator: Benj

Post Reply
Manie Serrao
Flowcode V4 User
Posts: 26
Joined: Mon Nov 28, 2011 3:19 pm
Location: Cape Town South Afica
Has thanked: 10 times
Been thanked: 2 times
Contact:

PWM problem with 16f88

Post by Manie Serrao »

Hi,

The attached file is my first project I've actually built for use, the idea is that two strips of LED's must continuously fade in and fade out but the strips are 180 degrees out of phase with each other. To drive the LED strips have used TIP 122's, one with a TTL inverter to achieve the "out of phase". Tested manually I can switch the LEDs. The crystal is a 19,608 Mhz with a pair of 10pF caps, a 10k pot with the wiper connected to pin 17 RA0.
I "Compile to chip" with success but when I insert the chip into the circuit I built....nothing. I have coupled the LED's to the 16f88 via pin 6 and pin 9...nothing.
In simulation it appears to work. I found some help in the 4 BUGs Forum ie PIC16F88 RB0 PMW output won't work. by Zane » Mon Aug 15, 2011 10:43 am I have tried the various options suggested namely "ticked" the alternate check box in COMPONENT PROPERTIES, CCP1 muxed option RB0 and RB3 in PIC MICRO CONFIG (EXPERT), plus some of my own combinations, with out success.
I am obviously doing something very wrong PLEASE HELP this frustrated newbie. Regrds Manie
Attachments
PWM BASF free running 16F88.FCF
Two Strips of LED's each continuously fade up and down but 180 degrees out of phase to each other
(13 KiB) Downloaded 392 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: PWM problem with 16f88

Post by Benj »

Hello,

Right I would untick the Use alt pin setting in the PWM component and also change the value in the config to use CCP1 Mux as RB3.

Other then this all your settings look correct so maybe its another problem.

Have you connected VDD to the MCLR pin via a pull up resistor?

Have you connected 22pF ceramic caps between your crystal pins and ground?

Might be worth creating a very basic program that runs in a loop outputting 1 to the LED control pin, delaying, outputting 0 to the pin and delaying again. This way you can count out all PWM related issues and see if the program is running at all.

Manie Serrao
Flowcode V4 User
Posts: 26
Joined: Mon Nov 28, 2011 3:19 pm
Location: Cape Town South Afica
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: PWM problem with 16f88

Post by Manie Serrao »

Thanks for reply, will assemble basic circuit as suggested. But I think the MCLR pull up resistor to Vdd is what I've missed in tutorials. Frustration subsiding, hope growing......nothing like a dangling carrot to keep up the interest...............

Manie Serrao
Flowcode V4 User
Posts: 26
Joined: Mon Nov 28, 2011 3:19 pm
Location: Cape Town South Afica
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: PWM problem with 16f88

Post by Manie Serrao »

Well, happy to say a little progress has been made. I have included a LED with delays, as suggested, into my originol program and physically wired a pull up resistor to the MCLR pin. Result The new LED blinks happily but when I connect the Strip LED's and drivers to PWM output (pin 9, RB3) the new LED contiues to blink but the strip LED's still nothing. In PWM Properties, alternate pin checkbox was left blank, In the Config. Expert Screen I have selected RB3 in "CCP1 Mux pin" option. I have also tried connecting the oscilloscope onto pin 9 and no wave form whatsoever was found. I was expecting to find a 5volt square with a varying mark to space ratio, is my assumption correct.
Any otherpointers / suggestions would be appreciated.

Regards, Manie

medelec35
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: PWM problem with 16f88

Post by medelec35 »

Hi Manie, I have tested attached flowchart and I can confirm the waveform at pin 3 is as expected, measured with an oscilloscope. I have adjusted pot and can vary the rate at which Connected LED fades.
For some reason, to enable waveform at B3 you need to set CCP1 in expert configuration to B3 which is understandable, but you also need to have use alternate pin selected in PWM properties.
Do you realise you need time base on 20uS since PWM has been left at 19.2KHz?

When you set the led to flash, did you do something like:

Code: Select all

While 1
Port b0=1
delay=500ms
Port b0=0
delay=500ms
Loop
Then make sure flash rate is 1Hz

Does not appear to be a bug.
Hope this helps

Martin
Attachments
PWM BASF free running 16F88.FCF
(13 KiB) Downloaded 435 times
Martin

Manie Serrao
Flowcode V4 User
Posts: 26
Joined: Mon Nov 28, 2011 3:19 pm
Location: Cape Town South Afica
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: PWM problem with 16f88

Post by Manie Serrao »

Success, Thanks a lot guys the project working as required, constructed and "performing" in the field.
Am not sure on how to "post a thank you" but please consider this as a HUGE thanks.
Great having you guys there as back up, looking forward to the next project and learning curve, especially understanding and using interrupts.

Best Regards

Manie

medelec35
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: PWM problem with 16f88

Post by medelec35 »

Hi Manie,
Just glad your up and running :)
Thank you for letting us know.

To say thanks you need to be logged on, then click the thumbs up icon (to the right of quote) on the posts you would like to thank

Martin
Martin

Post Reply