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

Using a 7 segment display without a shift register

7 segment display

  • Please log in to reply
9 replies to this topic

#1 Basset

Basset

    New Member

  • Members
  • Pip
  • 7 posts
  • LocationCanada

Posted 13 August 2013 - 11:15 PM

Hello,

 

I have been working on getting a 7 segment display to work with my Netduino plus 2 without a shift register and have gotten 1 digit out of 2 working so far.  The issue I am having is how to, for example, count down from 99 on the display.  I understand that 7 segment displays are multiplexed, it's just that i don't know how to implement that into the software.  Would threading be of use here?

 

Here is the code I have written so far, if there is a better way to do it please let me know!

 

Program.cs

Display.cs

 

 

I am a beginner so any critique on the code is appreciated.

 

Thanks for your help!



#2 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 14 August 2013 - 08:29 AM

you totally wanna use a shift register.

its a waste of pins to use it without.

 

and you should not connect it directly to your netduino pins, its 7-8 leds, if all are on they may damage the common anode/cathode pin.

so use transistors for max brightness, or at least a big enuff resistor

 

i used that code to test a 4 digit one: http://pastebin.com/rMJRSHqn

 

btw: using pins directly is way more complicated than a 74hc595 where you can send bytes directly,

it shortens the code by a big ammount (sorry, cant find a sample code for that)



#3 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 14 August 2013 - 01:08 PM

Using SPI to control a single shiftreg, wouldn't that require a pretty tight loop for multiplexing a 2-digit 7-segment display?



#4 nakchak

nakchak

    Advanced Member

  • Members
  • PipPipPip
  • 404 posts
  • LocationBristol, UK

Posted 14 August 2013 - 01:38 PM

Using SPI to control a single shiftreg, wouldn't that require a pretty tight loop for multiplexing a 2-digit 7-segment display?

It would be like driving any shift register not particularly difficult. more info in the wiki

personally i would look at chaining a couple of 74LS47's together then just write a byte array to it last time i checked you could get 5 for under a $ on ebay.

 

Nak.



#5 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 14 August 2013 - 02:03 PM

Using SPI to control a single shiftreg, wouldn't that require a pretty tight loop for multiplexing a 2-digit 7-segment display?

 

well, i even multiplexed 8x8 ledmatrixes with 74hc595, works great.

even rgb ledmatrix.

 

see link in my signature, i even posted the code there :D



#6 Basset

Basset

    New Member

  • Members
  • Pip
  • 7 posts
  • LocationCanada

Posted 14 August 2013 - 11:11 PM

Thanks for the replies.

 

I forgot to put my setup in the first post but I am running each led with a 330 resistor and driving the common anode pins with transistors.  I don't currently have any shift registers so that is why I'm driving it directly from the netduino.  A few shift registers will be added to my next order to clean it up a bit.

 

I have been able to display 2 different characters on the display now however I am still unsure on how to "push" new characters to the screen.  In my code it is just a while loop switching between displaying the first digit and the second digit, preventing me from sending it a new character.  I would like to be able to write a function that writes to the display and keeps it there until another command is set.  I believe this is accomplished by threading a method to keep the screen 'alive' and send it an event(?) to update it.  I haven't used events or threading before however so I'm not sure how to implement it yet so any help is appreciated. 

 

Here it is displaying 'HI':

Posted Image

 

And the updated code.

 

Thanks!



#7 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 15 August 2013 - 06:41 AM

If you don't want to go down the shift register route then I agree with Nak on the 74HC47's.  They are easy to use.  If you want a circuit then look here.

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#8 JoopC

JoopC

    Advanced Member

  • Members
  • PipPipPip
  • 148 posts

Posted 15 August 2013 - 12:03 PM

A good way to use the 7 Segments is with a MAX7219.  Did you see this project? http://embedded-lab.com/blog/?p=6644



#9 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 20 August 2013 - 01:10 PM

I have been able to display 2 different characters on the display now however I am still unsure on how to "push" new characters to the screen.  In my code it is just a while loop switching between displaying the first digit and the second digit, preventing me from sending it a new character.  I would like to be able to write a function that writes to the display and keeps it there until another command is set.  I believe this is accomplished by threading a method to keep the screen 'alive' and send it an event(?) to update it.  I haven't used events or threading before however so I'm not sure how to implement it yet so any help is appreciated. 

 

 

Since characters currently don't "stick" you are doing multiplexing by looping while toggling between the two digits. Sure, you could do the multiplex loop in a thread but there's a good chance it will flicker depending on how much and what you do in your main thread. To get "sticky" characters, you'd have to use some kind of slave chip like the ones suggested some of the other guys earlier in this thread.

 

As for "pushing in" arbitrary characters, you could display other letters quite easily by simply reading them from an array of digits or something like that.

 

Consider creating a base class "Digit" for setting the GPIOs for any given character you wan't to display in either of the two 7-segment digits. The class could have a method called "Render()" that would set the GPIOs as necessary depending on which character the class instance represents.

 

You could then derive one sub class from "Digit" for each character that you need, i.e. among others, you would have sub classes DigitH, DigitI and Digit0...Digit9 and so forth overriding the Render method. You could then create and dictionary of Digit objects and simply index the array using the corresponding ASCII character taken from the string(s) that you want to display, i.e. "HI", "40" etc.

 

This software approach can be used regardless of whether or not you choose to use a slave chip.



#10 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 20 August 2013 - 07:38 PM

Have a look at the LED Cube wiki article.  You are effectively doing a simpler form of a cube - i.e. only two layers and 7 LEDs.


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter






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.