XOUT and HPWM


Closed Thread
Results 1 to 22 of 22

Thread: XOUT and HPWM

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hmmm, what I missed was the Polarity of the XOUT signal. The PBP manual didn't really go into too much detail, but i found another document on the web that explained it better. It's description goes like this.
    Transmit to Power Line—Output a high on this line within 200 μ of Zero Crossing
    going high, and hold the line high, to output a one on the power line—that is, to turn on
    the 120 kHz oscillator. Use the same timing with a low output to output a zero. The line
    should be low if the interface is not to transmit data, since that keeps the oscillator off.
    So, 1 turns the 120khz ON, 0 turns it off.

    But with the TRIS bit, it works the other way around. 1 = INPUT (OFF),  0 = OUTPUT (ON). Just a little backwards.

    I think you're right though, the only way around it is to change the XOUT command itself. Fortunately, it's an easy change if you're willing to tamper with the PBPPIC14.LIB file.

    If so, be sure to make a copy of the file before editing, you might want it back the old way later on.

    Your mission, should you choose to accept it, is to ...

    Open the PBPPIC14.LIB file in the PBP folder, and do a search for XOUT. You should see a section that looks like this
    Code:
        ifdef XOUT_USED
      LIST
    XOUT2   movlw   2               ; Default to 2 cycles
    XOUT    movwf   R2              ; Save number of cycles
            movf    RR1, W          ; Get data port
            movwf   FSR             ; Put it into FSR
            movf    RM1, W          ; Get data bit mask
       ;     call    LOWT            ; Set data to low, output
    Comment out the "call     LOWT". We'll handle setting the pin to the correct state manually.

    Then scoll down a little bit to xout1loop and change it like this
    Code:
    xout1loop 
       ;     movf  RM1, W           ; Get data bit mask
       ;     iorwf   INDF, F        ; Set the bit
            comf    RM1, W          ; Get inverted data bit mask
            andwf   INDF, F         ; Clear the bit
    
            movlw   high 1000       ; Pause 1 ms
            movwf   R0 + 1
            movlw   low 1000
            call    PAUSEUSL
    
       ;     comf    RM1, W          ; Get inverted data bit mask
       ;     andwf   INDF, F         ; Clear the bit
            movf    RM1, W          ; Get data bit mask
            iorwf   INDF, F         ; Set the bit
    It just reverses whether it sets the pin high or low.

    Now, to use it ..
    Code:
        TRISB.3 = 1          ' start with output OFF
        XOUT TRISB.3,PORTA.0,[house\lightsOff]
    Fingers crossed

    P.S. Don't blame me if you don't backup the file first.
    DT

  2. #2
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Darrel, that was brilliant!

    Worked the first time. If I wore a hat, i'd have raised it now.

    Thanks and regards,

    Anand

  3. #3
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Darrel, whatever you suggested in the earlier messages worked perfect, and that's made me more ambitious/adventureous/greedy.

    What I wonder is, can this also be achieved using your popular timer0/1 based PWM techniques (instead of the PIC's HPWM) to modulate the XOUT signal? The idea being able to use this with any pic, and on any pin.

    Thanks in advance.

    Regards,

    Anand

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Anand,

    I think at 120kz, the interrupts required to generate that frequency on ANY pin (250,000 per second) would interfere with the timing of the XOUT command.

    I can't think of an easy way off hand.

    DT

  5. #5
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Oh, okay.

    Nothing like actually trying it out, I guess.

    Referring to some of your earlier posts I think I should be able to see if it flies.

    Shall keep this thread posted for the benefit of others, if it works.

    Thanks for all the inputs, Darrel.

    Anand

  6. #6
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Anand,

    The 8-pin 12F683 has HWPM and only costs slightly more than the 12F629 or 12F675. I posted a simple example of turning it on/off using ~120kHz with 1ms bursts at 10ms intervals in another thread recently. Here it is again...
    Code:
    DEFINE OSC 8
    @ DEVICE PIC12F683, INTRC_OSC_NOCLKOUT, MCLR_OFF
    
    TRISIO.2 = 0				'GPIO.2=Output
    PR2 = 17			        'PWM Period   117.7kHz
    CCPR1L = 8				'PWM Duty-Cycle  
    T2CON = %00000100    			'Timer2=ON, 1:1 prescale
    OSCCON = %01110001                      'INT HF OSC 8MHz
    WHILE OSCCON.3>0: WEND                  'OSC startup timeout
    WHILE OSCCON.2=0: WEND                  'INT HF OSC stable
    WHILE OSCCON.2>0 
      CCP1CON = %00001100 'PWM ON
      PauseUS 1000        'generate 1ms burst 
      CCP1CON = 0         'PWM OFF
      Low GPIO.2
      Pause 10            'pause 10ms
    WEND
    The disadvantage of using XOUT is that it cannot send microdim/microbright and cannot send the extended commands X-10 introduced 6-7 years ago.

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hey Anand,

    Still using the 628A ?
    and what OSC ?

    I think I have something for you.

    DT
    Last edited by Darrel Taylor; - 5th May 2006 at 05:49. Reason: Come on... get your butt outta bed, this is Cool!

  8. #8
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel,

    Yes, still on the 16F628, with the internal 4 Mhz oscillator, although I'm hoping to migrate it to an 8 pin (or even 6?) device.

    I could of course use an 12F683 as Dave pointed out, but I'm still curious to see if this can be done without the HPWM module.

    Very eager to see your suggestion!

    Anand

Members who have read this thread : 0

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