Show Posts
Pages: 1 ... 50 51 [52] 53 54 ... 64
766  Using Arduino / Project Guidance / Re: Global variable values rest? on: June 16, 2011, 10:23:58 am
OK, then how about the else after the check for favicon?  Your indentation indicates that you expect everything under it to be inside the else but there is no opening brace following the else.  This means the for loop is the only thing the else relates to  so the statusSerial and statusLCD will execute.
767  Using Arduino / Installation & Troubleshooting / Re: Mega 2560 bootloader revised? on: June 16, 2011, 09:41:14 am
Tobi,  I got in contact with the developer that wrote the bootloader yesterday.  Nice guy.  I sent him what I had that didn't work with the watchdog timer and he has already fixed the ! ! ! problem.  He's up to his ears in something and will be getting back to me.  There may be a fix on the way in a few days.

I'll let you know what happens by a post here.  I was beginning to think I was the only person that had this problem.
768  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet Shield on: June 16, 2011, 02:43:25 am
Here's the latest code I used for pachube on a device I haven't posted about yet.

Code:
void sendPachubeData(){
  char dataBuf[100];
 
  if(pachube.connected()) // already trying to get data, just leave
    return;
  if(round(realPower) == 0.0)  // don't send invalid data
    return;
  tNow = now();
  strcpy_P(Dbuf2,PSTR("Data at %02d:%02d:%02d: "));  // Debugging
  sprintf(Dbuf,Dbuf2,hour(tNow),minute(tNow),second(tNow));
//  Serial.print(Dbuf);
  // construct the data buffer so we know how long it is
  int poolMotorState = 0;
  if(strcmp(poolData.motorState,"High") == 0)
     poolMotorState = 2;
  else if(strcmp(poolData.motorState,"Low") == 0)
    poolMotorState = 1;
  strcpy_P(Dbuf2, PSTR("%d,%d,0.%d,%d.%02d,%d.%02d,%d.%02d,%d,%d,%d,%d"));
  sprintf(dataBuf,Dbuf2,
    (int)round(realPower),
    (int)round(apparentPower),
    (int)(powerFactor*100),
    (int)rmsCurrent,
    (int)(((rmsCurrent+0.005) - (int)rmsCurrent) * 100),
    (int)rmsVoltage,
    (int)(((rmsVoltage+0.005) - (int)rmsVoltage) * 100),
    (int)(frequency),
    (int)(((frequency+0.005) - (int)frequency) * 100),
    (ThermoData[0].currentTemp + ThermoData[1].currentTemp)/2,
    (int)round(outsideTemp),
    poolMotorState, poolMotorState == 0 ? 10 : poolData.poolTemp);
  Serial.println(dataBuf);
//return;
  strcpy_P(Dbuf,PSTR("Pachube Connecting..."));
  Serial.print(Dbuf);
  if(pachube.connect()){
    strcpy_P(Dbuf,PSTR("OK"));
    Serial.println(Dbuf);
    tNow = now();
    strcpy_P(Dbuf,PSTR("PUT /api/9511.csv HTTP/1.1\n"));
    pachube.print(Dbuf);
    strcpy_P(Dbuf,PSTR("Host: www.pachube.com\n"));
    pachube.print(Dbuf);
    strcpy_P(Dbuf,PSTR("X-PachubeApiKey: stuffinhere\n"));
    pachube.print(Dbuf);
    strcpy_P(Dbuf,PSTR("Content-Length: "));
    pachube.print(Dbuf);
    pachube.println(strlen(dataBuf), DEC); // this has to be a println
    strcpy_P(Dbuf,PSTR("Content-Type: text/csv\n"));
    pachube.print(Dbuf);
    strcpy_P(Dbuf,PSTR("Connection: close\n"));
    pachube.println(Dbuf);
    pachube.println(dataBuf);   
    pachube.stop();
    pachubeUpdateTime = now();
  }
  else {
    pachube.stop();
    while(pachube.status() != 0){
      delay(5);
    }
    strcpy_P(Dbuf,PSTR("failed"));
    Serial.println(Dbuf);
  }
}

This works every time the actual board is working.  I also have code around the ethernet board itself to make sure it is working that is separate from this stuff.  For example, this is the code to reset the ethernet board:

Code:
void ethernetReset(){

  pinMode(rxSense, INPUT);  //for stabilizing the ethernet board
  pinMode(ethernetResetPin,INPUT);
  while(1){
    digitalWrite(ethernetResetPin, HIGH);
    pinMode(ethernetResetPin, OUTPUT);
    digitalWrite(ethernetResetPin, LOW);  // ethernet board reset
    delay(100);
    digitalWrite(ethernetResetPin, HIGH);
    delay(5000);
    // now, after the reset, check the rx pin for constant on
    if (ethernetOk())
      return;
    delay(100);
  }
}

Keep in mind that this depends on the hardware mods I did to the board so that I can reset it separately from the rest.  Since I'm using an arduino 2560 that has the watchdog timer bug in the boot loader I can't do a regular watchdog reset.  I use one of the timer interrupts instead and do a call to address 0 to reset the board.  That took some time to figure out.

I also have a little routine that I call that watches the RX led on the ethernet board.  It seems in my case that when the board hangs up the RX led is solid on.  So I hooked a wire to it and watch it with an arduino pin.  If the led is on too many times in a timing loop, it means the board is hung up.  So I use the reset routine above to reset it.

Code:
boolean ethernetOk(){
  int cnt = 10, result;

  cnt = 10;
  result = 0;
  while (cnt-- != 0){  // simply count the number of times the light is on in the loop
    result += digitalRead(rxSense);
    delay(50);
  }
  strcpy_P(Dbuf,PSTR("Ethernet setup result "));
  Serial.print(Dbuf);
  Serial.println(result,DEC);
  if (result >=6)      // experimentation gave me this number YMMV
    return(true);
  return(false);
}

Like your experience, I found that one MUST close the connections or the darn thing hangs up.  I guess I was extremely lucky to have it fail immediately so that I had to work up solutions before I started relying on it.

On the new device that updates pachube, there is still one problem I have to deal with.  Sometimes pachube itself stops responding and I have trouble telling if it was pachube messing up or the ethernet board failing.  I'm still thinking about that problem and suspect it will be easy to fix by just checking the pachube response for 'OK' and also looking at some of the other web interactions the board is doing to see if they are working ok.  If all else fails, I'll just interogate my router to see if it's alive.  That way I can just wait for pachube to come back up.  I've had this problem three times now which is not bad for several months of data transmission.

One other thing I want to mention is that I use the TimeAlarms library to time the updates to pachube instead of counting milliseconds or something like that.  I set an alarm to fire every so often and just go do other stuff as necessary keeping the values I want to send to pachube updated.  This way I don't have anything hanging me up because Ijust let the alarm fire and it takes care of that kind of thing for me.  This trick allows me to have a display that steps through the various values and little LEDs that tell me what is going on at a glance.  I am using the TimeAlarm libray as a task controller and then just set up the various tasks.

Too much information???
769  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet Shield on: June 16, 2011, 12:40:41 am
First, I do NOT know what the problem is.  However, I do know that this happens a lot in my experience.  The first time I used the ethernet card I thought it was broken.  I eventually got it to work pretty reliably like you did, but it would drop out on occasion and not come back.  After even more testing and code changing I gave up and took a solution similar to yours.  However, I went even further.  I modified the hardware such that I can reset the ethernet board from one of the digital pins such that I can just reset the ethernet board to see if it recovers.  If that fails, I can then reset the arduino and start over from scratch.  This works quite well since the arduino can reboot in a couple of seconds and pachube doesn't even notice I went away.

To see the degree I went to trying to handle this problem take a look at my blog draythomp.blogspot.com under the thermostat tab where I put pictures of the modifications I made.  This problem existed with the previous version of the ethernet card as well as the newer ones.

I suspect the ethernet protocol on the chip itself has a problem and goes away from time to time.  The library can't overcome something like that, so we have to do it ourselves.
770  Using Arduino / Networking, Protocols, and Devices / Re: Unusual position tracking technique with XBees: possible ? on: June 16, 2011, 12:30:48 am
PaulS is correct, you should get a couple of XBees and try the RSSI to see if the granularity is good enough for you.  I suspect the problems that PaulS went into will bring you to a halt on using them.  The RSSI doesn't seem to change until it almost goes away, if there is enough difference to be able to triangulate I would be surprised.  Also as Paul mentioned, the update time is probably much shorter than you want.  I suspect the person could move a couple of feet before you knew it.

771  Using Arduino / Project Guidance / Re: Global variable values rest? on: June 16, 2011, 12:23:33 am
Correct me if I'm wrong because I don't use the String library.  But the line:

String readString = String(30); //string for fetching data from address

Will create a String whose contents is "30", not a thirty byte buffer to hold stuff.  So the line

          readString += c; //replaces readString.append(c);

if it returns an upper case 'H' will make readString become "30H"; at least until you reset it at the bottom of the loop.  Is that what you intended?  Also I couldn't find an example of an array of Strings; lots of examples of strings out there though.  Could it be that there is a problem with the String table you are trying to do the index on?

I'm only jumping in since the experts on the String library haven't jumped in.
772  Using Arduino / Project Guidance / Re: Upgraded Generator control board Possible? on: June 15, 2011, 11:35:31 pm
I disagree.  My neighbor has a new generator for home backup that is totally electronic and works really well.  There's little effort in placing the arduino in a sealed plastic box and taking wires out to "old school relays"  or new school sealed low voltage relays or solid state devices that would last forever without having the contacts burn.  Once you got the basic operation working, adding things like frequency control, oil sensing and altitude sensing would be possible.  You could turn the choke on harder for cold starts, do automatic restarts, disconnects when power came on, etc.  Besides, you could put a cool control panel on it and show it off on trips.

Reliability is not about the era the device was created, it's about testing, adapting and design.  Cars used to be ready for the junk yard in 75,000 miles.  Nowadays we run them twice that before changing the spark plugs.  Something sure seems to be better about electronic controls.  Sure there will be some challenges and it will probably cost twice what you think it will, but you'll have a device that can tell you things like low spark, run temperature and oil temperature that you just can't get now.

Then, when you finish with that project, you'll start to look at the other control systems on the rest of the motorhome.  Automatic leveling and airshock adjustment would be cool too.  Maybe a computer controlled system to keep the batteries in top condition or signal tracking on the satellite TV. 
773  Community / Bar Sport / Re: Your latest purchase on: June 15, 2011, 12:30:03 pm
mowcius:  I'm just guessing here, but I suspect that the British may not have the kind of corporate waste that we see in the US.

cr0sh: Thanks, I think I'll drive over and take a look.  I'm North of phoenix in New River so it'll be about a 40 minute drive.
774  Community / Bar Sport / Re: Your latest purchase on: June 14, 2011, 08:40:03 pm
I live close enough to drive to Apache reclamation, is it worth the gas?
775  Using Arduino / Project Guidance / Re: wireless sprinker system control on: June 14, 2011, 04:17:38 pm
I see what you mean about the Nordic device.  Nice little radio, can't see I blame you for wanting to use it.  The one from sparkfun that is on a breakout board is 19.95 and I pay 20.21 for an XBee so the price difference is not worth worrying about.  Both of them would be fun to play with.

I originally didn't intend to hook up to the internet.  My mind was changed one day when I forgot to turn off the pool motor before I left the house.  That problem is now solved.  Plus it is so cool to pull out the cell phone and show off how I can turn the temperature down or up in the house from a couple of thousand miles away.  Doesn't help impress the girls at the bar though; they still want the guy with the Mercedes.  The reason for the central arduino that controls everything is that I wanted to play with an Arduino 2560 and have a bunch of blinking LEDs, LCD Display, and such to just set and stare at.  (OK, maybe I'm being too honest here).

Each of my thermostats is autonomous as far as setbacks and such, but greater control is more easily accomplished by having something else control them.  So the central box does that.  I got tired of walking from one to the other programming stuff in for them to do.  Plus, I ran out of memory on the darn things a couple of times.  The pool controller is a simple translation device from the idiotic pool control protocol to something more reasonable (in my mind).   Fine grain control of the pool is part of the central controller.  For example I turn the light on at 8PM for an hour to attract bugs that the bats fly around and catch.  This makes it fun to set on the patio watching the bats dive, skim across the water and then bank away from the side.  Ah, the joys of rural living.

Real Time Clocks are just way cool.  I went with a slightly different method simply because I could.  It was fun figuring out how to use a GPS module (that had an RTC inside it) to get and broadcast the time.  Now I can sample the time anywhere around the house, yard, barn, cactus patch or that pack rat den over there.  Silly I know, but it is fun.

As you can tell, my system is a hodgepodge of different technology and techniques.  Very little was originally designed to operate together  and much of it was invented along the way.  Way Cool.  In my mind, this is a fun thing to do and experiment with.  A smoking voltage divider is a lesson in Ohms law, not a failure.

But, I am soooo going to get one of those relay boards.  I could hook an XBee to it and control.......sigh.
776  Using Arduino / Project Guidance / Re: wireless sprinker system control on: June 14, 2011, 10:57:08 am
For power:  I used a big ol 24V transformer in my AC unit to power my web enabled thermostats for my home.  When these are rectified and filtered they put out about 37V DC that has to be regulated to 5V somehow.  I used a really cool device
http://www.dimensionengineering.com/de-swadj.htm.  I have two of these and they have both been working really well for several months.  This saved me a lot of money and time searching for a transformer.  There are other options on that site as well.  You can then use the same AC voltage through the relays to run the solenoids.

Regarding XBees, if you are going to be doing other stuff via wireless control, such as monitoring the soil moisture in various spots, flipping on a light for yard accents, and so forth, the XBee is probably the better choice.  Sure, they are more complicated, but are they really more complicated than tuning, writing your own retry code, testing range yourself, addressing and such?  PaulS and I disagree on the complexity of Series 2.  Once you get two of them working (took me a week the first time and 12 minutes the second) adding another one is about 45 seconds of work.  I even built a remote temperature sender in around 45 minutes from the ground up using one of these and a few other parts.  Don't bother with a shield for these, contrary to what you hear and read, they can be hooked directly to the darn Arduino if you use the low power models.  You can use a cheap adapter board like the https://www.adafruit.com/products/126 if you want to use the high power devices.  The low power ones have a surprising range outside using the wire antenna.  Inside, not so good, so you might need a third one to relay; that is incredibly easy also.  And, you can get three of the low power ones for the price of one high power one (depending of course on where you buy it)

I might suggest that you use an arduino as the controller and web enable it.  The reason is that you will not have to have a computer hooked up and working all the time.  A little arduino controller is fun to build and can have timers (using timeAlarm library) that do things for you.  This way you can put it on the web and watch the sprinklers from Paris while you're on vacation.  But this is a decision you can make at any time.  You can also put the timers in the sprinkler arduino, but you would have more programming in it then.

Take a look at my blog draythomp.blogspot.com to see how I control my thermostats, measure the power in the house, control the swimming pool and such using XBees, Arduinos and such.  The thermostat tab is where I did something similar with 24V control, ethernet boards and relays.  My project is ongoing and will be until I get too old to hold the soldering iron.
777  Using Arduino / Project Guidance / Re: Never built one before building a skinner box with web based button control on: June 14, 2011, 10:18:00 am
This is a really cool idea.  If you really want to do it, the folks on this board will totally help you on it.  Let me start you off with a few questions that matter a lot.

How far is the coup from power?  Do you have something like a light to scare off the 'coons nearby?
How far is the coup from where some computer stuff is plugged in.  Like, do you have an ethernet plug somewhere nearby?  How hard would it be to run some wires to it.
Sunlight?  Maybe solar power is possible to recharge batteries.

See, the feeder has to be with the chickens, but the arduino can be somewhere else.  Suppose you built a screw driven conveyor that dropped corn and ran wires from it to the house?  If that's too hard or not fun enough, how about an XBee on the feeder with a little control circuitry that is wireless to an Arduino in the house.  If that isn't fun enough, put the arduino in the coup with the feeder hook an XBee to it and another one in the house hooked to something on the web.

Webcam?  You simply got to have a webcam !  We would all want to see how fat we could make your chickens.

Think about the physical aspects of doing this.  The electronics will be based on how you think it could be done the best.
778  Using Arduino / Programming Questions / Re: Serial garble at beginning of output. on: June 13, 2011, 11:43:18 pm
Now, go edit the first post and add [Solved] to the subject line  smiley-twist

tee hee.
779  Using Arduino / Programming Questions / Re: ascii char to int conversion on: June 13, 2011, 05:53:41 pm
You're certainly welcome.  Remember though, there's about as many ways to do this as there are people on this forum.  My particular method has some advantages and some disadvantages; notably seeming waaay to complicated. The main purpose is to have some fun and accomplish something interesting.  If you implement Pauls's suggestion of an ending character, then the loop will get even simpler.  Just have a new case with that value, save your integers and go do something with them.
780  Using Arduino / Networking, Protocols, and Devices / Re: Using XBee and USB cable at the same time. on: June 13, 2011, 03:03:44 pm
Working from memory here, so take it for what it's worth.  The DH, DL address is factory set for broadcast when shipped.  That means everything talks to everything in peer to peer mode.  That should make them talk, but not efficiently.  This doesn't mean that someone in the supply chain set up a test bed that changed the devices before you got them.  Once again, I have zero experience with Series 1, but that's what I've read people's experiences have been.  If you already have a couple of them running in the house in some other mode, there may be problems.  Series 2 will work out of the box if there is already a coordinator running.  If there isn't you gotta make one, then they work.
Pages: 1 ... 50 51 [52] 53 54 ... 64