Electronic Circuits and Projects Forum



BoostC Charlieplexed PWM 32

1234511 ... Last »
  1. #1
    Mike, K8LH Mike, K8LH is offline

    BoostC Charlieplexed PWM 32

    Would anyone care to study or critique my very first BoostC program?

    It's a novelty 12F683 program that does 32 PWM brightness levels per LED in a Charlieplexed matrix of 20 LEDs. The refresh rate is 62.5 Hz and each LED duty cycle can be varied from 0% to 20% in thirty two 0.625% (100 usec) steps.

    The picture doesn't seem to show the smooth transitions I'm seeing. In fact you can hardly tell those are green LEDs.

    Mike



    Attached Files
    Last edited by Mike, K8LH; 25th June 2008 at 12:44 PM.

  2. #2
    Pommie Pommie is online now
    Very nice indeed. Managing 32 PWM levels on a 4*5 matrix completely in software is impressive. And a good refresh rate as well.

    Code wise, I like the way you lay it out, especially the comments. I hate the recent trend of putting comments within a procedure and in the code space ( and on every other line). Your full width comments before and right side comments during a procedure (and initialisation) should be mandatory.

    I also like the neatness of the end_of_period and end_of_cycle checks. I'm assuming that you couldn't find a way to avoid the asm - the shift at end_of_period looks like it should be C able.

    The only thing I can see that isn't required is the clearing of PIE1.

    Overall an excellent example. A++.

    Mike.
    0

  3. #3
    BeeBop BeeBop is offline
    WOW!!
    Yes, I must agree with Mike(Pommie); this is very well done, and your source is so well commented and very easy to follow.

    Mike(Mike, K8LH,) I think you should have an award for getting the most punch out of the least resources!!
    0

  4. #4
    edeca edeca is offline
    That's really impressive. I was considering doing something similar with the 8x8 square LED blocks from Futurelec to display patterns, I hadn't considered PWM to dim the lights. I might have to try on a much smaller scale with the Junebug LEDs tonight

    What's the board you are using, it looks like a nice size for prototyping or small projects.
    0

  5. #5
    3v0 3v0 is offline
    Moderator
    Mike: I like it
    0
    Last edited by 3v0; 25th June 2008 at 05:34 PM.
    Please post questions to the forums. PM's are for personal communication.

    BCHS/3v0's PIC C18 Tutorials
    Mondo Tech's Super Probe
    Brian Schmalz's USB Bit Whacker

  6. #6
    Mike, K8LH Mike, K8LH is offline
    Gentlemen,

    Thank you all for the nice comments.

    Pommie,

    I'm still trying to come up with optimized C code to replace those remaining few assembler sections. The C code equivalent for those rlf instructions uses two more words and cycles. I guess I'm being a "tightwad" (grin).

    edeca,

    That's a small Radio Shack proto' board made of phenolic or similar material.

    Regards, Mike
    0

  7. #7
    futz futz is offline
    Quote Originally Posted by Mike, K8LH View Post
    What is that second "jack" thing - lower left? Is that your programming connector? Better lighting and a second 3/4 angle shot would be good.

    Cool little doohickey! You should do a YouTube movie so we can see it in action.
    0
    Last edited by futz; 25th June 2008 at 11:58 PM.
    =========================
    Futz's Microcontrollers & Robotics
    =========================

  8. #8
    Mike, K8LH Mike, K8LH is offline
    I use 3.5mm sterio jacks on proto' boards for TTL232 connections.

    Sorry about the picture. I tried several different shots, lighting, shutter speeds, etc., trying to show off the smooth fade from about 10% to 100% brightness but never did come up with a good shot. I even tried it with red LEDs (below) but "no joy" as the color is all washed out.

    I don't have any video equipment for YouTube. Sorry.

    BTW, thanks for turning me onto BoostC. Writing C code for 12F' and 16F' devices for the first time is a blast.

    Regards, Mike
    Attached Images
    0

  9. #9
    mneary mneary is offline
    The green LEDs look good on my monitor. The brighter ones are a little washed out but the effect is perfect.

    Photography is a lot better than I would normally do.
    0

  10. #10
    futz futz is offline
    Quote Originally Posted by Mike, K8LH View Post
    I don't have any video equipment for YouTube. Sorry.
    You have a digital camera!?!? Never seen one yet that won't do video. That's how I do mine.

    BTW, thanks for turning me onto BoostC. Writing C code for 12F' and 16F' devices for the first time is a blast.
    Kewl, huh? And C code is very very portable from PIC to PIC. I wrote code for 16F88 and with only minor changes ran it on 18F248.
    0
    Last edited by futz; 26th June 2008 at 02:35 AM.
    =========================
    Futz's Microcontrollers & Robotics
    =========================

1234511 ... Last »
Tags
Similar Threads
Thread Starter Forum Replies Last Post
BoostC question.. AddressOf Mike, K8LH Microcontrollers 8 24th June 2008, 11:20 PM
LCD degree symbol with sprintf (BoostC) futz Microcontrollers 29 5th June 2008, 04:19 AM
math.h and lib for BoostC? futz Microcontrollers 3 31st March 2008, 05:29 AM
Charlieplexed code segment for the Cricket Thermostat William At MyBlueRoom Microcontrollers 2 14th March 2006, 04:12 PM
My PIC Projects Site NEW (includes 2 Charlieplexed Display) William At MyBlueRoom Electronic Projects Design/Ideas/Reviews 0 28th February 2006, 01:31 PM
Electronic Circuits  |  Learning Electronics

Join our community with over 100,000 Members! It's free, easy and when you're logged in you have many more features! Click to register.
Page Time: 0.07074 seconds      Memory: 7,407 KB      Queries: 17      Templates: 0