Time for additional Ethernet add-on with PWM output
Re: Time for additional Ethernet add-on with PWM output
I might have found the problem. I don't think that the header pins I am using are in tight enough. What do you think the best way to get a good connection would be?
Re: Time for additional Ethernet add-on with PWM output
I am thinking about removing the headers and just soldering the wire to the board. The pins I got from radio shack seem so loose in the header, they just don't make good contact. Maybe the pins I got have to small a diameter.
Do you all just solder your permanent projects?
Do you all just solder your permanent projects?
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Time for additional Ethernet add-on with PWM output
DB headers just take them apart and use the pins. They fit very nicely.
Re: Time for additional Ethernet add-on with PWM output
DB?DrewPalmer04 wrote:DB headers just take them apart and use the pins. They fit very nicely.
Did you mean MB?
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Time for additional Ethernet add-on with PWM output
http://en.m.wikipedia.org/wiki/D-subminiature
The pins out of the header. No need to buy the entire cable. The shack sells just the header for you to use the pins.
The pins out of the header. No need to buy the entire cable. The shack sells just the header for you to use the pins.
Re: Time for additional Ethernet add-on with PWM output
Ahh I see, I have a ton of those asking to be sacrificed.DrewPalmer04 wrote:http://en.m.wikipedia.org/wiki/D-subminiature
The pins out of the header. No need to buy the entire cable. The shack sells just the header for you to use the pins.
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Time for additional Ethernet add-on with PWM output
If only this could be controlled via the apps or portal. I have half a mind to maybe attach a little LCD and some buttons to change a few settings.
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Time for additional Ethernet add-on with PWM output
LCD is a good idea. I'll be working on RA communication with the Ethernet module soon. Just have to finish my other project first. Might be a week or two. But I'll see what I can figure out. Tons of people have been requesting that. I just wasn't sure if Roberto had plans to create a "RA" expansion based on this module or not. I didn't want to double develop it.
Re: Time for additional Ethernet add-on with PWM output
Well let me help. Just let me know what you want to try and we can work on it together. Of course it would also be very cool if Roberto wanted to chime in.
I really don't see why they should not communicate like any other expansion. Data is data. It's just sending it to the right place in the right format.
I really don't see why they should not communicate like any other expansion. Data is data. It's just sending it to the right place in the right format.
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Time for additional Ethernet add-on with PWM output
Exactly. It'll be easiest through I2C Wire.h lib. I attempted to read RA RTC values before and the RA didn't like that. But for just normal communication it should be easy as pie. Just going to use SDL SDA pins and go for it. When I find time.
Re: Time for additional Ethernet add-on with PWM output
Did you have to jumper your SDA/SCL pins on the head unit or are they already done? I assume they are standard jumpers if needed.
Making the ethernet board a slave should not be to difficult. Might have to solder direct to the pins? How does it work for other expansions? They use the hub on the relay.
Making the ethernet board a slave should not be to difficult. Might have to solder direct to the pins? How does it work for other expansions? They use the hub on the relay.
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Time for additional Ethernet add-on with PWM output
I already had the jumpers. I have the RF expansion. I last tried to connect to the jumpers last time. I was reading too frequently I think for the RTC. This was causing the RA to spaz. The usb port is exactly that. It contains the SDA SCL. The expansion hub (I believe) is a I2C expander which allows people to connect various # of devices. I'll be using the USB port the next go around. But I'll have to get an I2C expander
Re: Time for additional Ethernet add-on with PWM output
So it is usb in form but i2c in function?DrewPalmer04 wrote:I already had the jumpers. I have the RF expansion. I last tried to connect to the jumpers last time. I was reading too frequently I think for the RTC. This was causing the RA to spaz. The usb port is exactly that. It contains the SDA SCL. The expansion hub (I believe) is a I2C expander which allows people to connect various # of devices. I'll be using the USB port the next go around. But I'll have to get an I2C expander
Re: Time for additional Ethernet add-on with PWM output
My sketch is too big with the jebo pump control functions to even add the code to begin transmission let alone do anything else.
I wonder if it would be better to move the pump control to the ethernet board, and just leave the LED control on my RA. That or I need to upgrade to an RA+...
I wonder if it would be better to move the pump control to the ethernet board, and just leave the LED control on my RA. That or I need to upgrade to an RA+...
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Time for additional Ethernet add-on with PWM output
That depends on the mA draw of the pump and how it's controlled. RA is using a opamp and the Ethernet module is only straight from the pin. Check mA max for both.
Re: Time for additional Ethernet add-on with PWM output
hmm good point. I think I saw a guy on ReefCentral that made his own arduino controller. I'll have to look it up. What I guess I don't understand is why I need to include the functions for the pumps if I import the rf library that has all the modes in it. If I had the RF expansion mod and the wifi mod, the sketch fits. What am I missing? I am a little cloudy I guess on how the internal mem settings function with the expansion mods
Re: Time for additional Ethernet add-on with PWM output
The RF module doesn't implement the vortech modes, it just triggeres them on the vortech controller. Now you are trying to implement all those functions. It might work if you pick one or two that you want to use...Personally, I always recommend getting the plus if possible since even with all that I'm doing, I'm only using a fraction of the space whereas from my first wizard and customization I was over the 32k limit on the RA.
Re: Time for additional Ethernet add-on with PWM output
I think I am going to have to upgrade. Is it just a swap out of the board?
Re: Time for additional Ethernet add-on with PWM output
yestopjimmy wrote:I think I am going to have to upgrade. Is it just a swap out of the board?
Roberto.
Re: Time for additional Ethernet add-on with PWM output
Well I am just going to pic a few of the wave functions for now.
Roberto, what library can I look at to see the i2c functions? I know obviously wire.h but do you have some other written that would help with communications?
No sense reinventing the wheel.
Roberto, what library can I look at to see the i2c functions? I know obviously wire.h but do you have some other written that would help with communications?
No sense reinventing the wheel.
Re: Time for additional Ethernet add-on with PWM output
RA_PWM.cpp
And this is what I load in the dimming module for your reference:
And this is what I load in the dimming module for your reference:
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.onReceive(receiveEvent);
Wire.onRequest(NULL);
Wire.begin(8);
randomSeed(analogRead(0));
pinMode(3,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(9,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;
analogWrite(PWMports[cmd],data);
}
}
Roberto.
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Time for additional Ethernet add-on with PWM output
Very cool...that's super helpful
Re: Time for additional Ethernet add-on with PWM output
I also managed to get more pump functions to fit, once I realized that they were written for two pumps, using both daylight and actinic channels
I only have one pump......
I only have one pump......
Re: Time for additional Ethernet add-on with PWM output
Quick update: I loaded the code Roberto posted for the PWM expansion onto the Uno\Ethernet. I soldered the SDA , Clock, and ground to the 4a,5a and grn. I used 10k resistors connected to the +5v header to the clock and sda connections. The relay and the head unit did not like it. The relay buzzed and the head unit would randomly reset.
I did set up the head units jumpers, and used a fresh wizard with pwm exp. enabled.
I don't know if I can use that 5v header. I figured it was ok but maybe I'm mistaken. I can post the hybrid code that is part Drews ethernet, part PWM expansion if anyone is interested in looking it over.
Edit: Added mish mash of code.
I did set up the head units jumpers, and used a fresh wizard with pwm exp. enabled.
I don't know if I can use that 5v header. I figured it was ok but maybe I'm mistaken. I can post the hybrid code that is part Drews ethernet, part PWM expansion if anyone is interested in looking it over.
Edit: Added mish mash of code.
Code: Select all
#include <SPI.h>
#include <Wire.h>
#include <avr/wdt.h>
#include <Ethernet.h>
byte PWMports[] ={
3,5,6,9,10,11};
byte ChannelValue[] = {
0,0,0,0,0,0};
byte cmdnum=255;
byte datanum=255;
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; //YOUR MAC off sticker
IPAddress ip(192,168,1, 110); //YOUR STATIC IP HERE
IPAddress remoteserver(198,171,134,6); // forum.reefangel.com
EthernetClient clientout;
unsigned long lastmillisout=millis();
unsigned long lastmillisin=millis();
boolean sending=false;
char strout[400];
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ETHERNET MODULE |||||||||||||||||||||||||||||||||||||||||||||||*/
void ethernetmodule() //create ethernet function for loop
{
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
while (client.available()) {
char c = client.read();
if (sending==false) Serial.write(c);
lastmillisin=millis();
}
while (Serial.available()){
memset(strout,0,sizeof(strout));
int b=Serial.readBytesUntil('>',strout,sizeof(strout));
client.print(strout);
client.print(">");
if (millis()-lastmillisin>2000)
{
lastmillisin=millis();
client.stop();
}
}
if (millis()-lastmillisin>2000)
{
lastmillisin=millis();
client.stop();
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
}
else
{
if (Serial.available())
{
memset(strout,0,sizeof(strout));
int b=Serial.readBytesUntil('\n',strout,sizeof(strout));
if (b>10)
{
sending=true;
Serial.print(strout);
Serial.println(" HTTP/1.0");
Serial.println();
if (clientout.connect(remoteserver, 80))
{
clientout.print(strout);
clientout.println(" HTTP/1.0");
clientout.println();
lastmillisout=millis();
}
}
}
while (clientout.available()) {
char c = clientout.read();
Serial.print(c);
if (millis()-lastmillisout>8000)
{
lastmillisout=millis();
clientout.stop();
sending=false;
}
}
if (!clientout.connected())
{
clientout.stop();
sending=false;
}
}
if (millis()-lastmillisout>8000)
{
lastmillisout=millis();
clientout.stop();
sending=false;
}
//GET /status/submitp.aspx?t1=806&t2=0&t3=0&ph=441&id=test&em=0&rem=0&key=&atohigh=0&atolow=0&r=0&ron=0&roff=255 HTTP/1.0
//GET /status/submitp.asp?t1=806&t2=0&t3=0&ph=441&id=test&em=0&rem=0&key=&atohigh=0&atolow=0&r=0&ron=0&roff=255 HTTP/1.0
//Host: forum.reefangel.com
//
//GET /status/submitp.aspx?t1=806&t2=0&t3=0&ph=441&id=test&em=0&rem=0&key=&atohigh=0&atolow=0&r=0&ron=0&roff=255 HTTP/1.0
//Host: forum.reefangel.com
//Connection: Keep-Alive
}
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| END ETHERNET MODULE |||||||||||||||||||||||||||||||||||||||||||||||*/
void setup()
{
Serial.begin(57600);
Wire.onReceive(receiveEvent);
Wire.onRequest(NULL);
Wire.begin(8);
randomSeed(analogRead(0));
pinMode(3,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(9,OUTPUT);
// pinMode(10,OUTPUT);
// pinMode(11,OUTPUT);
wdt_enable(WDTO_1S);
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
// Ethernet connection ok and server started
}
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;
analogWrite(PWMports[cmd],data);
}
}
- DrewPalmer04
- Posts: 818
- Joined: Tue May 29, 2012 2:12 pm
- Location: Christopher, IL
Re: Time for additional Ethernet add-on with PWM output
Show me some pics of what you're up to.
Re: Time for additional Ethernet add-on with PWM output
I don't have a pic but I'll try to explain betterDrewPalmer04 wrote:Show me some pics of what you're up to.
On the 5v header I have two 10k resistors soldered to the pin, one goes to the pin for SDA, one to the SCL. Then from the relay unit I use the Data - , Data + and Grd, Each of those is soldered to the appropriate pin.
I assume that once power is supplied to the board. That all 5v pins are now "hot" and that there is no need to bring in any other 5v feed. The RA head unit is powering the Uno. So power is then dispersed through the regulator to all the +vcc pins.
Does it matter that I used the pin on the board as the +5v pull up for the resistor? Or does it have to be on the line coming in to the board?
Re: Time for additional Ethernet add-on with PWM output
edited earlier post to explain it better.