Thanks in advance for your advice... I'm totally stumped.
I would like to read two PWM sources with the BX and output a combined
signal, somewhat like making my own servo mixer. The end result will
be a downward-looking stabilized camera mount (already working) that
an onboard computer can send an "offset angle." The stabilization
offers a level-reference that allows the offset angle to point, for
example, a very steady 40deg forward and 30deg left. Welcome to my
GPS tracking camera mount!
I have two different PWM generators (one: stabilization by the
autopilot; two: the "offset" PWM signal from a SSC), so I can't
garuntee the frame alignment. I'm okay with some latency, so my idea
was to read a pulse on PWM1, read a pulse on PWM2, do my own mixing,
and output to the single servo.
My problem is that trying to read two PWM sources keeps reverting to
reading from only one source. When I connect the hardware for the
second PWM input, the first PWM input (even though it was working
before) suddenly switches to the same reading as the second PWM input.
It is almost like the command to read the first PWM input is being
overtaken by the shear fact the hardware sees pulses on the second PWM
input pin. Each works individually.
My best guess is that pulsein uses timer1 and maybe I need to force
the second PWM read onto timer2 somehow? I'm out of ideas and don't
know how to do this one. I have been reading around and searching
embeddedrealated for a couple days with no answers popping out.
My code seems simple enough ... what am I missing?
' ----------------------------------------------------------- '
Option Explicit
Public Sub Main()
Dim PulseWidthOne As Integer
Dim PulseWidthTwo As Integer
Delay(2.0)
Do
Debug.Print ""
' Wait for a high pulse on pin 16
PulseWidthOne = PulseIn(16, 1)
Debug.Print "One: "; cstr(PulseWidthOne)
' Wait for a high pulse on pin 17
PulseWidthTwo = PulseIn(17, 1)
Debug.Print "Two: "; cstr(PulseWidthTwo)
Delay (0.3)
Loop
End Sub
' ----------------------------------------------------------- '
Thanks again for any suggestions!
Dan

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )