Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

JamieDixon

Member Since 20 Feb 2012
Offline Last Active Oct 02 2016 04:09 PM
-----

#47324 Netduino and RC Receivers (I am using a Spektrum AR600)

Posted by JamieDixon on 18 March 2013 - 12:31 PM

OK, so I got it <almost> working now that I have this knowledge.  I plugged the RC Recevier into the Netduino 5V (I got tired of the 4.8V battery back needing to be rechanged) and I added this code:

        static OutputPort outputPort = new OutputPort(Pins.ONBOARD_LED, false);                public static void Main()        {            InterruptPort inputPort = new InterruptPort(Pins.GPIO_PIN_D0,                true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);            inputPort.OnInterrupt += new NativeEventHandler(inputPort_OnInterrupt);            Thread.Sleep(Timeout.Infinite);        }        static long leadingEdge = 0;        static long priorPulseWidth = 0;        static void inputPort_OnInterrupt(uint data1, uint data2, DateTime time)        {            if (data2 == 1)            {                leadingEdge = time.Ticks;            }            else            {                long currentPulseWidth = (time.Ticks - leadingEdge) / 1000;                long pulseWidthChange = currentPulseWidth-priorPulseWidth;                if(pulseWidthChange > 0)                {                    outputPort.Write(true);                }                if(pulseWidthChange < 0)                {                    outputPort.Write(false);                }                priorPulseWidth = currentPulseWidth;            }        }

 

When I push the stick up, the LED lights (with an occasional flash depending if I stop when I am pulling it)

When I push and leave the stick motionless at max up, the LED flashes

When I pull the stick down, the LED truns off (with an occasional flash depending if I stop when I am pulling it)

When I pull the stcik down and leave the stick motionless at max down, the LED flashes.

 

I am thinking of doing an average to smooth out the noise when I am pulling and pushing the stick.  I can't explain the max and min range blinking though...




home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.