Graham.fry's Content - 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's Content

There have been 15 items by Graham.fry (Search limited from 19-April 23)


By content type

See this member's

Sort by                Order  

#53239 Not able to change network settings

Posted by Graham.fry on 17 October 2013 - 12:54 PM in Netduino 2 (and Netduino 1)

I know it is not the exact answer you are looking for but if I need to use a fixed IP I get my netduino to run this line at the when it boots up.

 

Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].EnableStaticIP("192.168.1.122", "255.255.255.0", "192.168.1.62");

 

 

by using this I don't need to configure each device before using I just change the IP I want to change.




#52519 A first chance exception of type 'System.InvalidOperationException' o...

Posted by Graham.fry on 03 September 2013 - 08:03 AM in Netduino Plus 2 (and Netduino Plus 1)

For anybody that cares

 

If you having a problem using the hardware DLL in 4.3 (with servos) you need to uninstall all 4.3 sdk's and reinstall 4.2

 

This fixed my problem




#52264 A first chance exception of type 'System.InvalidOperationException' o...

Posted by Graham.fry on 21 August 2013 - 02:15 PM in Netduino Plus 2 (and Netduino Plus 1)

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);

}

}

}

}

 

 

 




#51979 Date from netduino plus

Posted by Graham.fry on 06 August 2013 - 12:03 PM in Netduino Plus 2 (and Netduino Plus 1)

Here is the code to get time from the internet using netduino

 

using System;

using System.Net;

using System.Net.Sockets;

using Microsoft.SPOT;

using System.Threading;

namespace GetTime

{

public class Program

{

public static void Main()

{

var result = UpdateTimeFromNtpServer("time.nist.gov", 2); // gmt + 2

Debug.Print(result ? "Time successfully updated" : "Time not updated");

while (true)

{

Debug.Print("netduino Time is: " + DateTime.Now.ToString());//TimeClient.LocalDate.ToString());

Thread.Sleep(60000);

}

//return result;

}

public static bool UpdateTimeFromNtpServer(string server, int timeZoneOffset)

{

try

{

var currentTime = GetNtpTime(server, timeZoneOffset);

Microsoft.SPOT.Hardware.Utility.SetLocalTime(currentTime);

return true;

}

catch

{

return false;

}

}

private static DateTime GetNtpTime(String timeServer, int timeZoneOffset)

{

// Find endpoint for TimeServer

var ep = new IPEndPoint(Dns.GetHostEntry(timeServer).AddressList[0], 123);

// Make send/receive buffer

var ntpData = new byte[48];

// Connect to TimeServer

using (var s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))

{

// Set 10s send/receive timeout and connect

s.SendTimeout = s.ReceiveTimeout = 10000; // 10,000 ms

s.Connect(ep);

// Set protocol version

ntpData[0] = 0x1B;

// Send Request

s.Send(ntpData);

// Receive Time

s.Receive(ntpData);

// Close the socket

s.Close();

}

const byte offsetTransmitTime = 40;

ulong intpart = 0;

ulong fractpart = 0;

for (var i = 0; i <= 3; i++)

intpart = (intpart << 8) | ntpData[offsetTransmitTime + i];

for (var i = 4; i <= 7; i++)

fractpart = (fractpart << 8) | ntpData[offsetTransmitTime + i];

ulong milliseconds = (intpart * 1000 + (fractpart * 1000) / 0x100000000L);

var timeSpan = TimeSpan.FromTicks((long)milliseconds * TimeSpan.TicksPerMillisecond);

var dateTime = new DateTime(1900, 1, 1);

dateTime += timeSpan;

var offsetAmount = new TimeSpan(timeZoneOffset, 0, 0);

var networkDateTime = (dateTime + offsetAmount);

return networkDateTime;

}

}

}




#51976 How to read data html with web server?

Posted by Graham.fry on 06 August 2013 - 11:44 AM in Netduino Plus 2 (and Netduino Plus 1)

Hi

[font="calibri;"]In my request I have limited my response to 2 characters and my var indicator is light= this works every time[/font]

 
 //Get request
  byte[] buffer = new byte[bytesReceived];
  int byteCount = clientSocket.Receive(buffer, bytesReceived, SocketFlags.None);
  string request = new string(Encoding.UTF8.GetChars(buffer));
  Debug.Print(request);

  //int countof = request.IndexOf("light="); //for my code
 int countof = request.IndexOf("user=");
  countof = countof + 6;
  //var s = request.Substring(countof, 2); //for my code

 

You may need to add the following and it may need some tweeking

 

 int noChatTotext = X //(this is the number of char to the end of user= it should constant)
 int lengthOfrequest = request.length(); //calculate the length of the hole request sent.
 int noCharToGet =  lengthOfrequest - noChatTotext; //the length of the text you want
 var s = request.Substring(countof, noCharToGet); //S will be the text you want




#51097 Hello World Webservice where to start Visual Studio 2012

Posted by Graham.fry on 05 July 2013 - 06:09 AM in Netduino Plus 2 (and Netduino Plus 1)

Hi all

 

I have installed the SDK and upgraded the board to 4.2.2.2

 

Under microframwork I get

  Class

  Device Emulator

  Windows Application

 

I can build a blinky application and control RGB's etc. that is using the console application should I just us the console application to build the webservice.




#51081 Hello World Webservice where to start Visual Studio 2012

Posted by Graham.fry on 04 July 2013 - 11:44 AM in Netduino Plus 2 (and Netduino Plus 1)

Thank you

 

I will look into these answers




#51043 Hello World Webservice where to start Visual Studio 2012

Posted by Graham.fry on 03 July 2013 - 08:24 AM in Netduino Plus 2 (and Netduino Plus 1)

[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]

 

 

 




#51021 RGB Led using PWM

Posted by Graham.fry on 02 July 2013 - 03:04 PM in Netduino 2 (and Netduino 1)

Thank will try this and let you know




#51015 RGB Led using PWM

Posted by Graham.fry on 02 July 2013 - 11:36 AM in Netduino 2 (and Netduino 1)

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

 




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

Posted by Graham.fry on 05 June 2013 - 06:13 AM in Netduino Plus 2 (and Netduino Plus 1)

Thanks for your help




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

Posted by Graham.fry on 03 June 2013 - 01:11 PM in Netduino Plus 2 (and Netduino Plus 1)

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.




#45200 cannot attach debugger engine!

Posted by Graham.fry on 09 February 2013 - 09:21 AM in Netduino Plus 2 (and Netduino Plus 1)

Hi All thank you for your help after much effort I have managed to flash my netdurino and go it working

 

I think it is something you need to learn when you start

 

Thanks




#44476 cannot attach debugger engine!

Posted by Graham.fry on 29 January 2013 - 06:19 AM in Netduino Plus 2 (and Netduino Plus 1)

Thanks for the replies

 

I will test this ASAP and get back to let you know if it works




#44376 cannot attach debugger engine!

Posted by Graham.fry on 28 January 2013 - 11:41 AM in Netduino Plus 2 (and Netduino Plus 1)

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.