12bit PWMParabola?
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?
Re: 12bit PWMParabola?
Yes, there is a code called i2cscanner. If you search the forum, you will find it...
But it won't work in your case because the bus is locked.
But it won't work in your case because the bus is locked.
Roberto.
Re: 12bit PWMParabola?
I had a 2nd one, I wired it up, and ran the i2c scanner.
I have globals.h set to this:
My chip is set for 54 (which is the same as eeprom 2, which I set to 5d)
Code: Select all
I2CScanner ready!
starting scanning of I2C bus from 1 to 128...
addr: 1 addr: 2 addr: 3 addr: 4
addr: 5 addr: 6 addr: 7 addr: 8
addr: 9 addr: A addr: B addr: C
addr: D addr: E addr: F addr: 10
addr: 11 addr: 12 addr: 13 addr: 14
addr: 15 addr: 16 addr: 17 addr: 18
addr: 19 addr: 1A addr: 1B addr: 1C
addr: 1D addr: 1E addr: 1F addr: 20 found!
addr: 21 addr: 22 addr: 23 addr: 24
addr: 25 addr: 26 addr: 27 addr: 28
addr: 29 addr: 2A addr: 2B addr: 2C
addr: 2D addr: 2E addr: 2F addr: 30
addr: 31 addr: 32 addr: 33 addr: 34
addr: 35 addr: 36 addr: 37 addr: 38
addr: 39 addr: 3A addr: 3B addr: 3C
addr: 3D addr: 3E addr: 3F addr: 40
addr: 41 addr: 42 addr: 43 addr: 44
addr: 45 addr: 46 addr: 47 addr: 48
addr: 49 addr: 4A addr: 4B addr: 4C
addr: 4D addr: 4E addr: 4F addr: 50 found!
addr: 51 addr: 52 addr: 53 addr: 54 found!
addr: 55 addr: 56 addr: 57 addr: 58
addr: 59 addr: 5A addr: 5B addr: 5C
addr: 5D addr: 5E addr: 5F addr: 60
addr: 61 addr: 62 addr: 63 addr: 64
addr: 65 addr: 66 addr: 67 addr: 68 found!
addr: 69 addr: 6A addr: 6B addr: 6C
addr: 6D addr: 6E addr: 6F addr: 70 found!
addr: 71 addr: 72 addr: 73 addr: 74
addr: 75 addr: 76 addr: 77 addr: 78
addr: 79 addr: 7A addr: 7B addr: 7C
addr: 7D addr: 7E addr: 7F addr: 80 found!
Code: Select all
// I2C Addresses
#define I2CPWM 0x08
#define I2CIO 0x09
#define I2CRF 0X10
#define I2CRA_Master 0x11
#define I2CRA_TouchDisplay 0x12
#define I2CTilt 0x1c
#define I2CExpander1 0x20
#define I2CExpander2 0x21
#define I2CIO_PCF8574 0x27
#define I2CExpModule 0x38 // 0x38-3f
#define I2CPWM_PCA9685EXP 0x54
#define I2CLeak 0X48
#define I2CMultiWaterLevel 0X49
#define I2CORP 0X4c
#define I2CSalinity 0X4d
#define I2CPH 0X4e
#define I2CWaterLevel 0X4f
#define I2CEEPROM1 0x50
#define I2CEEPROM2 0x5d
#define I2CHumidity 0x5c
#define I2CClock 0x68
Re: 12bit PWMParabola?
You need to change your chip to another address. You can't use one that is already in use
Sent from my SM-G900P using Tapatalk
Sent from my SM-G900P using Tapatalk
Roberto.
Re: 12bit PWMParabola?
Did that now, and it's still not working lol.