positive going edge trigger?


+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    76

    Default positive going edge trigger?

    Hi all,

    I'm working with PicBasic Pro on a timing issue. My current program watches for a low pulse on a pin. The pin is normally high. The negative going edge trigger starts a timming cycle.

    But I'd like to start the timming cycle on it's positive going edge. The pulse is probably long enough to write several lines of code to accomplish this but I thought there was a simple command in PicBasic Pro that would look for a positive going edge. I want to start the timming cycle at the end of the pulse.

    Any thoughts?

    Thank you,

    Ross
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Hi Ross,

    There's many many many way to accomplish this task. By using a simple IF Then, While loop, or waiting for an Interrupt. These interrupt can be selected on different port with often rising or falling edges. Tell us wich PIC you want to use and we will be able to tell you what are your Interrupt option.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    X VAR BYTE

    SYMBOL P_In = PORTB.0

    PULSIN P_In, 1, X

    ' Start timing cycle here

    PULSIN starts counting on the positive going edge, and stops on 1 to 0 transition allowing you to start your timing cycle after the high-going pulse starts & ends.

    You can just discard the result returned in X if you don't need it.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    76


    Did you find this post helpful? Yes | No

    Default

    Thank you Steve,

    I am aware of multiple ways around the barn. I just didn't know if there was a direct path through the barn... a command that allows you to set execution on the positive or negative going edge of a pulse. I couldn't find such a funciton in PBP but thought I might have overlooked it so I posed the question.

    I am satisfied with my solution and it only added a couple lines of code. Easy enough.

    The project I am working on uses a slave microcontroller to control pulses to a heater (through an alternistor). The zero-cross detector senses when the AC wave form crosses zero and outputs a pulse to the slave. The slave then outputs a pulse to the triac after a variable pause. But the zero-pulse came about 200us before actual zero and ended 200us after zero. If I acted on the beginning of the pulse, then I could never output a pulse at actual zero without fear of missing the next zero-cross. The following snippet should solve that problem.

    If it seems like I'm fussy about my controlling current right down to zero, it's because I'm trying to control many amps of current through three inches of nichrome ribbon (approx 1 ohm of resistance) and maintaining a set temperature. I'm trying to do it without a stepdown transformer. Don't know if I'll get there but I just have to try. :-) Can you say "welding transformer"? :-)

    I am receiving 400us pulses every 8ms. The trailing edge of the pulse is in the positive going direction. Portb is constantly updated with the required power (in one byte). The following waits for the pulse, then waits for the positive going transition to execute.

    wait_for_pulse:
    if portc.2 = 1 then goto wait_for_pulse

    wait_for_positive_edge:
    if portc.2 = 0 then goto wait_for_positive_edge
    pauseus 8276 - portb * 8
    pulsout portc.4,45 'fire alternistor
    goto wait_for_pulse
    end

    Thank you Steve for getting back to me!

    Ross
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  5. #5
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    76


    Did you find this post helpful? Yes | No

    Talking Cudos Bruce!

    Yep... that'd do it!

    Ha!

    Ross
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

Similar Threads

  1. mS Timer
    By whmeade10 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th September 2020, 12:12
  2. RC Servo decoding/encoding using 12F683
    By ScaleRobotics in forum Code Examples
    Replies: 13
    Last Post: - 14th September 2010, 00:49
  3. Replies: 2
    Last Post: - 8th February 2009, 05:10
  4. PIC driven transistor - smoothed signal edge - why?
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th June 2008, 08:58
  5. Need Help... 16f630 Schmitt Trigger
    By tohu thomson in forum mel PIC BASIC
    Replies: 1
    Last Post: - 13th August 2007, 15:13

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts