Multi-Button CSM with Pic16LF722A


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,643


    Did you find this post helpful? Yes | No

    Default Re: Multi-Button CSM with Pic16LF722A

    since the isr TB1 is an accurate timebase you can
    make a new var
    Code:
     kio_inhibit var byte
    modify the I/o key routine
    Code:
    IF KP = 0 THEN '1/0 BUTTON PRESSED
            ;use  p_level to see what state machine is in  0=off ,non zero = on
            if kio_inhibit==0 then
               kio_inhibit=152    ;152*32mS = about 5 seconds
            if  p_level then     
                ccp1con=0 ;must be on kill it
                led=0
                p_level= 0
            else         ;must be off  power to max
                p_level= 5
            endif
           endif
    and add this to the isr

    Code:
    if kio_inhibit then
        kio_inhibit =  kio_inhibit -1
        endif
    now the I/O key is inhibited for 5 sec after being acted on

    I like ART's quote and its so true
    PBP is very well documented, however you’ll notice all examples of command use are also examples of exactly how not to write a cyclic program.
    you need to adjust your way of thinking to loops , states and flags . it opens up a whole new vista
    Last edited by richard; - 25th May 2016 at 08:26.
    Warning I'm not a teacher

  2. #2
    Join Date
    Apr 2016
    Location
    Mi, USA
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: Multi-Button CSM with Pic16LF722A

    Wow, you are awesome. I'll have to try it out to see what it does. Thanks!

  3. #3
    Join Date
    Apr 2016
    Location
    Mi, USA
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: Multi-Button CSM with Pic16LF722A

    Hello again,

    Was that timestamp of 3:12 as in 3:12AM?! I did the modification as above. It works like you explained. It doesn't cycle now, but the 5-second delay is way too long to be able to
    power it up again. If I change the kio_inhibit value to a shorter value, will it just end up cycling again? Is there a means that if the 1/0 button is released it resets the counter to zero so that the button can be used immediately again? The long delay is fine for when the button is being held for an extended period of time. Thanks!

  4. #4
    Join Date
    Apr 2016
    Location
    Mi, USA
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: Multi-Button CSM with Pic16LF722A

    Hello again!

    Just curious as to why there isn't any reference to the PR2 register in the program, for setting up the PWM? If I wanted to increase the pwm frequency to 25Khz, I take it I would have to go to a higher oscillator frequency and use different prescaler values?! Thanks.

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,643


    Did you find this post helpful? Yes | No

    Default Re: Multi-Button CSM with Pic16LF722A

    Just curious as to why there isn't any reference to the PR2 register in the program, for setting up the PWM?
    flicker is virtually invisible to the human eye for switching frequencies above 50 Hz, switching losses increase with frequency , other than that the frequency is irrelevant .
    fine control of the pwm frequency is possible using pr2 at the expense of resolution . since the frequency is largely irrelevant why not have maximum resolution


    If I wanted to increase the pwm frequency to 25Khz, I take it I would have to go to a higher oscillator frequency and use different prescaler values?
    depends on required resolution, @4mHz 25kHz is possible with 1:1 prescale and pr2=39 , however maximum duty occurs @ pwm_duty_reg = 160 , ie pw range is 0 to 160 (instead of 0 to 1023 steps as before)
    Warning I'm not a teacher

  6. #6
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: Multi-Button CSM with Pic16LF722A

    Hi All,

    Has anyone had any experience with a 2 channel CSM slide switch?
    I would like to implement a slide switch rather than an up / down button arrangement to select the PWM output for a LED string.
    In my case, the granularity is quite coarse - only eight steps of PWM selection.

    Any input would be greatly appreciated.

    Cheers
    Barry

  7. #7
    Join Date
    Apr 2016
    Location
    Mi, USA
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: Multi-Button CSM with Pic16LF722A

    Hello,

    Regarding the flicker, you know this and I know this, however, we are trying to match an existing product that is set at 25khz. It appears at lower frequencies
    it is causing their power supply to make audible noise at the PWM frequency. And sure enough, at 1khz, at certain pwm levels, we can hear it in the power supply. I don't have to keep the oscillator at 4khz, but I assume making any changes to the main Oscillator will also affect the touch circuit, as well. I did see in the pwm section of the datasheet that the resolution drops depending on the oscillator frequency after I posted this. Thanks again!

  8. #8
    Join Date
    Apr 2016
    Location
    Mi, USA
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: Multi-Button CSM with Pic16LF722A

    Sorry for the repeated post.
    Last edited by RWright; - 4th June 2016 at 04:11. Reason: Duplicate post

  9. #9
    Join Date
    May 2013
    Location
    australia
    Posts
    2,643


    Did you find this post helpful? Yes | No

    Default Re: Multi-Button CSM with Pic16LF722A

    for barry
    Has anyone had any experience with a 2 channel CSM slide switch?
    I would like to implement a slide switch rather than an up / down button arrangement to select the PWM output for a LED string.
    In my case, the granularity is quite coarse - only eight steps of PWM selection.
    have now, seems to work nicely

    slider as per http://ww1.microchip.com/downloads/e...tes/01250a.pdf
    made on ds board the bottom side is unconnected, slider pad are 10mm*40mm the top is grounded
    covered with sticky tape (durex for a sniker from the euro's)
    see pic
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by richard; - 6th June 2016 at 07:27.
    Warning I'm not a teacher

  10. #10
    Join Date
    May 2013
    Location
    australia
    Posts
    2,643


    Did you find this post helpful? Yes | No

    Default Re: Multi-Button CSM with Pic16LF722A

    a slider design like this on single sided board is worth trying out,i think it would be more sensitive and the board could be painted to encourage the user to slide finger along the horizontal line. next time i'm doing some chemical etching I will make one [if I remember]
    Attached Images Attached Images
    Warning I'm not a teacher

Similar Threads

  1. Replies: 5
    Last Post: - 18th March 2012, 21:40
  2. multi functions button press
    By malwww in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th May 2009, 00:12
  3. Multi-Threading
    By Ted's in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 2nd September 2008, 05:55
  4. Multi-tasking
    By malc-c in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 13th July 2006, 18:50
  5. Multi Interrupt How To ?
    By capitano in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd February 2005, 14:48

Members who have read this thread : 3

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts