0

16 channel PWM shield
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

16 channel PWM shield

by tcotant on Thu Aug 01, 2019 1:09 am

I'm trying to find a shield to easily run 3 or 4 PC fans (3 wire) from an Arduino Uno. Besides the obvious on/off, I want to be able to tell each fan how fast to run. Will this shield work for me?
https://www.adafruit.com/product/1411

tcotant
 
Posts: 2
Joined: Thu Aug 01, 2019 1:06 am

Re: 16 channel PWM shield

by adafruit_support_bill on Thu Aug 01, 2019 5:52 am

Most 3 and 4-wire fans are designed to work with computer motherboards which use a 25KHz PWM frequency. The 16 channel PWM shield has a maximum frequency of 1.6KHz. Some fans do work at that frequency. Many do not. You would have to test with yours to determine if they are compatible.

You could use one of the M0-based Arduinos or compatible processors. These have lots of PWM-capable pins and can operate at higher frequencies than the PWM shield.

adafruit_support_bill
 
Posts: 74337
Joined: Sat Feb 07, 2009 10:11 am

Re: 16 channel PWM shield

by tcotant on Thu Aug 01, 2019 9:44 am

Thanks, I'll check out those M0 options. I was just looking on your site - where does it specify the PWM capabilities (frequencies)? Generally, how many of these more capable PWM pins are there available?

Also, in my application, I'd like to be able to turn the fan completely off as well. My understanding of these fans so far is that they generally will only do 30% of max as the lowest setting. I'd have to somehow create another switch (software controlled) to turn the power off completely. Any suggestions there?

Last question: I'd also like to expose control to Alexa. Do you guys have any tutorials available for this using your M0, or can you point the way?

Thanks for the great support.

tcotant
 
Posts: 2
Joined: Thu Aug 01, 2019 1:06 am

Re: 16 channel PWM shield

by adafruit_support_bill on Thu Aug 01, 2019 10:38 am

The "Pinouts" section of the product guide will tell you which pins are PWM capable. For example, here is the one for the Metro M0:
https://learn.adafruit.com/adafruit-met ... c-pins-2-6

The official Arduino libraries don't have support for changing frequencies, but there is a user contributed library here:
https://forum.arduino.cc/index.php?topi ... msg3161532

To cut power to the fan, you could use a transistor circuit like the one here: https://learn.adafruit.com/adafruit-ard ... ransistors
For a brushless fans, you do not need the diode.

To work with Alexa, you will need WiFi connectivity. The Feather M0 WiFi has a built-in WiFi module:
https://www.adafruit.com/product/3010

adafruit_support_bill
 
Posts: 74337
Joined: Sat Feb 07, 2009 10:11 am

Re: 16 channel PWM shield

by mmarc on Thu Aug 01, 2019 5:34 pm

Similar question on the PCA9685 PRODUCT ID: 815. I need different frequencies on the outputs. It seems like all outputs operate at the same frequency. The frequency range is fine. What product do I move to in order to achieve this? There can be fewer channels. Thanks

mmarc
 
Posts: 1
Joined: Thu Aug 01, 2019 5:21 pm

Re: 16 channel PWM shield

by adafruit_support_bill on Fri Aug 02, 2019 5:46 am

If you want different frequencies on different channels, A microcontroller is probably the best way to go. The ATSAMD chips like the M0 and M4 are a bit more flexible than the Atmega chips.

We also have the "Seesaw" board which is based on an ATSAMD09 processor set up as a reconfigurable I/O processor with an i2c interface.
https://www.adafruit.com/product/3657

adafruit_support_bill
 
Posts: 74337
Joined: Sat Feb 07, 2009 10:11 am

Re: 16 channel PWM shield

by gumfoo on Mon Aug 19, 2019 12:13 pm

Hello, I have encountered an issue with the PCA9865 shield. When using the latest version of the library 1.0.4 the arduino (nano 328p) seems to crash (gets stuck or reboots to setup() ) just as the pwm.begin() is called. I went back to library version 1.0.2 and this problem does not occur. I suspect the change in begin(), currently takes a prescale could be the culprit <somehow> (may be the memory location is not cleared). All the basic examples provided with the library showed the same error behaviour. I have set the address of the shield in use to 0x54 (0x40+0x14), may be this could also be affecting the outcome but I do not see how.

I hope this is enough information :)
Thanks!

Version 1.0.4
Code: Select all | TOGGLE FULL SIZE
void Adafruit_PWMServoDriver::begin(uint8_t prescale) {
  _i2c->begin();
  reset();
  if (prescale) {
    setExtClk(prescale);
  } else {
    // set a default frequency
    setPWMFreq(1000);
  }
}


Version 1.0.2
Code: Select all | TOGGLE FULL SIZE
void Adafruit_PWMServoDriver::begin(uint8_t prescale) {
  _i2c->begin();
  reset();
  // set a default frequency
  setPWMFreq(1000);
}


Code: Select all | TOGGLE FULL SIZE
/***************************************************
  This is an example for our Adafruit 16-channel PWM & Servo driver
  PWM test - this will drive 16 PWMs in a 'wave'

  Pick one up today in the adafruit shop!
  ------> http://www.adafruit.com/products/815

  These drivers use I2C to communicate, 2 pins are required to 
  interface.

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries. 
  BSD license, all text above must be included in any redistribution
 ****************************************************/

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x54);
// you can also call it with a different address you want
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);
// you can also call it with a different address and I2C interface
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(&Wire, 0x40);

void setup() {
  Serial.begin(9600);
  Serial.println("16 channel PWM test!");

  pwm.begin();
  pwm.setPWMFreq(1600);  // This is the maximum PWM frequency

  // if you want to really speed stuff up, you can go into 'fast 400khz I2C' mode
  // some i2c devices dont like this so much so if you're sharing the bus, watch
  // out for this!
  Wire.setClock(400000);
}

void loop() {
  // Drive each PWM in a 'wave'
  for (uint16_t i=0; i<4096; i += 8) {
    for (uint8_t pwmnum=0; pwmnum < 16; pwmnum++) {
      pwm.setPWM(pwmnum, 0, (i + (4096/16)*pwmnum) % 4096 );
    }
#ifdef ESP8266
    yield();  // take a breather, required for ESP8266
#endif
  }
}

gumfoo
 
Posts: 6
Joined: Mon Aug 19, 2019 11:37 am

Re: 16 channel PWM shield

by adafruit_support_bill on Mon Aug 19, 2019 1:06 pm

@gumfoo - Please start a new thread for your topic.
posting.php?mode=post&f=31

adafruit_support_bill
 
Posts: 74337
Joined: Sat Feb 07, 2009 10:11 am

Re: 16 channel PWM shield

by gumfoo on Mon Aug 19, 2019 1:23 pm

I have created a new post, viewtopic.php?f=31&t=155411
Sorry for the inconvenience.
Thanks!

gumfoo
 
Posts: 6
Joined: Mon Aug 19, 2019 11:37 am

Please be positive and constructive with your questions and comments.