• PicŪ Basic

  • PIC with upto 8 (alternating) HPWM extra channels

    I needed 6 channels extra besides the standard built-in HPWM of the PIC. I knew that a standard CMOS Muxer, can fulfill this.

    The only disadvantage is that 1 channel at-a-time can be selected, but that was not a problem (in my case).

    So I toke one CD/HEF4051 connect the Inhibit and the 3 ABC (e.g. BCD) lines to the PIC free ports.

    Rewrote my program a bit, tested, and it works just fine.

    With HPWM frequency of 2000Hz this is not a problem for the 4051, and for low-power applications.

    ; BCD_CD4051 BCD table   ; CD4051 ABC resp. pin 11-10-9 (MSB to LSB)
    ; BCD_CD4051 = %00000000 ; CD4051 Ch 1
    ; BCD_CD4051 = %00000001 ; CD4051 Ch 2 
    ; BCD_CD4051 = %00000010 ; CD4051 Ch 3
    ; BCD_CD4051 = %00000011 ; CD4051 Ch 4
    ; BCD_CD4051 = %00000100 ; CD4051 Ch 5
    ; BCD_CD4051 = %00000101 ; CD4051 Ch 6
    ; BCD_CD4051 = %00000110 ; CD4051 Ch 7
    ; BCD_CD4051 = %00000111 ; CD4051 Ch 8
    ; HPWM out to Pin 3 of CD4051
    ; Low  Inhibit ; output enable  eq. PORTC.5 or any other port
    ; High Inhibit ; output disable eq. PORTC.5
    Symbol Inhibit   = PORTC.5    ; to CD4051 pin 6
    pwm = 127       ; 50% or wathever you choose
    ;from Goto or GoSub (whatever) 
    BCD_CD4051 = %00000000  ; CD4051 Ch 1
    GoSub BCD_OUT
    HPWM 1, pwm, 2000       ; at 2kHz (or lower)  
    HPWM 1, 0, 2000
    High Inhibit             ; CD4051 output disable PORTC.5
    BCD_CD4051 = %00000001  ; CD4051 Ch 2
    GoSub BCD_OUT
    HPWM 1, pwm, 2000       ; at 2kHz (or lower)  
    HPWM 1, 0, 2000          ; The "Ch_off" are all the same, so you can even invoke GoSub, if you like.  
    High Inhibit             ; CD4051 output disable PORTC.5
    ;Repeat this for the next channels, the only differences are BCD_CD4051 bit's, and the Ch x names.
    ; GoSubs section  
    BCD_OUT:                  ; BCD to Port (PORTB as example)
    PORTB.6 = BCD_CD4051.2    ; A pin 11 4051 
    PORTB.5 = BCD_CD4051.1    ; B pin 10 
    PORTB.4 = BCD_CD4051.0    ; C pin  9
    Low Inhibit               ; output enable  PORTC.5
    For more information on the 4051 just Google `CD4051' for the datasheet.

    Do not forget to connect pin 7 and pin 8 to VSS, (e.g. ground), and pin 16 to VDD (e.g. +5v).

    The rest of the pin's is documented in the code.
    How you arrange the channels out from the 4051 is up to you.

    This article was originally published in forum thread: PIC with upto 8 (alt.) HPWM channels extra started by Henk57 View original post
  • Recent Activity



    Thread Starter: normnet

    Coming soon a new IDE: FineLineIDE! Features include:<O:p</O:p Bracket lines linking If-Endif, For-Next etc.<O:p</O:p Tabbed explorer so...

    towlerg Yesterday, 16:49 Go to last post

    Pic16f18877 oread

    Thread Starter: evoortman

    Hi, On a PIC16F18877 the OREAD command doesn't seem to work. The code is working on a PIC16F1939. Both controllers use 32MHz int osc. If i...

    evoortman Yesterday, 11:13 Go to last post

    Multiple functions by a single switch

    Thread Starter: amod

    Hi, How can I use multiple function by a single switch.I want to use 4 functions by a single switch.

    amod Yesterday, 17:15 Go to last post

    FUSES for PIC18F47K20

    Thread Starter: gtv_pic

    000 Good morning I am using the PIC18F47K20 and in the help of the proton I did not locate the FUSES for said micro. Where can I locate...

    hadv215 Today, 00:22 Go to last post