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

Newbie on shif register using 74HC595N


  • Please log in to reply
4 replies to this topic

#1 nguada

nguada

    New Member

  • Members
  • Pip
  • 2 posts

Posted 23 July 2013 - 04:14 AM

[font="consolas;"][color=rgb(0,0,255);][color=rgb(0,0,0);]Hello Guys!
 
Sorry in advanced for next newbie questions about Netduino and 74HC595N...
 
I'm so new working with Netduino 2 Plus. I've been testing all labs and tests that I found on Internet (Sparkfun, Adafruit, Netduino's wiki, enthusiast and go on...)
 
Also, I've been studying a lot about how other people have been building very interesting projects using 74HC595N ICs to multiplex serial data and handle parallel bits on several ways (best examples: Led Cube or using SPI devices).
 
However, I'm stuck in some points because my background is not on electrical matters, but is on software development. Actually, I read all "Newbie" project that I found on this forum:[/color]
http://forums.netdui...-74hc595-chips/
http://wiki.netduino...le-74HC595.ashx [color=rgb(0,0,0);]and finally[/color]
http://wiki.netduino...t-Register.ashx
 
[color=rgb(0,0,0);]I understood very well how the shift register works and also I built the whole lab (CIRC-05 | 8 more Leds), and actually worked fine, but I noticed that, when I code to turn HIGH all my leds using this simple program:[/color][/color][/font]

[font="consolas;"][color=rgb(0,0,255);] [/color][/font]

[font="consolas;"][color=rgb(0,0,255);]public[/color][/font] [font="consolas;"][color=rgb(0,0,255);]static[/color][/font] [font="consolas;"][color=rgb(0,0,255);]void[/color][/font][font="consolas;"] Test()[/font]

[font="consolas;"]{[/font]

[font="consolas;"][color=rgb(43,145,175);]OutputPort[/color][/font][font="consolas;"] data = [/font][font="consolas;"][color=rgb(0,0,255);]new[/color][/font] [font="consolas;"][color=rgb(43,145,175);]OutputPort[/color][/font][font="consolas;"]([/font][font="consolas;"][color=rgb(43,145,175);]Pins[/color][/font][font="consolas;"].GPIO_PIN_D11, [/font][font="consolas;"][color=rgb(0,0,255);]false[/color][/font][font="consolas;"]);[/font]

[font="consolas;"][color=rgb(43,145,175);]OutputPort[/color][/font][font="consolas;"] clock = [/font][font="consolas;"][color=rgb(0,0,255);]new[/color][/font] [font="consolas;"][color=rgb(43,145,175);]OutputPort[/color][/font][font="consolas;"]([/font][font="consolas;"][color=rgb(43,145,175);]Pins[/color][/font][font="consolas;"].GPIO_PIN_D13, [/font][font="consolas;"][color=rgb(0,0,255);]false[/color][/font][font="consolas;"]);[/font]

[font="consolas;"][color=rgb(43,145,175);]OutputPort[/color][/font][font="consolas;"] latch = [/font][font="consolas;"][color=rgb(0,0,255);]new[/color][/font] [font="consolas;"][color=rgb(43,145,175);]OutputPort[/color][/font][font="consolas;"]([/font][font="consolas;"][color=rgb(43,145,175);]Pins[/color][/font][font="consolas;"].GPIO_PIN_D12, [/font][font="consolas;"][color=rgb(0,0,255);]false[/color][/font][font="consolas;"]);[/font]

[font="consolas;"][color=rgb(0,0,255);]for[/color][/font][font="consolas;"] ([/font][font="consolas;"][color=rgb(0,0,255);]int[/color][/font][font="consolas;"] i = 0; i < 8; i++)[/font]

[font="consolas;"]{[/font]

[font="consolas;"] latch.Write([/font][font="consolas;"][color=rgb(0,0,255);]false[/color][/font][font="consolas;"]);[/font]

[font="consolas;"][color=rgb(0,0,255);] for[/color][/font][font="consolas;"] ([/font][font="consolas;"][color=rgb(0,0,255);]int[/color][/font][font="consolas;"] j = 0; j < 8; j++)[/font]

[font="consolas;"] {[/font]

[font="consolas;"][color=rgb(0,0,255);]   if[/color][/font][font="consolas;"] (i == 2 || i == 3 || i == 4 || i == 5 || i == 6 || i == 7)[/font]

[font="consolas;"]   {[/font]

[font="consolas;"]   data.Write([/font][font="consolas;"][color=rgb(0,0,255);]true[/color][/font][font="consolas;"]);[/font]

[font="consolas;"] }[/font]

[font="consolas;"][color=rgb(0,0,255);]   else[/color][/font]

[font="consolas;"]   {[/font]

[font="consolas;"]   data.Write([/font][font="consolas;"][color=rgb(0,0,255);]false[/color][/font][font="consolas;"]);[/font]

[font="consolas;"]   }[/font]

[font="consolas;"]   clock.Write([/font][font="consolas;"][color=rgb(0,0,255);]true[/color][/font][font="consolas;"]);[/font]

[font="consolas;"][color=rgb(43,145,175);]   Thread[/color][/font][font="consolas;"].Sleep(1);[/font]

[font="consolas;"]   clock.Write([/font][font="consolas;"][color=rgb(0,0,255);]false[/color][/font][font="consolas;"]);[/font]

[font="consolas;"] }[/font]

[font="consolas;"]   latch.Write([/font][font="consolas;"][color=rgb(0,0,255);]true[/color][/font][font="consolas;"]);[/font]

[font="consolas;"][color=rgb(43,145,175);]   Thread[/color][/font][font="consolas;"].Sleep(500);[/font]

[font="consolas;"]}[/font]

[font="consolas;"]data.Dispose();[/font]

[font="consolas;"]clock.Dispose();[/font]

[font="consolas;"]latch.Dispose();[/font]

[font="consolas;"]}[/font]

 

[font="consolas;"]all leds bright, but too low (almost you cannot see if there are on or off). According with the package, all leds are:[/font]

 

[font="consolas;"]5 mm super bright blue 3.2V 20mA[/font]

 

[font="consolas;"]According with Netduino 2 Plus spec (http://www.netduino....plus2/specs.htm), each pin have:[/font]

[font="consolas;"]max current: 25mA per pin[/font]

[font="consolas;"]digital I/O are 3.3V -- but 5 V tolerant[/font]

 

[font="consolas;"]and according with 74HC595N specs sheet(http://ardx.org/data.../IC-74HC595.pdf), each pin output is:[/font]

 

[font="consolas;"]+/- 35mA[/font]

 

[font="consolas;"]I used several combinations for registers:[/font]

 

[font="consolas;"]a) Using 100 ohm register connected to each cathode and then to ground[/font]

[font="consolas;"]B) Using 100 ohm register connected to each anode and each cathode to ground directly[/font]

[font="consolas;"]c) With no registers!![/font]

 

[font="consolas;"]Always I received the same (each led turns on, but the bright is too low) results[/font]

 

 [font="consolas;"]So, my questions are:[/font]

 

[font="consolas;"]1.) Do I need to use some kind of capacitor to increase the amount of voltage to get the right current?[/font]

[font="consolas;"]2.) What connections (pin to pin) do I need to care about? (I mean, I'm connecting 5V pin to a breadboard, and from the breadboard I'm connecting directly to 74HC595 pin 16 (VCC).[/font]

 

[font="consolas;"]Again, sorry for this newbie question...[/font]

 

[font="consolas;"]I hope that somebody can help me to understand this scenario[/font]

 

[font="consolas;"]Kind regards![/font]

 

 



#2 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 24 July 2013 - 11:08 AM

there are some things not so correct.

 

first: the 595 can only supply around 90ma total, so max 3 pins can reach the 35ma.

since you use 8 it gets split over all (like 10ma per pin) - its not healthy for the ic todo that.

 

than: you open and dispose the output ports, dont do that. let them open the whole time.

also, whats your main loop doing? if it ends it may give odd results.

 

and why are you bitbanging spi? (and in a even strange way ...)

 

use hardware spi, its way faster. and dynamic :D

 

connect it like that:

https://netmftoolbox...pported devices

 

in the link in my sig is a good multispi class, and ill add my 74hc595 drivers.

use it like: IC74HC595 hc = IC74HC595(latch, SPIModule-1-or-whatever-you-wanna-use);

hc.WriteData(0xFF); // turn all leds on

hc.WriteData(0x00); // turn all leds off

 

 

edit: btw, that circ-05 used 350ohm resistors, on the cathode side (negative) and the leds are connected with anode (positive) to the 595's - thats the way id do it also, ou should also do it like that, not 2 resistors and get the correct value.

Attached Files



#3 nguada

nguada

    New Member

  • Members
  • Pip
  • 2 posts

Posted 25 July 2013 - 03:48 PM

there are some things not so correct.

 

first: the 595 can only supply around 90ma total, so max 3 pins can reach the 35ma.

since you use 8 it gets split over all (like 10ma per pin) - its not healthy for the ic todo that.

 

than: you open and dispose the output ports, dont do that. let them open the whole time.

also, whats your main loop doing? if it ends it may give odd results.

 

and why are you bitbanging spi? (and in a even strange way ...)

 

use hardware spi, its way faster. and dynamic :D

 

connect it like that:

https://netmftoolbox...pported devices

 

in the link in my sig is a good multispi class, and ill add my 74hc595 drivers.

use it like: IC74HC595 hc = IC74HC595(latch, SPIModule-1-or-whatever-you-wanna-use);

hc.WriteData(0xFF); // turn all leds on

hc.WriteData(0x00); // turn all leds off

 

 

edit: btw, that circ-05 used 350ohm resistors, on the cathode side (negative) and the leds are connected with anode (positive) to the 595's - thats the way id do it also, ou should also do it like that, not 2 resistors and get the correct value.

 

Thanks a lot NooM!!!

 

Basically, I'd understood that each single pin from 74HC595N could emit max 35mA but I didn't notice about max output for the shift register (80mA Max according with the datasheet).

 

Regarding to your question about why I'm opening and disposing ports in this way. This is not the final program. It's just a test about how to add all bits into the shift register.

 

I'll try using 330 ohm resistors to build the same circuit and check the output for each pin.

 

I've another doubt...because you're recommend me use SPI ports, where can I find what advantages has use SPI instead regular output ports?

 

Kind regards



#4 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 25 July 2013 - 06:18 PM

real spi ports are million* times faster. - they do that in hardware what you do in software, and that a lot faster than you can

set the pins in software.

 

the 595 is a quasi spi device, so its made for that.

 

also, what you do seems way more complicated than what i explained (with my spi and 595 class)

 

best to forget about your doubts (where did they came from?) and just trust me. :D



#5 Anthony Glenwright

Anthony Glenwright

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 26 July 2013 - 04:17 AM

Hi nguada,

 

In case it helps you to decide to follow NooM's advice:  I am using hardware SPI to communicate with a 74HC595 to drive an LCD screen, and it works great.  And it is much easier than your code above.

 

Won't help you with the output current problem, of course.  Perhaps the 74HC595 with a transistor array like this (http://www.taydaelec...y-8-npn-ic.html) will help with that?






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.