Zero cross detect - switching audio


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Zero cross detect - switching audio

    Hank that looks like good logic to me, but to make sure I get where you are heading -
    on switch press, call ISR,
    Inside ISR, wait for the signal to cross zero (in either direction, max time here would be .3333mS?)
    Crossed so do what needs to be done and leave.

    Yes you can use while/end like that.
    Don't forget to set/clear the IOC caller so as not to re-trigger as soon as you leave.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  2. #2
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Zero cross detect - switching audio

    Quote Originally Posted by cncmachineguy View Post
    Inside ISR, wait for the signal to cross zero (in either direction, max time here would be .3333mS?)
    Hi Bert...thanks for the confirmation - yes, you understand what I'm trying to do ...what I would add at this point is the full sequence of events really needs to be like this...

    1. Switch gets pressed
    2. IOC interrrupt routine Entered

    hang around at this point, until....


    3. comparator toggles (zero cross) -> Audio switch control voltage get's 'enabled' as quickly as possible thereafter.

    hang around at this point, until....

    4.Switch gets released (finger removed!)
    5. comparator toggles (another zero cross)-> Audio switch control voltage get's 'disabled' as quickly as possible thereafter.
    6. exit the IOC switch interrupt routine.

    where did your .333mS number come from?

    I don't need to trap the initial switch press too quick (anything sub 4mS will likely be ok), but from the comparator flipping state to the audio switch control voltage changing needs to be as blisteringly fast as I can make it (as obviously, the longer this bit takes the 'further' the AC signal is going to be away from 'zero') ..... 333us seems like a long time!
    Last edited by HankMcSpank; - 30th October 2011 at 15:22.

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


    Did you find this post helpful? Yes | No

    Default Re: Zero cross detect - switching audio

    The delay will vary with the frequency of the audio but if you always switch on the falling edge, you will be slightly ahead of ZC and can add a delay if needed. The app note I referenced details how to calculate the delays for 60Hz - you can adapt it to your audio frequencies.
    Last edited by dhouston; - 30th October 2011 at 15:59.

  4. #4
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Zero cross detect - switching audio

    Aah...tks Dave.

    I should prpbably point out that I'm not after a perfect 'zero' switch...just ahem 'close to zero' (I guess what I really want is an 'avoid switching at signal voltage peak' type of switch!)

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


    Did you find this post helpful? Yes | No

    Default Re: Zero cross detect - switching audio

    Quote Originally Posted by HankMcSpank View Post
    I should prpbably point out that I'm not after a perfect 'zero' switch...
    Perfect would require calculating the difference between Logic 0 and Logic 1 vs ZC for each frequency and for both rising and falling edges. Close enuff is probably using Logic 0 on a falling edge to trigger the switch.

  6. #6
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Zero cross detect - switching audio

    Quote Originally Posted by dhouston View Post
    Close enuff is probably using Logic 0 on a falling edge to trigger the switch.
    :-)

    Bert, ok...just sussed, where you came up with the 333us number!

    1.5khz maximum audio frequency expected = 1/1500 = 660us period .....therefore half a period would be 333us.

    so 'zero cross to signal peak' (90 degrees) at that frequency would be about 150us..... if I can get within 10% of zero @1.5Khz I'd be very happy.

    If I run the PIC at 16Mhz, I reckon I ought to be get reasonably close to zero - even at the maximum expected audio frequency of 1.5Khz - in my mind, 15us is a chunky amount of 'window' to get an audio IC switch after the PIC's comparator has toggled?
    Last edited by HankMcSpank; - 30th October 2011 at 17:10.

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