Shop OBEX P1 Docs P2 Docs Learn Events
Reading PWM signal from a receiver — Parallax Forums

Reading PWM signal from a receiver

bulkheadbulkhead Posts: 405
edited 2006-06-16 23:16 in General Discussion
I would like to interface a 6ch airplane radio with my javelin for a radio control robot. Has anyone done this before? Is there a VP that takes care of this, or do I need to read it in my main loop?

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-06-16 18:27
    There is no VP for reading pwm signals (only for generating).
    So you are required to do it manually in your mainloop.

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-06-16 22:20
    A possible approach is to combine the ADC vp with the CPU.count() method.

    pwm signal o
    +
    o countPin
    ······· ··········· |
    ··········· ······ [noparse][[/noparse]R1]
    ··············· ··· |·········· +
    o ADC inPin
    ·················Ua·+----[noparse][[/noparse]R]----+----[noparse][[/noparse]R]---o ADC outPin
    ················· · |·········· |
    ················· ·[noparse][[/noparse]C1]········[noparse][[/noparse]C]
    ················· · |·········· |
    ················ ··GND········ GND

    The ADC vp measures the average voltage Ua that represents the pwm dutycycle
    The count() measures the number of pulses in a given timeperiod (eg. 100msec or so)
    From both you can calculate the duration of low and high period of the pwm signal.

    Or use two pulseIn() commands, the first measures a high pulse, the second a low pulse.
    You must assume then that adjacent pulses do not change, or at least not rapidly.

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-06-16 23:16
    Here is a class that uses the double pulseIn() approach.
    I placed it in the folder lib/stamp/core

    regards peter
Sign In or Register to comment.