Salut pinhead,
If I had to extend an existing controller with PWMs, I'd use e.g. PIC16F18313.
It has 8 pins, I2C and 4 independent PWMs at a cost of less than 1,50€. I
cannot tell however if the MCLR pin can be used for I2C. A safe choice would be
12F1572 which is even cheaper and has 4x 16bit PWM. You can use serial_software
for communication, as the PWMs run happily on their own.
Yes, the way you're describing you could dim LEDs, but each time something else
is happening, like new I2C-input is processed, all your LEDs would slightly
flicker.
When I did bitbang-dim 120 multiplexed LEDs, i did it binarily: If bit 7 is
set, light up the LED for 128µs. Then, if bit 6 is set, light up the LED for
another 64µs and so on. The brightness sums up in the eye of the beholder. I've
programmed a timer to generate an interrupt in succession after 128, then 64,
then 32... µs. However, 4,2 and 1 µs I did without leaving the ISR. I did not
use any "if" for that, I had an 8x8bit matrix with the dimming values, which I
rotated by 90°, so I had a byte full of "bit7" of each channel, a "bit6" of
each channel and so on. So, the ISR had nothing to do but move the "bit7"-byte
to the output port right before the 128µs interrupt delay, the "bit6"-byte
before the 64µs delay... That way I could dim 8 LEDs (all on e.g. PORTA) for
the price of one.
Oliver is my real name, but Kiste (=Carton(fr) =Doos(nl) =Box(en)) is my very
common nickname, even in real life.
Greets,Kiste
Am Dienstag, 20. Juni 2023 um 22:10:07 MESZ hat [email protected]
<[email protected]> Folgendes geschrieben:
Hello Oliver,
Indeed, PIC18F27J13 could be a candidate. I overlooked this one too quickly (I
already ranted about the parametric search tool on the µchip site :-{ )I'll
check for the other characteristics.No internal OPAMP and internal VREF are a
bit annoying, but if it's the only missing parts, it's ok.
Anyway, what about a PIC that would be programmed as a I²C generator with
several independant channels, and I²C slave.
He would have nothing else to do than generating the signals.Consider one
channel:- A register contains the value of its duty cycle (from 0 to 255)- In
the main loop, a 8-bit counter is incremented.
- At each increment, its value is compared to the duty cycle register, and if
needed, the corresponding output is toggled.
You could generate as many PWM signals as there are IOs available.The I²C-slave
interface would be handled by the MSSP module with interrupts (yes, this could
cause glitches in the PWM signals if the time needed to process the I²C
processes is greater than the time it takes to increment the PWM counter by
one, but if it is only to dim some LED's, I think I could live with it)
The frequency could be adjusted by changing the oscillator frequency and/or
adding delays in the main loop when the main counter is incremented
Just for the sake of it, I think I will give it a try.....
Hoping I am not overlooking a major impediment
Thanks for your suggestion, Oliver (or Kiste ?)
Le mardi 20 juin 2023 à 20:43:01 UTC+2, Oliver Seitz a écrit :
Hi!
A software PWM library isn't easy. Without a timer, it blocks everything. With
a timer, it's complicated and would only add a few channels. I've done software
PWM for 120 LEDs independently with a 28 pin controller, but it couldn't do
much more than that at 64MHz.
Have you had a look at, say, PIC18F27J13? It has 3+7 independent ccp modules
(with 3 TMR2-type timers).
Greets,Kiste
Am Dienstag, 20. Juni 2023 um 19:49:33 MESZ hat [email protected]
<[email protected]> Folgendes geschrieben:
Hi,
I'm falling short of PWM outputs for a project.I need 6 independant outputs,
and the only way to get them is to use a 64-pin 18fxxxx, which is a bit
overkill for me, or use a second PIC, bond to the first (I²C or SPI) which is
also overkill but could be acceptable in the absence of another "clean"
solution.
It will only be used for dimming LED's, and I don't need particular features
like dead-band, half or full bridges, precise or stable frequency.....
To my surprise, I didn't find a software PWM library in Jallib 1.8.....Or do I
miss something ?
Have a nice day
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jallib/923bd215-4855-49d9-b7e1-17e02482c219n%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jallib/9aad71fb-a1f2-47f3-8cc4-82a1110327c2n%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jallib/1639372286.1548147.1687325901648%40mail.yahoo.com.