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.

Mark Anderson

Member Since 26 Dec 2013
Offline Last Active Feb 20 2014 02:10 PM
-----

Topics I've Started

Deploy via web

03 January 2014 - 11:19 PM

Hi Guys

 

I'm considering commercializing a project I'm working on. If I did, is there anyway to install updated via web (using a built-in web client: i.e. the user would have an option to check for updates and if available download and apply). 

 

I don't see any way to do this, but I'm wondering if I missed something. Is there another option other than a user having to know how to use MFdeploy?

 

Regards

 

mark

 


Detect Dry Contact Closure

02 January 2014 - 05:46 PM

Hi Guys

 

What's the easiest way to detect a dry contact state (I can use either NO or NC). it's a float switch and max frequency will be every 10 secs. Would like to use interrupt rather than polling and use on board power supply if possible.

 

Regards

 

Mark


Help understanding some C# for LED strip

01 January 2014 - 02:29 PM

Hi Guys

 

I bought one of these: http://www.adafruit.com/products/306 and can drive it from netduino using the modified example code on the adafruit site:

using Microsoft.SPOT.Hardware;        public static void LightStripSpi()        {            var spi = new SPI(new SPI.Configuration(Cpu.Pin.GPIO_NONE,                false, 0, 0, false, true, 10000, SPI.SPI_module.SPI1));            var colors = new byte[3 * 32];            var zeros = new byte[3 * ((32 + 63) / 64)];             while (true)            {                // all pixels off                for (int i = 0; i < colors.Length; ++i) colors[i] = (byte)(0x80 | 0);                // a progressive yellow/red blend                for (byte i = 0; i < 32; ++i)                {                    colors[i * 3 + 1] = 0x80 | 32;                    colors[i * 3 + 0] = (byte)(0x80 | (32 - i));                    spi.Write(colors);                    spi.Write(zeros);                    Thread.Sleep(1000 / 32); // march at 32 pixels per second                }            }        }

I can't for the life of me figure out what line 8 is doing:

 

var zeros = new byte[3 * ((32 + 63) / 64)];

 

I know it's creating a byte array. I assume the values of 63 and 64 are related to the no of LED's (32). Pretty poor example really: would be much clearer if no of LED's was defined as a variable or const.

 

Anyway why not just use: 

 

new byte[3 * 32]

 

I've never used byte arrays before, but it looks like byte[3 * 32] creates an array of 96 bytes (which makes sense: 1 byte per color * 3 * 32 LEDs) and it looks like byte[3 * ((32 + 63) / 64) creates a byte array of 4.453125 bytes - clearly this can't be what it's doing. Can anyone enlighten me?

 

It also seems that the zeros array never gets initialized to anything, so I'm surprised spi.Write(zeros) actually does clear the LEDs.

 

Is there a reason why line 13 isn't just:

 

[color=rgb(0,0,0);font-family:monospace;font-size:13px;]spi[/color][color=rgb(102,102,0);font-family:monospace;font-size:13px;].[/color][color=rgb(102,0,102);font-family:monospace;font-size:13px;]Write[/color][color=rgb(102,102,0);font-family:monospace;font-size:13px;]([/color][color=rgb(0,0,0);font-family:monospace;font-size:13px;]zeros[/color][color=rgb(102,102,0);font-family:monospace;font-size:13px;]);[/color]

 

Also, I'm not sure what line 17 does:

 

colors[i * 3 + 1] = 0x80 | 32;

 

I know it's writing a value to the i-th array member, but not sure why the color is OR'd with the color value. I guess it's just setting the MSB to 1, but not sure why.

 

TIA

 

Mark

 

 


Getting Started with Interrupts

27 December 2013 - 09:48 PM

Hi Guys

 

I'm just getting started with Netduino (done a little arduino stuff). My first project is a sump pit/pump monitor. I have the water level monitoring working on arduino and figure that will be easy to move over when I get my netduino (next week).

 

What I need to add are two things:

 

  • Pump operation stats 
  • RS232 messaging to a home automation server (send current water level, pump stats)

 

For No 1, I need to detect when the pump runs (from an external sensor: currently a float switch, but will change to current sensor later). So this will need to be interrupt driven. I reckon I can figure that out from the examples I've seen. Where I'm "stuck" is what happens when there is an interrupt (new area for me, but I do do know difference between a regular interrupt and NMI).

 

Right now I'm thinking a tread that loops continually and takes a reading of the water level every x-seconds. It will then send a message over RS232 with the value. I may use a network connection to something like thingsalk later. If the pump runs while reading the distance sensor or sending the message, it will generate an interrupt, but I don't know what that does to any executing code. 

 

Can someone give me a brief explanation or point me in right direction?

 

TIA 

 

Mark


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.