Page 1 of 2

Re: 2nd Dimming Expansion Module

Posted: Mon Feb 26, 2018 5:57 pm
by Loose
:) Yep, LOL,I figured you were going to ask me that... The RA* is in one room and the module is screwed to the mounting board in another... with the 72" heat sink and lights.

I'll un-mount the module and use my multi-meter to check for voltage.

Re: 2nd Dimming Expansion Module

Posted: Mon Feb 26, 2018 6:23 pm
by Loose
With 0x41 attached to the RA* and the below code:

Code: Select all

    // 16 channelPWM testing
    ReefAngel.PWM.Set16ChannelRaw(0,369);
    ReefAngel.PWM.Set16ChannelRaw(1,1107);
    ReefAngel.PWM.Set16ChannelRaw(2,1845);
    ReefAngel.PWM.Set16ChannelRaw(3,2583); 
I get the following:

ch 0 - 0.43v
ch 1 - 1.33v
ch 2 - 2.24v
ch 3 - 3.14v
ch 4 - 0.0v
ch 5 - 0.0v

You still have any of those 16ch dimming modules left?

Re: 2nd Dimming Expansion Module

Posted: Mon Feb 26, 2018 6:57 pm
by rimai
So, that means the module is working fine as well as your code.
The only thing left is the communication from RA* to the cloud wifi hub.
I have to check, but I'm almost sure I didn't include it.
I'll check it later tonight after I put my kid to sleep.
It's feeding time now :)

Re: 2nd Dimming Expansion Module

Posted: Mon Feb 26, 2018 7:02 pm
by Loose
Dude, no hurry. I understand the night time feedings; got five kids and did most of them late nighters... wonderful time as I remember it.

Re: 2nd Dimming Expansion Module

Posted: Tue Feb 27, 2018 9:00 am
by rimai
Yes, the 16ch is confirmed not to be in the publishing of variables.
It would take a change in the libraries for this to work.
I think the best would be to just add this to your own code and it would take a bit of patience to get this completed.
Do you want to give it a try?
I can get the code started for you to test.

Re: 2nd Dimming Expansion Module

Posted: Tue Feb 27, 2018 11:44 am
by Loose
Yes, please. I would love to do this.

I was also serious when I asked if you had any 16ch modules left? Some of the things I'm thinking of doing with my lights, I'm thinking, would be easier with a single 16ch module as opposed to two 6ch modules.

Re: 2nd Dimming Expansion Module

Posted: Tue Feb 27, 2018 11:55 am
by rimai
Those modules were only 0-5V PWM signal.
What drivers are you using?

Re: 2nd Dimming Expansion Module

Posted: Tue Feb 27, 2018 12:05 pm
by Loose
Meanwell LDD-1000H and LDD-700H.

Re: 2nd Dimming Expansion Module

Posted: Tue Feb 27, 2018 12:24 pm
by rimai
I think those are 0-5V PWM, right?
If that is the case, I can make one for you, but it takes a few weeks and it does not come with a plastic enclosure.
It would be about $89.
PM me if interested.

Re: 2nd Dimming Expansion Module

Posted: Tue Feb 27, 2018 12:33 pm
by Loose
That's correct; 0-5V PWM for those drivers.

A few weeks, $89, and a PM. Got it.

Re: 2nd Dimming Expansion Module

Posted: Wed Feb 28, 2018 7:04 pm
by rimai
OK, so we need to update both your RA* and your cloud wifi hub.
Let do the RA* first.
On your code, add this above setup()

Code: Select all

unsigned long last16channelcheck = millis();
int OldPercentage16[16];
byte OldPercentage16Override[16];
char buffer[15];
Add this to setup()

Code: Select all

  ReefAngel.Add16ChPWM();
And add this to loop() right above ReefAngel.Network.Cloud()

Code: Select all

  ReefAngel.PWM.Set16Channel(0, (now() % 10 < 5) ? 50 : 100);
  if (millis() - last16channelcheck > 1000 && ReefAngel.Network.IsMQTTConnected())
  {
    last16channelcheck = millis();
    for (byte a = 0; a < 16; a++)
    {
      if (ReefAngel.PWM.SIXTEENChExpansionChannel[a] != OldPercentage16[a])
      {
        if (a<10)
          sprintf(buffer, "%s0%d:%d", "PWM16E", a, ReefAngel.PWM.SIXTEENChExpansionChannel[a]);
        else
          sprintf(buffer, "%s%d:%d", "PWM16E", a, ReefAngel.PWM.SIXTEENChExpansionChannel[a]);
        Serial.println(buffer);
        ReefAngel.Network.CloudPublish(buffer);
        OldPercentage16[a] = ReefAngel.PWM.SIXTEENChExpansionChannel[a];
      }
      if (ReefAngel.PWM.SIXTEENChExpansionChannelOverride[a] != OldPercentage16Override[a])
      {
        if (a<10)
          sprintf(buffer, "%s0%d:%d", "PWM16EO", a, ReefAngel.PWM.SIXTEENChExpansionChannelOverride[a]);
        else
          sprintf(buffer, "%s%d:%d", "PWM16EO", a, ReefAngel.PWM.SIXTEENChExpansionChannelOverride[a]);
        Serial.println(buffer);
        ReefAngel.Network.CloudPublish(buffer);
        OldPercentage16Override[a] = ReefAngel.PWM.SIXTEENChExpansionChannelOverride[a];
      }
    }
  }
This should start sending the 16ch messages to the cloud server.

Re: 2nd Dimming Expansion Module

Posted: Thu Mar 01, 2018 7:01 am
by Loose
Thanks Roberto. I got off work late yesterday.

Will update the RA* with this code this evening.

Question - I use the WebWizard's code page to upload code, is there another way I could/should be using? I do have the Reef Angel Arduino loaded on my computer, but the RA* isn't listed there on the drop-down list and am didn't see an option for remote uploading; I try not to touch the RA* as it likes to reboot when I do.

Re: 2nd Dimming Expansion Module

Posted: Thu Mar 01, 2018 8:15 am
by rimai
Just use the webwizard.

Re: 2nd Dimming Expansion Module

Posted: Thu Mar 01, 2018 3:56 pm
by Loose
Added and uploaded.

Re: 2nd Dimming Expansion Module

Posted: Thu Mar 01, 2018 10:36 pm
by rimai
Ok, now using a paper clip, push the button through the pinhole on the side of the module.
If the module is connected to wifi, it should start downloading the new firmware. It will go through a reset and come back alive in a few seconds.
Use Arduino IDE and open serial port to get the debug message.

Re: 2nd Dimming Expansion Module

Posted: Fri Mar 02, 2018 5:16 am
by Loose
Module reset

Serial output:

Code: Select all

Connecting to cloud server...
Connected
Subscribing to Loose/out/#
Loose/in: all:0
Loose/in: io:255
cloud:PWM16E00:2047
PWM16E00:2047
cloud:ATOLOW:0
cloud:ATOHIGH:0
cloud:EM:137
cloud:EM1:20
cloud:REM:7
cloud:BID:4
cloud:AF:0
cloud:SF:0
cloud:PWMD:89
cloud:PWMA:100
cloud:PWMDO:255
cloud:PWMAO:255
cloud:R1:99
R1:99
cloud:ROFF1:255
ROFF1:255
cloud:RON1:0
RON1:0
cloud:R2:131
R2:131
cloud:ROFF2:255
ROFF2:255
cloud:RON2:0
RON2:0
cloud:R3:0
R3:0
cloud:ROFF3:255
ROFF3:255
cloud:RON3:0
RON3:0
cloud:R4:0
R4:0
cloud:ROFF4:255
ROFF4:255
cloud:RON4:0
RON4:0
cloud:R5:0
R5:0
cloud:ROFF5:255
ROFF5:255
cloud:RON5:0
RON5:0
cloud:R6:0
R6:0
cloud:ROFF6:255
ROFF6:255
cloud:RON6:0
RON6:0
cloud:R7:0
R7:0
cloud:ROFF7:255
ROFF7:255
cloud:RON7:0
RON7:0
cloud:R8:0
R8:0
cloud:ROFF8:255
ROFF8:255
cloud:RON8:0
RON8:0
cloud:ALARM:0
cloud:PWMD2:36
cloud:PWMA2:0
cloud:PWMD2O:255
cloud:PWMA2O:255
cloud:WL:0
cloud:WL1:103
cloud:WL2:83
cloud:WL3:35
cloud:WL4:4
cloud:HUM:0
cloud:DCM:0
cloud:DCS:0
cloud:DCD:0
cloud:DCT:0
cloud:PWME0:15
PWME0:15
cloud:PWME1:0
PWME1:0
cloud:PWME2:12
PWME2:12
cloud:PWME3:0
PWME3:0
cloud:PWME4:0
PWME4:0
cloud:PWME5:0
PWME5:0
cloud:PWME0O:255
PWME0O:255
cloud:PWME1O:255
PWME1O:255
cloud:PWME2O:255
PWME2O:255
cloud:PWME3O:255
PWME3O:255
cloud:PWME4O:255
PWME4O:255
cloud:PWME5O:255
PWME5O:255
cloud:AIW:0
cloud:AIB:0
cloud:AIRB:0
cloud:RFM:0
cloud:RFS:0
cloud:RFD:0
cloud:RFW:0
cloud:RFRB:0
cloud:RFR:0
cloud:RFG:0
cloud:RFB:0
cloud:RFI:0
cloud:RFWO:0
cloud:RFRBO:0
cloud:RFRO:0
cloud:RFGO:0
cloud:RFBO:0
cloud:RFIO:0
cloud:IO:0
cloud:LEAK:0
cloud:C0:0
cloud:C1:0
cloud:C2:0
cloud:C3:0
cloud:C4:0
cloud:C5:0
cloud:C6:0
cloud:C7:0
cloud:R:0
cloud:ROFF:255
cloud:RON:0
cloud:T1:739
cloud:T2:768
cloud:T3:771
cloud:PH:797
cloud:T4:694
cloud:T5:0
cloud:T6:0
cloud:ORP:0
cloud:SAL:344
cloud:PHE:0
cloud:PAR:0
cloud:CEXP0:0
cloud:CEXP1:0
cloud:CEXP2:0
cloud:CEXP3:0
cloud:CEXP4:0
cloud:CEXP5:0
cloud:CEXP6:0
cloud:CEXP7:0
cloud:WL1:102
cloud:PH:798
cloud:WL1:99
cloud:PH:797
cloud:PWM16E00:4095
PWM16E00:4095
cloud:WL1:98
cloud:PH:798
cloud:WL2:84
cloud:PH:797
cloud:WL1:102
cloud:PH:798
cloud:WL1:99
cloud:WL2:82
cloud:WL1:102
cloud:WL2:83
cloud:PWM16E00:2047
PWM16E00:2047
cloud:WL1:101
cloud:WL1:103
cloud:WL2:82
cloud:PH:797
cloud:WL1:102
cloud:WL2:84
cloud:PH:798
cloud:WL1:98
cloud:WL2:83
cloud:WL1:100
cloud:PWM16E00:4095
PWM16E00:4095


Re: 2nd Dimming Expansion Module

Posted: Fri Mar 02, 2018 8:37 am
by Loose
A note for someone else that is using this thread for their setup, when I reset the Cloud Wifi Hub, it didn't auto reconnect to the networks. I just did the factory reset procedures, as detailed in the Cloud Wifi Attachment Manual 2.0.1.

Re: 2nd Dimming Expansion Module

Posted: Fri Mar 02, 2018 9:09 am
by Loose
Roberto, up and working with lights hooked to 0x41 channel 0 alternating from dim (50%) to bright (100%) every second.

Since I'm a novice at the language please allow me to confirm some things.

This code alternates between a dimming setting of 50% and 100% each time through the loop:

Code: Select all

  ReefAngel.PWM.Set16Channel(0, (now() % 10 < 5) ? 50 : 100);
I'm not sure what '% 10 < 5' actually does?

This 'if' statement checks to see if one second has passed since the last check and if MQTT is connected with the first line resetting the variable to the current time:

Code: Select all

if (millis() - last16channelcheck > 1000 && ReefAngel.Network.IsMQTTConnected())
  {
     last16channelcheck = millis();
     ...
     ...
  }
This main part of the code checks each of the 16 channels to see if there is a change in the percentage setting and if there is, it writes the new value to cloud Wifi hub using the variable 'buffer.' It then sets the old percentage equal to the new percentage for the next time it's checked (done on a per channel basis):

Code: Select all

for (byte a = 0; a < 16; a++)
    {
      if (ReefAngel.PWM.SIXTEENChExpansionChannel[a] != OldPercentage16[a])
      {
        if (a<10)
          sprintf(buffer, "%s0%d:%d", "PWM16E", a, ReefAngel.PWM.SIXTEENChExpansionChannel[a]);
        else
          sprintf(buffer, "%s%d:%d", "PWM16E", a, ReefAngel.PWM.SIXTEENChExpansionChannel[a]);
        Serial.println(buffer);
        ReefAngel.Network.CloudPublish(buffer);
        OldPercentage16[a] = ReefAngel.PWM.SIXTEENChExpansionChannel[a];
      }
This section of code is repeated for the Override function.

Re: 2nd Dimming Expansion Module

Posted: Fri Mar 02, 2018 9:20 am
by Loose
I did a modification for testing, to this, for the 6ch expansion I currently have:

Code: Select all

    ReefAngel.PWM.Set16Channel(0, (now() % 10 < 5) ? 100 : 3);
    ReefAngel.PWM.Set16Channel(1, (now() % 10 < 5) ? 3 : 100);
    ReefAngel.PWM.Set16Channel(2, (now() % 10 < 5) ? 100 : 3);
    ReefAngel.PWM.Set16Channel(3, (now() % 10 < 5) ? 3 : 100);
    ReefAngel.PWM.Set16Channel(4, (now() % 10 < 5) ? 100 : 3);
    ReefAngel.PWM.Set16Channel(5, (now() % 10 < 5) ? 3 : 100);
  if (millis() - last16channelcheck > 1000 && ReefAngel.Network.IsMQTTConnected())
  {
    last16channelcheck = millis();
    for (byte a = 0; a < 6; a++) // a < 16 has been Modified for 6ch Dimming module
I believe I can make this operational code by changing

Code: Select all

ReefAngel.PWM.Set16Channel(0, (now() % 10 < 5) ? 100 : 3);
to something like this

Code: Select all

ReefAngel.PWM.Set16Channel(0, PWMParabola(13,0,20,0,0,63,0) );
and changing this

Code: Select all

  if (millis() - last16channelcheck > 1000 && ReefAngel.Network.IsMQTTConnected())
to this

Code: Select all

  if (ReefAngel.Network.IsMQTTConnected() )
Would this be correct?

Re: 2nd Dimming Expansion Module

Posted: Fri Mar 02, 2018 5:50 pm
by rimai
Yes, the code was set to alternate between 50 and 100.
Correct, you can change that code I used for testing to whatever you want including the one you posted above.
don't change anything regarding the millis() check.
The reason it is there is because sometimes, the module doesn't like to receive too much data too fast, so the check is simply to make sure we only send data once per second.
Just add the part where you set the 16 channels to whatever waveform type you want and you should be good.
Isn't the cloud wifi hub awesome???!!!!
I think you are the first one to actually use it :)
I tested it once with a Japanese guy holding an RA* in Japan and I was changing the water level module here in the USA. He was receiving data in Japan on his RA* just fine and it was so amazing!!! :)

Re: 2nd Dimming Expansion Module

Posted: Sat Mar 03, 2018 12:09 pm
by Loose
:lol:
Yes, it absolutely is an awesome device!! First huh? That's kinda cool... Hey, if you want to test code in an operational setting, just let me know.

For my setup, it makes it a clean(er) look with my family room show piece.
If I could build a hobby-business around installing and maintaining reef tanks, this device would be a key feature to the (RA based) setup. ;)

I did take the millis() check out (the parabola/slope waveforms don't change that much over a few hours) but will put it back in and experiment with working it under the full second... I'd like to work the connected channels into lightening code and I think 1 sec response is a bit too long.

Couple questions from the picture below, what are these ports and are they active?

Re: 2nd Dimming Expansion Module

Posted: Sat Mar 03, 2018 8:36 pm
by rimai
The broadcast of data through the cloud server is not going to be fast enough for lightning.
If you want to implement that, you will have to program the cloud wifi hub code itself and implement the lightning code in there and just send a trigger signal to start and stop the lightning code.
If you want to do that, you will need to use the Arduino IDE with the latest dev branch of the libraries.
The header is for two temp probe and two input channels. They are enabled and are currently T4 and T5 and channel 6 and channel 7 of the I/O expansion.

Re: 2nd Dimming Expansion Module

Posted: Wed Mar 07, 2018 7:56 pm
by Loose
Ahhh... data throughput limit is with the cloud server and not with the module.

Header for two temp probes, two I/O ports, and can accept code independently of the RA*, this module looks better and better.

Re: 2nd Dimming Expansion Module

Posted: Mon Aug 13, 2018 5:53 pm
by tngo
Hey Roberto,

Has the 2nd dimming expansion module been implemented into the libraries? I wanted to connect and test a new light fixture using a second dimming module.

Thanks,
Tim

rimai wrote:Actually,I just remember that you also have to change the ID of the 2nd expansion module.
Open the module and place a jumper on ID1.
That way both your modules will have distinct addresses.
The first one is I2CPWM_PCA9685 and the second one is I2CPWM_16CH_PCA9685.
Also, I just looked at the libraries and since both these addresses are distinct and already in the libraries, all you need to do is place this line on the setup() section:

Code: Select all

ReefAngel.Add16ChPWM();
Then you can control the channels of the second module as if it were a 16ch.

Code: Select all

ReefAngel.PWM.SetChannel(0,4096); // Sets channel 0 of 1st dimming module to 4096
ReefAngel.PWM.Set16Channel(0,4096); // Sets channel 0 of 2nd dimming module to 4096
Channels for both modules start at 0.

Re: 2nd Dimming Expansion Module

Posted: Mon Aug 13, 2018 9:42 pm
by rimai
It's been in the libraries for a long time, but none of the apps will allow you to override the %.

Re: 2nd Dimming Expansion Module

Posted: Wed Aug 15, 2018 10:08 am
by tngo
Okay, cool thanks.

Tim

Re: 2nd Dimming Expansion Module

Posted: Sun Aug 19, 2018 5:52 am
by binder
rimai wrote:It's been in the libraries for a long time, but none of the apps will allow you to override the %.
if you are referring to the 16ch dimming module, my android app supports it and allows for overriding the %.
if you are talking about something else, then you are probably right.

Sent from my XT1585 using Tapatalk

Re: 2nd Dimming Expansion Module

Posted: Sun Aug 19, 2018 10:10 am
by rimai
Oh. I thought I didnt.
Good to know :)