Prop1 Spin; best method for reflecting a signal
macrobeak
Posts: 354
in Propeller 1
Under certain circumstances I wish to pass through, or reflect a signal unchanged from an input pin to an output pin.
The signal is a standard servo pulse signal from a RC receiver.
Obviously one method is a continuous read and write loop.
Are their any more efficient Spin coding methods to achieve this?
The signal is a standard servo pulse signal from a RC receiver.
Obviously one method is a continuous read and write loop.
Are their any more efficient Spin coding methods to achieve this?
Comments
If you want this to run autonomously, you could launch this method into a cog (with cognew). It uses CTRA to measure the incoming pulse, CTRB to create the outgoing pulse. I made a note where you can adjust the output pulse value. Since this is a Spin cog, you can use a global variable to drive the adjustment.
Warning: I just woke up and this is not tested.
http://forums.parallax.com/discussion/163764/simple-question-about-simpleide-and-fdserial-155200-baud#latest
Edited: 4 counters was actually for 2 signals
POSFEEDBACK = %01001
...
ctra := (POSFEEDBACK<<26)+(dummyPin<<9)+servoInPin
ctrb := (POSFEEDBACK<<26)+(servoOutPin<<9)+dummyPin
dira := |<dummyPin + |<servoOutPin
FWIW, I use something like the code below with some of my quadcopter projects to pass through lines from a RC receiver.
This particular code requires the input pins to on lower numbered pins than the output pins but it would certainly be easy to modify the code to use any group of input and output pins.
I think the above loop runs at 4MHz with an 80MHz clock.
Edit: I had an "or" where a "mov" needed be.
Thank you for your input, much appreciated.
I suspected there would be some elegant solutions to this task, and you have identified and documented them very clearly.
The Prop 1 brains trust has delivered again!