2nd Dimming Expansion Module

Do you have a question on how to do something.
Ask in here.
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

2nd Dimming Expansion Module

Post by Loose »

I saw in this thread that I could use a second Dimming Expansion Module to control more than 6 channels of lighting.

http://forum.reefangel.com/viewtopic.php?p=50059#p50059

I built my DIY RapidLEDs fixture to use 12 channels and have 2 dimming expansion modules.

How do I access/control the ports on the second dimming module? Do I need to/should I customize my libraries?

I have an RA*.
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: 2nd Dimming Expansion Module

Post by rimai »

No change to the libraries. You would have to implement the communication to the second module in your code.
Roberto.
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post by Loose »

Thanks Roberto.

Would you give me an example; if I wanted set channel #7 (#1 on the second Dimming Module) to 90%, what would that code look like?
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: 2nd Dimming Expansion Module

Post by rimai »

All the code for the Dimming expansion module can be found on the file RA_PWM.cpp
Here is what you need:

Code: Select all

    Wire.beginTransmission(I2CPWM_PCA9685);
    Wire.write(0x8+(4*channel));
    Wire.write(data&0xff);
    Wire.write(data>>8);
    Wire.endTransmission();
Where channel would be 7 and data would be 90% of 4095.
Roberto.
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post by Loose »

Thank you Sir,

Exactly what I needed.

I have that printed out but this section threw me off:

#ifdef PWMEXPANSION
else if (Channel>=OVERRIDE_CHANNEL0 && Channel<=OVERRIDE_CHANNEL5) // Dimming Expansion channel 0-5
SetChannelOverride(Channel-OVERRIDE_CHANNEL0,Value);

Still learning the language.

FYI, I'm doing this remotely with the Dimming Expansion modules and Expansion relay connected to the Cloud Wifi expansion hub through an Expansion Hub module.

Again, thanks much!
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post by Loose »

A couple of follow-up questions.

Can I designated one module to be channels 0-5 and the other 6-11 or is it determined automatically?
If determined automatically, would it ever switch?
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: 2nd Dimming Expansion Module

Post by rimai »

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.
Roberto.
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post by Loose »

Got it. With jumper on, 2nd module is addressable as a 16ch, that makes it easy.

Thanks.

--Loose
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post by Loose »

Is there something that would keep a 6 ch Dimming module from working with a Cloud Wifi Hub expansion?

I inserted the jumper on JP1 and added the code to my INO.

void setup():

Code: Select all

ReefAngel.Add16ChPWM();
and used the following as a test.
void loop():

Code: Select all

    ReefAngel.PWM.Set16Channel(0,9);
    ReefAngel.PWM.Set16Channel(1,27);
    ReefAngel.PWM.Set16Channel(2,45);
    ReefAngel.PWM.Set16Channel(3,63);
I can see the changes in the android app but the lights do not turn on

I switched the the following code:

Code: Select all

    ReefAngel.PWM.Set16ChannelRaw(0,369);
    ReefAngel.PWM.Set16ChannelRaw(1,1107);
    ReefAngel.PWM.Set16ChannelRaw(2,1845);
    ReefAngel.PWM.Set16ChannelRaw(3,2583);
With the same results

I attached the jumpered 6ch module to the RA* and ran the I2CScanner.INO just to verify that the address was 0x41 and it was detected there correctly.

I even tried your test code, slightly modified, as I only have 4 channels from that module attached right now.
void loop()

Code: Select all

  for (int a=0;a<4;a++)
  {
    CustomExpansion(0x41,a,50);
  }
  CustomExpansion(0x41,now()%4,99);

Code: Select all

void CustomExpansion(byte id, byte channel, byte percentage)
{
  Wire.beginTransmission(id);
  Wire.write(0);
  Wire.write(0xa1);
  Wire.endTransmission();
  int newdata=(int)(percentage*40.95);
  Wire.beginTransmission(id);
  Wire.write(0x8+(4*channel));
  Wire.write(newdata&0xff);
  Wire.write(newdata>>8);
  Wire.endTransmission();
}
This is what my setup in the remote room looks like at the moment:
Attachments
20180225_221754.jpg
20180225_221754.jpg (121.05 KiB) Viewed 9487 times
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: 2nd Dimming Expansion Module

Post by rimai »

Hummm.
I may not have implemented the publishing of this module. :(
I have to double check.
Does it work if you use it directly connected to RA*?
Roberto.
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post 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.
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post 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?
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: 2nd Dimming Expansion Module

Post 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 :)
Roberto.
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post 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.
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: 2nd Dimming Expansion Module

Post 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.
Roberto.
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post 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.
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: 2nd Dimming Expansion Module

Post by rimai »

Those modules were only 0-5V PWM signal.
What drivers are you using?
Roberto.
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post by Loose »

Meanwell LDD-1000H and LDD-700H.
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: 2nd Dimming Expansion Module

Post 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.
Roberto.
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post by Loose »

That's correct; 0-5V PWM for those drivers.

A few weeks, $89, and a PM. Got it.
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: 2nd Dimming Expansion Module

Post 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.
Roberto.
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post 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.
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: 2nd Dimming Expansion Module

Post by rimai »

Just use the webwizard.
Roberto.
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post by Loose »

Added and uploaded.
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: 2nd Dimming Expansion Module

Post 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.
Roberto.
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post 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

Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post 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.
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post 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.
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post 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?
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: 2nd Dimming Expansion Module

Post 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!!! :)
Roberto.
Post Reply