Need custom code for custom expansion
Need custom code for custom expansion
Hi everyone,
I would like to use a arduino uno for control 4 relay to operate my dosing pumps with pin 2,4,7,8
I want that the RA talk to the arduino uno in single way, maste/slave.
Unfortunately I'm not very good in programing, but I am very confident with electronic circuits.
So I would like to have a code for the arduino uno (slave) and a code for the RA (master)
I know I could do the same thing more easily with a PWM or I/O module, but the arduino uno was given to me.
Thank you for your help it's very appreciated.
Aqua-O
I would like to use a arduino uno for control 4 relay to operate my dosing pumps with pin 2,4,7,8
I want that the RA talk to the arduino uno in single way, maste/slave.
Unfortunately I'm not very good in programing, but I am very confident with electronic circuits.
So I would like to have a code for the arduino uno (slave) and a code for the RA (master)
I know I could do the same thing more easily with a PWM or I/O module, but the arduino uno was given to me.
Thank you for your help it's very appreciated.
Aqua-O
Osaka 40g with 55g sump
Radion, 2X Tunze 6045, Swc-160 mini cone
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Need custom code for custom expansion
I wish people gave me free unos all the time
Re: Need custom code for custom expansion
thank you,
I use this to set the uno, and I use the code pwm expansion module for RA?
Then I set the Uno with the version of arduino I usually use for RA? (normally I use the arduino wizard) or should I download it directly from arduino?
Thank you very much.
Yes, my friend had bought it for a school project.DrewPalmer04 wrote:I wish people gave me free unos all the time
But he never finished the project.
Osaka 40g with 55g sump
Radion, 2X Tunze 6045, Swc-160 mini cone
Re: Need custom code for custom expansion
Yes. Load that into your uno and it will act just as if it were a pwm module
Roberto.
Re: Need custom code for custom expansion
Wow
Thank you I can not wait to try it.
I will keep you posted.
Thank you very much for your support I would not have this good service with another controller.
Eric
Thank you I can not wait to try it.
I will keep you posted.
Thank you very much for your support I would not have this good service with another controller.
Eric
Osaka 40g with 55g sump
Radion, 2X Tunze 6045, Swc-160 mini cone
Re: Need custom code for custom expansion
I put the code of PWM module in the uno and the upload has run.
I used the wizard for generated my RA code
Here is the code
I also wondered if it was possible to repeat a command like a dosing pump ? (run 15 seconds every hour)
And I would like to know if I need to put the jumper in SDA-SCL position like the pwm expansion instruction manual ?
Cause if I change the jumper position, I have an error message in the arduino (Uploading error)
Thank you
Eric
I used the wizard for generated my RA code
Here is the code
Code: Select all
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <ReefAngel.h>
////// Place global variable code below here
////// Place global variable code above here
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
ReefAngel.AddStandardMenu(); // Add Standard Menu
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port7Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = 0;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = 0;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 869 );
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port3 );
ReefAngel.Relay.On( Port4 );
ReefAngel.Relay.On( Port5 );
ReefAngel.Relay.On( Port6 );
ReefAngel.Relay.On( Port7 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.DosingPumpRepeat( Port8,0,60,60 );
ReefAngel.PWM.SetChannel( 0, PWMParabola(0,40,0,45,100,100,100) );
ReefAngel.PWM.SetChannel( 1, PWMParabola(0,45,0,50,100,100,100) );
ReefAngel.PWM.SetChannel( 2, PWMParabola(0,50,0,55,100,100,100) );
ReefAngel.PWM.SetChannel( 3, PWMParabola(0,55,1,00,100,100,100) );
////// Place your custom code below here
////// Place your custom code above here
// This should always be the last line
ReefAngel.ShowInterface();
}
void DrawCustomMain()
{
int x,y;
char text[10];
// Dimming Expansion
x = 15;
y = 2;
for ( int a=0;a<6;a++ )
{
if ( a>2 ) x = 75;
if ( a==3 ) y = 2;
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :" );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,ReefAngel.PWM.GetChannelValue(a) );
y += 10;
}
pingSerial();
// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 43, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 43, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();
// Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 12, 84, TempRelay );
pingSerial();
// Date and Time
ReefAngel.LCD.DrawDate( 6, 122 );
pingSerial();
}
void DrawCustomGraph()
{
}
And I would like to know if I need to put the jumper in SDA-SCL position like the pwm expansion instruction manual ?
Cause if I change the jumper position, I have an error message in the arduino (Uploading error)
Thank you
Eric
Osaka 40g with 55g sump
Radion, 2X Tunze 6045, Swc-160 mini cone
Need custom code for custom expansion
Yes it works,
Now how to repeat a command with the ''PWM module'' like a dosing pump? Ex: run 15 sec every hours
Thank you so much
Eric
Now how to repeat a command with the ''PWM module'' like a dosing pump? Ex: run 15 sec every hours
Thank you so much
Eric
Osaka 40g with 55g sump
Radion, 2X Tunze 6045, Swc-160 mini cone
Re: Need custom code for custom expansion
Excuse my ignorance because I do not know really anything programing and English is not my first language.
But I love this controller for its infinite possibility (I'd really like to understand the programing )
Thank
Eric
But I love this controller for its infinite possibility (I'd really like to understand the programing )
Thank
Eric
Osaka 40g with 55g sump
Radion, 2X Tunze 6045, Swc-160 mini cone
Re: Need custom code for custom expansion
Code: Select all
ReefAngel.PWM.SetChannel( 0, now()%3600<15?:100:0);
Roberto.
Re: Need custom code for custom expansion
it does not work,
when I try to uploaded I got this message.
expected `)' before ':' token
The following features were automatically added:
Watchdog Timer
Version Menu
The following features were detected:
Dimming Expansion Module
Dimming Signal
Custom Main Screen
Standard Menu
RA_OSAKA_test_ino.cpp: In function 'void loop()':
RA_OSAKA_test_ino:74: error: expected `)' before ':' token
RA_OSAKA_test_ino:75: error: expected `)' before ':' token
RA_OSAKA_test_ino:76: error: expected `)' before ':' token
RA_OSAKA_test_ino:77: error: expected `)' before ':' token
And I realized that I did not need the PWM signal in uno I need as digital signals to activate my relay board.
Like this testing code
I try to change the code of the PWM module to change the analog signals into digital but without success. I change analogRead and analogWrite to digitalRead and digitalWrite.
Here is my attempt.
I want to operate 4 dosing pump with the Uno and send the order to Uno with RA. In the future I want purchase the wifi module.
I think if you have the knowledge in programing thing is possible, but for me it's really complicated.
I think I'm going to take lessons on arduino language
thank you very much and I am so sorry for my weakness programing.
Eric
when I try to uploaded I got this message.
expected `)' before ':' token
The following features were automatically added:
Watchdog Timer
Version Menu
The following features were detected:
Dimming Expansion Module
Dimming Signal
Custom Main Screen
Standard Menu
RA_OSAKA_test_ino.cpp: In function 'void loop()':
RA_OSAKA_test_ino:74: error: expected `)' before ':' token
RA_OSAKA_test_ino:75: error: expected `)' before ':' token
RA_OSAKA_test_ino:76: error: expected `)' before ':' token
RA_OSAKA_test_ino:77: error: expected `)' before ':' token
And I realized that I did not need the PWM signal in uno I need as digital signals to activate my relay board.
Like this testing code
Code: Select all
// Basic 4 Realy board connection
// Each relay is turned on for 2 seconds and then off.
// You can here them click as there state changes from off to on and on to
// off.
// You will also see the corresponding Red LED on the 4 Relay board
// light up when the relay is on.
// define names for the 4 Digital pins On the Arduino 7,8,9,10
// These data pins link to 4 Relay board pins IN1, IN2, IN3, IN4
#define RELAY1 7
#define RELAY2 8
#define RELAY3 9
#define RELAY4 10
void setup()
{
// Initialise the Arduino data pins for OUTPUT
pinMode(RELAY1, OUTPUT);
pinMode(RELAY2, OUTPUT);
pinMode(RELAY3, OUTPUT);
pinMode(RELAY4, OUTPUT);
}
void loop()
{
digitalWrite(RELAY1,LOW); // Turns ON Relays 1
delay(2000); // Wait 2 seconds
digitalWrite(RELAY1,HIGH); // Turns Relay Off
digitalWrite(RELAY2,LOW); // Turns ON Relays 2
delay(2000); // Wait 2 seconds
digitalWrite(RELAY2,HIGH); // Turns Relay Off
digitalWrite(RELAY3,LOW); // Turns ON Relays 3
delay(2000); // Wait 2 seconds
digitalWrite(RELAY3,HIGH); // Turns Relay Off
digitalWrite(RELAY4,LOW); // Turns ON Relays 4
delay(2000); // Wait 2 seconds
digitalWrite(RELAY4,HIGH); // Turns Relay Off
}
Here is my attempt.
Code: Select all
#include <Wire.h>
#include <avr/wdt.h>
byte PWMports[] ={
3,5,6,9,10,11};
byte ChannelValue[] = {
0,0,0,0,0,0};
byte cmdnum=255;
byte datanum=255;
void setup()
{
Serial.begin(57600);
Wire.begin(8);
Wire.onReceive(receiveEvent);
randomSeed(digitalRead(0));
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
wdt_enable(WDTO_1S);
}
void loop()
{
wdt_reset();
//Serial.println(ChannelValue[0],DEC);
if (cmdnum!=255)
{
ProcessCMD(cmdnum,datanum);
cmdnum=255;
datanum=255;
}
}
void receiveEvent(int howMany) {
wdt_reset();
if (howMany==5)
{
byte cmd1, cmd2, cmd3, cmd4, cmd5;
cmd1=Wire.read();
cmd2=Wire.read();
cmd3=Wire.read();
cmd4=Wire.read();
cmd5=Wire.read();
if (cmd1=='$' && cmd2=='$' && cmd3=='$')
{
cmdnum=cmd4;
datanum=cmd5;
//Serial.println(cmd4,DEC);
//Serial.println(cmd5,DEC);
}
}
else
{
for (int a=0;a<howMany;a++)
{
Wire.read();
}
}
}
void ProcessCMD(byte cmd, byte data)
{
wdt_reset();
// Individual Channel
if (cmd>=0 && cmd<=5)
{
ChannelValue[cmd]=data;
digitalWrite(PWMports[cmd],data);
}
//Clouds
if (cmd==6)
{
//Serial.println(data,DEC);
for (int b=0;b<7;b++)
{
if (b<6)
{
for (int a=ChannelValue[b];a>0;a--)
{
analogWrite(PWMports[b],a);
wdt_reset();
delay(data);
}
}
if (b>0)
{
for (int a=0;a<ChannelValue[b-1];a++)
{
analogWrite(PWMports[b-1],a);
wdt_reset();
delay(data);
}
}
}
}
//Thnderstorm
if (cmd==7)
{
wdt_reset();
for(int a=0;a<6;a++)
{
analogWrite(PWMports[a],255);
}
delay(30);
for(int a=0;a<6;a++)
{
analogWrite(PWMports[a],0);
}
delay(10);
analogWrite(PWMports[0],255);
delay(100);
analogWrite(PWMports[4],0);
analogWrite(PWMports[3],0);
delay(10);
analogWrite(PWMports[0],0);
analogWrite(PWMports[3],ChannelValue[3]);
analogWrite(PWMports[1],0);
delay(60);
analogWrite(PWMports[3],0);
delay(90);
analogWrite(PWMports[4],ChannelValue[4]);
analogWrite(PWMports[1],ChannelValue[1]);
analogWrite(PWMports[2],0);
wdt_reset();
delay(100);
analogWrite(PWMports[2],255);
analogWrite(PWMports[5],255);
analogWrite(PWMports[4],0);
delay(30);
analogWrite(PWMports[5],0);
analogWrite(PWMports[0],255);
wdt_reset();
delay(300);
analogWrite(PWMports[4],ChannelValue[4]);
for(int a=0;a<6;a++)
{
analogWrite(PWMports[a],ChannelValue[a]);
}
}
//Thnderstorm Random
if (cmd==8)
{
for(int a=0;a<10;a++)
{
analogWrite(PWMports[random(6)],random(256));
analogWrite(PWMports[random(6)],0);
analogWrite(PWMports[random(6)],255);
wdt_reset();
delay(random(200));
}
delay(30);
for(int a=0;a<6;a++)
{
analogWrite(PWMports[a],ChannelValue[a]);
}
}
}
I think if you have the knowledge in programing thing is possible, but for me it's really complicated.
I think I'm going to take lessons on arduino language
thank you very much and I am so sorry for my weakness programing.
Eric
Osaka 40g with 55g sump
Radion, 2X Tunze 6045, Swc-160 mini cone
Re: Need custom code for custom expansion
Minor typo. Try this:rimai wrote:Code: Select all
ReefAngel.PWM.SetChannel( 0, now()%3600<15?:100:0);
Code: Select all
ReefAngel.PWM.SetChannel( 0, now()%3600<15?100:0);
Re: Need custom code for custom expansion
Yeah this code works in the Reef Angel and I see in the screen when the port it is opened and closed. But I think the Uno does not receive the order of ReefAngel, cause I have no signal on the UNO pin.
I wonder if I correctly connect the Uno to RA. I connect the Uno with Usb port of the relay box. Do I need to put a jumper on the UNO?
Thank you so much
Eric
I wonder if I correctly connect the Uno to RA. I connect the Uno with Usb port of the relay box. Do I need to put a jumper on the UNO?
Thank you so much
Eric
Osaka 40g with 55g sump
Radion, 2X Tunze 6045, Swc-160 mini cone
Re: Need custom code for custom expansion
Oh no... You will need to hard wire and create your own cable.
The USB port of the relay box has I2C SDA and SCL signals.
If I remember correctly, Arduino uses A4 and A5 for SDA and SCL.
Goggle for connecting 2 arduinos as master/slave
The USB port of the relay box has I2C SDA and SCL signals.
If I remember correctly, Arduino uses A4 and A5 for SDA and SCL.
Goggle for connecting 2 arduinos as master/slave
Roberto.
Re: Need custom code for custom expansion
Ok now I understand why it does not work.
After my Google search I know how to connect the UNO for use I2C protocol with pins A4 and A5 for SDA and SCL.
But with the RA I dont know what pins it should be use.
Can I use the USB cable supplied with the RA and plug in to the relay box?
If I can use this cable, What is the color of which indicates the 5v, GN, SDA and SCL ?
Thank Eric
After my Google search I know how to connect the UNO for use I2C protocol with pins A4 and A5 for SDA and SCL.
But with the RA I dont know what pins it should be use.
Can I use the USB cable supplied with the RA and plug in to the relay box?
If I can use this cable, What is the color of which indicates the 5v, GN, SDA and SCL ?
Thank Eric
Osaka 40g with 55g sump
Radion, 2X Tunze 6045, Swc-160 mini cone
Need custom code for custom expansion
This is the cable
Osaka 40g with 55g sump
Radion, 2X Tunze 6045, Swc-160 mini cone
Re: Need custom code for custom expansion
no, you need to create your own cable.
Just buy a regular USB cable and strip it.
Google for USB pinout.
D- goes to A4
D+ goes to A5
Just buy a regular USB cable and strip it.
Google for USB pinout.
D- goes to A4
D+ goes to A5
Roberto.
Re: Need custom code for custom expansion
YES YES YES YES YES YES
It works!
I had an old USB cable and 2k resistors that I used to make my own cable.
Thank you very much for your patience Roberto (I know I'm an idiot programing ) and for your help it was very appreciated.
You're very helpful
I love the Reef Angel
Thank
Eric
next step purchase and install wifi module
It works!
I had an old USB cable and 2k resistors that I used to make my own cable.
Thank you very much for your patience Roberto (I know I'm an idiot programing ) and for your help it was very appreciated.
You're very helpful
I love the Reef Angel
Thank
Eric
next step purchase and install wifi module
Osaka 40g with 55g sump
Radion, 2X Tunze 6045, Swc-160 mini cone
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Need custom code for custom expansion
Let's see some pics of what you've accomplished AuqaO
Re: Need custom code for custom expansion
Yes I will post pictures later I need to fix some detail.
Thank you for your interest.
Eric
Thank you for your interest.
Eric
Osaka 40g with 55g sump
Radion, 2X Tunze 6045, Swc-160 mini cone
Re: Need custom code for custom expansion
Yeah, very interested to see what you did with the dosing pumps... what pumps are you using.
I'm currently investigating how to dose, and not thrilled with the idea of wasting outlets (want to do triple channel) and having to waste all those relay ports. I like the standalone controllers like Bubble Magus, but sooo expensive. Considering the chinese knock-off Marine Magic which looks good, but I feel like it's such a waste having the RA that could do all that...
The RA dosing pump should connect to the PWM ports and have a PWM driver. If it was controllable like that or directlyw ithout the dimming module, I'd be snatching it up in a heartbeat. So very curious on the details here...
Edit: From the store-front, the previosly out-of-stock dosing pump looks like it's been replaced.. any details? It looks like the slave pump from another dosing pump i've seen...
I'm currently investigating how to dose, and not thrilled with the idea of wasting outlets (want to do triple channel) and having to waste all those relay ports. I like the standalone controllers like Bubble Magus, but sooo expensive. Considering the chinese knock-off Marine Magic which looks good, but I feel like it's such a waste having the RA that could do all that...
The RA dosing pump should connect to the PWM ports and have a PWM driver. If it was controllable like that or directlyw ithout the dimming module, I'd be snatching it up in a heartbeat. So very curious on the details here...
Edit: From the store-front, the previosly out-of-stock dosing pump looks like it's been replaced.. any details? It looks like the slave pump from another dosing pump i've seen...
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Need custom code for custom expansion
I have a triple magic dosing set up and to be honest it sucks. Every doser gives out different amounts. So you have to do some serious math for two part dosing. And they like to wear down and dose less and less and then you have to adjust the speed settings/recalculate again and the cycle repeats. Just FYI
Need custom code for custom expansion
Because a picture is worth a thousand words
Do not forget is in progress.
Here is the dosing pump I use
(purchased on eBay)
Here is my DiY case
And Video
http://youtu.be/oV4HXv71SxQ
Do not forget is in progress.
Here is the dosing pump I use
(purchased on eBay)
Here is my DiY case
And Video
http://youtu.be/oV4HXv71SxQ
Last edited by AquaO on Wed Oct 30, 2013 4:30 pm, edited 8 times in total.
Osaka 40g with 55g sump
Radion, 2X Tunze 6045, Swc-160 mini cone
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Need custom code for custom expansion
Where'd you get the bare doser motor? 12v I'm assuming?
Re: Need custom code for custom expansion
I corrected the link of the pics, sorry
I bought the motor on ebay, I believe that it is the same as Profilux.
Yes they are 12v
I was also working to change the speed of the motor manually, for avoided programming all the time.
I bought the motor on ebay, I believe that it is the same as Profilux.
Yes they are 12v
I was also working to change the speed of the motor manually, for avoided programming all the time.
Osaka 40g with 55g sump
Radion, 2X Tunze 6045, Swc-160 mini cone
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Need custom code for custom expansion
So jealous...I need an Uno now...
Good DIY!!!
Good DIY!!!
Re: Need custom code for custom expansion
AquaO,
That is awesome! I just bought a few of those pumps, actually I bought the $30 ones that are already in an encosure with a potentiometer. I would love to convert it at some point to do what you did and control them individually with PWM instead of relays on my outlet strip...
Do you think you could do a more comprehensive post on what you did to setup the UNO? Do you know what would be needed if I wanted to just integrate with the RA Dimming module?
Thanks in advance and again awesome job!
Edit: Wow, the UNO is only $35... I'd gladly purchase one of these if I knew what to do with it!
That is awesome! I just bought a few of those pumps, actually I bought the $30 ones that are already in an encosure with a potentiometer. I would love to convert it at some point to do what you did and control them individually with PWM instead of relays on my outlet strip...
Do you think you could do a more comprehensive post on what you did to setup the UNO? Do you know what would be needed if I wanted to just integrate with the RA Dimming module?
Thanks in advance and again awesome job!
Edit: Wow, the UNO is only $35... I'd gladly purchase one of these if I knew what to do with it!