HPWM signal transfered to an other pin!


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118

    Default HPWM signal transfered to an other pin!

    Hi,

    Using PBP 2.6
    16F627A, 4MHz

    Using HPWM Duty Cycle 50% at 40Khz for a period of 150 us with waiting time of 1 ms between periods.
    It is generating the signal on RB3 as expected.
    (Yup, the book says max of 32767Hz but it works at 40KHz)
    It obviously have something to do with "long version of PBP" which I don't know the difference between the "long" and the "not long version"
    I am just glad I seam to have the long version!


    Getting back to my question, I am driving an ultrasonic transducer but applying the signal to only one of its pins does not generates enough Tx power.
    Before I add more hardware I was wondering if it is possible to have RB3 trigger 1 other pin replicating the opposite of RB3s signal which would drive the Tx in a fashion where both Tx pins have opposit voltages (making it 10VPP) ?

    Mike

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    You can cross-feed your HPWM to one of the Hardware Comparators and have it invert the signal.

  3. #3
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    Sounds simple,

    I presume I only need one comparator so I would make CMCON = %100101
    I would then connect RA1 (VIN-) to ground and feed RA2(VIN+) from RB3 (PWM signal)
    I would connect my Tx to RA2 and pick another unsused pin (RB5)

    I figure I would get the inverted signal from RA2 by reading CMCON.7

    But how to I pass the value of CMCON.7 to RB5?

    Or am I going the wrong way?

    This is what works feeding just one pin of the Tx
    Code:
    Main:
    
    ;reset timer
    hpwm 1, 127,40000       ;   Send burst, Ch1, D.Cycle50%, Freq 40Khz
    pauseus 150             ;   length of burst.
    CCP1CON = 0             ;   Turn off PWM
    pause 100               ;   Wait to prevent picking up 
                            ;       noise generated by Tx
    ; detect timer overflow
    ; do the maths
    ; display results
    GOTO Main

    Mike

  4. #4
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    Ok so I think I have my answer (mostly).

    I realized I must use this operating mode to access the output directly from an I/O pin:
    Name:  comp.jpg
Views: 497
Size:  44.4 KB

    Therefore I have used CMCON = %110
    Connected RB3 (PWM signal) to RA0
    and I can see the inverted signal on RA3


    Now I still have an issue, the rising edge of RB3 happens at the same time as the falling edge of RA3 but the rising edge of RA3 happens 4uS after the falling edge of RB3.

    Is there something I can do to fix this?

    Thanks

    Mike

  5. #5
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    Found it...!
    I added a 100K resistor between RA2 and +5, not sure if 100K is the perfect value but it works.

    Thanks for the guidance.

    Mike

  6. #6
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    Now I am starting to feel psycho responding to myself that many times but after putting my glasses on, it is a 180 ohms I have there and the delay is now 80nS, tried 1k and got 120nS, also tried direct but no go.
    So 80nS is acceptable and way better than 4uS.

    If anyone can figure out a way to make it 0 delay that would make things just perfect.

    Mike

  7. #7
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    You won't make it zero. There's hardware between the input and output, and it takes time for the little electrons to wiggle their way through very tiny wiring. You could always strap RA2 directly to +5, but it won't get much better than that. The performance limits are somewhere in the back of the Datasheet.

  8. #8
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    I tried to connect RA2 direct to +5 but that gives me a straight 5 V at RA3

    But its good now, I have improved the range, driving one side of the Tx was 10 feet and now having the inverted output I get 28 feet.

    I will probably improve more when I get to the mechanical aspect.

    Thanks for your help.

    Mike
    Last edited by lilimike; - 22nd April 2010 at 20:27.

Members who have read this thread : 1

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