PDA

View Full Version : PWM multiple 7-segment LEDs



Demon
- 15th February 2024, 21:58
I would use what Maxim suggest for the displays and would not bother with mods to drive common anodes. ...

Yeah, I wasn't going to keep fighting against the current.


I'm looking at using PICs instead. Concatenating values and remembering which one is in which position is going to be a massive chore, with lots of place for error.

9610


I'm looking at using PICs instead. My 7-segment displays will range between 2 and 6 digits. I just send each PIC a USART message with the value they have to display and forget about them until the value changes.

This is why I had gotten common anode in the first place. The power to the LEDs was going to be controlled by pot & PWM from a main PIC. I was planning on using transistors to control the 8 segments. It's cheaper to use MAX7219, but in my case I don't think it's worth it.

Another thing consider is that this is the "basic" console; the Cessna 152 is one of the simplest planes with a single engine in MSFS 2020. I plan on making consoles for much more complex planes, most having 2 - 4 engines. That's a truckload of displays; that's why USART-and-forget is my favorite technique so far.

I started looking at 16F PICs on JLCPCB. I forgot about those and had only looked at 18F PICs the first time. So far I'm looking at:

- 14-pin 16F1823 @ $1.16
- 28-pin 16F1933 @ $1.51

And I'm just starting, I'm pretty sure I saw some 44-pins in there. I can easily control 6 digits with that and a few transistors.

tumbleweed
- 15th February 2024, 22:54
This is why I had gotten common anode in the first place. The power to the LEDs was going to be controlled by pot & PWM from a main PIC
Wouldn't it be simpler with common cathode? That way you only have a single sink transistor/fet for each set of digits, making it easy to PWM.

Demon
- 15th February 2024, 23:24
Wouldn't it be simpler with common cathode? That way you only have a single sink transistor/fet for each set of digits, making it easy to PWM.


Hmm, is sink more efficient than source?


EDIT: Gotten from a quick google:

'While this may sound strange or non-ideal, it is generally easier for the microcontroller to shunt this current to ground and absorb a little power as heat rather than try and generate the sourcing current. Sourcing current can cause large voltage swings on the input which can introduce noise.'

Interesting, I never really put a lot of thought in this before.

I suppose that's because the PIC didn't have to source the power consumed by the device, only the leftovers.

Where-as if it has to source, it has to source everything. Never thought of that.

Demon
- 16th February 2024, 02:50
PWM is done at a higher level by a central PIC, so all LEDs across the console get the same VDD-LED.

My largest display has 6 digits with 1 decimal point. This was my most recent gameplan. I can use smaller PICs for smaller displays:

9611


EDIT: Right now JLCPCB has 500 units of 16F946 in stock for $2.15, 2889 units of the 16F1947 for$2.21.

When you consider the MAX9217 costs me $20 for each DIP for my testing, I'll need 20 to test the entire console.

Using PICs in this case is not much more expensive and so much more affordable and convenient, especially when it comes to transmitting the values to the displays.

richard
- 16th February 2024, 05:14
i see a lot of smoke in your future

apart from the upside down mosfet

pic1f946 max chip current 95mA although each pin can sink or source 25mA equally well
@ 42 leds [or 48] if you use dp's thats 2.2mA per led 2 Full bright , the 270 ohm seg resistors are not going to do that for you

pic1f1947 max chip current 120mA [the industrial ver can sink more] although each pin can sink or source 50mA equally well
@ 42 leds [or 48] if you use dp's thats 2.8mA per led 2 Full bright , the 270 ohm seg resistors are not going to do that for you

9612
9613

Ioannis
- 16th February 2024, 08:06
The sink is always better choice than sourcing.

Then N-channel MosFets along with NPN transistors are much better than P equivalent ones and more choices available.

And finally, even if a PIC can source or sink 20, 30 or 50mA per pin, there is a maximum TOTAL dissipation for the whole chip, so that you cannot source at the same time on all pins a max of 50mA on each pin!

You will melt the chip!

So, yes. I am for the sink topology too.

Ioannis

Ioannis
- 16th February 2024, 08:14
Now, if you look at datasheet, p236, for the 946 chip.

Output Low is 0.6 Volt at only 8.5mA but,

Output High Vdd-0.7 Volt at 3.0mA

So, yes. It is better to sink than source.

Ioannis

richard
- 16th February 2024, 11:29
for my money i would do it the traditional way or if multiplexed display is not bright enough use a bunch of tpic6b595's

9614

note schema is not complete but you get the idea, i was going to try it in proteus then i remembered how crap proteus is at simulating multiplexing
so i gave up

tumbleweed
- 16th February 2024, 12:38
With that many displays I assumed they would be multiplexed as in richard's post #17.
Surely a lot less supply current, and you wouldn't need nearly as many pic's to drive them... maybe get away with one or two 44-pin packages.

Demon
- 16th February 2024, 20:20
(I'll move the PWM LED posts to an off-topic thread in a few minutes to keep this about Chuck's code example. I just want to put down some comments first.)


... apart from the upside down mosfet ...

I was hoping you wouldn't see that. :D It was late and I went to bed.



i see a lot of smoke in your future ...

Usually I'd agree with you, and yes I'm aware of the current limitations on PICs and pins. :)

But ... LEDs are special. You can get different performance out of them via PWM. This is identical LEDs:

- left, 5V rail with 270ohm resistor.
- right, PWM without resistor.

https://www.youtube.com/watch?v=ApQaT-b4drY


I can get identical brightness with 2.5mA less. If I add a 270 ohm resistor to PWM, I get 1/2 the current.

9615


Yeah, I thought I could improve this even further down to 2mA but that isn't gonna happen. The LED won't be bright enough.

And yes, I've been playing with using transistors/MOSFETs and I'll be going back that way again.

9616


I had dropped that idea cause HPWM has lower limits on Frequencies and I didn't like not have total control (64 MHz is 3905Hz).

But I just realized I could pulse the devices using a timer interrupt; switching between different ON-time and OFF-time.

Demon
- 16th February 2024, 20:23
for my money i would do it the traditional way or if multiplexed display is not bright enough use a bunch of tpic6b595's...

Thanks, I'm off to google that chip (no idea what it is). I've also seen talk about using a 74HC595 (never met that creature either).


EDIT: Google says TPIC6B595 can sink up to 150mA at 50V. JLCPCB carries them at $1.54.

Google says 74HC595 has a 70mA total limit, so there goes that chip. JLCPCB has them at $0.11 too. :(

Ioannis
- 16th February 2024, 21:34
The 74HC595 is a shift register. How can this help on 7-seg LED's ?

Dedicated chips like Maxims or the TPIC6B595 I think is the way to go.

Ioannis

Demon
- 17th February 2024, 00:58
The 74HC595 is a shift register. How can this help on 7-seg LED's ? ...


Some people use them to drive 7-segment LEDs. They don't have digit control, only segment control, so you need one per digit.

https://www.youtube.com/watch?v=QI1IJLB42G8


It turns out my supplier for 7-segment LEDs also print and assembles PCBs. It wouldn't be cost effective to ship my LEDs back, so I might very well do the jump to the MAX7219 if I have to buy more LEDs.

I'm keeping all my options open for the time being, but the MAX7219 does offer one really neat feature; an intensity control. That TPIC6B595 is a close 2nd for common anode LEDs.

richard
- 17th February 2024, 02:50
You should also look at HT16K33 , that can read in switches and buttons too
ditto for
tm1637 and 1638

Demon
- 19th February 2024, 02:37
Alibaba is a game-changer for little people like me.

I'm talking with a supplier for 15 inch displays 4K UHD 3840X2160; just the screen and the controller board (I'm using Acer 19 inch displays at only 1366x768 myself).

I already resized all my gauges to make sure they can fit in the space. I end up with high quality graphics, low weight, lower cost, and a LOT less work.

9621


That's all the gauges practically identical to the game, and this screen runs on VGA or HDMI. I just hope it's better quality than the ones I already got from AliExpress.

Ioannis
- 19th February 2024, 10:52
Impressive isn't it?

Ioannis

Demon
- 25th February 2024, 04:36
This is why I went with the 7-segment display route. I had bought 2 LCDs from AliExpress and was really disappointed by the quality. The viewing angle was just too narrow, and the backlight was overly bright, even with setting turned down to zero (my decade-old Acer x183H in the background is still better).

https://i.imgur.com/MkrugVL.jpg


This pic is from the manufacturer using my image, on her PC in the back, and the display in the front.

https://i.imgur.com/eTH3xH9.jpg


It's not a photoshop; she also sent me video. They sell these to laptop manufacturers.

Using 7-segment displays brings its own challenges; more complicated, lots of parts for solder, lots of circuits to install. I didn't get a final price on the 15" display, but it's most likely going to be a justified expense. And it's going to look freaking awesome once assembled. :)

There's another advantage; the next plane on my list is the Cessna 172 and it uses 2 displays side-by-side:

https://stormbirds.blog/2022/04/30/testing-out-the-improved-cessna-172-flight-model-in-msfs/#jp-carousel-48750


I haven't done any tests yet, but I should be able to place both of those on the 15" screen.

Ioannis
- 25th February 2024, 12:08
Definitely the LCD is the way to go!

I would not bother with any LEDs display. Maybe only for the buttons or pots. Or is this possible to be done with touch displays too?

Ioannis

Demon
- 25th February 2024, 16:03
It's always possible to do touch, but I like the feel of mechanical devices. 🙂

Ioannis
- 25th February 2024, 20:33
Me too!

Ioannis