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.
I am aGuegu, a freshman in Netduino with a little experience programming on C51. And I come from China.
I just opened my case of Netduino about 1 hour ago. And I just received "Getting Started with the Internet of Things" for 3 days. Hope I can make some new friends here.
Here is my first try of making a breathing LED on the board. It is breathing, Not blinking.
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
namespace _002_BreathingLED
{
public class Program
{
public static void Main()
{
// write your code here
OutputPort ledPort = new OutputPort(Pins.ONBOARD_LED, false);
int i,j;
while (true)
{
i = 1;
for (; i < 0x0f; i++)
{
ledPort.Write(true);
Thread.Sleep(i);
ledPort.Write(false);
Thread.Sleep(0x0f - i);
}
for (; i > 1; i--)
{
ledPort.Write(true);
Thread.Sleep(i);
ledPort.Write(false);
Thread.Sleep(0x0f - i);
}
}
}
}
}
I know that another way to make a breathing LED is by PWM. But I have not got into that yet. The unit in Thread.Sleep() in in Millisecond. That is quite long time for me. Is there anything like _nop_(); exsisted in Netduino?
Hi aGuegu,
Welcome to the boards!
Actually the correct way would indeed be PWM
But if you want a sleep shorter then 1ms, you could check out this thread: http://forums.netdui...dpost__p__12994
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
namespace _002_BlinkingLED
{
public class Program
{
public static void Main()
{
// write your code here
OutputPort ledPort = new OutputPort(Pins.ONBOARD_LED, false);
int iMax=0xff, iMin=1;
int i = iMin;
while (true)
{
for (; i < iMax; i++)
{
ledPort.Write(true);
funDelay(i);
ledPort.Write(false);
funDelay(iMax - i);
}
for (; i > iMin; i--)
{
ledPort.Write(true);
funDelay(i);
ledPort.Write(false);
funDelay(iMax - i);
}
}
}
static private void funDelay(long lTicks)
{
DateTime tNow = DateTime.Now;
DateTime tDue = tNow.AddTicks(lTicks*0x100);
while (DateTime.Now < tDue) ;
return;
}
}
}
Right now, my code is updated that the breath goes much smoother and gentler. I have wrote the funDelay() in my another project doing UART communication with C51. It just turns out that it work perfectly here.
Hi aGuegu,
Also, the hardware PWMs are used to drive four of the digital pins. To make the onboard LED breath/change intensity, you'll need to do software PWM (as you have done--good job!).
Welcome to the Netduino community,
Chris
Also, the hardware PWMs are used to drive four of the digital pins. To make the onboard LED breath/change intensity, you'll need to do software PWM (as you have done--good job!).
Welcome to the Netduino community,
Chris
Hi Chris, I have read your answers to several questions.
I have got the system halt during "Preparing to Deploy Assemblies to the Device" for about a dozen times in my first hour programming Netduino. That is quite annoying. I have tried to use "MFDeploy.exe" to recovery the basic code, however, it could not get the response from Ping. And I have to erase the chip by force.
I am not sure whether there is anything to do with my program. Maybe while cpu is waiting in the loop, it could not response to the signal from USB.
The second question is IDE VS2010, the Key F5 means debugging the code. Nevertheless, in Micro Framework it is also used to deploy the program to the board. It looks like deploying is a sub-function of debugging, which is weired. The case in programming C51 is that compile the code to a file in Hex format, and then burn it to the chip with another program as a downloader. They are seperated. But in the case of Netduino, it feels like these two functions are screwed up.
Hi aGuegu,
If your program is busy sending out lots of data via Debug.Print, that can cause the debugger to have troubles trying to deploy a new app.
Regarding erasing your app, you should be able to do that without any troubles. Are you using the v4.1.0, v4.1.1, or v4.2 beta firmware?
Finally, there is a "deploy" option in Visual Studio--but the traditional workflow for .NET Micro Framework is to deploy and start your app in one step. You can always press F5 and then stop debugging.
BTW, you can copy your app off of the Netduino by "creating an application deployment file" from MFDeploy. This HEX file can then be written to other Netduinos or SAM7X chips for production.
Does that help?
Chris
Thanks Chirs.
All I know is that the firmware I installed is the one downloaded from http://www.netduino.com/downloads. It is 4.1, however I have no idea about the sub-sub-version no. Is there a quick way to check it? Which version do you prefer?
Regarding the deploying, right now the best way I could figure out is that to press F5 to debug & deploy, and after it is done, press shift+F5 to release Netduino. If vs2010 is halted while preparing, unplug Netduino, and press ctrl+break to stop deploying. Then plugin Netduino and press F5 to try again.
I have tried Target > Application Deployment > Create Application Deployment in MFDeploy.exe several times, but the MFDeploy halt on every single time I click it. Do not know why.
Hi aGuegu,
Which versions of Windows are you using?
Also, the pushbutton on your Netduino acts as a reset button (unless you're using it as a button input in your Netduino app). If you press the button on your Netduino, does that help Visual Studio deploy properly?
There may be a bug in the .NET MF SDK or Visual Studio here... If we can reproduce this, let's get a bug report filed at netmf.codeplex.com.
Finally...to get the version of your Netduino firmware, use MFDeploy and select the "Device Capabilities" option. Your version # will be listed as "SolutionVersion" and will be something like "4.1.0.6" or "4.1.1.0".
Chris
I am using Windows XP SP3
The version I got is 4.1.0.6, is it too old? Which version would you prefer?
I just know that the onboard button can be used as a reset, that explains why the onboard led responses to the button, even through there is no code related to the button. Thank you.
The version I got is 4.1.0.6, is it too old? Which version would you prefer?
I just know that the onboard button can be used as a reset, that explains why the onboard led responses to the button, even through there is no code related to the button. Thank you.
Your current firmware should work well, although if you'd like to update to the new 4.2 beta it has some new USB handling code. It is beta--and you'd need to update to the .NET MF 4.2 SDK as well.
Right now, if you push the button on your Netduino (which resets it) when Visual Studio is stuck in deployment...does that workaround the issue for you?
Your current firmware should work well, although if you'd like to update to the new 4.2 beta it has some new USB handling code. It is beta--and you'd need to update to the .NET MF 4.2 SDK as well.
Right now, if you push the button on your Netduino (which resets it) when Visual Studio is stuck in deployment...does that workaround the issue for you?
Chris
Thanks Chris, my Netduino works so good today that I tried deloying different program and it works everytime. Maybe it is because I press shift+F5 in time to release Netduino. Have no idea. I will let you know if I got problem in deploying,