November 22, 2024, 01:47:25 PM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Driving 7 segment LED display with BS2 - Common Anode or Cathode

Started by jukingeo, October 26, 2007, 05:26:57 PM

Previous topic - Next topic

jukingeo

Hello,

I am beginning to learn moreand more about the BS-2 with each day, but as of now I pretty much want to get out of just making LED's flash and chase.

Now I want 'graduate' to displays.

I currently have the Prop-2 with the Prop-1 trainer.  I do have a solderless breadboard and I am going to go directly from the 12 voltage reference on the BS2 and connect the BS2 outputs to the 7 segment display via a 680 ohm resistor on each segment.  This should keep the currents levels on each sement in line.

But now here is the kicker, the way the Prop-2 is arranged, the output circuit is referenced to the positive supply and the circuit is completed when the pin is referenced to ground through the load.  This would dictate the use of a common anode 7 segment display.   The problem is that common cathode 7 segment displays are more common and all of my displays are of the common cathode variety.

So my question is this:

Can I use my common cathode  7 segment displays with the Prop -2?  I am going to assume this will be a yes, but what alterations to the code must I do?

Thanx in advance for your help.

Geo

randyaz

check out chapter 6 of the "Whats a Microcontroller" for all about the Prop2/BS2 and a 7 segment display

http://www.parallax.com/dl/docs/books/edu/Wamv2_2.pdf

JonnyMac

You can use common cathode displays only if you go from the TTL (Px.W) terminals; that means limiting the current quite a bit to protect the pins (use 1K).  If you want to use V+ and the OUTx terminals then you must use a common anode display.
Jon McPhalen
EFX-TEK Hollywood Office

jukingeo

Quote from: JonnyMac on October 26, 2007, 08:29:34 PM
You can use common cathode displays only if you go from the TTL (Px.W) terminals; that means limiting the current quite a bit to protect the pins (use 1K).  If you want to use V+ and the OUTx terminals then you must use a common anode display.


Hello Jon,

That is what I was afraid of.   I do have the "What's A Microcontroller" documentation that Randy mentioned above and I am currently up to that part of the exercise.  Now, the document does show a common cathode display but that is for the assumption one is doing the exercises on Parallax Board of Education.  I am doing all of my experimenting from the Prop-2.

Now here is my dilema, the Prop-2 doesn't have regular terminal access points as the BOE does.  It has the servo connector pins.  Thus I figured I may as well just use the 12v supply output and go directly to the screw terminals and out using the Prop-2's output as an interface to a solderless breadboard...thus mimicking having a BOE.  BUT, the output circuitry for the Prop - 2 is arranged common anode, so that is why I asked if there was a way to program around this.

Since a practical application would dictate connection to the terminals, I guess it would be easier (and cheaper) to buy a common anode display (as I already have the 680 ohm resistors too).  Sure the resistors are cheap, but the servo headers are not as cheap.

I mean I really could go either way but as you pointed out, I would have to limit the current even more going direct.

Regardless, what would be the programming differences (if going directly to the BS2)?  The WAM book doesnt mention this scenario.

Finally, you mentioned using a 1k resistor when using the direct outputs...but that would be for 12 volts right?  The direct output is 5 volts, correct? 

Thanx,

Geo

JonnyMac

I don't know what you mean, "doesn't have regular access points." What do you think P0.W through P15.W are?  Those are [near] direct connections to the processor I/O pins.  Each is protected by a 220-ohm resistor as on the Parallax homework board -- this is to protect from accidents (many customers refuse to learn and apply Ohm's law).  The problem is not with the Prop-2; it is what it is and we've never falsely promoted any of its capabilities.  And it was never meant to be a replacement for or work-alike of the BoE; it is in fact an industrial controller that uses an BASIC Stamp 2 processor core.  Male header pins and associated female sockets are very common in the electronics world -- servos aren't the only things to use them.

Use 1K for the 5v outputs to limit the current through the displays so that you don't exceed the output spec of the PIC16C57 (PBASIC core).  You can allow more current to flow through the display if you're using the ULN outputs because those outputs can handle a lot of current, the PIC outputs can't.  If you use the direct outputs then it's just exactly like using the Prop-1 trainer: to light a segment you make the respective output high.  See StampWorks for other 7-segment programming examples that you can apply this way.  And if you end up using the ULN outputs with a common-anode display, you can always use high logic (1 = on) in the code and invert it on the way out:

  OUTL = segments ^ %11111111

This will flip the bits of segments and write it to the outputs on P0..P7.

I recommend brushing up on your basic electronics skills before moving forward.  Once you start connecting custom circuits you're responsible for design decisions that could adversely affect the Prop-2.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Just to clarify... I use 1K when connecting 7-seg displays; since the Prop-2 already has 220-ohm resistors inline with each pin, you could use 680, but I don't suggest going lower than this (safety).  In the rarely-read documentation for our controllers you'll find a specification called IOHg -- this is the total output current for a group (P0..P7 or P8..P15); it's 50 mA for the Prop-2.  To be safe you want to stay well under that (most practical engineers de-rate specs by 50%).

Assuming 1.5v per segment diode, using a 680 in line would give you about 3.9 mA per segment, or 31 mA (max) for the group -- this is safe and should provide enough segment current to see the display (if not, use the OUTx terminals).  Here's the math (I = E/R):

  total current (IOHg) = ((5.00 - 1.50) / (220 + 680)) x 8
Jon McPhalen
EFX-TEK Hollywood Office

jukingeo

Quote from: JonnyMac on October 27, 2007, 11:11:06 AM
I don't know what you mean, "doesn't have regular access points." What do you think P0.W through P15.W are?

What I meant was the physical connection.  The BOE has connection points that allow you to hook up solid 22awg wire to a breadboard.  A 'regular' bare wire to bare wire connection that is what I meant.

QuoteThose are [near] direct connections to the processor I/O pins.  Each is protected by a 220-ohm resistor as on the Parallax homework board -- this is to protect from accidents (many customers refuse to learn and apply Ohm's law).  The problem is not with the Prop-2; it is what it is and we've never falsely promoted any of its capabilities.  And it was never meant to be a replacement for or work-alike of the BoE; it is in fact an industrial controller that uses an BASIC Stamp 2 processor core.  Male header pins and associated female sockets are very common in the electronics world -- servos aren't the only things to use them.

I never said anything about a problem with the BS-2 and I never said anything 'falsely promoted' about the BS2.  Up to now I have been extremely happy with the product and I don't feel I have said or did anything to the contrary. This is the second time you assumed this of me. 

Right now I have the one controller and I am using it to learn with.  However to work through most of the exercises in both WAM and the Stampworks book based on your recommendation requires a breadboard.  So the point I was making was that I wanted to use the screw terminal outputs of the Prop - 2.  I have plenty hook up wire, but I don't have much in terms of the servo header connection wires at the moment.  Thusfar I have not looked into a cheap source for them either.  I am just working with what I have at the moment.  I found out that the output is common anode, and I only have common cathode displays, thus that is my problem.  No biggie, I only was asking for a work-around and I wasn't in any way dissing the capabilities of the Prop - 2.

QuoteUse 1K for the 5v outputs to limit the current through the displays so that you don't exceed the output spec of the PIC16C57 (PBASIC core).  You can allow more current to flow through the display if you're using the ULN outputs because those outputs can handle a lot of current, the PIC outputs can't.

I do know about ohms law and limiting.  I = E/R   5/1000  = 5 ma.  Kinda low if you ask me.  This was another reason why I wanted to use the ULN outputs. 

QuoteIf you use the direct outputs then it's just exactly like using the Prop-1 trainer: to light a segment you make the respective output high.  See StampWorks for other 7-segment programming examples that you can apply this way.  And if you end up using the ULN outputs with a common-anode display, you can always use high logic (1 = on) in the code and invert it on the way out:

  OUTL = segments ^ %11111111

This will flip the bits of segments and write it to the outputs on P0..P7.

Thank you...that is it.  That is all I was asking, if there was a code work around.

QuoteI recommend brushing up on your basic electronics skills before moving forward.  Once you start connecting custom circuits you're responsible for design decisions that could adversely affect the Prop-2.

I can assure you that my electronic skills are above average and for the moment I am not doing anything outside of the exercises documented in the WAM and Stampworks books and I am sure to keep items hooked up to the outputs within tolerances.  I have printed the spec sheet out for the Prop 2 and I understand what the limitations are.

jukingeo

Quote from: JonnyMac on October 27, 2007, 11:24:30 AM
Just to clarify... I use 1K when connecting 7-seg displays; since the Prop-2 already has 220-ohm resistors inline with each pin, you could use 680, but I don't suggest going lower than this (safety).

Up to now I did see the resistors on the board, but couldn't read the value and I just didn't bother to measure them out with a meter as of yet.

QuoteIn the rarely-read documentation for our controllers you'll find a specification called IOHg -- this is the total output current for a group (P0..P7 or P8..P15); it's 50 mA for the Prop-2.  To be safe you want to stay well under that (most practical engineers de-rate specs by 50%).

Yes, I have read it (surprised?) and saw the Hg current limitation which is why I made the 'kinda low' remark in my last email. I have read the specs for my displays...which are about 25ma per segment max.  Like I said, this is another reason why I wanted to use the higher current outputs I wanted to drive the display with enough current to see what it looks like.  Of course I don't intend to go the full 25ma per segment.  But I was shooting for around 17ma, which would be the case setting up with the existing 12v supply and the 680ohm resistors I mentioned.  Sure I can use 1000k resistors as well.

QuoteAssuming 1.5v per segment diode, using a 680 in line would give you about 3.9 mA per segment, or 31 mA (max) for the group -- this is safe and should provide enough segment current to see the display (if not, use the OUTx terminals).  Here's the math (I = E/R):

  total current (IOHg) = ((5.00 - 1.50) / (220 + 680)) x 8

Yeah, that is a little too dim.  I have these older displays that have a filter over them.  The documention recommends driving from 8ma to 20ma per segment with 25ma being the absolute max.  So if I were going directly, I would be hoping I would be able to see the display. 

Well, one thing I don't know is that what is the minimum current needed to light an LED in the first place?  That was something I never looked into.

I know my 7 segment displays don't have the nice high bright LED's you have on the prop-1 trainer.  Regardless I don't have the headers right now, so I think I am better off with the higher power outputs anyway.

Thanx,

Geo





JonnyMac

The BoE is designed as a training device; the Prop-2 is designed and a ready-to-integrate professional product.  If you crack open any piece of of professional electronic gear you're not going to find breadboard-type connections, you will find male post headers and mating connectors -- they're reliable, that's why they're used.  Can you imagine what would happen to BoE type connections in moving prop?  It might not be pretty, that's why we don't have them on any of our controllers.

Page 1 of the Prop-2 docs spells out the servo-style header and 220-ohm protection resistor on all I/O pins.  Our docs may not be perfect but they do contain a lot of useful information.

Jon McPhalen
EFX-TEK Hollywood Office