Graham.fry - Viewing Profile: Topics - 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.

Graham.fry

Member Since 30 Dec 2012
Offline Last Active Aug 19 2014 02:34 PM
-----

Topics I've Started

A first chance exception of type 'System.InvalidOperationException' occurred in...

21 August 2013 - 02:15 PM

Hi

 

I am trying to get a servo working I copied this code from the internet when I run it, it fails with the following error

 

A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.SPOT.Hardware.dll

 

Any help will be appreciated

 

Thanks in advance

 

Graham

 

Attached is the code I am using on a netduino plus2 version 4.2.2

 

program.cs

 

using System.Threading;

using SecretLabs.NETMF.Hardware.Netduino;

using Microsoft.SPOT;

namespace MinelectricsV2

{

public class Program

{

static Servo[] servos = new Servo[4];

public static void Main()

{

//Netduino only has four PWM pins: GPIO_PIN_D5, 6, 9, and 10

servos[0] = new Servo(Pins.GPIO_PIN_D5);

servos[1] = new Servo(Pins.GPIO_PIN_D6);

servos[2] = new Servo(Pins.GPIO_PIN_D9);

servos[3] = new Servo(Pins.GPIO_PIN_D10);

while (true)

{

MoveServos(0);

MoveServos(90);

MoveServos(180);

}

}

private static void MoveServos(uint angle)

{

for (int i = 0; i < servos.Length; i++)

{

servos[i].Angle = angle;

}

Thread.Sleep(2000);

}

}

}

 

 

 

 

class.cs

 

using Microsoft.SPOT.Hardware;

using SecretLabs.NETMF.Hardware;

namespace MinelectricsV2

{

public class Servo

{

static PWM servo;

public Servo(Cpu.Pin pin)

{

servo = new PWM(pin);

servo.SetDutyCycle(dutyCycle: 0);

}

private uint _angle = 0;

public uint Angle

{

get

{

return _angle;

}

set

{

const uint degreeMin = 0;

const uint degreeMax = 180;

const uint durationMin = 500; // 480

const uint durationMax = 2300; // 2450

_angle = value;

if (_angle < degreeMin) _angle = degreeMin;

if (_angle > degreeMax) _angle = degreeMax;

uint dur = (_angle - degreeMin) * (durationMax - durationMin) / (degreeMax - degreeMin) + durationMin;

servo.SetPulse(period: 20000, duration: dur);

}

}

}

}

 

 

 


Hello World Webservice where to start Visual Studio 2012

03 July 2013 - 08:24 AM

[font="arial, sans-serif;"][color=rgb(34,34,34);]Hi[/color][/font]

 

[font="arial, sans-serif;"][color=rgb(34,34,34);]I am trying to write a web service for my Netduino plus 2 and I can’t find where to start.[/color][/font]

 

[font="arial, sans-serif;"][color=rgb(34,34,34);]I can write basic applications and have set up the I.P. and mac address for the Netduino.[/color][/font]

 

[font="arial, sans-serif;"][color=rgb(34,34,34);]I am using Visual studio 2012 express, do I need the pro version.[/color][/font]

 

[font="arial, sans-serif;"][color=rgb(34,34,34);]All the examples I can find seem to use 2010 and suggest I start in Netduino Plus Application. I can’t seem to find the equivalent in Visual studio 2012 express. [/color][/font]

 

[font="arial, sans-serif;"][color=rgb(34,34,34);]I would appreciate any help or sample code, just a simple HELLO World and how to run it in 2012 express is fine. [/color][/font]

 

[font="arial, sans-serif;"][color=rgb(34,34,34);]Thank you[/color][/font]

 

 

 


RGB Led using PWM

02 July 2013 - 11:36 AM

Hi

 

I am trying to get an RGB Led working. I am using some code from the web.

 

The problem is that every time I deploy it, it comes up with the following error:

 

The thread '<No Name>' (0x2) has exited with code 0 (0x0).

A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.SPOT.Hardware.dll

 

and then you an not connect any more you need to flash the firmware to be able to do anything.

 

I am using firm ware 4.2.2.2 and the right SDK 4.2.

 

I have tried different I/O (4,5,6) and combinations.

 

I have tested the board with, a basic blinky app and a push button app and all is working

 

Code sample

 

using System; //use base classes using System.Threading; //use threading classes using Microsoft.SPOT; //use smart personal objects technology classes using Microsoft.SPOT.Hardware; //use hardware related SPOT classes using SecretLabs.NETMF.Hardware; //use Secret Labs hardware framework using SecretLabs.NETMF.Hardware.Netduino; //use the Netduino specific classes

 

namespace NCIR01 /// Define the namespace we are in /// {   public class Program   {   public static void Main() /// The Main loop (run at power up) ///   {   PWM rgb1 = new PWM(Pins.GPIO_PIN_D8);   PWM rgb2 = new PWM(Pins.GPIO_PIN_D9);   PWM rgb3 = new PWM(Pins.GPIO_PIN_D10);

  while (true) /// Do Forever ///   { rgb1.SetDutyCycle(100); rgb2.SetDutyCycle(0); rgb3.SetDutyCycle(0);

  } /// Close Forever Loop ///   } /// Close the Main() Loop ///     } /// Close the Program Loop /// } /// Close the Namespace Loop ///

 

Any ideas would help

 

Thanks

 

Graham

 


The thread '<No Name>' (0x2) has exited with code 0 (0x0).

03 June 2013 - 01:11 PM

Hi All

 

I am having a problem

 

I am deploying a simple blinky app.

 

I keep getting the following error when I deploy to my netduino plus 2, running firmware version NetduinoPlus2_Firmware_4.2.1.1 or NetduinoPlus2_Firmware_4.2.2.2 I have tried both.

 

The thread '<No Name>' (0x2) has exited with code 0 (0x0).

 

Everything seems to work but I don't know what the implications are for a larger application.


cannot attach debugger engine!

28 January 2013 - 11:41 AM

Hi

 

I am new to Netduino or anything like this so please help if I am posting this in the wrong place or anything like that.

 

I am a C# developer and so far have nothing but good things to say about the netdruino and love working with it.

 

Currently I am having a small issue I have a basic blinky working on the netduino plus 2 running version 2.somthing

I then took an RGB Led and got it producing the three primary colours, I then removed all my code and wrote one pwm line of code with all the setup things I needed to do.

 

When I up loaded this nothing happened no lights came on or any thing I then tried to roll back to blinky and I get the error

... cannot attach debugger engine!

 

Error 1 Unable to communicate with device USB:Netduino  

Please help I am going crazy Not being able to play with my netduino.

 

 

The code that broke my favorite toy

 

 

static PWM ledgreen = new PWM(Pins.GPIO_PIN_D6);

const uint period = 3 * 1000 * 1000; // 3 ms

const uint duration = 1 * 1000 * 1000; // 1 ms

 

public static void Main()

{while (true)

{

ledgreen.SetPulse(period, duration);}

}

 

Thanks

 

Graham


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.