Show Posts
Pages: 1 ... 24 25 [26] 27 28 ... 36
376  Using Arduino / Programming Questions / Re: How to time how many minutes an output is on on: July 22, 2012, 10:46:43 am
I didn't include the whole sketch, just the parts relevant to this thread.  Thanks for the tip about 60000.
377  Using Arduino / Programming Questions / Re: How to time how many minutes an output is on on: July 22, 2012, 08:18:01 am
Here's what I came up with

Code:

bool waterFillOnTrigger;       // one shot trigger when water fill valve is turned on

void setup(){
waterFillOnTrigger = false;
}


void loop() {
  static uint8_t waterAddedToday;      // minutes of water added today
  static uint32_t waterFillStart;      // Saves millis() setting of when water fill timer starts

  // Check to see if water fill valve has just opened
  if(digitalRead(WATER_OUTPUT) == HIGH && waterFillOnTrigger == false)
  {
    // Valve just opened, set waterFillOnTrigger and add millis to start time
    waterFillOnTrigger = true;
    waterFillStart = millis();
  }
 
  // check to see if water fill valve has just closed
  if(digitalRead(WATER_OUTPUT) == LOW &&  waterFillOnTrigger == true)
  {
    // Valve just closed, reset waterFillOnTrigger 
    waterFillOnTrigger = false;
   
    // Calculate time (minutes) that valve was on and to daily timer
    waterAddedToday += (millis() - waterFillStart) / 60000;
  }
 
  // Reset waterAddedToday every night at 11PM
  if (poolTime > 23.0)
    {waterAddedToday = 0;}
}
378  Using Arduino / Programming Questions / How to time how many minutes an output is on on: July 21, 2012, 05:36:50 pm
I have an output that adds makeup water to my pool.  There's a couple of things that can make the output turn on - button being pushed, low pressure detected, start of day - stays on for 30 minutes.  I don't want the output to be on for more then 60 minutes each day.  I'm looking for a way to time how long the output is on, then reset it at the end of the day.  Resetting is simple, but I'm scratching my head to figure out how to add up the time for the output. It could be on several times during the day, so it's not a matter of just timing one event. I'm sure I can do it, but everything I think if is kind of kludgy and complex, I'm hoping someone has already figured this out and has a better solution.
379  Using Arduino / Networking, Protocols, and Devices / Re: Arduino + Ethernet + XBee: Leonardo works, UNO doesn't on: July 09, 2012, 09:36:36 pm
It's working on the UNO now, I'm not sure why. I'm still doing serial print.
380  Using Arduino / Networking, Protocols, and Devices / Re: Arduino + Ethernet + XBee: Leonardo works, UNO doesn't on: July 09, 2012, 08:37:29 am
Code is attached
381  Using Arduino / Networking, Protocols, and Devices / Arduino + Ethernet + XBee: Leonardo works, UNO doesn't on: July 08, 2012, 07:51:51 pm
I've have a Leonardo with an Ethernet R3 shield attached and a Sparkfun XBee shield on the top of the Ethernet shield.  This setup works fine, but if I replace the Leonardo with an UNO and leave everything else the same, I have problems.  The XBee still works, but when the sketch tries to post to COSM.com, I get a HTTP 401 error.  If I switch back to Leonardo, everything is fine.  Any ideas what's happening?

I want to use the UNO because it has more available memory (because the bootloader is smaller).  My current program is almost at the memory limit.
382  Using Arduino / Programming Questions / Re: How to reduce program size on: July 04, 2012, 11:43:29 pm
   If you have any global variables that could be made local instead this can save a lot of memory.

That's good to know.
383  Using Arduino / Programming Questions / Re: How to reduce program size on: July 04, 2012, 05:56:05 pm
Code:
Defining variable don't seem to affect it, which is surprising.
Not if you understand where variables are stored. Program space is read only, unless the bootloader is uploading a new hex file. Since variables need to be written to, they are not stored in program space. So, they do not affect the amount of program space needed.

I have no idea where stuff is stored, or even what the different parts are.  Any suggestions on a good source that explains this?
384  Using Arduino / Programming Questions / How to reduce program size on: July 04, 2012, 11:34:16 am
I'm trying to understand which parts of my sketch affect program size.
Defining variable don't seem to affect it, which is surprising.  I notice that reducing the text in Serial.print() helps.  Now I mostly use Serial.print(F()) to put the strings in EEPROM, but I don't think that reduces the compile size.
Including libraries that are not actually used by the code doesn't seem to affect it.
385  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet shield - multiple connections on: July 04, 2012, 10:51:08 am
It wasn't the pointers.  I think I was running out of memory, I changed a bunch of Serial.print() to Serial.print(F()) and it's working now.

Regarding the pointers, this is what I am doing:

Code:
void PrintPoolData(float *poolData);  // function prototype

void loop(){
  static float poolData[10];  // define array of floats

   poolData[0] = 100;
   poolData[1] = 101; 
  // and so on

   PrintPoolData(poolData); // prints poolData array, poolData is sent to function as pointer
}

void PrintPoolData(float *poolinfo) {
  Serial.print(F("Pool Temp = "); 
  Serial.println(poolinfo[0]);
  // and so on
}


   
386  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet shield - multiple connections on: July 04, 2012, 09:36:35 am
I made am bare bones sketch using both ERxPachube.h and twitter.h and it worked.  Now I think the real problem is I'm not using pointers correctly when passing them to a function.  I'm just learning this and I think there might be some malloc() functions needed.  For now, I'm going to must make the variables global and not worry about passing them to a function as a parameter.  At least that way I can rule or verify this pointer issue.
387  Using Arduino / Networking, Protocols, and Devices / Ethernet shield - multiple connections on: July 03, 2012, 05:08:41 pm
I'm using a Leonardo with Ethernet shield R3.  I am sending data to COSM (ie Pachube) using ERXPachube.h library and I want to also send a Twitter message using twitter.h library.  Both work fine if they are in different sketches, but when I try to do both from the same sketch, I get a 401 error from COSM.  I don't know much about Ethernet protocol, but from searching around I found that the Ethernet shield can support 4 connections.  I assumes this means I can connect to 4 different servers.  To make sure there were no naming conflicts, in twitter.cpp I changed "client." to "tweetclient.", but that didn't help.  I'd appreciate any suggestions on how to make this work?
388  Using Arduino / Networking, Protocols, and Devices / Re: Multiple Arduino Unos communicating via Xbee on: July 01, 2012, 04:15:39 pm
What board is the XBee plugged into?  According to the comments on the Sparkfun product page, there seems to be a problem with Sparkfun's shield and the UNO.
http://www.sparkfun.com/products/9976
389  Using Arduino / Networking, Protocols, and Devices / Re: Multiple Arduino Unos communicating via Xbee on: July 01, 2012, 01:36:53 pm
I didn't realize you were using series 2. I've never used those, so I doubt my sketch will work.  Sorry.
390  Using Arduino / Networking, Protocols, and Devices / Re: Multiple Arduino Unos communicating via Xbee on: July 01, 2012, 01:24:09 pm
I've never tried 64-bit addressing, but I have my XBees Series 1 working with 16-bit addressing.  I've attached two sketches and two X-CTU profiles.  If you load these profiles on your XBees they should work with the sketches.  In the Rx sketch it tells you the address of the transmitting XBee.  In the Tx sketch, you send data to a particular XBee, based on the MY address, not DL or DH addresses.

I hope this helps.
Pages: 1 ... 24 25 [26] 27 28 ... 36