Pwm16

From BitWizard WIKI
Jump to: navigation, search

PWM16

The board comes in two variants, the -b suffix has bigger FETs.

specifications

  • PCA9685 PWM chip.
  • Each channel drives a N-channel mosfet.
    • Note when switching a load with an N-channel mosfet, the load is wired with its positive directly

connected to power and the mosfet will switch the negative terminal of your load.

  • For ease of hooking up, each channel has a power and a switched connection.

The small fets can handle 1A each. Running a total of 16A through the whole board will heat it up a bit, but should still work. Slightly more than 1A is permissible, provided it doesn't last too long. But keep in mind that electronics works on a different timescale. "a second" Is already a very long time for such a small component.

The big fets can handle 5A each. But running 80A through the whole board is going to heat it up beyond permissible limits. Again a bit more for a short period can be permitted, but timescale of "a few milli seconds" and not "a few seconds".

pinout

Bottom edge has outputs 1-8, each with a <output> <V+> . Each is marked as such on the back of the PCB, as the front was full with components.


Top edge has outputs 9-16, each with a <output> <V+> . Each is marked as such on the back of the PCB, as the front was full with components.

The right edge of the PCB has 6 connections: GND, V1, V1, GND, V2, V2. The power connections are separate. This alows you to run one side of the PCB at a different voltage than the other side. Say 5V on V2 for the top edge of the board, and 12V for the bottom edge. There are two Vx connectors to make it easy to connect one powersupply by looping a sort wire from the second V1 to V2.


The i2c connector pinout is documented here: https://www.bitwizard.nl/wiki/I2C_connector_pinout (note that the pin1 (and marking) is closest to the PCA chip).


The J1 jumper block allows you to configure the address of the PCA chip. No jumper is 0, a jumper is 1. A0 is the position closest to the PCA chip, A3 is the furthest.

If your board has a second i2c connector, you can use it to chain multiple boards on one I2C bus. Make sure you configure each board for a different address in that case.

Usage

For full documentation see the PCA9685 datasheet.

To initialize:

  • set register 0xfe to 5
  • set register 0 to 0x20.

Now the chip is initialized and will do about 1500Hz PWM

To set a channel, write 4 bytes to an address 6+ 4*<channel number> . The first two bytes are the turn-on-timestamp. Write 0x00 0x00. The second two are the turn-off-time. So values 0...0x0fff will set the PWM value (low byte first!). The highest value now will still have the output "off" for 1/4096 period. To turn the output fully on, you need to set the "always on" bit, which is in the "turn on" register that we've been setting to zero. So to turn it fully on send 0x00 0x10 0x00 0x00.

OPTIONAL: if you don't understand this, ignore it.

There are different ways to configure the chip. For example, if you want to set five channels to 0x203, 0x405, 0x607, 0x809 and 0xa0b, the above recommendation works, but it loads your powersupply a bit weird. I've chosen the PWM values a bit wonky so that you can see where the differnt parts go: So above would send 00 00 03 02, 00 00 05 04, 00 00 07 06, 00 00 09 08, 00 00 0b 0a (if the channels are consecutive you can send all that in one go!). In this configuration all five loads are loading the powersupply from 000 to 0203 in each PWM period. And none are loading the powersupply from 0a0b to 0fff.

But slightly easier on the power supply would be: 00 00 03 02: First channel is on from 000 to 0203. Then 03 02 08 06: second channel is on from 0203 to 0608. Then 08 06 0f 0c: third channel on from 0608 to 0c0f. Then 0f 0c 18 04: the fourth channel wraps around: it is on from 0c0f to 0418! Continue with 18 04 23 0e and now from 000 to 0e23 two loads are loading the powersupply and from 0e23 to 0fff only one: The variation in load on the powersupply is much less. This strategy works very good when the loads are all identical. When the loads are not identical the calculations become more complex.