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

#21 exanko

exanko

    New Member

  • Members
  • Pip
  • 4 posts

Posted 20 August 2011 - 10:47 PM

Hi

Iam trying follow your tut. Inputs alone works fine (added Debug.Print(PinId.ToString()); to interrupt methods, and the pointer is right). Outputs works only if i disconnect clock wire between output and input IC's.
Iam using simple loop to test outputs:

int cnt = 0;
while (true)
{
Leds[cnt].Write(true);
Debug.Print(cnt.ToString());
Thread.Sleep(1000);
Leds[cnt].Write(false);
cnt++;
if (cnt > 15) cnt = 0;
}

Everything is ok when clock wire goes only on output IC's, but when is connected farther to input IC's, the first output (Qa) on both 74HC595 is stil in 1 (ON) and the bits are shifted (Leds[0].Write(true); turns Qb, Leds[1].Write(true); turns Qc .....).

Here is video with clock disconnecting: Youtube
(the connection is checked milion times).

Thx for any suggestions.

#22 Stefan

Stefan

    Moderator

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

Posted 21 August 2011 - 07:41 AM

Stat's strange, since the clock wire is only outgoing from netduino. I can't think of a reason causing this. But I do know (dis)connecting clock or one of the data lines while the program runs, the shifter IC's gets 'confused' since it probably misses a few bits. Do you have your IC's connected to +5V or +3.3V? Also, which pins did you use as latch/chip select pin? I know pin 4 has some timing issues.
"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

#23 exanko

exanko

    New Member

  • Members
  • Pip
  • 4 posts

Posted 21 August 2011 - 08:48 AM

Stat's strange, since the clock wire is only outgoing from netduino. I can't think of a reason causing this.

But I do know (dis)connecting clock or one of the data lines while the program runs, the shifter IC's gets 'confused' since it probably misses a few bits. Do you have your IC's connected to +5V or +3.3V?
Also, which pins did you use as latch/chip select pin? I know pin 4 has some timing issues.


+5V :rolleyes: my fault. 3,3V works nice. Thanks for your help.

#24 Stefan

Stefan

    Moderator

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

Posted 21 August 2011 - 08:57 AM

+5V :rolleyes: my fault. 3,3V works nice. Thanks for your help.

Glad to read that! I had the same issue once.
The IC's work on 2.5 to 6V, but since the clock and datalines from the netduino are 3.3V it can give troubles when you connect them to 5V. At least, I thought that's the case.
"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

#25 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 21 August 2011 - 03:35 PM

Stefan, the supply voltage of the external logic should not be a problem. The HCMOS chips work well with the high level below the nominal supply. However, the min threshold must be below the Netduino high-level (3.3V). Instead, I took a peek at the sources. About the HC595, you should set the SPI config with both "Clock_IdleState" and "Clock_Edge" to true. This because the SPI guarantees the stable data on the MOSI pin when the clock is rising, and changes it on the other edge. Probably the circuit is working at the limit, and when the power is +5V the troubles are evident. On the other side, neither the HC165 is properly driven, IMHO. The HC165 shifts on the rising edge of the clock, but the SPI is also sampling the MISO pin at the same time. This easily leads to an aleatory value. Moreover, you should drive the PL pin. How can you take a "snapshot" of the parallel inputs otherwise? Cheers
Biggest fault of Netduino? It runs by electricity.

#26 Stefan

Stefan

    Moderator

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

Posted 22 August 2011 - 07:35 AM

Stefan, the supply voltage of the external logic should not be a problem. The HCMOS chips work well with the high level below the nominal supply. However, the min threshold must be below the Netduino high-level (3.3V).

Instead, I took a peek at the sources.
About the HC595, you should set the SPI config with both "Clock_IdleState" and "Clock_Edge" to true. This because the SPI guarantees the stable data on the MOSI pin when the clock is rising, and changes it on the other edge.
Probably the circuit is working at the limit, and when the power is +5V the troubles are evident.

I shall look at it soon. It's one of my first netduino schematics so it could contain some mistakes :)


On the other side, neither the HC165 is properly driven, IMHO.
The HC165 shifts on the rising edge of the clock, but the SPI is also sampling the MISO pin at the same time. This easily leads to an aleatory value.
Moreover, you should drive the PL pin. How can you take a "snapshot" of the parallel inputs otherwise?
Cheers

I already gave that some thought and driving it correctly should require an additional NOT component I suppose. The funny thing is, you suggested the current setup here :D
"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

#27 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 22 August 2011 - 03:23 PM

The funny thing is, you suggested the current setup here

Unless I misinterpret your directive on how to connect the HC165, my intention was and still is to drive the PL pin using an OutputPort of the Netduino.

At this point I must ask a question, because I cannot make experiment here (I'm on vacation), and I don't remember what is the current SPI limitation. The PL pin could be driven "manually", by using any OutputPort to create a pulse (low). That pulse freezes the current state of the HC165 inputs to the shift register. It acts much like the button of a camera: you must pull it low to take a snapshot.
Well, it would be nice that it will be driven automatically by the SS output. This could improve the SPI performance, and get a cleaner code (and simpler as well). So, until the /PL is low, there's no way to shift any data. Thus the /PL should be NORMALLY low, and tied high when the SPI asks for the transfer. This is surely allowed by the SPI config, but it is complementary to the HC595 SS schema.
My question is: the current SPI implementation allows to create to different SPI configs, so that the HC595 and the HC165 could be hosted together, in the same app?
If so, that schema should be better.

If you may perform any test, feel free to tell me any news about it.
I told you, I am spending ten days in Suedtirol...(HEAVEN!)
Cheers
Biggest fault of Netduino? It runs by electricity.

#28 Stefan

Stefan

    Moderator

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

Posted 22 August 2011 - 03:32 PM

I told you, I am spending ten days in Suedtirol...(HEAVEN!)

Enjoy :D
"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

#29 exanko

exanko

    New Member

  • Members
  • Pip
  • 4 posts

Posted 06 September 2011 - 11:52 PM

Hi,

Iam back with news.
3.3V works nice, so i made little 8x8 (1 Output = 1 LED) display from 74HC595 ICs, video here.
Than I start with scrolling text, so I expand display with another same display connected in to series (16x 74HC595) and problem with first bit is back.
First of all I thought its because netduino power supply cant handle too much ICs and LEDs, so I took down LEDs from one of these displays (only ICs connected) and it was same, than i used external 3.3V (from ATX supply connected over opto couplers), but this not solved the problem.
Youtube video with problem is here. The problem starts when is second diplay connected to series (same with parallel). Multimeter shows voltage between Vcc+SRCLR (3.3V) and GND pins. Interesting is that problem disappear when i pull this voltage down, or disconnect Vcc, but "brightles" is decreased.

O_o cool i solved problem while writing this post. Just put small 220ohm (27ohm was too small) between pin 11 and first IC serial (SER) input pin (yellow wire on stefans fritzing). Dont ask me why, but works :) (only 3.3V. 5V makes another anomaly, some characters in text have missing parts)

Tomorrow I will make some videos of displays and add links here:


#30 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 07 September 2011 - 04:03 AM

I'll post some considerations after the Stefan's answer...
Biggest fault of Netduino? It runs by electricity.

#31 Stefan

Stefan

    Moderator

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

Posted 07 September 2011 - 07:36 AM

I'll post some considerations after the Stefan's answer...

I'm curious! I set up this project but you have much more knowledge about this.

I haven't found issues with the 74HC595 schematics, only with the 74HC165, which I'm trying to look into.
"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

#32 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 07 September 2011 - 08:18 AM

I checked the source by downloading it from your site (so I assume it is updated).
In the 595 SPI config, the ClockEdge is set to false, but it must be set to true.
Read my example on the Wiki, and it will be clear.

Exanko was able to get the circuit working with two "tricks":
  • keeping the power supply low enough (at 5V the circuit is not working properly);
  • placing a (small) resistor in series to a wire.
I hope it's clear that it is not a good symptom...
Both the above tricks contribute to "delay" the signal respect to the clock. Since the clock is phased out of 180', a little delay re-phases the datum respect to the clock edge.

Still not finished to comment, but at the moment I have no time.
Biggest fault of Netduino? It runs by electricity.

#33 Stefan

Stefan

    Moderator

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

Posted 07 September 2011 - 08:21 AM

Still not finished to comment, but at the moment I have no time.

Mario, I want to thank you for your help so far, and hopefully in the future ;)

I am currently revising a lot of code and schematics at home (and working on VB-versions) and going to correct this in the next version. Going to look to the wiki tonight since I also have little time.
"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

#34 Pete Brown

Pete Brown

    Advanced Member

  • Members
  • PipPipPip
  • 138 posts
  • LocationAnne Arundel County, MD

Posted 10 September 2011 - 05:57 AM

@Stefan

Thanks so much for posting this code. I used it to do a simple 8 button multiplexing test.

http://10rem.net/blo...th-the-netduino


Pete
Pete Brown - http://10rem.net (NETMF, C++, Windows, C64, and general geekery) Twitter: @pete_brown
I work for Microsoft. Opinions expressed here are my own and do not necessarily reflect those of my employer,our partners or customers.

#35 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 10 September 2011 - 06:38 AM

@Pete: I read right now your post. I admire your way to explain the hardware concepts to the people who don't know the basis. It wouldn't easy for me, cos I always tend to use the "formal" way! I wish to point a potential problem for your project. You say that the goal is to drive both the HC165 shifter for buttons, and the HC595 for LCD. This is a discussed limitation, that still has not a good/easy solution. Stefan proposed a trick, but it looks much like a "patch" instead of an elegant pattern. I'd suggest you to stay in touch, because both Stefan and me really would love to find a nice way to glue inputs and outputs together. Cheers
Biggest fault of Netduino? It runs by electricity.

#36 Stefan

Stefan

    Moderator

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

Posted 10 September 2011 - 08:15 AM

@Stefan

Thanks so much for posting this code. I used it to do a simple 8 button multiplexing test.

http://10rem.net/blo...th-the-netduino

Please don't solder your project just yet ;)
I've been working on improving the 74HC165 schematics which will probably be posted somewhere after my vacation (~26sept)
There are some performance issues with it. The 74HC595 schematic is OK but code can require some tweaks too.

For the LCD, try the attached Ic74HC595LcdProvider-class, together with this: http://geekswithblog...id_crystal.aspx
It's a tryout of myself which helps linking the LCD classes with other 74HC595 chains. I succeeded to drive multiple LCD's on one latch pin with it.

Attached Files


"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

#37 Stefan

Stefan

    Moderator

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

Posted 13 September 2011 - 04:38 PM

Just a small update to this project. There were some issues with the 74HC165 chains. I have this fixed with a lot of help from Mario (read: he fixed it, I implemented it :D). It still has some troubles running at high speeds with longer cables, but when using relatively short cables at 1MHz, it should be fine. New code can be found at: http://netmftoolbox.codeplex.com/ I am still trying to figure out the speed issue.
"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

#38 lesmondo

lesmondo

    Member

  • Members
  • PipPip
  • 24 posts

Posted 23 September 2011 - 02:56 AM

Hey Shifting Gurus :) It's been a while since I last made a PCB (think dinosaurs) so I was looking for a little project to learn how to make use of the cheap fab available to hobbyists and the obligatory reflow toaster oven. Inspired by this thread, I knocked up this little 595/165 port expander. I've been staring at it for days now and I'm sure it's OK to send off for fab but I just wanted to ask you guys to sanity check it. BTW LEDs are Vf=3.3 If=20ma pink ones (my daughter loves pink). Thanks Les

Attached Files



#39 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 23 September 2011 - 03:51 AM

Hello Les!
Great idea making a PCB: it was a long time project, but none even started it.

Well, about the schematic, it seems okay. I didn't check the PCB, though.

I'd tell my opinion, and I'd love other people add their suggestions, so that you may finish the project.
  • I'd use the positive logic for the leds. For the HCMOS chips there's no difference if you drive at high or low level, so I'd vote for the most intuitive polarity.
  • I'd make the shield "chainable", at least for the 595, so that the users may chain several shields, and driving many leds. I wouldn't see the necessity to chain more 165s.
  • I'm still uncertain whether is better to create a single shield for inputs and outputs, or create two different shields. It may depend on the PCB cost.
  • In the "chainable" context, it would be nice that the user may use connectors, instead of wiring several shields together. I suppose the wiring is tedious.
Feel free to suggest your viewpoint.
Don't forget to add how much will cost the PCBs.
Cheers
Biggest fault of Netduino? It runs by electricity.

#40 Stefan

Stefan

    Moderator

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

Posted 23 September 2011 - 06:49 PM

Sounds like a great plan! Mario's advise is a good one. If you can make the shield 'daisychainable' it would be awesome!
"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




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.