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

N+2 resetting and migration to 4.1


  • Please log in to reply
12 replies to this topic

#1 Buddy

Buddy

    Member

  • Members
  • PipPip
  • 17 posts

Posted 02 December 2012 - 06:46 PM

I was lucky enough to jump head first into Netduino with the N+2. The goal was to copy and paste Greg's garage door monitor and control code for the Netduino and Android. Seemed simple enough, but I did not do enough research to learn that the N+2 is a different code than the N+1. Have spent the last week, on vacation no less, banging my head. Would like to now to change the N+2 to 4.1. Have tried to erase the board by touching the gold pad with the 3.3V. (even verified that the 3.3v connection is producing 3.3v). After doing that, I still see the image on the board when checking with MF4.1. A second issue is that I downloaded the SAM-BA CDC2.12 and it is not showing up in device manager (have even tried the work-arounds that are posted here). Is it not showing because it is not supported with the N+2. Right now, my goal is to get the N+2 switched to 4.1 so I can copy/paste the existing code out there. Frustrated after wasting a weeks worth of vacation time, Buddy

#2 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 02 December 2012 - 07:06 PM

Research is important! You should read about the differences between the ND+ and ND+2 boards. You can't use SAM BA with the ND+2. It has a different processor than ND+. SAM BA is for Atmel based boards. The ND+2 is an ST Micro processor. You need to you use Dfuse software with this board. You cannot make this a 4.1 version board as there is no 4.1 firmware for the ND+2. You will need to reflash your board with the ND+2 based firmware which is .NET 4.2 based and you should use the latest version and instructions posted in this thread. http://forums.netdui...-v421-update-1/ The code you are using will need to be converted for the 4.2 framework by changing the framework version and using the appropriate Netduino DLL from SecretLabs.

#3 Buddy

Buddy

    Member

  • Members
  • PipPip
  • 17 posts

Posted 02 December 2012 - 07:33 PM

LOL, should have asked earier... Thank you. I was one of the first ten folks to d/l the latest version. So the conversion of the code will require some more focus. Pinging... TinyCLR HalSystemInfo.halVersion: 4.2.0.0 HalSystemInfo.halVendorInfo: Netduino Plus 2 (v4.2.1.1) by Secret Labs LLC HalSystemInfo.oemCode: 34 HalSystemInfo.modelCode: 177 HalSystemInfo.skuCode: 4102 HalSystemInfo.moduleSerialNumber: 00000000000000000000000000000000 HalSystemInfo.systemSerialNumber: 0000000000000000 ClrInfo.clrVersion: 4.2.0.0 ClrInfo.clrVendorInfo: Netduino Plus 2 (v4.2.1.1) by Secret Labs LLC ClrInfo.targetFrameworkVersion: 4.2.0.0 SolutionReleaseInfo.solutionVersion: 4.2.1.1 SolutionReleaseInfo.solutionVendorInfo: Netduino Plus 2 (v4.2.1.1) by Secret Labs LLC SoftwareVersion.BuildDate: Nov 30 2012 SoftwareVersion.CompilerVersion: 410894 FloatingPoint: True SourceLevelDebugging: True ThreadCreateEx: True LCD.Width: 0 LCD.Height: 0 LCD.BitsPerPixel: 0 AppDomains: True ExceptionFilters: True IncrementalDeployment: True SoftReboot: True Profiling: False ProfilingAllocations: False ProfilingCalls: False IsUnknown: False

#4 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 02 December 2012 - 07:49 PM

This looks like you are re-flashed properly. :D I haven't looked at Greg's code yet but plan to build this project to add to my home automation system. Moving it to NETMF 4.2 shouldn't be too hard. I imaging it should migrate pretty easily. I'll try to download it tonight and take a look. Will let you know any of my findings.

#5 Buddy

Buddy

    Member

  • Members
  • PipPip
  • 17 posts

Posted 02 December 2012 - 08:06 PM

Thanks. I changed the sensor that he used, primarily because it has to be almost touching the door in order to work. Instead I would rather use the Photointerrupter from sparkfun. It has a 10mm gap, so the room for door moment is increased. While running debug I can get 1 or 0 based on photo interruption. I am still using the analog port for the sensor... The attached pic shows how I am connecting the photointerrupter. Greg's code used set range (0 1024) on his sensor selection, of course that will not work with 4.2. For giggles, I also assembled the sensor assembly that Greg used and had no luck with overall functionality. When looking at the network traffic with Ethereal to monitor the Doid request to the N+2. I see the Get (from the Droid), but get a bad command response (from the Netduino).

Attached Files



#6 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 02 December 2012 - 08:10 PM

Hey Buddy,

I downloaded the code from Greg's Blog Post and upgraded it. It's pretty easy. Here are the steps.

1) Download the code and open in visual studio
2) Go to the project's property page and on the application tab change the Framework from 4.1 to 4.2
3) Open References in the Tree and drop SecretLabs.NETMF.Hardware.NetduinoPlus. Replace it with the SecretLabs.NETMF.Hardware.Netduino from 4.2 QFE2
4) Change the two includes from using SecretLabs.NETMF.Hardware.NetduinoPlus; to using SecretLabs.NETMF.Hardware.Netduino;

This should allow you to build and deploy the project.

I did did deploy and I am getting the same issue that you are with it hanging on the socket.Accept(). I'll take a look at it more when later and see if I can get it running.

#7 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 02 December 2012 - 08:16 PM

hanging on the socket.Accept()


its a blocking function, it does not not hang, it waits there till a client actually connects

i made a short non blockinmg (threaded) sample for networking

Attached Files



#8 Buddy

Buddy

    Member

  • Members
  • PipPip
  • 17 posts

Posted 03 December 2012 - 04:11 AM

Dave, Thanks for the info, it kept me digging in a better direction. :D This is a modified version code that NooM provided yesterday (Thanks!) with a sensor move from the analog port to digital port. :D Using the same resistance values that Greg has in his design for the garage monitor, I was able to get the Photointerrupter to show a true/false in debugging. I am using an external 5Vdc power supply, might have cooked my on-board 5V :angry: Will look to see how it impacts the overall Droid N+2 solution tomorrow. 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.Netduino; namespace NetduinoInfraredSensor { public class Program { public static void Main() { //Set the digital pin to monitor Pin 0 // Greg's 4.1 Code ->> AnalogInput garageSensor = new AnalogInput(Pins.GPIO_PIN_A0); InterruptPort irPort = new InterruptPort(Pins.GPIO_PIN_D0, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptNone); //Was getting an error on last part of this line, so I commented it out (yeah, not really a best practice) irPort.OnInterrupt += new NativeEventHandler(irPort_OnInterrupt); irPort.EnableInterrupt(); //Set sensor read // Greg's 4.1 Code ->> garageSensor.SetRange(0, 1024); irPort.Read(); //Program loop while (true) { Debug.Print(irPort.Read().ToString()); Thread.Sleep(1000); } } } }

#9 Buddy

Buddy

    Member

  • Members
  • PipPip
  • 17 posts

Posted 03 December 2012 - 02:11 PM

Greg's garage door project was divided up into two separate apps. The first app dealt with the sensor and the second app holds the web server, part of the sensor (garage door status check), and open/close instructions. Is it possible to consolidate these into one app? I tried by adding a class to the second app, then adding the information from the first app to the new class. The result is that I see the Get transmitted from the Droid, but the N+2 response is blank (0 bytes). Attached is the code that I have super glued together. (try not to giggle to loud when you see it) The new class is IS.cs (infrared sensor)

Attached Files



#10 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 03 December 2012 - 05:34 PM

you should really get some basics first before you try to port code.
stuff like: you press a button, a led turn on, you press it again, it turns off
than go for analog-digital-converter, pwm, communication busses (spi, i2c, uart)

heres is a good tutorial to start with, it has more pages, you should read tham all

Good Start

#11 Buddy

Buddy

    Member

  • Members
  • PipPip
  • 17 posts

Posted 04 December 2012 - 01:51 AM


//Was getting an error on last part of this line, so I commented it out (yeah, not really a best practice) irPort.OnInterrupt += new NativeEventHandler(irPort_OnInterrupt);



Fixed the part that was commented out

namespace NetduinoInfraredSensor
{
    public class Program
    {

        public static void Main()
        {

            //Set the digital pin to monitor Pin D0
            InterruptPort garageSensor = new InterruptPort(Pins.GPIO_PIN_D0, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptNone);

            garageSensor.OnInterrupt +=new NativeEventHandler(garageSensor_OnInterrupt);
            
            garageSensor.EnableInterrupt();

            //Program loop
            while (true)
            {
                Debug.Print(garageSensor.Read().ToString());
                Thread.Sleep(1000);
            }            }

        static void garageSensor_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            throw new NotImplementedException();
        }
        }

    }

Edited by Chris Walker, 04 December 2012 - 02:39 AM.
added [code][/code]


#12 Buddy

Buddy

    Member

  • Members
  • PipPip
  • 17 posts

Posted 04 December 2012 - 06:03 PM

For the record :huh: This morning I opened and closed the garage door with a modified version of this code, from my Droid Tab. Still working out the status indicator, which is key to really making this work.

#13 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 05 December 2012 - 01:33 AM

This morning I opened and closed the garage door with a modified version of this code, from my Droid Tab.

Woot! :)

Chris




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.