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

hardware quirk and bugs


  • Please log in to reply
6 replies to this topic

#1 perkunas

perkunas

    Advanced Member

  • Members
  • PipPipPip
  • 108 posts

Posted 12 April 2012 - 12:31 PM

On start up, only pin 3 and pin 7 fire high, and pin 3 looks like its only 50 percent, but only happens for like 5 seconds. Then the program starts. It looks like a hardware quirk. Here's the program using System; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino; namespace Example { public class Program { public const int SecondMs = 1000; public const int MinuteMs = 60 * SecondMs; public const int HourMs = 60 * MinuteMs; public const int DayMs = 24 * HourMs; public const int WeekMs = 7 * DayMs; static OutputPort ph = new OutputPort(Pins.GPIO_PIN_D2, true); static OutputPort b = new OutputPort(Pins.GPIO_PIN_D3, true); static OutputPort a = new OutputPort(Pins.GPIO_PIN_D4, true); static OutputPort drain = new OutputPort(Pins.GPIO_PIN_D5, true); static OutputPort solenoid = new OutputPort(Pins.GPIO_PIN_D6, true); static OutputPort heater = new OutputPort(Pins.GPIO_PIN_D7, true); static OutputPort controller = new OutputPort(Pins.GPIO_PIN_D8, true); public delegate void VoidAction(); public static void Main() { try { while (true) { Method_1(); AwaitCompletionOf(new VoidAction[] { Method_2, Method_3, Method_4, Method_5 }); AwaitCompletionOf(new VoidAction[] { Method_6, Method_7 }); Method_8(); Thread.Sleep(10000); } } catch { //Something has gone wrong; reset to a safe condition } } void RunTheStuff() { } public static void Method_1() { drain.Write(false); Thread.Sleep(16 * MinuteMs); drain.Write(true); } public static void Method_2() { solenoid.Write(false); Thread.Sleep(16 * MinuteMs); solenoid.Write(true); } public static void Method_3() { a.Write(false); Thread.Sleep(11 * MinuteMs + 7 * SecondMs); a.Write(true); } public static void Method_4() { b.Write(false); Thread.Sleep(6 * MinuteMs + 3 * SecondMs); b.Write(true); } public static void Method_5() { ph.Write(false); Thread.Sleep(3 * SecondMs); ph.Write(true); } public static void Method_6() { while (true) { controller.Write(false); Thread.Sleep(1 * SecondMs); controller.Write(true); Thread.Sleep(10 * MinuteMs); } } public static void Method_7() { heater.Write(false); for (int i = 0; i < 14; i++) { solenoid.Write(false); Thread.Sleep(20 * SecondMs); solenoid.Write(true); Thread.Sleep(1 * DayMs); } heater.Write(true); // added this } public static void Method_8() { drain.Write(false); Thread.Sleep(16 * MinuteMs); solenoid.Write(false); Thread.Sleep(16 * MinuteMs); Thread.Sleep(30 * MinuteMs); } public static void AwaitCompletionOf(VoidAction[] actions, int millsecondsTimeout = -1) { ManualResetEvent mre = new ManualResetEvent(false); Thread t = null; int total = 0; int target = actions.Length; for (int i = 0; i < target; i++) { if (null != t) t.Start(); int captured = i; t = new Thread(() => { try { actions[captured](); } finally { if (Interlocked.Increment(ref total) == target) mre.Set(); } }); } if (null != t) { t.Start(); mre.WaitOne(millsecondsTimeout, false); } } } }

#2 Stefan W.

Stefan W.

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts

Posted 12 April 2012 - 01:13 PM

How do you determine this?

On start up, only pin 3 and pin 7 fire high,
and pin 3 looks like its only 50 percent, but only happens for like 5
seconds. Then the program starts. It looks like a hardware quirk.


IIRC, on startup the microcontroller uses all pins as input with pullup enabled, then, after the startup-routine (bootloader and so on) is finished, the program starts ... so what's in your code will not take effect immediately after boot.
I believe that no discovery of fact, however trivial, can be wholly useless to the race, and that no trumpeting of falsehood, however virtuous in intent, can be anything but vicious.
-- H.L. Mencken, "What I Believe"

#3 perkunas

perkunas

    Advanced Member

  • Members
  • PipPipPip
  • 108 posts

Posted 12 April 2012 - 02:19 PM

"IIRC, on startup the microcontroller uses all pins as input with pullup enabled, then, after the startup-routine (bootloader and so on)" Not sure what that means, but I'm using optical relays, and I need them to all fire up on on startup off is On and On is off with them. As I understand it they all fire on on startup which is fine by me, but that's not happening.On start up Only pin 3 and pin 7 fire high,and pin 3 looks like its only 50 percent. So it's not correct its got to be some sort of glitch in the bootloader. I used a row of Leds to test it

#4 Stefan W.

Stefan W.

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts

Posted 12 April 2012 - 03:41 PM

What "input with pullup" means is that there effectively is a resistor between 3v3 & the pin. This resistor limits the current, so using leds to check is not adequate (the current might simply be so low that you don't see the led lighting up), you need a scope or a fast multimeter to check. There is also no way to turn a digital ouput on 50%.
I believe that no discovery of fact, however trivial, can be wholly useless to the race, and that no trumpeting of falsehood, however virtuous in intent, can be anything but vicious.
-- H.L. Mencken, "What I Believe"

#5 perkunas

perkunas

    Advanced Member

  • Members
  • PipPipPip
  • 108 posts

Posted 12 April 2012 - 03:56 PM

ok but the real question is whats the price of soup in China. Maybe this wont make me any problems, or should I even care; as I'm using optical relays and essentially they are all just leds.Guess I have to hook it all up and try it 1st but that's not going to happen soon. The rest of the programs fine I haven't tested it all yet but looks ok.

#6 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 12 April 2012 - 04:03 PM

Hi Perkunas,

Quite often other hardware (shields, breakout boards, etc.) attached to the Netduino causes strange behaviour. I would re-test with nothing connected to the Netduino apart from a voltmeter to read the level on the pins in question.

Pins 2, 3 and 7 are the high(er) current pins, this probably explains why the behaviour on these is different. See CW2's Wiki page How much current can I draw from Netduino? for a list of pins and what they can drive.

At start-up, the voltage on the pins will go high, but they are only driven high by a weak pullup resistor. This limits the amount of current that will be sourced from the pins. It is (sometimes annoyingly :( ) enough to drive logic gates and transistors ON, but is unlikely to be enough to drive a bigger load such as an LED.

I think you may be better off using a buffer chip (e.g. Octal buffer/line driver 74HCT541) or (npn) transistors to drive the LEDs.

Hope this helps - Paul

EDIT: I was typing this while Stefan W. was replying - I'm too slow!

#7 Stefan W.

Stefan W.

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts

Posted 12 April 2012 - 06:26 PM

You weren't too slow, your post has more helpful information than mine :) and your suggestion about not driving optocouplers/LEDs directly is certainly right.
I believe that no discovery of fact, however trivial, can be wholly useless to the race, and that no trumpeting of falsehood, however virtuous in intent, can be anything but vicious.
-- H.L. Mencken, "What I Believe"




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.