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.

Gauss

Member Since 22 Apr 2011
Offline Last Active Aug 09 2015 03:13 PM
-----

Topics I've Started

Queue's available for Netduino?

11 October 2013 - 05:15 PM

Ok, so I have a little project with heating elements, and based on a temperature differential the netduino will ask for a certain number to be on.

 

I am trying to create a little object which uses a Queue to equalize the loading on all of them so I don't manually have to swap them out to ensure even wearing over time.

 

Problem is the Queue initialization seems to be returning null, but its just the standard Queue from System.Collections. Does the .NET MF not actually implement Queue?

 

Code:

public class Balancer{              public Balancer(Cpu.Pin[] relayPins)        {            _avail = new RelayList(false);            foreach (Cpu.Pin relaypin in relayPins)                _avail.Enqueue(new Heater(relaypin));        }}public class RelayList{        protected bool _isActive;        protected Queue _list;        public RelayList(bool isActive)        {            _isActive = isActive;            _list = new Queue();        }        public virtual object Dequeue()        {            if (_list != null)                return _list.Dequeue();            return new object();        }        public virtual void Enqueue(object toAdd)        {            if (_list != null)                _list.Enqueue(toAdd);        }}

As you can see, _list is a Queue. I was concerned because the _avail.Enqueue was not putting the Heater objects into the Queue.

 

When I started my debug, basically the if(_list != null) in Enqueue was failing, so I walked through the constructor and, after the _list = new Queue() line, _list is still null. Am I doing something wrong? Is their a limit on call stack depth (this code is called about 4 deep during intialization, Main -> Balancer -> RelayList -> Queue)? Would that cause an error like this or would it throw an exception?


float vs. double in code

09 October 2013 - 04:51 PM

So, I am somewhat curious about the backend implementation of the .NET MicroFramework.

 

I am programming a temperature monitoring system for my house and using the Netduino to do all the interpretation and logic to drive everything.

 

I have been using floats since my temperature sensor is only accurate to ~0.1 degrees, my issue is AnalogInput, most of the built in Math library functions, and any deicmal number I type in the program seems to use use doubles, which I have been casting as floats for my math.

 

Is this actually saving me anything? Since we have a 32-bit uC, I presume this is saving a memory location and register for operations with my program because double is 64-bit, but for all I know I am adding an operation without gaining anything because all the calculations will still be done using double.

 

I have a code snippet below of what I am talking about:

	    private static float GetTemp()	    {		    return (((float)0.442368) * (float)_adc.Read()) - ((float)4.92304);	    }

0.442368, 4.92304, and _adc.Read() are being treated as doubles according to the IDE, and I am casting as a float.


Adafruit LCD Shield and I2C on the Netdunio Plus

24 September 2013 - 02:24 PM

Ok, I am looking to repurpose my Netduino plus relative to what it is currently doing and my new project requires an LCD screen.

 

The issue I am running into is that I am using the original Netdunio plus and seem to have issues confirming operation since everybody compares the current Arduino with the Netdunio plus 2, so I decided to come here since you guys are the experts :P

 

I'm looking to pick up this shield (http://www.adafruit.com/products/772) or equivalent, in this case the LCD is controlled through I2C.

 

Now I have never done any I2C with the original Netdunio Plus, but per the hardware specs (http://www.netduino....oplus/specs.htm) I should have:

analog pins 4-5: I2C SDA, SCL

 

I just wanted to confirm, that means my analog pin 4 is I2C SDA and pin 5 is I2C SCL and that I should be able to drive this LCD shield through those pins.

 

Are there any other concerns? Anybody done anything like this? Anything else I should be looking at?

 

Thanks in advance guys.


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.