Shop OBEX P1 Docs P2 Docs Learn Events
Question about the FREQOUT command in SX/B — Parallax Forums

Question about the FREQOUT command in SX/B

T'SaavikT'Saavik Posts: 60
edited 2007-02-16 19:55 in General Discussion
FREQOUT:
Does this command start the pulses and allow the program to continue on, or does it pause until the command is complete? I can't find this information in the sx-key sx/b command help page, is there somewhere else i should be looking?

For example if i do:
    FREQOUT IR_emit_Left, 1, 38000        ' FREQOUT (Pin, Duration in ms 1-255, Freq in hz 1-65335) square wave output
    COUNT Front_IR_Detect, 1, ir_in





Should i get anything in ir_in? Right now I'm trying this, and its not working. i tried adjusting the duration from 1 to 10 to 255 just in case it was too a transmit for my detector. If i bring in an external 38khz IR emitter (a remote control) and shoot it at the detector it does increment ir_in. I've replaced the IR emitter with a led and it does light. I haven't checked the freq of the output yet, my ghetto-scope isn't setup right now.

Comments

  • BeanBean Posts: 8,129
    edited 2007-02-16 19:34
    tsaavik,
    The FREQOUT command stops the program while it is generating.
    If you are using the SX48 you can easily use one of the two timers to generate 38KHz.

    On the SX28, you can create an interrupt to generate the 38KHz (but it make skew timing with other commands).

    The following is all you need for the interrupt routine. Make sure the LEDPin is set to an output.

    INTERRUPT NOPRESERVE 76000
      IR_Emit_Left = ~IR_Emit_Left   ' Toggle left led pin state
      IR_Emit_Right = ~IR_Emit_Right ' Toggle right led pin state
    RETURNINT
    


    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman

    Post Edited (Bean (Hitt Consulting)) : 2/16/2007 7:41:56 PM GMT
  • T'SaavikT'Saavik Posts: 60
    edited 2007-02-16 19:49
    Wow, that is some NICE code, thank you so much!! I originally was trying to do this as an interrupt but the examples i found were so complicated i jumped when i saw the FREQOUT command (plus i like saying freak out).
  • BeanBean Posts: 8,129
    edited 2007-02-16 19:55
    If I remember you are using a 50MHz resonator. That's good, then the interrupt routine won't cause problems as much.

    Yeah Freak-Out... da da da da... da da... da da... Freak-Out [noparse];)[/noparse]
    Okay, I'm showing my age...

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman
Sign In or Register to comment.