Hi Cesars,
thanks for the quick reply.
the update indeed works out of the box.
however I am having problems implementing your library, most probably due to my noobness…
if i update the count with a slow rate, the LEDs come on one after the other, with a noticeable time off.
If I increase the rate the LED flicker randomly and the intensity of all of them is only controlled by the pot connected to channel 0.
can you please have a look at my patch and see what I did wrong?
It works much better, but still the flickering is very noticeable and there is evident bleeding of the values.
Is there any way I can overcome this issues? it seems to me something is running out of sync with each other.
thank you again
yes, I also think I am doing something wrong.
but what I am trying to do is actually pretty basic if it wasn’t for the multiplexing.
I have two pots connected to one multiplexer and two LEDs connected to another multiplexer.
I am trying to control the individual brightness of both the LEDs simultaneously, and I would like them to be lit without flickering
with this I get the best results so far, a little flickering and bleeding, but it’s barely noticeable.
I will go ahead and continue building the project, meanwhile I will look around to see what might be the cause of the problem, to try and improve on this.
thank you so much for your help
I think the problem is due to ghosting between pins on the multiplexer.
If I remove the pots and just input a constant value of the brightness, the LEDs still flicker and bleed to each other. I am thinking if I could switch between channels that are not next to each other phisically, so say count 1-4-8-12-0-2-5-9-13-3-7-11-15-1… maybe that would help, I have to figure out how to do that.
Also I am reading about physically trying to solve the problem on the board.
I will let you know how I get on
but the flickering got much worse.
basically the LEDs are blinking very fast, and no matter how I try to control the counter, I cannot get a rate of update that can give good results…
Is there a limit how fast this multiplexer switches?
Or is there something inbuilt in the library that limits the update rate maybe…
I don’t know what else to think, I see people doing the same thing with the normal Arduino IDE and they don’t experience these problems lighting leds with multiplexers.
No, that didn’t help at all.
Also because if you take out read-4067 from the node, the flickering is still there,
so it must be something related to write.
thanks for looking into this, but I wonder if there is somebody out there who has an example of how I can implement this, or maybe this IC is the wrong one for the job.
It would be a lot easier if your “remote” IC could handle the PWM on its own instead of relying on the Arduino to try to switch digital pins over I2C fast enough. Is your current IC able to do this if you send it analog values? A board designed for controlling servos might work (not sure since servo control is not straight PWM).
From Data sheet:
" 74HCT4067 is a single-pole 16-throw analog switch (SP16T) suitable for
use in analog or digital 16:1 multiplexer/demultiplexer applications. The switch features
four digital select inputs (S0, S1, S2 and S3), sixteen independent inputs/outputs (Yn), a
common input/output (Z) and a digital enable input (E). When E is HIGH, the switches are
turned off. Inputs include clamp diodes. This enables the use of current limiting resistors
to interface inputs to voltages in excess of VCC.
Analog multiplexing and demultiplexing
Digital multiplexing and demultiplexing
Signal gating
I’m not really an expert at all, trying to make sense of things as they come my way, but I read more and more that controlling LED with this 74HC4067 might not be such a good Idea…
Everybody recommends 74HC595, so I will give it a try next, first I have to figure out the connections and the library in XOD.
I did modify the write-4067 node by replacing the pwm-write with the pwm-load node, and the LED respond much better, still with visible flickering but much more stable in brightness. Also I have coupled the LEDs with transistors and that also improved things
How are you powering all of this? Is it possible you are drawing too much power for your supply? Is VCC provided within range for ICs? Once you set IC to specific PWM value, it should control the LED with no input from Arduino. If you are getting flickering, either there is something wrong with IC, or Arduino is telling it to turn off & back on again rather than just leaving it on. If I’m reading your patch correctly, you are trying to change value for LED control pin very frequently. You just want to set the pwm value once, then leave it until you want a different brightness. The pwm value (between 0 and 1) will control brightness without constantly changing the value for the LED pin.
I don’t think power is an issue, problems are evident even with just one led, even if connected through a transistor to raw 5V input.
but I think you nailed the problem on the IC, it doesn’t have the ability to store a state until the next update as far as I can tell, it’s just switching between inputs like a madman and it shows on the LEDS flickering. it seems to me that the 74HC595 can do the job right, I am hooking it up now, but I have to figure out how to talk to it, wish me luck…
p.s. by the way, HC4067 does a great job at reading analog inputs…
I read the 595 is capable of pwm, but I couldn’t figure out how to do it with the library in XOD (thanks so much to you guys for providing it).
so I used a square wave to control the duty cycle, only problem is it doesn’t turn the led off, but I can find a way to make it work.
I wonder if there is a more elegant/simple way to do this, but for now that’s all I need to carry on my project.
thanks to all
New problem…
so if I copy and paste the above sketch 32 times, for each led i wish to control, the pro micro runs out of program space.
I am sure I am doing something stupid and there is a neat way to cycle through the inputs and outputs applying the same function to them.
so I explain what I am trying to achieve:
16 pads, each has one led normally on and one normally off.
when I press the pad, the on led turns off and the off led fades on to a brightness that is dependent on the pressure applied to the pad.
This can be done pretty easily with the Arduino IDE with a few lines of code, I imagine XOD can do the same, I just don’t know how to do it, yet…
I could also do it physically with transistors and logic gates, but I plan to program patterns for when buttons are pressed, that’s why I am trying to do it in the IDE.
Any ideas would be greatly appreciated