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.

cce1911's Content

There have been 59 items by cce1911 (Search limited from 24-June 23)


By content type

See this member's


Sort by                Order  

#52262 Interrupt event handler conflicts

Posted by cce1911 on 21 August 2013 - 01:47 PM in Netduino Plus 2 (and Netduino Plus 1)

I have a N+2 driving 2 stepper motors with the Sparkfun Easydriver. I have wired up several external buttons

InterruptPort ipT1 = new InterruptPort(Pins.GPIO_PIN_D0, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);ipT1.OnInterrupt += Target_OnInterruptT1;InterruptPort ipT2 = new InterruptPort(Pins.GPIO_PIN_D1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);ipT2.OnInterrupt += Target_OnInterruptT2;

?

 

Here are my event handlers

        static void Target_OnInterruptT1(uint data1, uint data2, DateTime time)            {            if (dtLastHit.AddMilliseconds(intBounceWait) > time) return; // prevent bounce            dtLastHit = time;            Debug.Print("Hit T1 = " + DateTime.Now.ToString("MM/dd/yy H:mm:ss.fff"));            }        static void Target_OnInterruptT2(uint data1, uint data2, DateTime time)            {            if (dtLastHit.AddMilliseconds(intBounceWait) > time) return; // prevent bounce            dtLastHit = time;            Debug.Print("Hit T2 = " + DateTime.Now.ToString("MM/dd/yy H:mm:ss.fff"));            }

My problem is that when I press button T1 it randomly executes Target_OnInterruptT2 or Target_OnInterruptT1. No rhyme or reason. The same thing happens if I press button T2.

 

What is odd is that I've used this same exact board with 5 buttons, in the past, and had no problems. Any idea what is happening? I thought it might be EMI from the Easy driver, but I still get the same behavior even if I disconnect power to the stepper motors.

 

I'm scratching my head...




#49493 Issues with buttons and LCD

Posted by cce1911 on 16 May 2013 - 01:55 PM in Netduino 2 (and Netduino 1)

Hanz,

Yes, I will stand up a new board with just the LCD on it and see if my wiring is the issue. It is a rather complex breadboard. I will also take a picture of the setup and what I'm seeing on the LCD. I won't be able to do this until this evening after work.




#49507 Issues with buttons and LCD

Posted by cce1911 on 17 May 2013 - 01:04 PM in Netduino 2 (and Netduino 1)

I'll remove the pull-downs on d0-d3, but do you think that is causing this problem?




#49527 Issues with buttons and LCD

Posted by cce1911 on 18 May 2013 - 04:24 AM in Netduino 2 (and Netduino 1)

Hanzibal,

Tweaking the delay to 2ms did the trick. I also removed the pull-downs. Thanks for all your help.




#49477 Issues with buttons and LCD

Posted by cce1911 on 16 May 2013 - 02:26 AM in Netduino 2 (and Netduino 1)

Hanzibal,

First let me say thank you for your assistance. I've been working with your code and I can't seem to get it to work. My breadboard is wired as shown in the attached image. I'm not sure if I have the pins assigned wrong or your code need to be tweaked for the N+2. Here is my code using your sample:

using System;using System.IO;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;using Hd44780Test;namespace FirstPlus    {    public class Program        {        public static void Main()            {            // create the LCD driver class (d4, d5, d6, d7, E, RS)            var lcd = new Hd44780(Pins.GPIO_PIN_D4, Pins.GPIO_PIN_D5, Pins.GPIO_PIN_D6, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D8);            lcd.Write("- Hd44780 Demo -");            bool onoff;            for (int i = 0; true; i++)                {                onoff = (i & 1) == 0;                lcd.ChangePosition(1, 0);                lcd.Write((i & 0xff).ToString("X2") + " LED is " + (onoff ? "ON " : "OFF"));                //led.Write(onoff);                Thread.Sleep(250);                }            }        }    }

Attached Thumbnails

  • wiring_diagram2.png



#49502 Issues with buttons and LCD

Posted by cce1911 on 17 May 2013 - 01:58 AM in Netduino 2 (and Netduino 1)

Here is the picture. I'll set the other board up this weekend.

Attached Thumbnails

  • breadboard.jpg



#49464 Issues with buttons and LCD

Posted by cce1911 on 15 May 2013 - 01:17 PM in Netduino 2 (and Netduino 1)

I agree, it's hardly a h/w error "anymore". Using a shiftregister would probably help but you need to change your wiring to use SPI with the shift register and probably have to use a different library (e.g. Mario's) too. Before trying that, I could post you some code to try when I'm home after work today. That code would be more or less a drop in replacement.

 

Any suggestions you have would be appreciated.




#49455 Issues with buttons and LCD

Posted by cce1911 on 15 May 2013 - 03:22 AM in Netduino 2 (and Netduino 1)

Hanz,

Well I'm still getting intermittent behavior with the second line of the display. I grounded D0-D4 with a 100k resistor as you suggested and that did not resolve the problem. I purchased another 16x2 LCD from Adafruit and that did not solve the problem. I've even ported my code to a N+2 and I'm still seeing the issue of sometimes being able to see line 2 but most of the time I can't. If I unplug the USB cable to reboot, hold my jaw just right and I'm not wearing any socks, the 2nd line will sometimes work. All joking aside, I'm convinced its not a hardware problem.

 

You mentioned that it could be an issue with clocking. I assume this would be in the MicroLiquidCrystal library correct? Would a shift register and Mario's library solve the problem?




#51764 N+2 Socket problem

Posted by cce1911 on 29 July 2013 - 02:40 PM in Netduino Plus 2 (and Netduino Plus 1)

I found the problem with my code. In the server app, the 2nd while loop should have had totalread instead of 0 for the second parameter of the .receive call. I was overwriting the data each time. Maybe this will help someone in the future...




#52087 N+2 Socket problem

Posted by cce1911 on 11 August 2013 - 12:52 PM in Netduino Plus 2 (and Netduino Plus 1)

Zero, so far I have only tested with a single client.




#51676 N+2 Socket problem

Posted by cce1911 on 25 July 2013 - 03:15 AM in Netduino Plus 2 (and Netduino Plus 1)

If I look at the byte array data, after receiving all the data, every byte above 255 has a value of 0. It's as if it stops reading at 255. If I debug.print in the while loop filling "data", I get the following output:

 

client accepting data client.Receive sizeinfo: currentread = 4, totalread = 4 total message size = 3296 client.Receive data: currentread = 252, totalread = 252 client.Receive data: currentread = 256 totalread = 508 client.Receive data: currentread = 256 totalread = 764 client.Receive data: currentread = 256 totalread = 1020 client.Receive data: currentread = 256 totalread = 1276 client.Receive data: currentread = 256 totalread = 1532 client.Receive data: currentread = 256 totalread = 1788 client.Receive data: currentread = 256 totalread = 2044 client.Receive data: currentread = 256 totalread = 2300 client.Receive data: currentread = 256 totalread = 2556 client.Receive data: currentread = 256 totalread = 2812 client.Receive data: currentread = 256 totalread = 3068 client.Receive data: currentread = 228 totalread = 3296 client.Receive data final: currentread = 228 totalread = 3296

 

So it is accepting 256 bytes each time, but they are all zero. Obviously, I don't understand what's going on:(




#51667 N+2 Socket problem

Posted by cce1911 on 24 July 2013 - 07:42 PM in Netduino Plus 2 (and Netduino Plus 1)

I'm new to sockets and just can't seem to get my app working. What I want to do is send a log file from the N+2 back to my laptop. The approach I took was to prepend the file size to the byte array before sending. However, I never seem to receive exactly what I send. I realize this is a very common problem with folks who are new to sockets and I've searched high and low to find tips on how to avoid this problem. Maybe this is something unique to N+2, but I kind of doubt it.
 
Here is my code. I've got a client app that runs on the N+2 and a console app running on my laptop. The data file I'm retrieving is attached below. This sort of works, but is not delivering the file consistently. Any help you can give me would be appreciated.
 
Client app running on N+2. When you press the onboard button, it sends the file.

 

[font="'courier new', courier, monospace;"]using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Text;
using System.IO;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;[/font]

[font="'courier new', courier, monospace;"]namespace SocketClient
  {[/font]

[font="'courier new', courier, monospace;"]   public class Program
  {
  static string strDeviceIP = "";
  static string strDeviceSubnet = "";
  static string strDeviceGateway = "";
  static string strDevicePort = "";
  static string strControllerIP = "";[/font]

[font="'courier new', courier, monospace;"]   public static OutputPort opLED = new OutputPort(Pins.GPIO_PIN_D13, false);
  InputPort button = new InputPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled);[/font]

[font="'courier new', courier, monospace;"]   public static void Main()
  {
  strDeviceIP = "192.168.2.102";
  strDeviceSubnet = "255.255.255.0";
  strDeviceGateway = "192.168.2.2";
  strControllerIP = "192.168.2.222";
  strDevicePort = "9999";
  InterruptPort btn = new InterruptPort(Pins.ONBOARD_SW1, false,[/font]

[font="'courier new', courier, monospace;"]Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);
  btn.OnInterrupt += new NativeEventHandler(ButtonPress);[/font]

[font="'courier new', courier, monospace;"]   while (true)
  {
 
  }
  }[/font]

[font="'courier new', courier, monospace;"]   public static void ButtonPress(uint data1, uint data2, DateTime time)
  {
  opLED.Write(true);[/font]

[font="'courier new', courier, monospace;"]   Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  IPAddress hostAddress = IPAddress.Parse(strControllerIP);
  IPEndPoint endpoint = new IPEndPoint(hostAddress, Int32.Parse(strDevicePort));[/font]

[font="'courier new', courier, monospace;"]   string fileName = "runlog2.txt";
 
  // read the file into a byte array
  byte[] data = File.ReadAllBytes(@"SD" + fileName);
  byte[] sizeinfo = new byte[4];
  byte[] senddata = new byte[4 + data.Length];[/font]

[font="'courier new', courier, monospace;"]   // check to make sure it's not too big
  if (data.Length > 850 * 1024)
  {
  Debug.Print("File too large");
  }[/font]

[font="'courier new', courier, monospace;"]   // convert data.length into a byte array
  sizeinfo[0] = (byte)data.Length;
  sizeinfo[1] = (byte)(data.Length >> 8);
  sizeinfo[2] = (byte)(data.Length >> 16);
  sizeinfo[3] = (byte)(data.Length >> 24);[/font]

[font="'courier new', courier, monospace;"]   // prepend the size into the senddata array
  sizeinfo.CopyTo(senddata, 0);[/font]

[font="'courier new', courier, monospace;"]   // copy read data into the senddata array
  data.CopyTo(senddata, 4);[/font]

[font="'courier new', courier, monospace;"]   // send the data
  socket.Connect(endpoint);
  socket.Send(senddata);
  socket.Close();
  opLED.Write(false);
  }
  }
  }[/font]

 

 

[font="'courier new', courier, monospace;"]Here is my server side console app.[/font]

 

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

[font="'courier new', courier, monospace;"]using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Collections;
using System.Threading;[/font]

 

 

[font="'courier new', courier, monospace;"]namespace SocketConsole
  {
  class Program
  {
  static void Main(string[] args)
  {
  Thread thread1 = new Thread(new ThreadStart(Listener));
  thread1.Start();[/font]

 

[font="'courier new', courier, monospace;"]   while (true)
  {
  }
  }[/font]

[font="'courier new', courier, monospace;"] public static void Listener()
  {
  try
  {
  Socket sktMain = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  sktMain.Bind(new IPEndPoint(IPAddress.Parse("192.168.2.222"), 9999));
  sktMain.Listen(10);
  var message = new ArrayList();[/font]

[font="'courier new', courier, monospace;"]   while (true)
  {
  // create the client socket
  using (var client = sktMain.Accept())
  {
  //If connected,
  if (SocketConnected(client, 100))
  {
  while (SocketConnected(client, 100))
  {
  byte[] sizeinfo = new byte[4];[/font]

[font="'courier new', courier, monospace;"]   //read the size of the message into sizeinfo
  int totalread = 0, currentread = 0;
  currentread = totalread = client.Receive(sizeinfo, 4, SocketFlags.None);[/font]

[font="'courier new', courier, monospace;"]   while (totalread < sizeinfo.Length && currentread > 0)
  {
  currentread = client.Receive(sizeinfo, totalread, sizeinfo.Length - totalread, SocketFlags.None);
  totalread += currentread;
  }[/font]

[font="'courier new', courier, monospace;"]   int messagesize = 0;
  messagesize |= sizeinfo[0];
  messagesize |= (((int)sizeinfo[1]) << 8);
  messagesize |= (((int)sizeinfo[2]) << 16);
  messagesize |= (((int)sizeinfo[3]) << 24);[/font]

[font="'courier new', courier, monospace;"]   byte[] data = new byte[messagesize];
  totalread = 0;
  currentread = totalread = client.Receive(data, 0, data.Length - totalread, SocketFlags.None);
  var received = Encoding.UTF8.GetChars(data);[/font]

[font="'courier new', courier, monospace;"]   int diff = data.Length - totalread;[/font]

[font="'courier new', courier, monospace;"]   while (totalread < messagesize && currentread > 0)
  {
  currentread = client.Receive(data, 0, data.Length - totalread, SocketFlags.None);
  totalread += currentread;
  for (var i = 0; i < received.Length; i++)
  message.Add(received[i]);
  }
  string fName = "runlog.txt";
  if (File.Exists(fName)) File.Delete(fName);[/font]

[font="'courier new', courier, monospace;"]   BinaryWriter bWrite = new BinaryWriter(File.Open(fName, FileMode.Create));
  bWrite.Write(data);
  bWrite.Close();
  }
  }
  }
  }
  }
  catch (Exception ex)
  {
  Console.WriteLine(ex.Message);
  }
  }[/font]

[font="'courier new', courier, monospace;"] // socket polling
static bool SocketConnected(Socket s, int ms)
{
return !(s.Poll(ms, SelectMode.SelectRead) & (s.Available == 0));
}[/font]

[font="'courier new', courier, monospace;"]   }
  }[/font]

 

 

Attached Files




#49404 N2 to NP2 issue

Posted by cce1911 on 14 May 2013 - 02:17 AM in Netduino Plus 2 (and Netduino Plus 1)

Ok, so I referenced

using SecretLabs.NETMF.Hardware.Netduino;

and I still get the same exception.

 

I next tried moving the button assignments around and now I get the same exception, but on a [font="arial, helvetica, sans-serif;"]different InterruptPort assignment.[/font]

 

[font="arial, helvetica, sans-serif;"]Keep in mind that I'm moving from a Netduino 2 to a Netduino + 2. Chris' post refers to N+ to N+2.[/font]




#49456 N2 to NP2 issue

Posted by cce1911 on 15 May 2013 - 03:26 AM in Netduino Plus 2 (and Netduino Plus 1)

This was a strange issue and I never did figure out why the N2 code would not run on the N+2, I did find a work around.

Basically, I defined the input using the Auto-Repeat button (http://forums.netdui...n-press-sample/) and it worked. Don't ask me why this worked, but it did.




#49406 N2 to NP2 issue

Posted by cce1911 on 14 May 2013 - 03:03 AM in Netduino Plus 2 (and Netduino Plus 1)

Upon closer examination, here is the debug output:

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

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

An unhandled exception of type 'System.ArgumentException' occurred in Microsoft.SPOT.Hardware.dll

 

Any suggestions?




#49372 N2 to NP2 issue

Posted by cce1911 on 12 May 2013 - 10:50 PM in Netduino Plus 2 (and Netduino Plus 1)

I have code that works fine when running on N2, but when I run the same code on the N2+ I get a System.ArgumentException on this line of code:

 

// Input Trigger - This input starts the cycle

InterruptPort inpTrigger = new InterruptPort(Pins.GPIO_PIN_A5, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);

 

 

It is simply a button to start my program running.

 

BTW I am using:

using SecretLabs.NETMF.Hardware.NetduinoPlus;

 

Any suggestions?

-Capel




#51238 NeonMika.NetduinoControl & NeonMika.Webserver.ClientLibrary

Posted by cce1911 on 09 July 2013 - 01:57 AM in Project Showcase

What version of Visual Studio is this built in? I get an error saying the project is incompatible with VS2010.




#51239 NeonMika.Webserver

Posted by cce1911 on 09 July 2013 - 02:06 AM in Project Showcase

Am I missing something? I downloaded the N+2 Version (10.12.12) and have it running,  but I can't create the "network name". Its not a parameter in

Server WebServer = new Server(PinManagement.OnboardLED, 80, false, "192.168.1.25", "255.255.255.0", "192.168.1.1");

 

[font="arial, helvetica, sans-serif;"]Does the N+2 version have this?[/font]




#56979 Netduino Plus 2 Firmware v4.3.1

Posted by cce1911 on 21 March 2014 - 09:20 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi cce1911,
 

In each project, go to project properties (right-click on the project name, select the "properties" menu option).

Then change the "Target Framework" from NETMF 4.3 to NETMF 4.2. It will probably close the window for you when you do this, to save the changes.

Then change the target framework back to NETMF 4.3.

Repeat the above for each project. If there are forty, it may take you 15 minutes. Tedious and no fun, but it should change everything from 'pre-production 4.3' to 'production 4.3.1' for you.

Now

 

Chris,

I just wanted to let you know that I was able to resolve my problem by compiling the toolbox with the 4.3.1 code.

-Capel




#57931 Netduino Plus 2 Firmware v4.3.1

Posted by cce1911 on 04 May 2014 - 11:38 AM in Netduino Plus 2 (and Netduino Plus 1)

It took me too many hours to figure out that you can't boot up both devices at the same time. You have to boot theEdimax 60 seconds before powering up the N+2.



#56910 Netduino Plus 2 Firmware v4.3.1

Posted by cce1911 on 19 March 2014 - 12:58 PM in Netduino Plus 2 (and Netduino Plus 1)

Thanks for the quick reply Chris. Do I also need to change the AssemblyVersion in AssemblyInfo.cs?




#56908 Netduino Plus 2 Firmware v4.3.1

Posted by cce1911 on 19 March 2014 - 12:34 PM in Netduino Plus 2 (and Netduino Plus 1)

I have downloaded the source, but I'm not real sure how to upgrade it to 4.3.1. Do I have to change the target framework on all 40 projects? Do I have to manually edit the AssemblyInfo files and change AssemblyVersion("4.3.1.0")?




#56903 Netduino Plus 2 Firmware v4.3.1

Posted by cce1911 on 19 March 2014 - 04:18 AM in Netduino Plus 2 (and Netduino Plus 1)

I've upgraded to vs2012, .netmf 4.3 and flashed the firmware successfully. I've upgraded my projects and their references to the 4.3 dlls, but when I go to deploy my programs the I'm getting errors with the .net microframework toolbox. I downloaded the 4.3 DLLs but I'm getting the following.

 

Link failure: some assembly references cannot be resolved!!
 
Assembly: Toolbox.NETMF.Hardware.Ic74HC595 (4.3.0.0) needs assembly 'mscorlib' (4.3.0.0)
 
 
My mscorlib is version 4.3.1.0.



#52260 Quick question about ND+2 Socket

Posted by cce1911 on 21 August 2013 - 12:50 PM in Netduino Plus 2 (and Netduino Plus 1)

http://msdn.microsof...y/ee434782.aspx

 

socket.listen(backlog)

 

backlog = The maximum number of incoming connections that can be queued for acceptance. Try

serverSocket.Listen(10);




#54131 Sparkfun Shift Register Breakout - 74HC595

Posted by cce1911 on 17 November 2013 - 08:45 PM in Netduino Plus 2 (and Netduino Plus 1)

Can someone point me to an example of using this breakout board with the Netduino?

https://www.sparkfun.../products/10680

 

I would like to use the .Net Microframework Toolbox, but it's not obvious to me how to wire it up.

 

 





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.