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

Easy multiplexing with the Netduino


  • Please log in to reply
64 replies to this topic

#41 lesmondo

lesmondo

    Member

  • Members
  • PipPip
  • 24 posts

Posted 25 September 2011 - 12:58 PM

Sounds like a great plan! Mario's advise is a good one. If you can make the shield 'daisychainable' it would be awesome!


Hey, Thanks for the input. I wasn't planning on making these or selling them, it's just a project for me to update my PCB making skills. But once I've got the board working and debugged I'll post the cad files and a write up on my blog.

Of course, if you want the files now, just shout and I'll chuck them and some code into github.

L

#42 stotech

stotech

    Advanced Member

  • Members
  • PipPipPip
  • 143 posts
  • LocationAustralia

Posted 20 September 2012 - 06:50 AM

I think I remember reading that the SPI on the Netduino Plus is limited because of the SD Card reader. Now that I look around I can't find it again though so I might be wrong. Can someone tell me if this will work on the PLUS. I need the extra output ports is all. Don't need the inputs. Thanks in advance.

#43 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 20 September 2012 - 07:41 AM

This will work just fine on a Plus. The Plus has 2 SPI ports in use, one for ethernet+SD and one for other stuff.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#44 stotech

stotech

    Advanced Member

  • Members
  • PipPipPip
  • 143 posts
  • LocationAustralia

Posted 20 September 2012 - 01:48 PM

Thanks for the quick reply. I also should have asked what happens with this design when my beloved Netduino is booting up. are all the pins held high? Or do they wait for some code over the SPI. Grant

#45 stotech

stotech

    Advanced Member

  • Members
  • PipPipPip
  • 143 posts
  • LocationAustralia

Posted 21 September 2012 - 06:46 AM

As well as the question above I've got a few more when you get some time. Personally, I amazed how often your picture turns up in the forums so I'm totally grateful whenever you help out.
I'm trying to copy your schematic but I don't need the extra inputs. and on one of the 595's add a display using this post as a reference. http://geekswithblog...id_crystal.aspx I noticed on his blog he is using pin 10 where you are using pin 9. Which one is easier to use or doesn't it matter.
Do I need to use his library as well as your library together or just yours.
Is this even possible?

Thanks in advance.

Grant

#46 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 21 September 2012 - 08:37 AM

are all the pins held high? Or do they wait for some code over the SPI.

I'm actually not sure, it should be in the datasheet of the 74hc595, but I normally just try such things out B)

Personally, I amazed how often your picture turns up in the forums so I'm totally grateful whenever you help out.

Aww, thanks!

Do I need to use his library as well as your library together or just yours.
Is this even possible?

It's your pick, you can use both. I never compared them in performance but his library has more built-in features. I only made mine to be more flexible with pins, both multiplexed and not multiplexed. And to learn more about those displays.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#47 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 21 September 2012 - 09:20 AM

Thanks for the quick reply. I also should have asked what happens with this design when my beloved Netduino is booting up. are all the pins held high? Or do they wait for some code over the SPI.

Grant


Since the pins are completely owned by the '595s, the Netduino behavior has nothing to do with that.
The '595 outputs could be in any state at power-on, because there's no logic setting them. There's a RESET pin but it acts on the first stage of the register, and has no effect on the output latch. You should "give" a positive edge to the STCP pin (12) to take the first stage status to the output latch.
Fortunately, the Netduino behavior comes as help on that, because it pulls any I/Os high, thus even the STCP.

It remains a problem: how to place a RESET (pin 10) at power-up.
You could ensure that by placing a small capacitor (e.g. 10-100nF) between the RESET pin and ground. You should add also a resistor (e.g. 10k) between the same RESET pin and the '595 positive supply.
That keeps the RESET pin low a bit longer than the rest of the circuit, so that the stages should be cleared.

BTW, if you want my viewpoint, I'd avoid relying on these quirky behaviors, either of the Netduino, as well as the '595. Instead, use the /OE pin (13) to enable the outputs only when your app really wants it. At power-on that pin should be pulled high (e.g. by any Netduino output), so that *ALL* the '595 outputs are Hi-Z (i.e. floating). At this point, you may place pull-ups, pull-downs, or whatever else you need, in whole safety.
No strange behaviors, full customizable, very elegant.

Cheers
Biggest fault of Netduino? It runs by electricity.

#48 stotech

stotech

    Advanced Member

  • Members
  • PipPipPip
  • 143 posts
  • LocationAustralia

Posted 22 September 2012 - 12:39 PM

Thanks Mario for that detailed response. I'm afraid for now some of it went over my head but I'll get it by the end of this little journey no doubt. I'd like to start by just blinking an led. I dove 3 hours today to pick up a 595 and I've copied the schematic on the front of this thread minus the inputs. But when I try the following code I get a few red underlines. I've referenced the toolbox correctly I think because I started by opening the example. The terms it underlines are "ChainOut" "OutputPortShift"

Please help. I'm so excited to get more ports.

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using Toolbox.NETMF.Hardware;


namespace Multiplexing_Test
{
    public class Program
    {
        public static void Main()
        {
            Ic74hc595 IcOutChain = new Ic74hc595(SPI_Devices.SPI1, Pins.GPIO_PIN_D9, 2);

            Ic74hc595 IcOut1 = new Ic74hc595(ChainOut, 0);

            OutputPortShift Led0 = new OutputPortShift(IcOut1, Ic74hc595.Pins.GPO_PIN_D0, false);

            while (true)
            {
                Led0.Write(true);
                Thread.Sleep(500);
                Led0.Write(false);
                Thread.Sleep(500);
            }
        }
    }
}



#49 stotech

stotech

    Advanced Member

  • Members
  • PipPipPip
  • 143 posts
  • LocationAustralia

Posted 22 September 2012 - 11:47 PM

This sort of works, the first time I run it, it turns the led on but doesn't blink. If I reset the Netduino it runs again but this time turns it off. Getting somewhere though. Actually it only seems to be on when I first connect the power. does it matter that I've only got one 595 connected? I should also note that I've tried 2 different 595's and that I'm running 4.2.
this is the part
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using Toolbox.NETMF.Hardware;


namespace Multiplexing_Test
{
    public class Program
    {
     
        public static void Main()
        {
            OutputPort onBoardLed = new OutputPort(Pins.ONBOARD_LED, false);

            // Defining two 74HC595s daisychained on the SPI bus, pin 9 as latchpin
            Ic74hc595 IcChain = new Ic74hc595(SPI_Devices.SPI1, Pins.GPIO_PIN_D9, 1);

            int x = 0;

            while (x < 5)
            {
                onBoardLed.Write(true);
                Thread.Sleep(500);
                onBoardLed.Write(false);
                Thread.Sleep(500);
                x++;
            }

            x = 0;

            while (x < 5)
            {
                IcChain.Pins[0].Write(true);
                IcChain.Pins[1].Write(true);
                IcChain.Pins[7].Write(true);
                IcChain.Pins[8].Write(true);
                Thread.Sleep(500);
                IcChain.Pins[0].Write(false);
                IcChain.Pins[1].Write(false);
                IcChain.Pins[7].Write(false);
                IcChain.Pins[8].Write(false);
                Thread.Sleep(500);
                x++;
            }

            x = 0;

            while (x < 5)
            {
                onBoardLed.Write(true);
                Thread.Sleep(500);
                onBoardLed.Write(false);
                Thread.Sleep(500);
                x++;
            }
        }
    }
}


#50 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 23 September 2012 - 07:32 AM

Just to be sure, you connected it according to this schematic? http://netmftoolbox....pported devices 1 or 2 chips shouldn't make a difference, as long as the constructor is ok.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#51 stotech

stotech

    Advanced Member

  • Members
  • PipPipPip
  • 143 posts
  • LocationAustralia

Posted 23 September 2012 - 08:21 AM

Thanks for getting back to me so fast. I've been refreshing the page all day hoping. I'm really grateful. Exactly the same as the 595 on the right. I've gone back and checked it a thousand times. Grant Attached File  DSC05364.jpg   1.21MB   21 downloads

#52 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 23 September 2012 - 08:27 AM

That's interesting, here it just works. but...

This sort of works, the first time I run it, it turns the led on but doesn't blink. If I reset the Netduino it runs again but this time turns it off.

Which LED? The onboard, or one connected with the 595s?
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#53 stotech

stotech

    Advanced Member

  • Members
  • PipPipPip
  • 143 posts
  • LocationAustralia

Posted 23 September 2012 - 08:31 AM

sorry, the one connected to the 595. I later found that it was a one off. now it's just on while the Netduino is booting the first time. if I hit the reset it doesn't come on. only when I first connect the power. I assumed I was missing something in the code. I've changed it a million times.

#54 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 23 September 2012 - 08:39 AM

Wait a minute. There are a few 595s. Could you please give the full name of the chip? There's one that works from 4.5V I believe. Maybe that's the case. If not, I can work out a short code to do more testing, but I'm kinda busy preparing for makerfaire atm :(
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#55 stotech

stotech

    Advanced Member

  • Members
  • PipPipPip
  • 143 posts
  • LocationAustralia

Posted 23 September 2012 - 08:51 AM

Nooooooooooooooooooooooooooooooooooo! Your not going to believe this. It just started working when I changed back to the other 595. So I thought, maybe a bad 595. Changed back again and what do you know. now they're both working. must have been bad connection some where.

Here is the finished code.

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using Toolbox.NETMF.Hardware;


namespace Multiplexing_Test
{
    public class Program
    {
     
        public static void Main()
        {
            OutputPort onBoardLed = new OutputPort(Pins.ONBOARD_LED, false);

            // Defining two 74HC595s daisychained on the SPI bus, pin 9 as latchpin
            Ic74hc595 IcChain = new Ic74hc595(SPI_Devices.SPI1, Pins.GPIO_PIN_D9, 1);

            int x = 0;

            while (x < 5)
            {
                onBoardLed.Write(true);
                Thread.Sleep(500);
                onBoardLed.Write(false);
                Thread.Sleep(500);
                x++;
            }

            x = 0;

            while (x < 5)
            {
                IcChain.Pins[7].Write(true);
                Thread.Sleep(500);
                IcChain.Pins[7].Write(false);
                Thread.Sleep(500);
                x++;
            }

            x = 0;

            while (x < 5)
            {
                onBoardLed.Write(true);
                Thread.Sleep(500);
                onBoardLed.Write(false);
                Thread.Sleep(500);
                x++;
            }
        }
    }
}



#56 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 23 September 2012 - 08:53 AM

Glad to see it's solved!
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#57 stotech

stotech

    Advanced Member

  • Members
  • PipPipPip
  • 143 posts
  • LocationAustralia

Posted 23 September 2012 - 08:53 AM

A million times thankyou for your help. If this super shield project gets off the ground. I'll be sending complimentary version to all you guys who've helped me out.

#58 stotech

stotech

    Advanced Member

  • Members
  • PipPipPip
  • 143 posts
  • LocationAustralia

Posted 26 September 2012 - 08:30 AM

Thanks To Mario I've got the boot up issue sorted out. I've connected pin 13 of the register to pin 8 on the Netduino through a 5k resistor. On boot I declare it as an output pin starting high. And when I'm using the register pull it low. I think that's what he meant? correct me if I'm wrong some one. Thanks Again

#59 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 26 September 2012 - 11:36 AM

Thanks To Mario I've got the boot up issue sorted out. I've connected pin 13 of the register to pin 8 on the Netduino through a 5k resistor. On boot I declare it as an output pin starting high. And when I'm using the register pull it low. I think that's what he meant? correct me if I'm wrong some one.

Thanks Again


Yes, I meant that.
About the register outputs, bear in mind that they're in the Z-state during the /OE high. That means there's NO either pull-up, nor pull-down from them. If any of the outputs should drive another gate input (e.g. an AND input or similar), the problem faced is the same: an input can't be left floating.
However, that's a problem for the implementor of the target circuit.
Cheers
Biggest fault of Netduino? It runs by electricity.

#60 gfcwfzkm

gfcwfzkm

    Advanced Member

  • Members
  • PipPipPip
  • 52 posts
  • LocationBrig-Glis, Switzerland

Posted 01 October 2012 - 12:15 PM

Nice, but i have some problems... I become (When i translate the code to VB) some "This is not defined" errors: Der Typ "Ic74HC595Chain" ist nicht definiert. Same with InterruptPortShift and OutputPortShift. Did i need some others .dll 's? I just have Toolbox.NETMF.Hardware imported mfg gfc EDIT:// Code problems resolved =) THX to Stefan and Grant.




1 user(s) are reading this topic

0 members, 1 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.