Netduino home hardware projects downloads community

Jump to content

The Netduino forums have been replaced by new forums at This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.


Member Since 21 Jan 2011
Offline Last Active May 14 2017 10:50 PM

#57865 two dc motor with pwm

Posted by Gutworks on 01 May 2014 - 04:53 AM

Hi eurobog and welcome to the Netduino community. Unfortunately I think your question is regarding the Arduino platform which uses a different programming language than the very powerful .Net Micro Framework used on the Netduino. The two platforms are very similar however the code is considerably different. Personally I find it much easier to develop and use the Netduino, but I am a bit biased. :)


Just to be clear, are you using an Arduino or Netduino? If you do have a Netduino I would be more than willing to give you hand with some simple DC motor controls and PWM samples. If you are indeed using an Arduino you may want to post your question on their forum found here: 


Regardless of the platform you use, you're in for a lot of fun.  :)




#55839 A stupid question...

Posted by Gutworks on 03 February 2014 - 06:55 PM

Hmm. Interesting...


Can you right click in the Output window and make sure you have "Program Output" checked? That will also suppress the Debug.Print statements if not checked. 

  • HCB likes this

#55145 PWM using Netduino Go and Shield Base ...

Posted by Gutworks on 02 January 2014 - 08:48 PM

Hi Dave, 
It looks like you are using the Microsoft PWM class rather than the Secretlabs PWM class. The MS PWM class has two constructors, one that is often used for driving pulsing LEDs and piezo buzzers, and the other for devices like servos. I think you should be using the other constructor that looks like this:

public PWM(Cpu.PWMChannel channel, uint period, uint duration, PWM.ScaleFactor scale, bool invert);

Some time ago I wrote a sample app for a servo and the Netduino Go Shield Base and I also have a couple other posts that go a little more in detail about the PWM class. Hopefully so of these links will help you along the way.

#45221 Components Library

Posted by Gutworks on 09 February 2013 - 10:45 PM

Hi Everybody, I'm new to netduino. Just want to see if there is a centralized library which supports various hw components line servos, ir/sonar sensors, LCD screens, etc. I've some bits of code here and there just want to know if somebody has a chance to put them together, Thanks, Ruben

Hi Ruben,


Welcome to the Netduino community. A great place to start is the NETMF Toolboxwhich is maintained by Stefan Thoolen. There are also some examples found on the Netduino Wiki, and Fabien Royer has a library on Github


Happy Hacking!


#44895 New: Netduino 4.3 SDK and VS2012 support!

Posted by Gutworks on 04 February 2013 - 05:23 PM

By Upgrading to the 4.3 SDK am I bringing all the boards under one SDK and no longer requiring separate SDK's to use a specific board? Earlier I had 4.1 for the Netduino then got a Netduino GO and wanted to upgrade everything to 4.2 and I had to remove 4.1 to use it. Then discovered the original netduino didn't work with the upgraded firmware and had to flash it etc etc. All of that equals a big headache. Good learning experience though.


So by doing this upgrade are we removing all the compatibility issues? It would make for an excellent SDK if that is true. I saw that the other Netduinos are qeued for this upgrade so I realize that they are not "Plugged in " to this yet but the post stated that 4.2 boards will work.


I just don't want to download and install 4.3 only to discover that something won't work with it and all the work done on that something is now thrown out the window. Then I have to uninstall and reinstall each SDK to do work on a board compatible with it. lol. So I am reiterating the question :


Does this SDK bring all the boards under one SDK and firmware update?

To my knowledge each board still requires its own latest firmware version to be installed, however with in Visual Studio you can select which NETMF framework you wish to deploy the application to. I have tested a NP1 using 4.1 firmware and NETMF 4.1, NP1 with 4.2 firmware and NETMF, the  NP2 with the latest 4.3, and the Netduino Go using 4.2 firmware and the 4.3 SDK. In all cases each board worked great in both Visual Studio 2012 Pro and Express. 




#44885 Getting Started with Netduino error in Chapter 5

Posted by Gutworks on 04 February 2013 - 04:31 PM

Hi typcs,


Welcome to the community! I loved the Getting Started with Netduino book, and it really gave me a good primer and helped me as someone who had little prior knowledge of microcontrollers and the C# language. Since the book's publication there have been several changes to the .Net Micro Framework, and as a result some of the sections in the book require slight modifications in order for the samples to work. The samples use the Secret Labs AnalogInput and PWM classes, and since the books release, Microsoft has added new PWM and AnalaoInput classes to NETMF 4.2. The good news is that the code will still work but you need to strictly define the classes namespace to avoid conflict with the MS classes.


To do so you will need to add the SecretLabs.NETMF.Hardware.AnalogInput assembly file to your project. To do this you simply:

  • Right click on "Reference" in the Solution Explorer within Visual Studio, generally located to the far right of your screen. 
  • Select "Add Reference"
  • In the .Net Applications tab find and add the SecretLabs.NETMF.Hardware.AnalogInput assembly file. 

Now in your code you need to make sure you fully define the namespace and class name like so:

SecretLabs.NETMF.Hardware.AnalogInput pot = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A0);


After doing this, your project should run perfectly. Once you have mastered the samples in the book you can try the Microsoft's AnalogInput and PWM classes, which you will see used often in more recent code samples. They have slightly different constructors, and accept different arguments when you create a new instance of them. There are a few examples found in our forums when you're ready to give it a shot. 


Happy hacking and if you have any other questions feel free to post them here in the forum. 




#44675 A fast way to fry a netduino plus 2

Posted by Gutworks on 31 January 2013 - 04:54 PM

I shed a tear this morning reading your post. I have yet to lose a loved one in such a way, but I'm sure that day will come. To commemorate this sad occasion I thought I'd pen something for its tombstone. 

Posted Image



Sad Regards,


#44392 Netduino Libraries / Code examples

Posted by Gutworks on 28 January 2013 - 03:21 PM

Hi KevinT,


Welcome to the Netduino community! 


Stefan has also created a fantastic library that includes an ever expanding list of devices and helper class for the Netduino. The .Net Micro Framework Toolbox can be found here:


Fabien Royer has also created several libraries that can be found in the Netduino Helpers repository Codeplex. They also maintain some great libraries for the Netduino Go which can be found in their bitbucket repository


Happy hacking!


#44216 SPI Configuration and the various Modes

Posted by Gutworks on 26 January 2013 - 08:04 AM

Hi CW2,
Thanks for your great primer. It was very useful and quickly help me get my head wrapped around those settings. Originally in my SPI sample code I was simply creating an array with 3 bytes directly in the Write method (i.e. spi.WriteRead(new byte[] { 1, 2, 3 }); ). Because of that I never really got to see the effects of passing it an buffered array that would be commonly used in SPI communications. 
For example if one were to create two arrays to hold the data that will be sent and received as such:

sendBuffer = new byte[10];receiveBuffer = new byte[10];sendBuffer[0] = 0x01;sendBuffer[1] = 0x02;sendBuffer[2] = 0x03;spi.WriteRead(sendBuffer, receiveBuffer); //No offsets used

The resulting output would look like this:
Attached File  NP2_SPI-Mode_0-Offsets.jpg   65.78KB   49 downloads
And if instead I new I only need the first three meaningful bytes, I could use the offsets as such:

sendBuffer = new byte[10];receiveBuffer = new byte[10];sendBuffer[0] = 0x01;sendBuffer[1] = 0x02;sendBuffer[2] = 0x03;spi.WriteRead(sendBuffer, 0, 3, receiveBuffer, 0, 3, 0);

And the resulting output would look a lot cleaner:
Attached File  NP2_SPI-Mode_0-Offsets-3.jpg   62.11KB   52 downloads
As for the ChipSelect_SetupTime and ChipSelect_HoldTime I found that the setup and hold times seem to have a bit of padding when initialized at 0s, which is mentioned in the Wiki. Interestingly enough the NETMF API documentation for SPI is a bit sparse and has some incorrect information. There it states, "The setup time for the chip select port, in milliseconds.", however we see with the logic anlazyer that it's in fact measured in microseconds. There's also a missing constructor for the Configuration class, but I won't get into that right now :)
Here's what Mode 0 and a setting of 0s for both the ChipSelect_SetupTime and ChipSelect_HoldTime look like with the following code:

SPI.Configuration spiConfiguration = new SPI.Configuration(				     Pins.GPIO_PIN_D10, //Chip Select pin				     false,     // Chip Select Active State low				     0,         // Chip Select Setup Time 0us				     0,         // Chip Select Hold Time 0us				     false,     // Clock Idle State				     true,      // Clock Edge				     500,       // Clock Rate in kHz				     SPI_Devices.SPI1); //SPI ModuleSPI spi = new SPI(spiConfiguration);while (true){	spi.Write(new byte[] { 1, 2, 3 });}

And the output looks like this:
Attached File  NP2-SPI-Mode_0-ChipSelect_SetupTime-0.jpg   67.82KB   55 downloads
And by adding 20s to each setting, we see this result:
Attached File  NP2-SPI-Mode_0-ChipSelect_SetupTime-20.jpg   65.16KB   37 downloads
Note that the additional 20s to the ChipSelect_SetupTime did not translate into exactly 23.5625s (3.5625s + 20s) but rather 18.6875s. I don't believe it really has any adverse affect to the data, but curious none the less. 
Anyway, It's time for me to grab some shut eye. Thank you everyone for your input thus far. I'm learning a ton and will hopefully be able to pass some of that knowledge off to other people just starting to get their SPI feet wet. 




P.S. These tests were done with the latest Netduino Plus 2 Firmware,

#43950 Unexpected Error when leaving DFU Netduino plus 2

Posted by Gutworks on 22 January 2013 - 05:28 PM

Hi endo, 


To erase your Netduino Plus 2 you need to do the following:

1. Detach your Netduino 2. Press and hold your Netduino's pushbutton while plugging it in via USB; this will put it in bootloader mode. 3. Erase the firmware on your Netduino using the STDFU Tester application > a. Select the "Protocol" tab > b. Press the "Create from Map" button > c. Select the "Erase" radio button option > d. Press the "Go" button > e. Wait for erase process to complete


In your description you are using "Create Empty" and it should be "Create from Map".


Once the erase procedure has completed close the STDFU Tester applicaiton and open up DfuSe Demonstrator without unplugging your Netduino. Then follow these instructions laid out by Chris:

4. Flash the attached .DFU file using the ST DfuSe Demonstrator application (included with STDFU Tester) > a. Locate the "Upgrade or Verify Action" pane (bottom-right pane) > b. Press "Choose..." and select the attached DFU file > c. Check the "Verify after download" option > d. Press "Upgrade". It will take a few minutes to update your Netduino. > e. Detach and reattach your Netduino (power cycle) or press "Leave DFU mode"


This should work smoothly but just make sure you don't quit the DfuSe Demonstrator application until the process is complete.


Hope this helps.



#43946 Reasonable frequencies for PWM? Did I screw up my Netduino?

Posted by Gutworks on 22 January 2013 - 04:39 PM

Hi Verdis,    This one stumped me for a bit as well. Hopefully from what I've learned from Chris, Wikipedia, Physics class, and this community, can shed some light on this topic which comes up often.   Most of the PWMs on the Netduino are 16-bit, which means that the largest value you can use for the period, in microseconds, is 65,535. The number 65,535 is the the largest unsigned integer one can have for a 16-bit value ( 2^16 = 65,535). So in this case we need to make sure we don't provide frequencies to the MS PWM constructor that will result in a value great than 65,535 microseconds or more commonly seen as ?s.   To find out what the resulting period will be for any given frequency we can use the formula, period = 1/frequency, where the frequency is measured in hertz (Hz) and the period in seconds.    So let's have a look at your scenario where you would like to have a frequency of 1Hz. Plugging this into our formula we find that we have 1/1 = 1 s. If we convert 1 second to microseconds we have a value of 1,000,000?s. We now can see that 1,000,000?s is much larger than the largest possible value of 65,535?s due to the 16-bit PWM. And if we attempt to use that value the compiler gets incredibly cranky, and in older firmware versions would corrupt the Netduino, though I have found this isn't the case any longer with the latest NP2 firmware.


So what is the lowest frequency we can use for the 16-bit PWMs? Well the formula for frequency is 1/period. So if we convert our max period value of 65,535?s, which is 0.06535 seconds, we get ~15.26Hz. Rounding it up to ensure compatibility we get 16Hz as the lowest value. Unfortunately this isn't as low as you would like it, but alas, there is a possible workaround!


As I said at the start, "most" PWMs use 16-bit, however if you are using the Netduino Plus 2, the STM32F4 has a 32-bit PWM snuck in there. Looking at the datasheets we see that the 32-bit timer TIM2/TIM5 is on pin PB10. And lucky for us that pin is mapped to D10 on the Netduino Plus 2.


So what does this all mean? We now have access to a much larger period, 2^32 = 4,294,967,295?s! And if you try your 1Hz frequency using D10, or PWM_3, it should work since the period of a 1Hz frequency is 1,000,000?s which will fit nicely inside of a 32-bit value. 


Hopefully this has shed some light on PWM. Happy hacking!





P.S. I'm not near my Netduinos at the moment, so I haven't tested D10 just yet, but it should work in theory. :)

#43674 Blinkin' LED code not working

Posted by Gutworks on 18 January 2013 - 05:02 PM

Thanks for the test Dave! Just a point of clarification the new assembly file for the NP2 is actually named Netduino.dll :)


James, a thought just came to mind. In addition to upgrading your firmware, have you installed the new SDK? If not, then I highly suggest you do, otherwise you will need to manually replace the old Netduino.dll with the new one. 


The SDK can be found on the Netduino downloads page.



#43544 Cheap Sound Modules?

Posted by Gutworks on 16 January 2013 - 05:30 PM

You can find Stefan's SOMO-14D code and samples here: http://netmftoolbox....pported devices


It's one of the few devices that I don't have from Stefan's list of devices. I think perhaps it's time to order me some SOMO. :)



#43475 Netduino 2 Pinout Reference Sheet

Posted by Gutworks on 15 January 2013 - 07:55 PM

Hi everyone,


Here is a pinout and reference sheet to help you with your Netduino 2. It's really exciting to see the Netduino family grow and I hope this can help you with your upcoming Netduino 2 projects. 


In case you're wondering, the image is intentionally large, however it makes it difficult to move around using the forum's lightbox. To open the pinout zoomed out, click here: Netduino 2 Pinout


Attached File  Netduino2-Pinout-v1.jpg   121.63KB   86 downloads



#43398 Shield Base Firmware (beta 5)

Posted by Gutworks on 14 January 2013 - 05:41 PM

Hi everyone, 


If interested I have updated the Shield Base pinout to reflect the changes found in this Beta 5 update. You can find the post here: http://forums.netdui...ld-base-pinout/




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.