Menu

Detecting servo pulse train, PULSIN or equiv?

Help
2009-03-28
2013-05-30
  • Nobody/Anonymous

    Hi there,

    Getting started in PIC micro development. I've done a couple of hello world style blinking LED and speaker circuits to cut my teeth on, but would to to progress from here. Just wanted to know if there was a PULSIN command possibly in the works. Looking at hooking up a 12F629 to monitor a spare channel on my R/C car receiver to turn lights on and off (possibly other things later on, baby steps ;) ).

    Any idea for how I would go about monitoring a servo pulse that swings from limit to limit without a PULSIN command?.

    Thanks in advance,
    Ross

     
    • kent_twt4

      kent_twt4 - 2009-04-07

      The undocumented PULSIN command is in the stdbasic.h include/lowlevel folder.  The macro/sub shown below gives the syntax expected.

      'PulseIn
      macro PulseIn (Pin, Variable, Units)
          Variable = 0
          Do While Pin = On
              Wait 1 Units
              Variable += 1
              If Variable = 0 Then Exit Do
          Loop
      end macro

      The other way to accomplish this is to just use the Do While loop, with the appropriate wait state.  In the case of the servo decode, a 'wait 10 us' works best.  You might also expect the RC receiver to invert the signal, and would therefore use, Do While Pin = Off.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.