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

    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!

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

  3. #3
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Dave, thanks for the inputs. I could not have designed the actual hardware interface to the mains without your invaluable pointers to powerline carrier articles.

    Are you suggesting that X10 signals would be better generated in PBP without using the XOUT macro? My X10 transmitter is a very basic one, so the micro dim/brights are not an issue.

    I would have loved to have some extended commands though.

    Again, a heartfelt thanks.

    Anand Dhuru

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


    Did you find this post helpful? Yes | No

    Default

    4mhz! You don't believe in making things easy do you.

    but I'm still curious to see if this can be done without the HPWM module
    I believe it can be done on any pin, without any hardware modules, CCP or Timer, and no Interrupts.

    Last time, we used the CCP module to create the 120khz, then used XOUT to turn that output on and off. But during that 1ms period that it's sending a "1", the XOUT command is just spinning it's wheels in a PAUSEUS 1000.

    Instead of just sitting there letting the hardware do all the work, why not just create the frequency in software for 1ms and be done with it.

    Once again, I've never done this, but maybe I can get lucky twice in a row.

    For a 120khz signal of 1ms in duration, we need to create 120 cycles.
    Each cycle is 8.3333 us (1/120,000).
    @ 4mhz it doesn't divide perfectly, so the closest we can get is an 8us cycle which ends up at 125khz. I hope that's close enough.

    First off, in your main program, make a variable like this to use for counting the cycles
    Code:
    LoopCounter  VAR BYTE  $20  SYSTEM

    Now let's go back to the PBPPIC14.lib file. Un-Comment the LOWT line that we had commented previously. This gives back control of the TRIS register to the XOUT command.
    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
    And, change the xout1loop that we modified before, to this ...
    Code:
    xout1loop 
        movlw   120   ; 120khz for 1ms = 120 cycles
        movwf   LoopCounter
        
    xout120loop
            ; ---- 1 cycle of the 120khz ---------------------
            movf    RM1, W              ; 1    Get data bit mask
            iorwf   INDF, F             ; 2    Set the bit
            nop                         ; 3    waist some time
            comf    RM1, W              ; 4    Get inverted data bit mask
            andwf   INDF, F             ; 5    Clear the bit
    
        decfsz   LoopCounter, F         ; 6    Are we done yet?
        goto     xout120loop            ; 8    NO.  Do it again.
    Then, using it should be like normal again ...
    Code:
    XOUT PORTB.3,PORTA.0,[house\lightsOff]
    Once again, Fingers crossed
    <br>
    DT

  5. #5
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default How do you do it?!

    Quote Originally Posted by Darrel Taylor
    4mhz! You don't believe in making things easy do you.


    Once again, Fingers crossed
    <br>
    Time to raise my hat again! That was superlative, Darrel. Worked the first time (that is, as soon as I remembered to switch off the CCP module enabled for the earlier version!). And of course, I confirmed it works as well on any other pin.

    Thanks a ton.

    Anand

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


    Did you find this post helpful? Yes | No

    Default

    Fantastic!

    My luck seems to be getting better.

    I'm thinking it's time for a trip to Vegas.

    You're very welcome, and thanks for the fun project.

    DT

    P.S. Dave's idea sounds pretty good too. More control.
    &nbsp; &nbsp; And Jeff might be happier without us messing with his macro's.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor
    P.S. Dave's idea sounds pretty good too. More control.
    I would love to see an example for the 12F683.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ardhuru
    Are you suggesting that X10 signals would be better generated in PBP without using the XOUT macro? My X10 transmitter is a very basic one, so the micro dim/brights are not an issue. I would have loved to have some extended commands though.
    I think the best approach is to create a procedure (using ASM or using the CCP module) to generate a 1ms burst of ~120kHz and then call it as needed from PBP. That gives you the flexibility to send arbitrary patterns. If you also use Darrel's Instant Interrupt's, you can do the X-10 part in the background, sending a manchester half-bit at each zero-crossing.

    Using the CCP module, you could even use a timer to end the ~120kHz burst and do single or 3-phase in the background with minimal loss of processing time. This would also allow you to listen to the powerline during manchester 0 half-bits to detect collisions. Note that it does no good to listen if using a TW523 or equivalent as it delays its output by 22 powerline half-cycles, acting like a 22-bit shift register with the powerline frequency as its clock.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ardhuru
    Dave, thanks for the inputs. I could not have designed the actual hardware interface to the mains without your invaluable pointers to powerline carrier articles.

    Are you suggesting that X10 signals would be better generated in PBP without using the XOUT macro? My X10 transmitter is a very basic one, so the micro dim/brights are not an issue.

    I would have loved to have some extended commands though.
    Anand,

    There may soon be another possibility. SmartLabs tells me they will release their powerline chips this month. They will cost less than $2 even in single quantities and can do both X-10 and Insteon.

  10. #10
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default Sounds very interesting

    Hi Dave,

    that sounds like a very useful product indeed; almost like a TW523-in-a-chip solutoin. I would look forward to its release.

    In the mean time, my home brew circuit with off the shelf part also seems to be holding its own. In fact, the transformer I used (one from the set used in AM radios), gives out a signal 2 to 3 times in amplitude as the one from the RR501/TM751.

    Regards,

    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