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.
Photo

Netduino Plus fw 4.2.0 Error reading Tacho from 12v Fan

Tacho RPM Fan Netduino Plus 4.2.0 tachometer

  • Please log in to reply
2 replies to this topic

#1 John Cutburth

John Cutburth

    Advanced Member

  • Members
  • PipPipPip
  • 41 posts

Posted 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;}


#2 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 14 August 2013 - 08:35 AM

if the white wire has 12v you fry your netduino

 

id also change the on fan rotation to just cound up, and if 1 sec is over divide it to get the rpm, like a fps counter.

 

but your netduino may not bbe able to read high frequencies.

 

iirc its 10khz max or so.



#3 nakchak

nakchak

    Advanced Member

  • Members
  • PipPipPip
  • 404 posts
  • LocationBristol, UK

Posted 14 August 2013 - 08:43 AM

I suspect line 48 may be the culprit, as it looks like a memory allocation issue.

 

Try moving it into your if statement, also try declaring as a private class member rather than a variable that gets created each interrupt, im guessing that the GC isnt clearing the memory quickly enough, so make that variable longer lived and just update the reference each interrupt instead.

 

i.e.

private static int Current = 0;static void OnFanRotation(uint data1, uint data2, DateTime time){if(_lastPulse > 0){ Current = Utility.GetMachineTime().Ticks / TImeSpan.TicksPerMillisecond;...}...}

Nak.







Also tagged with one or more of these keywords: Tacho, RPM, Fan, Netduino Plus, 4.2.0, tachometer

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.