Step 7: The slave driver electronics
Initially I was looking for a simple IC that just converts a serial signal like I2C or SPI into three PWM. I also wanted to be able to have a two way communication because I was sure there would be noise on the signals because I packed power cables and signal cables into the same bundle, so a shift register based solution did not do.
Since there are no I2C to PWM ICs available, I decided to make a little microcontroller board to do it.
It is more ore less a breakout board of an ATTiny24 with a 5V regulator added to it so I can supply it with 12V.
The ATTiny24 can be seen as an Arduino with not as many pins and not as many functions but it has just enough to do I2C communication and output PWM signals. Also, it is very cheap only 1$ a piece.
You can buy it from digikey for example:
The circuit board I made on the CNC milling machine as well but you can also use online order services or use any other home-brew circuit making technique availble. Another possibility is to order the through hole version of the Tiny24 instead of the SMD version and just use a prototyping board to solder the components.
The two pullup resistors on the I2C lines (SCK and SCL) are optional. I only added them (about 2k ohms) in the last lamp as well as 1.5k Ohm in the master lamp but that one does not have the Tiny24 adapter board in it. To get more info about these pullups, read into how I2C works.
Download AVRStudio 4.
Now compile and upload the code (no additional libraries necessary). You need to compile the code for each lamp, as the I2C address is fixed in the program (read the code and find where the address is defined). Do not forget to make a mark on the PCB which one contains which address.
I wanted to add it into EEPROM but never got around to do it. And it only takes 10 seconds to change the address and recompile. And also, this only needs to be done once for each lamp. Ever.
Note: If you already connected the I2C signals, disconnect them, uploading does not work if the I2C lines are connected.
To add the power supply, crack open the casing and remove the electronics inside. Clip the 230V connections (leave some cable to solder the connecting cable) and cap the 12V cable about 10cm from the board.
When you finish the board, connect the 12V power supply to the tiny24 board. Also connect the three PWM signals from the led drivers. Refer to the code to see which pin I assigned to which color (also take a look at the datasheet of the tiny24). The I2C signal will be sent to the long cable, connecting two lamps and is the very last thing we will connect. Also connect the fan to the pins.