XOUT and HPWM


Closed Thread
Results 1 to 22 of 22

Thread: XOUT and HPWM

Hybrid View

  1. #1
    Join Date
    Oct 2004
    Posts
    448

    Default XOUT and HPWM

    Hi, this is about the X10 command. I would like to modulate the signal coming out of X10, at 120 KHz. I can currently do this by using the HPWM on one pin, and getting the XOUT on another, and then combining them externally. This is at the cost of 1 extra pin, and the external circuitry.

    Is there any way that this can be done in software, so that one gets a composite modulated X10 signal out of a single pin?

    Thanks in advance for any suggestions!

    Regards,

    Anand

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


    Did you find this post helpful? Yes | No

    Default

    Hi ardhuru,

    I've never done anything like that before, but after looking at the macro's for XOUT, I think it might be possible.

    But the method used depends on the chip. Which one are you using?

    Darrel

  3. #3
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Currently, the 16F628A for its HPWM. Being able to do it on this would be fine, but if I could achieve it on a 12F629/75, better still.

    Thanks, and I'm hoping you'd have some trick to suggest!

    Regards,

    Anand

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


    Did you find this post helpful? Yes | No

    Default

    628A, OK, that should make it easy.

    XOUT TRISB.3,PORTA.0,[house\lightsOff]


    The idea is that the XOUT command takes a register and a bit for the output pin assignment. Normally this is something like PORTB.0 but it really doesn't matter which register and bit you use.

    So by assigning TRISB.3 as the output, it should modulate the PWM by turning the pins output on and off.

    PBP finds the location of the corresponding TRIS register by simply adding 80h to the PORTs address. For PORTB (06H), TRISB would be 06h + 80h = 86h.   So now, if PBP thinks that TRISB.3 is a physical pin, then it will also try to set the pin to Output by clearing (106h).3 which now lines up with PORTB again in bank2. But since that pin is overriden by the Peripheral select switch, the data doesn't get thru, so all's well.



    The reason I say all of that, is because if you try to do the same thing on an 18F, the registers don't line up next to each other like that, and can cause some pretty nasty problems.

    As for the 12F629/75, I suppose you could set up the timer to generate the frequency using interrupts, and do the same thing with TRIS.

    Should work for SEROUT(2) as well. Assuming it works at all.

    HTH,
       Darrel

  5. #5
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Darrel, thanks for the detailed reply.

    I tried this, and was at first delighted to see a strong(er) signal than what I was getting by the 2-pin method.

    But, it did not work. I notice the waveform looked different from the 2 pin waveform as well (as seen after the transistor that combined the 2 signals).

    I think the problem is, when you control the HWPM *before* and *after* the XOUT line, the spaces between the data bits that XOUT gives, which should remain low, are now consistently transitioning at 120 KHz. I suspect for this to work, like you pointed out earlier, the XOUT macro itself might have to be modified.

    Is my analysis correct, or am I being too dense?

    Regards,

    Anand

  6. #6
    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

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