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.

John Cutburth

Member Since 27 Jan 2012
Offline Last Active Dec 09 2013 03:06 PM
-----

Topics I've Started

Netduino Plus fw 4.2.0 Error reading Tacho from 12v Fan

14 August 2013 - 05:33 AM

I am trying to read the RPM from the tacho sensor on a 12v fan but am getting errors once the fan spins up.

 

Error:

Failed allocation for 17 blocks, 204 bytes

private static double _lastPulse = 0;private static double _lastDifference;public static void Main(){    /*Fan Pin Layouts        * Red - +12Vdc        * Black - GND        * White - TACH/Sense        */    var input = new InterruptPort(Pins.GPIO_PIN_A0, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);    input.OnInterrupt += new NativeEventHandler(OnFanRotation);    var button = new InterruptPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);    button.OnInterrupt += new NativeEventHandler(OnButtonPress);                Thread.Sleep(Timeout.Infinite);}static void OnButtonPress(uint data1, uint data2, DateTime time){    if (_lastDifference > 0)    {        const int milliSecondsPerMinute = 60000;        var milliSecondsPerRotation = _lastDifference * 2; //2 Pulses per rotation        var rpm = milliSecondsPerMinute / milliSecondsPerRotation;        Debug.Print("RPM: " + rpm.ToString());    }}static void OnFanRotation(uint data1, uint data2, DateTime time){    var current = Utility.GetMachineTime().Ticks / TimeSpan.TicksPerMillisecond;    if (_lastPulse > 0)    {        _lastDifference = current - _lastPulse;        //2 pulses per rotation'    }    _lastPulse = current;}

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.