Maker Pro
Maker Pro

Possible to control resistance using microcontroller?

magic-smoke

Oct 31, 2021
6
Joined
Oct 31, 2021
Messages
6
My project is a clock with 4 7-segment leds controlled by MAX7219 led driver IC. I want to adjust the brightness of the display.
There are 2 ways to adjust the brightness.
First, I can control it in software - I can programmatically choose one of 16 levels of brightness by sending a value to the MAX7219.
Second, the brightness is also controlled by hardware - a resistor between the MAX7219 Power pin and ISET pin.
But what I'd like to do is control the brightness using software/microcontroller but with a wider range than the 16 levels provided. (At night, I want the display to be very very dim. And when very well lit, I want the display to be bright. And ideally a continuum of brightness in between these). So I'd like to use software to control the hardware side too.

Previously i've used 2 resistors, and set a transistor to effectively bypass one of the resistors when I want the display to be brighter. But this meant a noticeable step-change in the brightness when I moved from one to two resistors.

Is there a better way? A a programmatic way a microcontroller could control the effective resistance between Power and ISET? Without using a dedicated digital potentiometer?
 

PETERDECO

Dec 19, 2019
239
Joined
Dec 19, 2019
Messages
239
Welcome to the forum. A uC with a PWM can control the brightness by supplying power to the common LED pin. An LDR could also be used on a uC ADC input to vary the brightness with respect to ambient light in the room. What uC are you using?
 

magic-smoke

Oct 31, 2021
6
Joined
Oct 31, 2021
Messages
6
I'm using an ESP32.
The microcontroller isn't connected to the LEDs directly, the connections are all via the LED driver which gives a more even lighting of the segments and a simpler interface than I could achieve without it.
I am reading resistance from an LDR to decide a desired brightness, but my question is about actually adjusting the brightness on the display.
 

bertus

Moderator
Nov 8, 2019
2,721
Joined
Nov 8, 2019
Messages
2,721
Hello,

@PETERDECO , PWM on the common pin of the display will not work, as the driver is multiplexed.
@magic-smoke , you could use PWM on the transistor that controls the current.
MAX7219-MAX7221 application.png

Bertus
 

magic-smoke

Oct 31, 2021
6
Joined
Oct 31, 2021
Messages
6
Hi @bertus,
Thanks for the reply. Could you clarify where the transistor goes? Would it go between the LED driver's power and ISET pins? Or would it go between the circuit's VCC and the driver's V+?
 

PETERDECO

Dec 19, 2019
239
Joined
Dec 19, 2019
Messages
239
Sorry - I missed the LED driver thing but have had success in the past driving the display directly from the uC.
 

bertus

Moderator
Nov 8, 2019
2,721
Joined
Nov 8, 2019
Messages
2,721
Hello,

You could try something like this:
Max current dim.png
Bertus
 

magic-smoke

Oct 31, 2021
6
Joined
Oct 31, 2021
Messages
6
Hi @bertus.
I tried a circuit similar to the one you suggested, and it's working great.
I used a NPN since I have so many, and I didn't use the 10K resister. I'm not sure why that's there?

Would you mind explaining why the 10K?
And does this circuit (this is what I actually built) have any problem?

My idea is that when the transistor is on, it shorts the 100K so the total resistance is only around 9.5KOhms.
When the transistor is off, the total resistance is 109.5KOhms.
upload_2021-10-31_18-59-35.png

This is almost identical to what I had built the first time when I said "Previously i've used 2 resistors, and set a transistor to effectively bypass one of the resistors when I want the display to be brighter".
But previously I just set the transistor ON or OFF with a microcontroller pin directly, I hadn't thought of PWMing it.
 

bertus

Moderator
Nov 8, 2019
2,721
Joined
Nov 8, 2019
Messages
2,721
Hello,

The 10K is there to ensure the transistor is turned off.

Bertus
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
12,720
Joined
Nov 17, 2011
Messages
12,720
The MAX7219 has a built-in digital brightness control:
Digital control of display brightness is provided by an internal pulse-width modulator, which is controlled by the lower nibble of the intensity register.
See the datasheet page 8. No need for external circuitry, just set the brightness via a command.
 

bertus

Moderator
Nov 8, 2019
2,721
Joined
Nov 8, 2019
Messages
2,721
Hello

@Harald Kapp , in his openings post the OP mentioned that he wants to have a wider range of intensities than the provided ones in the MAX
Using the resistor control a wider range should be possible

Bertus
 

magic-smoke

Oct 31, 2021
6
Joined
Oct 31, 2021
Messages
6
@Harald Kapp, thanks for the suggestion but I did also say "...without using a dedicated digital potentiometer."
I don't have a digital potentiometer and I'd like to make this with more 'standard' basic (and also cheap) components.
 
Top