VS2012 NetduinoPlus 4.2 firmware - Netduino Plus 2 (and Netduino Plus 1) - Netduino Forums
   
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

VS2012 NetduinoPlus 4.2 firmware


Best Answer dbradshaw, 28 February 2013 - 09:53 AM

Hi Chris,

If you want to create a small repro (<20 lines of code) that changes the PWM of the onboard LED and post it...we'll be happy to replay it here and provide a solution directly.


 

Would that be something like the file I attached in my first post and the modified version I attached in my latest post?

So I attach a copy of the solution and would ask if someone would like to open the solution in VS2012 and run the code on a netduino plus with 4.2.0.1 firmware and tell me if it works or not.

 

I'm waiting for the delivery of a Plus2 before I revisit this properly again but in the meantime if the attached sample assists then great; once again thanks for your help.

 

The plus2 arrived and the PWM code works fine - so I'll mark this thread as solved -  shame the plus2 is faulty (no Ethernet connectivity - no led on pcb or on network switch) and is about to be returned.

 

Dave

Go to the full post


  • Please log in to reply
16 replies to this topic

#1 dbradshaw

dbradshaw

    Member

  • Members
  • PipPip
  • 18 posts
  • LocationUK

Posted 22 February 2013 - 11:26 PM

[font="arial, helvetica, sans-serif;"]I have a netduno plus - version 1 (Rev a pcb). I want to use VS2012 Professional to develop code so I believe I need the following[/font]

  • [font="arial, helvetica, sans-serif;"].Net Micro Framework SDK 4.3[/font]
  • [font="arial, helvetica, sans-serif;"]Netduino SDK v4.3[/font]
  • [font="arial, helvetica, sans-serif;"]Netduino 4.2 Firmware (because the 4.3 firmware for the netduino plus is not yet available)[/font]

[font="arial, helvetica, sans-serif;"]I followed the instructions at http://www.geekality...irmware-update/ to update the firmware which involves[/font]

  • [font="arial, helvetica, sans-serif;"]Short 3v3 to small pad near Digital I/O 0[/font]
  • [font="arial, helvetica, sans-serif;"]Power cycle netduino plus[/font]
  • [font="arial, helvetica, sans-serif;"]Run sam-ba[/font]
    • [font="arial, helvetica, sans-serif;"]Select at91sam7x512-ek as device type[/font]
    • [font="arial, helvetica, sans-serif;"]Execute Boot from Flash Script[/font]
    • [font="arial, helvetica, sans-serif;"]Execute Enable Flash Access script[/font]
    • [font="arial, helvetica, sans-serif;"]Download TinyBooterDecompresser.bin[/font]
    • [font="arial, helvetica, sans-serif;"]Answer No to Lock Flash Areas[/font]
  • [font="arial, helvetica, sans-serif;"]Power cycle netduino plus[/font]
  • [font="arial, helvetica, sans-serif;"]Run MFDeploy[/font]
    • [font="arial, helvetica, sans-serif;"]Select at91sam7x512-ek as device type[/font]
    • [font="arial, helvetica, sans-serif;"]Download ER_CONFIG & ER_FLASH[/font]
  • [font="arial, helvetica, sans-serif;"]Power cycle netduino plus[/font]

[font="arial, helvetica, sans-serif;"]Target – device capabilities gives the following output[/font]

 

Ha[font="'courier new', courier, monospace;"]lSystemInfo.halVersion: 4.2.0.0[/font]

[font="'courier new', courier, monospace;"]HalSystemInfo.halVendorInfo:   Netduino Plus (v4.2.0.1) by Secret
Labs LLC[/font]

[font="'courier new', courier, monospace;"]HalSystemInfo.oemCode:   34[/font]

[font="'courier new', courier, monospace;"]HalSystemInfo.modelCode:   177[/font]

[font="'courier new', courier, monospace;"]HalSystemInfo.skuCode:   4097[/font]

[font="'courier new', courier, monospace;"]HalSystemInfo.moduleSerialNumber: 00000000000000000000000000000000[/font]

[font="'courier new', courier, monospace;"]HalSystemInfo.systemSerialNumber: 0000000000000000[/font]

[font="'courier new', courier, monospace;"]ClrInfo.clrVersion: 4.2.0.0[/font]

[font="'courier new', courier, monospace;"]ClrInfo.clrVendorInfo:   Netduino Plus (v4.2.0.1) by
Secret Labs LLC[/font]

[font="'courier new', courier, monospace;"]ClrInfo.targetFrameworkVersion: 4.2.0.0[/font]

[font="'courier new', courier, monospace;"]SolutionReleaseInfo.solutionVersion:   4.2.0.0[/font]

[font="'courier new', courier, monospace;"]SolutionReleaseInfo.solutionVendorInfo:
Netduino Plus (v4.2.0.1) by Secret Labs LLC[/font]

[font="'courier new', courier, monospace;"]SoftwareVersion.BuildDate:   Sep 19 2012[/font]

[font="'courier new', courier, monospace;"]SoftwareVersion.CompilerVersion:   410894[/font]

[font="'courier new', courier, monospace;"]FloatingPoint:   True[/font]

[font="'courier new', courier, monospace;"]SourceLevelDebugging: True[/font]

[font="'courier new', courier, monospace;"]ThreadCreateEx: True[/font]

[font="'courier new', courier, monospace;"]LCD.Width:   0[/font]

[font="'courier new', courier, monospace;"]LCD.Height: 0[/font]

[font="'courier new', courier, monospace;"]LCD.BitsPerPixel: 0[/font]

[font="'courier new', courier, monospace;"]AppDomains: True[/font]

[font="'courier new', courier, monospace;"]ExceptionFilters: True[/font]

[font="'courier new', courier, monospace;"]IncrementalDeployment:   True[/font]

[font="'courier new', courier, monospace;"]SoftReboot: True[/font]

[font="'courier new', courier, monospace;"]Profiling:   False[/font]

[font="'courier new', courier, monospace;"]ProfilingAllocations: False[/font]

[font="'courier new', courier, monospace;"]ProfilingCalls: False[/font]

[font="'courier new', courier, monospace;"]IsUnknown:   False[/font]

 

[font="arial, helvetica, sans-serif;"]When I execute the following code from VS2012 all is well and the blue led flashes - I can edit the time delay and redeploy the code successfully.[/font]

using System;

using System.Net;

using System.Net.Sockets;

using System.Threading;

using Microsoft.SPOT;

using Microsoft.SPOT.Hardware;

using SecretLabs.NETMF.Hardware;

using SecretLabs.NETMF.Hardware.NetduinoPlus;

 

namespace _1000_HelloWorld

{

  public class Program

  {

  public static void Main()

  {

  OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);

  lcd myLcd = new lcd();

  {

  bool ledState = false;

  while (true)

  {

  ledState = !ledState;

  led.Write(ledState);

  Thread.Sleep(500);

  }

}

 }

  }

 

  public class lcd

  {

  public lcd()

  {

//PWM backlightPwm0 = new PWM(Cpu.PWMChannel.PWM_5, 10, 100, false);

  }

  }

}

 

[font="arial, helvetica, sans-serif;"]However when I un-comment the PWM line the code deploys successfully but does not run and not only does VS2012 become un-responsive when stopping the “execution” but I need to repeat 1) through 6) in order to try again![/font]

 

[font="arial, helvetica, sans-serif;"]I've attached the project files as a zip archive.[/font]

 

[font="arial, helvetica, sans-serif;"]I'm very probably doing something wrong or have incompatible hardware/software/firmware and would be grateful for a pointer because I can now flash new firmware without need to consult the documentation having  repeated the process several times on both my Windows 8 desktop and Wndows 7 laptop machines.[/font]
 

Attached Files



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 22 February 2013 - 11:58 PM

HI dbradshaw, Cpu.PWMChannel.PWM_5 won't work on Netduino Plus 1. The new gen2 Netduinos have 6 PWM channels (0-5), but the gen1 gear only have 4 PWM channels (0-3). I'd also recommend using PwmChannels.PWM_PIN_D# to choose the PWM channel. That way you'll get an exception if you try to use one of the new gen2 channels...and it's easy to tell which pin is used. Welcome to the Netduino community, Chris

#3 dbradshaw

dbradshaw

    Member

  • Members
  • PipPip
  • 18 posts
  • LocationUK

Posted 23 February 2013 - 02:50 AM

Hi Chris,

 

Thanks for the advice - I was wondering how to sensibly map the actual pins to the PWM channels.

 

PWM backlightPwm0 = new PWM(PWMChannels.PWM_PIN_D3, 10, 100, false);

 

 

The above is much more sensible - however it still doesn't run and still corrupts the board. I'm beginning to think the best way forward is to get a Plus 2 which would use 4.3 firmware.

 

Has anyone used PWM successfully on 4.2 firmware with 4.3 SDK?

 

 

Dave



#4 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 23 February 2013 - 10:34 AM

you set the output to netmf 4.2 in properties?



#5 dbradshaw

dbradshaw

    Member

  • Members
  • PipPip
  • 18 posts
  • LocationUK

Posted 23 February 2013 - 10:46 AM

Target Framework = .Net MicroFramework 4.2

Output Type = Console Application



#6 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 24 February 2013 - 11:46 PM

Hi dbradshaw, In your PWM constructor, your period is 10us and your duration is 100us. Period needs to be at least as long as the duration. Duration is the amount of time that the PWM is held high. If you were looking for 100% dutycycle instead, use the constructor with doubles and specify the dutyCycle parameter as 1.0. Does that help? Chris

#7 dbradshaw

dbradshaw

    Member

  • Members
  • PipPip
  • 18 posts
  • LocationUK

Posted 25 February 2013 - 12:04 AM

Hi Chris,

 

The intellisense on my machine suggests two methods with the following signatures

  • CPU.PWMChannel channel, double frequency_Hz, double dutyCycle, bool invert
  • CPU.PWMChannel channel, uint period, uint duration, PWM.ScaleFactor scale, bool invert

 

I'd assumed  was using the first one because I am only supplying 4 values - not 5 (does this logic not apply in the MicroFramework and Netduino world).

 

Good suggestion though I never thought of changing the values - I'll try my code again with different values and let you know how it goes.

 

Dave



#8 dbradshaw

dbradshaw

    Member

  • Members
  • PipPip
  • 18 posts
  • LocationUK

Posted 25 February 2013 - 02:31 AM

Chris,

 

Sorry but any one of the following lines cause the board to be trashed. I'm beginning to remember why I put the netduino plus back in an anti-static bag two years ago just after I first purchased them - so much promise but soooooooooooo frustrating. :rolleyes:

 

 

//PWM backlightPwm0 = new PWM(PWMChannels.PWM_PIN_D3, 10, 100, false);

//PWM backlightPwm0 = new PWM(PWMChannels.PWM_PIN_D3, 100, 10, false);

//PWM backlightPwm1 = new PWM(PWMChannels.PWM_ONBOARD_LED, 100, 10, PWM.ScaleFactor.Milliseconds, false);

 

 

Dave



#9 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 25 February 2013 - 03:30 AM

Hi Dave,

Okay, none of those three lines of code will work. Let me help tweak each of them with you...

PWM sample #1
PWM backlightPwm0 = new PWM(PWMChannels.PWM_PIN_D3, 10, 100, false);
This dutyCycle is being set to 10,000% (value of 100, range is 0.0-1.0). If you change the constructor as follows, it should work for you:
PWM backlightPwm0 = new PWM(PWMChannels.PWM_PIN_D3, 10, 1.0, false);
PWM sample #2
PWM backlightPwm0 = new PWM(PWMChannels.PWM_PIN_D3, 100, 10, false);
Sorry, I glanced at the constructor earlier and didn't realize you were using the frequency and dutyCycle constructor. So my advice wasn't terribly helpful. Please ignore :) For the solution, see the code sample above this one.

PWM sample #3
PWM backlightPwm1 = new PWM(PWMChannels.PWM_ONBOARD_LED, 100, 10, PWM.ScaleFactor.Milliseconds, false);
100 milliseconds is too long of a period for 16-bit PWM. 65ms is about the longest period you can get. If you change the ScaleFactor to MicroSeconds (1/1000th of a millisecond) it should work for you.

We're going to take a long look at how the new PWM classes handle invalid parameters and see if we can throw some exceptions. Exceptions would be a much happier way to handle this rather than having NETMF get grumpy and asserting.

Does this help get you up and running with PWM?

Chris

#10 dbradshaw

dbradshaw

    Member

  • Members
  • PipPip
  • 18 posts
  • LocationUK

Posted 25 February 2013 - 11:37 AM

Hi Chris,

 

Sorry but either line still causes the problem

 

I apreciate your efforts to help me and either we will resolve this and I'll become a convert to Netduino or I'll put the Netduino back in its nice warm anti-static bag and go back to AVR Studio and GCC - where at least I know what I'm doing.

 

Every time I try this as a solution and it fails I have to wipe the board, install the bootloader and then install the micro framework (so I've done this three times this morning - each line un-commented seperately and the second one with the onboard led flash disabled to check it didn't interfere with using PWM on the led).

 

If this is a coding error on my part (e.g. invalid values) then the code not working or working in an unexpected way fine - but having to reflash the board is a pretty hefty price to pay for a typo.

 

 

 

Dave

 

 

 

//PWM backlightPwm0 = new PWM(PWMChannels.PWM_PIN_D3, 10, 0.60, false);//PWM backlightPwm1 = new PWM(PWMChannels.PWM_ONBOARD_LED, 100, 10, PWM.ScaleFactor.Microseconds, false); 

(On the plus side I've found the code tags in the forum editor)



#11 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 25 February 2013 - 12:18 PM

you nearly got it :)

its: //PWM backlightPwm0 = new PWM(PWMChannels.PWM_PIN_D3, 1000, 0.6f, false);

 

you cant use too low frequenzy (iam not sure whats the smallest value is you can use, theres a thread about it, gutworks explained it there)

 

first value is the pin, second is the freuqenzy in hz, thrid is the duty cycle in percent, 4th is the inverting setting (like 0.1f duty gets to 0.9f than -

thats just that you can use the same code for different external circiuts, cos it makes a difference wich transistor and such you choose, npn, pnp)



#12 dbradshaw

dbradshaw

    Member

  • Members
  • PipPip
  • 18 posts
  • LocationUK

Posted 25 February 2013 - 01:32 PM

Hi Noom,

 

That also doesn't make any difference - I would expect the compiler to warn if it explicitly needs a float; trying 1000 for the frequency also made no difference.

 

I'm still concerned that it trashes the bootloader and/or framework - at the end of the day all the PWM code needs to do is set a few bits in some counter timer registers and put a couple of 8 bit values in some more registers - even if the values were rubbish why does the whole board become unresponsive?

 

Either I have

  • Wrong/incompatible versions of libraries or 
  • I have missed something in the answers above or
  • It doesn't work or
  • Something else (suggestions on a postcard)

 

So I attach a copy of the solution and would ask if someone would like to open the solution in VS2012 and run the code on a netduino plus with 4.2.0.1 firmware and tell me if it works or not.

  • If it works for someone else then it eliminates 2.
  • If it works and someone else has different versions of firmware or libraries then I might be able to find out what I need to change - particularly if they can post the output from MFDeploy - Target capabilities for me to compare with mine - or similar info from their dev environment.
  • If it doesn't work for someone else it might be 3 and I can take comfort in the knowledge that at I am not alone.

 

Fortunately this is not mission critical for me - I only added an LCD to have a status display and the PWM was only a test to control the backlight as the first stage after HelloWorld/BlinkLed test program :-)

 

 

Dave.

Attached Files



#13 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 25 February 2013 - 01:57 PM

it doesent warn you cos float is a lot of numbers, in fact 10(.0) is a float too.

 

in anohter thread chris mentioned to call pwm.Start();  -- so i think thats the problem here



#14 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 28 February 2013 - 06:57 AM

Hi dbradshaw, If you want to create a small repro (<20 lines of code) that changes the PWM of the onboard LED and post it...we'll be happy to replay it here and provide a solution directly. And yes, you do need to call PWM.Start() to start the PWM objects that are created. Also...what is probably happening with the out-of-range arguments is that the native code side of NETMF is not properly throwing an ArgumentException. We're currently looking into that with the 4.2.2.3 release. Unfortunately when the native side asserts, the thread scheduler is suspended so the board appears to be unresponsive. You can usually work around this by pressing the ERASE button in MFDeploy immediately after plugging in your board...to erase the current app...but the nuclear option of erase-and-reflash-the-board always works as a backup backup too. BTW...the minimum PWM frequency is around 32Hz. Maximum PWM frequency is 1MHz. Does that help at all? Chris

#15 dbradshaw

dbradshaw

    Member

  • Members
  • PipPip
  • 18 posts
  • LocationUK

Posted 28 February 2013 - 09:53 AM   Best Answer

Hi Chris,

If you want to create a small repro (<20 lines of code) that changes the PWM of the onboard LED and post it...we'll be happy to replay it here and provide a solution directly.


 

Would that be something like the file I attached in my first post and the modified version I attached in my latest post?

So I attach a copy of the solution and would ask if someone would like to open the solution in VS2012 and run the code on a netduino plus with 4.2.0.1 firmware and tell me if it works or not.

 

I'm waiting for the delivery of a Plus2 before I revisit this properly again but in the meantime if the attached sample assists then great; once again thanks for your help.

 

The plus2 arrived and the PWM code works fine - so I'll mark this thread as solved -  shame the plus2 is faulty (no Ethernet connectivity - no led on pcb or on network switch) and is about to be returned.

 

Dave


Edited by dbradshaw, 28 February 2013 - 06:07 PM.


#16 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 28 February 2013 - 11:38 PM

Hi Dave, We'd love to get the Netduino Plus 2 back into engineering at some point. We test the network feature on every board before it ships...so it would be very helpful to determine how that feature stopped working in-field. First instinct is that it could be a flaky pin in the Ethernet jack or shipping-related damage. Chris

#17 dbradshaw

dbradshaw

    Member

  • Members
  • PipPip
  • 18 posts
  • LocationUK

Posted 01 March 2013 - 04:55 AM

I've ordered a second board (which I'll test before upgrading the firmware to 4.3 beta) - if the second board works and I think the first one is really faulty (I never checked the Ethernet LEDs before upgrading the firmware) I'll be happy to post it direct to you rather than return it to Amazon.

 

I did waggle the Ethernet plug and press on the connector - but not even a flicker of a led on pcb or network switch.

 

Dave






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.