12bit PWMParabola?
12bit PWMParabola?
I'm trying to work with some external LED drivers that use a PCA9685 I2C PWM chip. It natively does 12bit PWM (0 - 4096). There is a table in the PCA9685 library that converts 8bit PWM (0 - 255) values to 12bit PWM values but I think it would be a much smoother effect to use 12bit with PWM Parabola.
How do I modify PWMParabola to support 12bit PWM?
How do I modify PWMParabola to support 12bit PWM?
12bit PWMParabola?
If you look in Globals.cpp in the libraries folder, you can search for the PWMParabola function.
I think you could just copy the function into your INO with a new name and change the bytes to int and then just pass in the range you want. I don't see any map or constrains in the function that would limit it to 0-100.
Then the next part would be how to write to the driver...that may be a bit more complex. Are you using an expansion module or the built in ports?
I think you could just copy the function into your INO with a new name and change the bytes to int and then just pass in the range you want. I don't see any map or constrains in the function that would limit it to 0-100.
Then the next part would be how to write to the driver...that may be a bit more complex. Are you using an expansion module or the built in ports?
12bit PWMParabola?
Just realized that the native library now uses values over 100 to override the port setting so it may be tricky...but it also sounds like you may be writing to a custom i2c device? So maybe you'll handle it there? Hope I was somewhat helpful
Re: 12bit PWMParabola?
v1.0.7 includes code to use that chip
Set your chip to I2C address:
Now, you can simply call:
The libraries will do the heavy lifting for you
Set your chip to I2C address:
Code: Select all
#define I2CPWM_PCA9685 0x40
Code: Select all
ReefAngel.PWM.SetChannel(0,50); // Set channel 0 to 50%
Roberto.
that is awesomerimai wrote:v1.0.7 includes code to use that chip
Set your chip to I2C address:Now, you can simply call:Code: Select all
#define I2CPWM_PCA9685 0x40
The libraries will do the heavy lifting for youCode: Select all
ReefAngel.PWM.SetChannel(0,50); // Set channel 0 to 50%
Re: 12bit PWMParabola?
Wow, very nice. Guess I should be updating my libraries.
I wrote my own library for the PCA9685 a long while back but I'll check out the one you're using so I can see if I was doing anything wrong/stupid. I used the I2C library with it because I was having problems with the old pre 1.0 arduino Wire library. It's actually a lot nicer than Wire because it only needs 2 or 3 method calls for a typical write operation vs the 6 to 8 that Wire needs.
But I digress. Thank you for the information and assistance.
I wrote my own library for the PCA9685 a long while back but I'll check out the one you're using so I can see if I was doing anything wrong/stupid. I used the I2C library with it because I was having problems with the old pre 1.0 arduino Wire library. It's actually a lot nicer than Wire because it only needs 2 or 3 method calls for a typical write operation vs the 6 to 8 that Wire needs.
But I digress. Thank you for the information and assistance.
Re: 12bit PWMParabola?
Haven't dug into it yet but I'm using 8 PCA9685 drivers with 6 LED channels per driver.
I have 2 Ecoray 60 LED fixtures I rewired. Each uses 2 of the driver boards. They have 5x 350mA LED RB strings, 5x 350mA LED white strings, 1x 750mA LED RB string, and 1x 750mA 405nm UV string. Each string has 5 LED's.
I also have 2 MakersLED fixtures that also use 2 driver boards each. They each have 3x 1000mA RB strings, 2x 1000mA NW strings, 3x 500mA OceanCoralWhite strings, and 2x 750mA 405nm/435nm UV strings.
So I'm dealing with 8 I2C addresses and I'll need 8 PCA9685 objects. The only problem I see is I'll either have to group the colors and do a slope for each color or if I want more control I'll need to do a slope for each channel.
I have 2 Ecoray 60 LED fixtures I rewired. Each uses 2 of the driver boards. They have 5x 350mA LED RB strings, 5x 350mA LED white strings, 1x 750mA LED RB string, and 1x 750mA 405nm UV string. Each string has 5 LED's.
I also have 2 MakersLED fixtures that also use 2 driver boards each. They each have 3x 1000mA RB strings, 2x 1000mA NW strings, 3x 500mA OceanCoralWhite strings, and 2x 750mA 405nm/435nm UV strings.
So I'm dealing with 8 I2C addresses and I'll need 8 PCA9685 objects. The only problem I see is I'll either have to group the colors and do a slope for each color or if I want more control I'll need to do a slope for each channel.
Re: 12bit PWMParabola?
125g tall, 2' x 2' x 4'.rimai wrote:Wow... Lot's of channels
How big is your tank?
Yeah, it's overkill for sure. It started with the ecorays and I didn't like that they weren't dimmable. There aren't any dimmable drivers that can push 30 leds on one string so I designed my own drivers based on the PT4115 chip and had the PCB's fabbed by iseeedstudio. I also had to drill the ecoray PCB's to separate the big strings into manageable 5 led strings strings. Worked out well but they weren't enough spread because my canopy isn't very tall. So I built the makersled fixtures and they really put out the light so now I have too much output but good coverage.
Here's some pics http://www.dfwmas.org/Forums/viewtopic. ... 4&t=108378
Re: 12bit PWMParabola?
Looks like multiple boards should be easy as creating a new library based on RA_PWM with just the expansion methods. Modify the object instantiation to take the I2CPWM_PCA9685 address and store in a private variable. Then instantiate 8 RA_PCA9685 objects like so "RA_PCA9685 PCA1(0x40);" Then create parabolas for each channel of each object.
Re: 12bit PWMParabola?
Okay, I've modified RA_PWM a lot so I can pass the address and channels for each color during instantiation. Some issues because the "new" c++ keyword doesn't exist in Arduino.
Is there a better way to do this? I'm going to have 8 RA_PWM objects so the ReefAngelClass constructor is going to get pretty long once I add the other 7?
Is there a better way to do this? I'm going to have 8 RA_PWM objects so the ReefAngelClass constructor is going to get pretty long once I add the other 7?
Code: Select all
// here's the RA_PWM constructor
RA_PWM(byte address, byte rbChannels, byte nwChannels, byte uvChannels, byte ocwChannels);
// simplified ReefAngel.h
class ReefAngelClass {
public:
ReefAngelClass();
RA_PWM Ecoray1RB;
}
// ReefAngelClass constructor
ReefAngelClass::ReefAngelClass() : Ecoray1RB(0x41, B00000000, 0, 0, 0) {
}
Re: 12bit PWMParabola?
I was thinking of adding this to the next update, but if you feel like sending me a pull request, that would be awesome!!!!
We only need 2 modules and they will use address 0x40 and 0x41, because I designed the hardware to only use those 2 addresses. But you would be able to easily modify it to your needs.
Here is my idea:
1. Increase the arrays:
#define NUM_PCA9685_MODULES 2
byte ExpansionChannel[PWM_EXPANSION_CHANNELS*NUM_PCA9685];
byte ExpansionChannelOverride[PWM_EXPANSION_CHANNELS*NUM_PCA9685];
Then, we can assign values to channels 0-11 for the 2 modules.
When the ExpansionWrite() function is called, we can adjust the I2C address depending on which channel you are sending it too... 0-5 would be address 0x40 and 6-11 would be address 0x41.
What do you think?
We only need 2 modules and they will use address 0x40 and 0x41, because I designed the hardware to only use those 2 addresses. But you would be able to easily modify it to your needs.
Here is my idea:
1. Increase the arrays:
#define NUM_PCA9685_MODULES 2
byte ExpansionChannel[PWM_EXPANSION_CHANNELS*NUM_PCA9685];
byte ExpansionChannelOverride[PWM_EXPANSION_CHANNELS*NUM_PCA9685];
Then, we can assign values to channels 0-11 for the 2 modules.
When the ExpansionWrite() function is called, we can adjust the I2C address depending on which channel you are sending it too... 0-5 would be address 0x40 and 6-11 would be address 0x41.
What do you think?
Roberto.
Re: 12bit PWMParabola?
Sounds like it would work but I went a different direction by creating a new library. The new library still has methods to set the channels individually or you can define a single slope or parabola for a color and the method creates the individual slope or parabolas needed for each channel assigned to that color. This is why I pass the constructor the address and the bit arrays assigning the channels to one of the 4 colors. This is of course customized to my particular scenario and a lot of my ReefAngel.cpp is custom because I added setup menus for each color on each fixture. I'm sure I could have gone the custom menu route with that but it was easier for me to just take everything out of the ReefAngel lib I wasn't using and add what I needed. That also helped me to figure out what is going on behind the scenes.
I'm also adding 12bit PWM to CIE luminance conversion as detailed here: http://neuroelec.com/2011/04/led-bright ... ection-no/. Multiplying the percentage by 40.95 works but it doesn't appear linear to me when I set a parabola over 1 minute to test. Not sure if this matters to the corals or not though.
Once I get things working I'll put it all up on my github so if there was anything useful that I did (who knows, stranger things have happened) then you can pull it over.
I'm also adding 12bit PWM to CIE luminance conversion as detailed here: http://neuroelec.com/2011/04/led-bright ... ection-no/. Multiplying the percentage by 40.95 works but it doesn't appear linear to me when I set a parabola over 1 minute to test. Not sure if this matters to the corals or not though.
Once I get things working I'll put it all up on my github so if there was anything useful that I did (who knows, stranger things have happened) then you can pull it over.
Re: 12bit PWMParabola?
I don't have my RA in front of me, does it still work like this for the newest versions of RA+?v1.0.7 includes code to use that chip
Set your chip to I2C address:
CODE: SELECT ALL
#define I2CPWM_PCA9685 0x40
Now, you can simply call:
CODE: SELECT ALL
ReefAngel.PWM.SetChannel(0,50); // Set channel 0 to 50%
The libraries will do the heavy lifting for you
Also how does one utilize the pwm as a non light pin within the ReefAngel? Or am I better off using BRunnel's library for this?
Re: 12bit PWMParabola?
Yeah, channel 0 is the output 0 in the chip.
What do you mean as non-light pin?
What do you mean as non-light pin?
Roberto.
Re: 12bit PWMParabola?
Roberto, how do you set it up with 2 chips?
Re: 12bit PWMParabola?
You would need to use custom code.
Search the forums for the 16 channel module. You will find the code.
Search the forums for the 16 channel module. You will find the code.
Roberto.
Re: 12bit PWMParabola?
Okay, i'm just a little more then slightly confused looking at the PWM class, how is this 16 channel capable when only 6 channels are defined in the library? The global variable #define PWM_EXPANSION_CHANNELS is 6, and the Internal EEPROM is only defined out to PWMChannel6 at 0x480.
Can you provide me a walk through on what I'm missing here, and what if anything I need to do to get just one chip working for now?
Can you provide me a walk through on what I'm missing here, and what if anything I need to do to get just one chip working for now?
Re: 12bit PWMParabola?
There is no support for the 16 channel on our libraries. You need custom code as I mentioned before.
AlanM has started this though:
http://forum.reefangel.com/viewtopic.ph ... 16+channel
Take a look at this code to see how to do it without the libraries integration:
http://forum.reefangel.com/viewtopic.ph ... ion#p38671
AlanM has started this though:
http://forum.reefangel.com/viewtopic.ph ... 16+channel
Take a look at this code to see how to do it without the libraries integration:
http://forum.reefangel.com/viewtopic.ph ... ion#p38671
Roberto.
Re: 12bit PWMParabola?
Thank you!
Any sneaky pitfalls I should be on the look out for when I add in the custom code?
Any sneaky pitfalls I should be on the look out for when I add in the custom code?
Re: 12bit PWMParabola?
Okay, I finally got my code to compile correctly using Kraven's library.
The problem is when I hook up my adafruit breakout chip to the i2c port on the relay, I get a steady blinking red light under status and it does not dim up/down like it should.
I have tried my best to diagnose the issue, but am failing to see what the issue is at the moment.
To verify: I did create my own usb to i2c cable, with the following configuration;
Black - Ground
Green - SDA
White - SCL
Red - VCC
Code: Select all
int i = 0;
while (i < 100)
{
ReefAngel.PCA.SetAllChannelsPercent(i);
Serial.println(i);
i++;
}
while (i >= 0)
{
ReefAngel.PCA.SetAllChannelsPercent(i);
i--;
}
I have tried my best to diagnose the issue, but am failing to see what the issue is at the moment.
To verify: I did create my own usb to i2c cable, with the following configuration;
Black - Ground
Green - SDA
White - SCL
Red - VCC
Re: 12bit PWMParabola?
Shameless bump to figure this out. Any help from anyone would be appreciated.
Re: 12bit PWMParabola?
Did you try inverting the SDA/SCL wires?
It's something in the bus that is causing this.
It's something in the bus that is causing this.
Roberto.
Re: 12bit PWMParabola?
I did. The chip is set to 0x4e (I believe) so I set that in the globals and moved the PHProbe to a different address.
Could this be the source of the issue?
Could this be the source of the issue?
Last edited by Meldrath on Tue May 13, 2014 8:04 am, edited 1 time in total.
Re: 12bit PWMParabola?
Can you confirm the breakout board is working with another arduino board?
Roberto.
Re: 12bit PWMParabola?
Not readily available.
Re: 12bit PWMParabola?
The address won't be the issue.
If the status is blinking, it means your bus is locked.
So, I know it is something in that cable you've made or it is the breakout board/chip that is non-functional.
Burned out chips can cause this too.
If the status is blinking, it means your bus is locked.
So, I know it is something in that cable you've made or it is the breakout board/chip that is non-functional.
Burned out chips can cause this too.
Roberto.
Re: 12bit PWMParabola?
Is there a verify within reef angel or something to see if the chip is functional?