PWM Expansion
PWM Expansion
I have a few questions:
1. Is the Expansion Hub the same thing as the PWM Expansion?
2. How is the Expansion Hub connected to the controller?
3. What all can be plugged into the Expansion Hub? Is it primarily for LED lights (assuming it is the PWM Expansion)?
4. If I'm way off with these, what is the PWM Expansion and how does it work?
curt
1. Is the Expansion Hub the same thing as the PWM Expansion?
2. How is the Expansion Hub connected to the controller?
3. What all can be plugged into the Expansion Hub? Is it primarily for LED lights (assuming it is the PWM Expansion)?
4. If I'm way off with these, what is the PWM Expansion and how does it work?
curt
Re: PWM Expansion
1. No
2. 2nd Gen relay boxes have a usb like connector on the side of the box that you can use to connect one expansion module or the expansion hub.
3. All expansion modules can be plugged into the hub. Currently there are Relay, PWM and I/O expansion modules. Some are only on special order basis for now.
4. The PWM expansion module is a little tiny box with 6 boosted independent PWM channels. It has another 328p inside of it working as a slave. You can communicate with it through I2C. I decided to make it with another 328p in slave mode to take the load of lighting effects off of the master head unit.
So, it is very simple to call any effect that you may want or even change effects if one would like to.
Attached is the PDE file that is loaded into the PWM expansion module.
One could actually very easily turn it into a stand-alone 6 channel PWM controller, by just modifying the code.
To call the effects on the module, you can issue the following commands:
Change individual channel, where x is a number from 0 to 5, which represent which channel you would like to change and y is the a number from 0 to 255, which represent the PWM duty cycle.
For Fast Cloud
For Slow Cloud
For Thunderstorm 1 (preset pattern)
For Thunderstorm 2 (random pattern)
2. 2nd Gen relay boxes have a usb like connector on the side of the box that you can use to connect one expansion module or the expansion hub.
3. All expansion modules can be plugged into the hub. Currently there are Relay, PWM and I/O expansion modules. Some are only on special order basis for now.
4. The PWM expansion module is a little tiny box with 6 boosted independent PWM channels. It has another 328p inside of it working as a slave. You can communicate with it through I2C. I decided to make it with another 328p in slave mode to take the load of lighting effects off of the master head unit.
So, it is very simple to call any effect that you may want or even change effects if one would like to.
Attached is the PDE file that is loaded into the PWM expansion module.
One could actually very easily turn it into a stand-alone 6 channel PWM controller, by just modifying the code.
To call the effects on the module, you can issue the following commands:
Change individual channel, where x is a number from 0 to 5, which represent which channel you would like to change and y is the a number from 0 to 255, which represent the PWM duty cycle.
Code: Select all
PWMExpansion(x,y);
Code: Select all
PWMExpansion(6,1);
Code: Select all
PWMExpansion(6,15);
Code: Select all
PWMExpansion(7,0);
Code: Select all
PWMExpansion(8,0);
- Attachments
-
- PWMExpansionCommands.pde
- (2.86 KiB) Downloaded 530 times
Roberto.
Re: PWM Expansion
wish I knew about the thunderstorms before my last order
oh well, and life goes on
oh well, and life goes on
Re: PWM Expansion
alexwbush wrote:wish I knew about the thunderstorms before my last order
oh well, and life goes on
+1
Re: PWM Expansion
will these effects work with just 2 drivers and no PWM expansion module and just the 2 standard outputs on the base relay box?
Re: PWM Expansion
Im interested if you dont mine helping me out.
Brian
Brian
Re: PWM Expansion
http://forum.reefangel.com/viewtopic.ph ... 7&start=10bmhair03 wrote:Im interested if you dont mine helping me out.
Brian
Roberto.
Re: PWM Expansion
I am hoping to control between 3 and 5 banks of LED lights. Also included in that would be a fan, possibly controled through PWM.
However I can't find the PWN expansion for sale anywhere? How does one go about adding that to an order? If they are not available, I can simplify to 2 banks of lights, and a ON/OFF fan, but I would like to do more.
Thanks!
However I can't find the PWN expansion for sale anywhere? How does one go about adding that to an order? If they are not available, I can simplify to 2 banks of lights, and a ON/OFF fan, but I would like to do more.
Thanks!
Re: PWM Expansion
Here is the pinout:
- Attachments
-
- ReefAngel_PWM_Expansion_Pin.jpg (34.67 KiB) Viewed 6795 times
Roberto.
Re: PWM Expansion
Quick question regarding the voltage on the PWM expansion.
Using a Voltmeter, if I connect the 12V to a ground, I should read 12 Volts DC, correct? Or is that an input of 12 V?
I ask because I am getting nothing across the pins of the PWM expansion currently. I did put the two jumpers inside the main head unit, and the USB cable is connecting the expansion to the relay box. I do have a green led lit up inside the expansion.
If it matters, here is my code, just in case I am messing up the expansion somehow.
Using a Voltmeter, if I connect the 12V to a ground, I should read 12 Volts DC, correct? Or is that an input of 12 V?
I ask because I am getting nothing across the pins of the PWM expansion currently. I did put the two jumpers inside the main head unit, and the USB cable is connecting the expansion to the relay box. I do have a green led lit up inside the expansion.
If it matters, here is my code, just in case I am messing up the expansion somehow.
Code: Select all
// Autogenerated file by RAGen (v1.0.4.92), (09/17/2011 15:54)
// RA_091711_1554.pde
//
// This version designed for v0.8.5 Beta 12 or later
/* The following features are enabled for this PDE File:
#define DisplayImages
#define DateTimeSetup
#define VersionMenu
#define DirectTempSensor
#define DisplayLEDPWM
#define StandardLightSetup
*/
#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>
//*********************************************************************************************************************************
//Start of PWM Expansion Code Header
// This is just how we are going to reference the PWM expansion ports within the code.
// You can change the labels if you would like, just as long as they are changed all throughout the code too.
#define LEDPWM0 0
#define LEDPWM1 1
#define LEDPWM2 2
#define LEDPWM3 3
#define LEDPWM4 4
#define LEDPWM5 5
// Initial values to all 6 channels at startup. They will always be 0.
byte PWMChannel[]={
0,0,0,0,0,0};
//End of PWM Expansion Code Header
//*********************************************************************************************************************************
//*********************************************************************************************************************************
//Start of PWM slope function code designed for the PWM Expansion module
void PWMExpansion(byte cmd, byte data)
{
Wire.beginTransmission(8); // transmit to device #2
Wire.send('$'); // sends $
Wire.send('$'); // sends $
Wire.send('$'); // sends $
Wire.send(cmd); // sends a value
Wire.send(data); // sends 255
Wire.endTransmission(); // stop transmitting
}
//End of PWM slope function code designed for the PWM Expansion module
//*********************************************************************************************************************************
void setup()
{
ReefAngel.Init(); //Initialize controller
ReefAngel.FeedingModePorts = B00000000;
ReefAngel.WaterChangePorts = B00000000;
ReefAngel.OverheatShutoffPorts = B00101010;
ReefAngel.LightsOnPorts = B00000000;
//*********************************************************************************************************************************
//Start of PWM Expansion Code for Slope
PWMChannel[LEDPWM0]=PWMSlope(12,0,20,00,20,50,60,PWMChannel[LEDPWM0]);
PWMChannel[LEDPWM1]=PWMSlope(13,0,21,00,20,50,60,PWMChannel[LEDPWM1]);
PWMChannel[LEDPWM2]=PWMSlope(14,0,22,00,20,50,60,PWMChannel[LEDPWM2]);
PWMChannel[LEDPWM3]=PWMSlope(12,0,22,00,20,50,60,PWMChannel[LEDPWM3]);
// The lines above are what calculates the slope.
// You can change the schedule by changing the parameter inside the parenthesis of the PWMSlope() function
// The are as follow:
// 1st parameter: hour to start slope
// 2nd parameter: minute to start slope
// 3rd parameter: hour to end slope
// 4th parameter: minute to end slope
// 5th parameter: % of the PWM signal to start slope
// 6th parameter: % of the PWM signal to end slope
// 7th parameter: duration of slope in minutes
// 8th parameter: always the same as the variable before the PWMSlope() call
//PWMChannel[LEDPWM1]=PWMSlope(15,0,21,30,15,45,90,PWMChannel[LEDPWM1]);
// In the example above, we are starting the slope at 3:00pm with 15% and going up to 45% within 90 minutes, which would be 4:30pm.
// Then it would stay at 45% from 4:30 to 90 minutes prior to 9:30pm, which would be 8:00pm.
// Then from 8:00pm, it would start sloping down from 45% all the way back to 15% within 90 minutes, which would be 9:30pm.
PWMExpansion(LEDPWM0,int(2.55*PWMChannel[LEDPWM0]));
PWMExpansion(LEDPWM1,int(2.55*PWMChannel[LEDPWM1]));
PWMExpansion(LEDPWM2,int(2.55*PWMChannel[LEDPWM2]));
PWMExpansion(LEDPWM3,int(2.55*PWMChannel[LEDPWM3]));
//End of PWM Expansion Code for Slope
//*********************************************************************************************************************************
}
void loop()
{
ReefAngel.ShowInterface();
// Specific functions
ReefAngel.StandardHeater(Port1);
ReefAngel.StandardLights(Port2);
ReefAngel.StandardHeater(Port3);
ReefAngel.StandardLights(Port4);
ReefAngel.StandardHeater(Port5);
ReefAngel.StandardLights(Port6);
ReefAngel.StandardFan(Port7);
ReefAngel.StandardLights(Port8);
}
Re: PWM Expansion
the pwm code is only being called when the controller starts up. After that nothing gets changed. You most likely will need the pwm code inside the loop function so that it will get updated as the controller is running.
Side note: setup() only runs once when the controller starts up. After that, loop() runs continuously. All functions that monitor or control something should be called inside loop().
curt
Side note: setup() only runs once when the controller starts up. After that, loop() runs continuously. All functions that monitor or control something should be called inside loop().
curt
Re: PWM Expansion
On the pin out diagram above, +12VDC and GND on the right most header is actually input and not output.
You need to feed 12VDC with a power supply to source power to the booster circuit.
With your code, what Curt was saying is to use your code like this:
You need to feed 12VDC with a power supply to source power to the booster circuit.
With your code, what Curt was saying is to use your code like this:
Code: Select all
// Autogenerated file by RAGen (v1.0.4.92), (09/17/2011 15:54)
// RA_091711_1554.pde
//
// This version designed for v0.8.5 Beta 12 or later
/* The following features are enabled for this PDE File:
#define DisplayImages
#define DateTimeSetup
#define VersionMenu
#define DirectTempSensor
#define DisplayLEDPWM
#define StandardLightSetup
*/
#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>
//*********************************************************************************************************************************
//Start of PWM Expansion Code Header
// This is just how we are going to reference the PWM expansion ports within the code.
// You can change the labels if you would like, just as long as they are changed all throughout the code too.
#define LEDPWM0 0
#define LEDPWM1 1
#define LEDPWM2 2
#define LEDPWM3 3
#define LEDPWM4 4
#define LEDPWM5 5
// Initial values to all 6 channels at startup. They will always be 0.
byte PWMChannel[]={
0,0,0,0,0,0};
//End of PWM Expansion Code Header
//*********************************************************************************************************************************
//*********************************************************************************************************************************
//Start of PWM slope function code designed for the PWM Expansion module
void PWMExpansion(byte cmd, byte data)
{
Wire.beginTransmission(8); // transmit to device #2
Wire.send('$'); // sends $
Wire.send('$'); // sends $
Wire.send('$'); // sends $
Wire.send(cmd); // sends a value
Wire.send(data); // sends 255
Wire.endTransmission(); // stop transmitting
}
//End of PWM slope function code designed for the PWM Expansion module
//*********************************************************************************************************************************
void setup()
{
ReefAngel.Init(); //Initialize controller
ReefAngel.FeedingModePorts = B00000000;
ReefAngel.WaterChangePorts = B00000000;
ReefAngel.OverheatShutoffPorts = B00101010;
ReefAngel.LightsOnPorts = B00000000;
}
void loop()
{
ReefAngel.ShowInterface();
// Specific functions
ReefAngel.StandardHeater(Port1);
ReefAngel.StandardLights(Port2);
ReefAngel.StandardHeater(Port3);
ReefAngel.StandardLights(Port4);
ReefAngel.StandardHeater(Port5);
ReefAngel.StandardLights(Port6);
ReefAngel.StandardFan(Port7);
ReefAngel.StandardLights(Port8);
//*********************************************************************************************************************************
//Start of PWM Expansion Code for Slope
PWMChannel[LEDPWM0]=PWMSlope(12,0,20,00,20,50,60,PWMChannel[LEDPWM0]);
PWMChannel[LEDPWM1]=PWMSlope(13,0,21,00,20,50,60,PWMChannel[LEDPWM1]);
PWMChannel[LEDPWM2]=PWMSlope(14,0,22,00,20,50,60,PWMChannel[LEDPWM2]);
PWMChannel[LEDPWM3]=PWMSlope(12,0,22,00,20,50,60,PWMChannel[LEDPWM3]);
// The lines above are what calculates the slope.
// You can change the schedule by changing the parameter inside the parenthesis of the PWMSlope() function
// The are as follow:
// 1st parameter: hour to start slope
// 2nd parameter: minute to start slope
// 3rd parameter: hour to end slope
// 4th parameter: minute to end slope
// 5th parameter: % of the PWM signal to start slope
// 6th parameter: % of the PWM signal to end slope
// 7th parameter: duration of slope in minutes
// 8th parameter: always the same as the variable before the PWMSlope() call
//PWMChannel[LEDPWM1]=PWMSlope(15,0,21,30,15,45,90,PWMChannel[LEDPWM1]);
// In the example above, we are starting the slope at 3:00pm with 15% and going up to 45% within 90 minutes, which would be 4:30pm.
// Then it would stay at 45% from 4:30 to 90 minutes prior to 9:30pm, which would be 8:00pm.
// Then from 8:00pm, it would start sloping down from 45% all the way back to 15% within 90 minutes, which would be 9:30pm.
PWMExpansion(LEDPWM0,int(2.55*PWMChannel[LEDPWM0]));
PWMExpansion(LEDPWM1,int(2.55*PWMChannel[LEDPWM1]));
PWMExpansion(LEDPWM2,int(2.55*PWMChannel[LEDPWM2]));
PWMExpansion(LEDPWM3,int(2.55*PWMChannel[LEDPWM3]));
//End of PWM Expansion Code for Slope
//*********************************************************************************************************************************
}
Roberto.
Re: PWM Expansion
Thanks for the quick responses. I got the impression from some other post that I might have needed a power supply, but wasn't sure.
Can I put this in setup:
And then this part in the loop?
Or is it just best to leave it all in the loop?
Now off to dig through my wall warts for a 12v power supply!
Can I put this in setup:
Code: Select all
//Start of PWM Expansion Code for Slope
PWMChannel[LEDPWM0]=PWMSlope(12,0,20,00,20,50,60,PWMChannel[LEDPWM0]);
PWMChannel[LEDPWM1]=PWMSlope(13,0,21,00,20,50,60,PWMChannel[LEDPWM1]);
PWMChannel[LEDPWM2]=PWMSlope(14,0,22,00,20,50,60,PWMChannel[LEDPWM2]);
PWMChannel[LEDPWM3]=PWMSlope(12,0,22,00,20,50,60,PWMChannel[LEDPWM3]);
Code: Select all
PWMExpansion(LEDPWM0,int(2.55*PWMChannel[LEDPWM0]));
PWMExpansion(LEDPWM1,int(2.55*PWMChannel[LEDPWM1]));
PWMExpansion(LEDPWM2,int(2.55*PWMChannel[LEDPWM2]));
PWMExpansion(LEDPWM3,int(2.55*PWMChannel[LEDPWM3]));
Now off to dig through my wall warts for a 12v power supply!
Re: PWM Expansion
No. Leave it all inside the loop. The first block of code sets/changes the values. The second block of code sends the values to the expansion module. If you did what you suggest, you would always have the same values and the code will not ramp up & down.
So keep it all in the loop grouped together.
curt
So keep it all in the loop grouped together.
curt
Re: PWM Expansion
Okay, will do. Thank you both for the excellent support.
Re: PWM Expansion
Just thought I should pop back in and say I got it setup and it works beautifully. I can hardly express how pleased I am!!!
Also I think I am going to use channel 5 to run a fan (or 2).
Any reason I can't hook the 5th channel directly to a regular 12 volt 120mm computer fan? Someone is telling me that he thinks the fan spinning down after removing power from it will feed back some power into the PWM expansion and fry it.
If I can't I will just buy PWM controlled fans, and get them their own 12 Volt power supply, but the less wall warts the better in my opinion!
David
Also I think I am going to use channel 5 to run a fan (or 2).
Any reason I can't hook the 5th channel directly to a regular 12 volt 120mm computer fan? Someone is telling me that he thinks the fan spinning down after removing power from it will feed back some power into the PWM expansion and fry it.
If I can't I will just buy PWM controlled fans, and get them their own 12 Volt power supply, but the less wall warts the better in my opinion!
David
Re: PWM Expansion
Connecting the fan directly to the PWM expansion module is not recommended.
It will create unwanted spikes and feedback voltages on the module, unless you place a diode to take care of this unwanted side-effects.
But, even if you do that, you will still incur in humming noise being generated by the PWM frequency being applied directly onto a DC motor.
I'm using 120mm PWM controlled fans on my system just fine when connected directly to the PWM module, but I did have problems when I started using these high power PWM controlled blowers. They were generating too much noise in the system and it was causing it to lock-up. The solution was to create an opto-isolation board to isolate the blowers from the module and it's been working beautifuly for severals months now.
It will create unwanted spikes and feedback voltages on the module, unless you place a diode to take care of this unwanted side-effects.
But, even if you do that, you will still incur in humming noise being generated by the PWM frequency being applied directly onto a DC motor.
I'm using 120mm PWM controlled fans on my system just fine when connected directly to the PWM module, but I did have problems when I started using these high power PWM controlled blowers. They were generating too much noise in the system and it was causing it to lock-up. The solution was to create an opto-isolation board to isolate the blowers from the module and it's been working beautifuly for severals months now.
Roberto.
Re: PWM Expansion
Just a quick note I forgot, my 120mm fan shares the same 12V wall wart as the PWM Expansion module, so all you need is 3 wires from the module directly to the fan.
12VDC
GND
Channel 5 PWM output
12VDC
GND
Channel 5 PWM output
Roberto.
Re: PWM Expansion
This sounds like a good option. Fans will be ordered this weekend.rimai wrote:Just a quick note I forgot, my 120mm fan shares the same 12V wall wart as the PWM Expansion module, so all you need is 3 wires from the module directly to the fan.
12VDC
GND
Channel 5 PWM output
Re: PWM Expansion
When testing the PWM commands on the expansion box, what is the "best" way to do it? Is it good to hookup a voltmeter to watch for the signal changes? Is there a PWM DIY that would work well for a light (say a PWM to an LED or something)?
I'm asking because I'm doing some development with the module and I want to make sure I test things properly.
curt
I'm asking because I'm doing some development with the module and I want to make sure I test things properly.
curt
Re: PWM Expansion
You can use a voltmeter or you can use a simple 3mm or 5mm LED in series with a 1K resistor.
Roberto.
Re: PWM Expansion
One troubleshooting question.
I am checking from the ground to the Channel 0 pin, with it programmed to be 100% on, and I get no voltage. Am I doing something wrong? I do get 12v from the + to ground, which is normal, but I can't seem to get a PWM signal. It was working for a while, then I moved my setup over the tank, and it is no longer functional. What should be my next troubleshooting step? I do have a green light on in the PWM expansion.
I am checking from the ground to the Channel 0 pin, with it programmed to be 100% on, and I get no voltage. Am I doing something wrong? I do get 12v from the + to ground, which is normal, but I can't seem to get a PWM signal. It was working for a while, then I moved my setup over the tank, and it is no longer functional. What should be my next troubleshooting step? I do have a green light on in the PWM expansion.
Re: PWM Expansion
Nope, all of them that I have programmed, for now it is just the first 5.
Re: PWM Expansion
Sorry this has taken me so long to get back to. Kids have been sick, and that's kept us pretty busy.
Here's the files you asked for. Let mw know if I need to upload something else.
Here's the files you asked for. Let mw know if I need to upload something else.
- Attachments
-
- RA_PWM.pde
- With my PWM code
- (5.3 KiB) Downloaded 422 times
-
- Memory_120211_2203.pde
- Memory File
- (5.4 KiB) Downloaded 417 times
Re: PWM Expansion
Upload the code in this post and then paste the results back:
http://forum.reefangel.com/viewtopic.php?p=328#p328
http://forum.reefangel.com/viewtopic.php?p=328#p328
Roberto.
-
- Posts: 14
- Joined: Thu Feb 16, 2012 5:46 am
- Location: Brazil
Re: PWM Expansion
GROUND DOUBT
When you say to use a power supply 12V in PWM Expansion OK, but the ground should be the (-) from the same 12V power supply?
12 V Power Supply =
+12V -Ground?
When you say to use a power supply 12V in PWM Expansion OK, but the ground should be the (-) from the same 12V power supply?
12 V Power Supply =
+12V -Ground?
Regards,
Joao C. Destro
Joao C. Destro