I have requirement of 14 PWM output for a project. Can anyone guide me whether I should find a controller with 14 PWM output or I should be using PWM pin extender ICs.
Thanks
Thanks
Thank you. @jpanhalt Yes, I looked into it but I require 14 independent PWM to control led panels.This should take you to a parametric search and show those PIC's wtih 14 or more PWM channels: https://www.microchip.com/ParamChartSearch/Chart.aspx?branchID=30048
Oops, link doesn't work to go to the parsed page. It just goes to the main selection page. You can do the search there. Here are some 16F that meet that criterion:
View attachment 221266
EDIT:
Those numbers seem to be based on counting re-assignable pins, not actual, independent PWM drivers. Yes, it seemed too simple, so I checked:
View attachment 221269
Thank you @John P The least I require is 1KHz frequency with two different states(full and 1/3). I have to include a switch button and RF module for wireless connectivity so I guess software generated PWM might keep the controller busy.It's important to know what frequency these PWM outputs need to run at, and how many different states (duty cycles) each needs to have. If the frequency is low, then it may be possible to synthesize them in software.
Thank you @Ian0 I will look into it.
Thank you @nsaspook I will look into it.I'd use something designed for your requirement and free your controller for other duties.
https://www.adafruit.com/product/815
unsigned char leds0to7;
unsigned char leds8to13; // These are global variables, accessible from anywhere
bit tick; // Globally accessible flag
void interrupt(void) // 3KHz repeat rate
{
tick = 1;
PortA = leds0to7;
PortB = leds8to13;
}
main()
{
unsigned char phase, i, mask;
unsigned int led_state[14]; // This array needs to contain 0 for a light that has a 33% duty cycle, and nonzero for a light
// that is at full brightness.
// Do whatever you need to set up the interrupt with a 3KHz repeat rate, and set PortA and PortB to outputs
while (1)
{
if (tick)
{
tick = 0; // If flag is set, clear it
phase++;
if (phase >= 3)
{
phase = 0;
leds0to7 = 0xFF; // All LEDs on in phase 0
leds8to13 = 0x3F; // Only 6 bits in 2nd byte
}
else if (phase == 1) // Some LEDs will turn off on phase 1, and nothing changes in phase 2
{
mask = 1;
for (i = 0; i < 8; i++)
{
if (led_state[i] == 0)
leds0to7 &= ~mask; // Maybe set a single bit to zero, if led_state was 0
if ((i < 6) && (led_state[i + 8] == 0))
leds8to13 &= ~mask; // Apply test to 2nd byte only when i has value 0-5
mask <<= 1;
}
} // End phase == 1
} // End tick == 1
} // End while(1)
}
Thank you @John P . This seems workable. I will try it and will update you.All right, some useful information. I think this is an easy task that just about any processor can do if it has the port pins available, without using very much processing power at all. You'd need to have a loop running in main() that gets visited at least 3000 times per second, but that's easy enough. Alternatively, most of the code could run in an interrupt. Assuming you're working on an 8-bit processor, and the LEDs are connected to 2 8-bit ports, called PortA and PortB, then I'd do this (untested code, not guaranteed to work):
Code:unsigned char leds0to7; unsigned char leds8to13; // These are global variables, accessible from anywhere bit tick; // Globally accessible flag void interrupt(void) // 3KHz repeat rate { tick = 1; PortA = leds0to7; PortB = leds8to13; } main() { unsigned char phase, i, mask; unsigned int led_state[14]; // This array needs to contain 0 for a light that has a 33% duty cycle, and nonzero for a light // that is at full brightness. // Do whatever you need to set up the interrupt with a 3KHz repeat rate, and set PortA and PortB to outputs while (1) { if (tick) { tick = 0; // If flag is set, clear it phase++; if (phase >= 3) { phase = 0; leds0to7 = 0xFF; // All LEDs on in phase 0 leds8to13 = 0x3F; // Only 6 bits in 2nd byte } else if (phase == 1) // Some LEDs will turn off on phase 1, and nothing changes in phase 2 { mask = 1; for (i = 0; i < 8; i++) { if (led_state[i] == 0) leds0to7 &= ~mask; // Maybe set a single bit to zero, if led_state was 0 if ((i < 6) && (led_state[i + 8] == 0)) leds8to13 &= ~mask; // Apply test to 2nd byte only when i has value 0-5 mask <<= 1; } } // End phase == 1 } // End tick == 1 } // End while(1) }
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
PIC1000: Getting Started with Writing C-Code for PIC16 and PIC18 | Programming & Languages | 1 | ||
S | HELP!! I2c adc pic16, pic1LCD | Microcontrollers | 6 | |
LORA SX1278 with PIC16 | Microcontrollers | 5 | ||
E | Alternative to pic16 Series | Microcontrollers | 12 | |
Z | PicKit3 not uploading to PIC16 | Microcontrollers | 6 |
by Jake Hertz
by Jake Hertz
by Duane Benson
by Aaron Carman