Must-haves for EASY DIY controller?

mammut, the typical "ping" example we're currently testing with takes that approach:

PHP:
#include "etherShield.h"

// please modify the following two lines. mac and ip have to be unique
// in your local area network. You can not have the same numbers in
// two devices:
static uint8_t mymac[6] = {
  0x54,0x55,0x58,0x10,0x00,0x24}; 
static uint8_t myip[4] = {
  192,168,1,15};
// how did I get the mac addr? Translate the first 3 numbers into ascii is: TUX

#define BUFFER_SIZE 250
unsigned char buf[BUFFER_SIZE+1];

uint16_t plen;

EtherShield es=EtherShield();


void setup(){

 
 
  /*initialize enc28j60*/
  es.ES_enc28j60Init(mymac);
  es.ES_enc28j60clkout(2); // change clkout from 6.25MHz to 12.5MHz
 
  delay(10);

  /* Magjack leds configuration, see enc28j60 datasheet, page 11 */
  // LEDA=green LEDB=yellow
  //
  // 0x880 is PHLCON LEDB=on, LEDA=on
  // enc28j60PhyWrite(PHLCON,0b0000 1000 1000 00 00);
  es.ES_enc28j60PhyWrite(PHLCON,0x880);
  delay(500);
 
  //
  // 0x990 is PHLCON LEDB=off, LEDA=off
  // enc28j60PhyWrite(PHLCON,0b0000 1001 1001 00 00);
  es.ES_enc28j60PhyWrite(PHLCON,0x990);
  delay(500);
 
  //
  // 0x880 is PHLCON LEDB=on, LEDA=on
  // enc28j60PhyWrite(PHLCON,0b0000 1000 1000 00 00);
  es.ES_enc28j60PhyWrite(PHLCON,0x880);
  delay(500);
 
  //
  // 0x990 is PHLCON LEDB=off, LEDA=off
  // enc28j60PhyWrite(PHLCON,0b0000 1001 1001 00 00);
  es.ES_enc28j60PhyWrite(PHLCON,0x990);
  delay(500);
 
  //
  // 0x476 is PHLCON LEDA=links status, LEDB=receive/transmit
  // enc28j60PhyWrite(PHLCON,0b0000 0100 0111 01 10);
  es.ES_enc28j60PhyWrite(PHLCON,0x476);
  delay(100);
 
  //init the ethernet/ip layer:
  es.ES_init_ip_arp_udp_tcp(mymac,myip,80);
 

}

void loop(){

  plen = es.ES_enc28j60PacketReceive(BUFFER_SIZE, buf);

  /*plen will be unequal to zero if there is a valid packet (without crc error) */
  if(plen!=0){
       if(es.ES_eth_type_is_arp_and_my_ip(buf,plen)){
      	es.ES_make_arp_answer_from_request(buf);
      }
      // check if ip packets (icmp or udp) are for us:
      if(es.ES_eth_type_is_ip_and_my_ip(buf,plen)!=0){
         if(buf[IP_PROTO_P]==IP_PROTO_ICMP_V && buf[ICMP_TYPE_P]==ICMP_TYPE_ECHOREQUEST_V){
         		// a ping packet, let's send pong
          
            es.ES_make_echo_reply_from_request(buf,plen);
   		    }
      }
 
  }  
}

Note the lines in the setup() function that are writing to the PHLCON registers to blink the lights.

I really think we have a hardware issue; problem is our circuit matches known-good schematics. So it's something wrong with component placement (don't think so - our circuit has "better" placement on some of the sensitive components as far as I can tell by reading the datasheet), or component values, or something elsewhere on the Hydra is interfering or is incorrectly implemented.
 
well ive looked at the schematics again and I really cant find anything wrong , must be something interfering. maybe some emergent property because of the slave atmega ? try desoldering it and see what happens ?
 
I've tried that.

I've also tried running JUST the ENC without the AVR on the board at all, as instructed in the tuxgraphics page above - to see if it initializes correctly when it boots. No luck.
 
Good luck! Let us know how it goes!

Do you have any "standard" Arduino or compatible boards? Might be worth testing that shield in a completely known-good environment vs. just slapping on the Hydra.
 
No, this was my first adventure into the AVR/arduino world. I was using PICs before this.

I was thinking about ordering an RBBB kit or some extra resonators and breadboarding it. I have most of the extra parts including the AVR.
 
I realize I am changing the subject, but I just ordered a bunch of float sensor. The old fashioned way would be to wire them into a relay to control a pump. Let's use an auto top off as an example. When the water level drops the float switch throws the relay and the pump comes on.

The new way the Hydra would read the float valve. The hydra would then throw the relay and the pump would come on.

Now I realize that the Hydra will be 100% perfect, but … There should be a way to do both. My thought is to use and AND gate. The Hydra must say I want it on AND the float valve must be correct. The hydra could also read the status of the float valve.

If you did not want the ability to read the float valve could the TTL level signal go through the float valve. How long could the wires be?

Is there a better approach to one of these?

In theory either of these would work, but being a programmer I understand the logic just not all the limitation :)

Thanks
 
FishMan, that's an interesting concept. I'm tossing it around in my head trying to understand the difference between doing the AND in software vs. hardware and can't come up with anything solid. Would be interested to know if others have thoughts.
 
My concern is that the Hydra might lock up while the ATO is running (for example). The Hydra might never turn off the pump. The other concern is start up. If you aren't careful when the Hydra comes on with power up level something may come one until the Hydra can turn it off. Well if the code ever becomes corrupted (I know that will never happen either) then you can have a problem.
 
My concern is that the Hydra might lock up while the ATO is running (for example). The Hydra might never turn off the pump. The other concern is start up. If you aren't careful when the Hydra comes on with power up level something may come one until the Hydra can turn it off. Well if the code ever becomes corrupted (I know that will never happen either) then you can have a problem.

Thanks for reminding me of this. I had bought 2 float switches from BRS for this purpose but hadn't thought about how I was going to do the redundancy.

In my case I am using the port expander like terahz is, but I'm using transistors to activate the relays. I will probably have one float switch signal the arduino to activate the topoff relay. Then I'll mount the second float switch a few inches above the normal switch. I'll have this switch in between the port expander and the "base" leg of the transistor. That way if the arduino doesn't turn it off, the secondary float switch should cut the circuit for the transistor and stop the topoff pump.

The startup got me thinking too. I'm going to have to do some testing with a meter on this. I wouldn't want my dosing pumps to kick on when they shouldn't. Anyone know what the default is for I/O pins on the arduino and the port expander?
 
I jus torder the boards from futurlec. I tried to get a data sheet but no luck. It looked like the connectors had three screws. So I am hoping there is normally open and normally closed. This would solve the start up issue. Since you could wire the pump to be normally on or off. IIRC your power strip had individual realys already on board the linked to a 9 pin header. What are your options on that one? It sounded better than terahz option, but now I wonder. When my board get here I'ii let everyone know the options - unless terahz chimes in first (hint hint).

I imagine dosing pumps could be a real problem in a thunderstorm - brief electrical loss. Of course if the hydra ran off a battery/capacitor for a while that might solve that problem.
 
FWIW one of the projects I'm working on in conjunction with this, but haven't discussed here at all, is a tiny DC "UPS" to keep the Hydra alive for a few hours in the event of total power failure. It basically sits between your wall wart or other external power supply and the Hydra, and uses a NiMH battery to supply power if it detects a loss of mains power. It also has a status output that gets pulled high or low depending on the status of mains power, so the Hydra would "know" when power was lost or restored. I designed the circuit, ordered the PCBs and components, but never built it. If others are interested I can provide the info here.
 
It's a very small PCB, all SMT. The Eagle files have been on the hydra-reef project site for a few months. Look under hardware-DC_UPS in the repo. I'll go review and upload the BOM.
 
I've uploaded the BOM with Mouser part numbers for everything except the pin header (use whatever you want) and the two main ICs on the board, because Mouser doesn't carry them. They're both from Linear, and Linear is pretty good with free samples. Or you could probably get them from elsewhere. . .
 
I jus torder the boards from futurlec. I tried to get a data sheet but no luck. It looked like the connectors had three screws. So I am hoping there is normally open and normally closed. This would solve the start up issue. Since you could wire the pump to be normally on or off. IIRC your power strip had individual realys already on board the linked to a 9 pin header. What are your options on that one? It sounded better than terahz option, but now I wonder. When my board get here I'ii let everyone know the options - unless terahz chimes in first (hint hint).

I imagine dosing pumps could be a real problem in a thunderstorm - brief electrical loss. Of course if the hydra ran off a battery/capacitor for a while that might solve that problem.

The strip has 8 normally open relays. I could probably wire something up to make it normally open, but I'd have to look into it. I like the option because it was already wired up. I can't really say it was less work as terahz had to wire his up and I had to make a basic transistor board. I do believe this option will let me have everything more condensed and end up in a smaller main unit box, maybe about $10-20 cheaper. These are very basic coil relays though, but they should serve my purpose.
 
Back
Top