Menu

PULSIN (measuring pulses)

2007-11-13
2013-05-30
  • Nobody/Anonymous

    Does GCBASIC have a function/command to measure the width of a pulse (Input in PIC).  I see a PulseOut command to send a pulse but is there anything for measuring pulses?

     
    • kent_twt4

      kent_twt4 - 2007-11-13

      Like for decoding a RC or servo signal?  I had a tough time trying to pin down exact timing, whether running a 20mhz osc, or an internal 8mhz osc.  You could try starting and stopping one the Timers.  My inconclusive, and perhaps erroneous?, Timer tests showed up to a 20% variation from the wait routines they captured.

      #define PPM PortA.5
      dir PortA.5 in
      ...
      ...
      Do While PPM On 
      wait 5 us  ;weird time but works, int osc?
      TimerHigh = TimerHigh + 1
      Loop

       
    • Nobody/Anonymous

      Exactly... for R/C servos signals.
      I'll give that a shot.  Thanks.
      Too bad there is no "SERVO" command either...

       
    • kent_twt4

      kent_twt4 - 2007-11-13

      Well the beauty of GCBasic is you can make up whatever command that you want.  With something as simple as a servo command, it should be easy to just make a small subroutine.
      Say like:
      ...
      ...
      Servo(RServo,200)
      ...
      ...

      Sub Servo(servo1,pulse1)
      Set Servo1 On  ;could use Pulseout?
      wait pulse1 10us
      set Servo1 Off
      wait 18 ms
      End sub

       
    • Nobody/Anonymous

      That's great for controlling servos (via PIC output & pulseout)... but I need to read/measure the servo signal (same PWM signal seen by servo).

       
    • kent_twt4

      kent_twt4 - 2007-11-14

      whoops, misunderstood what you meant by "Servo" command.  Is that a documented command for Pic Basic or some other Basic?

       

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.