Show Posts
Pages: 1 ... 22 23 [24] 25 26 ... 35
346  Using Arduino / Networking, Protocols, and Devices / Re: Sudden unreliability with my network-enabled Arduino project on: August 07, 2012, 08:12:14 pm
Wow, you've done a lot of debugging so far.  You mentioned humidity as a potential problem. This is probably a long shot, but maybe the wood is absorbing moisture and causing a problem.  Do you have plastic stand-offs you could use to keep the circuit board from touching anything.  Another thing you might try is heat things up with a blow dryer - not too hot though - and see if things start failing.  You could also plug it into a UPS to make sure you have nice clean power.
Any chance the problem is with the garage door and not your circuit?
347  Using Arduino / Networking, Protocols, and Devices / Ethernet Shield + Pro Mini 3.3 v on: August 07, 2012, 07:55:28 pm
I want to take an Ethernet shield R3, and plug a proto shield on the top. The proto shield will have a Arduino Mini Pro 3.3v Atmel 328.  I know I need a 5v and 3.3 v power supply.  I think all I need to do is connect the D10-D13 pins to the Ethernet shield.  But normally these pins would all operate on 5v, but in this setup, I've got 5v and 3.3 volts.  So how should I deal with this?  Any other pitfalls I should be aware of?

The reason I'm doing this is the Pro Mini is actually a panStamp - it's a Pro Mini with an RF transceiver built in. 
348  Using Arduino / Networking, Protocols, and Devices / Re: Leonardo communicate with Pro Mini 3.3v on: August 05, 2012, 08:11:22 am
Thanks I'll try that.
349  Using Arduino / Networking, Protocols, and Devices / Leonardo communicate with Pro Mini 3.3v on: August 04, 2012, 08:51:05 pm
I want to get a Leonardo communicating with an Arduino Pro Mini 3.3v ATmega 328.  The two devices are only a couple inches apart.  I am leaning toward using I2C to do this.  What's the best way to deal with the different voltage levels between the two boards?
350  Using Arduino / Programming Questions / Re: Strange pushbutton behavior on: August 04, 2012, 09:32:36 am
Code:
    if(WaterFillTimer <= millis())  // need to check for pressure here becuse if valve is already open, pressure will be low
The comment has NOTHING to do with the code.
My original code had an input from a  pressure switch, when I took that out to do this test, I forgot to remove the comment.

Quote
Code:
      WaterFillTimer += WATER_FILL_BP_MIN;          // Timer is already on, add more minutes, but only if valve is already open
Adding unsigned longs is not a good idea. WaterFillTime might be a good name. WaterFillTimer is not.
WaterFillTime is a better name.  What's wrong with adding unsigned longs?

Quote
Code:
  if(((long)(millis() - WaterFillTimer) <= 0))
Why are you casting an unsigned value to a signed value? The result of the computation will be unsigned, and therefore not at all what you expect, before the cast takes place. The result will NEVER be negative.
I'm pretty new at this, and certainly no expert in casting.  But the above code works.  If I add Serial.println((long)(millis() - WaterFillTimer)) to see what's going on, it prints out negative numbers.  The output turns on for the specified amount of time in WaterFillTimer then turns off.

351  Using Arduino / Programming Questions / Re: Strange pushbutton behavior on: August 04, 2012, 08:38:47 am
I put my own 150mS delay (debounceTimer) in and it works well now.

Code:
#include <Button.h>     // For pushbutton http://github.com/carlynorama/Arduino-Library-Button
#define WATER_FILL_BP_MIN    242000   // minutes added to water fill timer
#define WATER_FILL_PB    8            // Push-button for water fill
#define WATER_OUTPUT     7            // Adds water to pool
uint32_t WaterFillTimer;  // Timer to turn on water fill valve, adds 15 minutes every time pushbutton is pressed
Button btnWaterFill = Button(WATER_FILL_PB, LOW);  // Setup pushbutton for water fill

void setup()
{
  Serial.begin(9600); 
  pinMode(WATER_OUTPUT, OUTPUT);
  digitalWrite(WATER_OUTPUT, LOW);
  delay(100);
}

void loop()
{
  static uint32_t debounceTimer;
 
  // Check for water fill pushbutton, if detected and there is pressure in the line, add 15 minutes to timer
  btnWaterFill.listen();
  if ( btnWaterFill.onPress() && millis() > debounceTimer )
  {
    debounceTimer = millis() + 150;
    // Add time to water fill timer
    if(WaterFillTimer <= millis())  // need to check for pressure here becuse if valve is already open, pressure will be low
    {
      WaterFillTimer = millis() + WATER_FILL_BP_MIN;  // First time button is pushed
      Serial.println("Initial timer");
    }   
    else if(digitalRead(WATER_OUTPUT) == HIGH)
    {
      WaterFillTimer += WATER_FILL_BP_MIN;          // Timer is already on, add more minutes, but only if valve is already open
      Serial.println("Add more time");   
    }             
  } 

  if (digitalRead(WATER_OUTPUT) ==  HIGH)
  {
    Serial.print("water fill countdown:  ");
    Serial.println(((WaterFillTimer - millis()) / 60000.0));
    delay(100);
  }

  // Turn on water fill valve
  if(((long)(millis() - WaterFillTimer) <= 0))
  {
    digitalWrite(WATER_OUTPUT, HIGH);
  }
  else
  { // Turn Pump off
    digitalWrite(WATER_OUTPUT, LOW);
  } 
}
352  Using Arduino / Programming Questions / Re: Strange pushbutton behavior on: August 04, 2012, 08:16:50 am
Use btnWaterFill.getDebounceDelay() to find out what your current de-bounce delay is set to, and then use btnWaterFill.setDebounceDelay(<some value>) to increase it.

getDebounceDelay shows it's set at 30 (I assume this is milliseconds).  I tried increasing it in steps all the way to 200, but that didn't solve the problem. For fun I lowered it to 10 and 20, but that didn't help.  I even tried to set it for 1000 - most of the time it missed the button press altogether, but sometimes I'd get a triple bounce.  

Something seems wrong, if I have the delay set to 100 and press the button quickly, there I shouldn't get two button presses.  It seems I'm either using this library incorrectly, or the button.h library needs something fixed.

I think I'll just use millis() and a timer to do a little additional debouncing.
353  Using Arduino / Programming Questions / Re: Strange pushbutton behavior on: August 04, 2012, 08:10:47 am
2 things that might help your issues are 1. Do you have the input pulled up or down as the logic requires and do you have a 100nF cap from the Pin to ground and 2. are you familiar with the bounce library or a delay without delay(). Both or either issue might well fix your problems.
Doc

Just tried the capacitor suggestion, that didn't work.
354  Using Arduino / Programming Questions / Re: Strange pushbutton behavior on: August 04, 2012, 07:51:45 am
2 things that might help your issues are 1. Do you have the input pulled up or down as the logic requires and do you have a 100nF cap from the Pin to ground and 2. are you familiar with the bounce library or a delay without delay(). Both or either issue might well fix your problems.

Doc

I have a 10k pull-up resistor.  I don't have a cap installed.  I'm not familiar with the bounce library. 
355  Using Arduino / Programming Questions / Strange pushbutton behavior on: August 03, 2012, 08:36:15 pm
I have project where an arduino can add water to my pool.  Every time I press a pushbutton, I want to add a few minutes to a timer that controls a water fill valve.  To test I just have a little momentary PCB pushbutton switch.  I'm using button.h library.  The problem is, if press the button and hold it for half a second or so, it works fine.  But if I press very quickly, it counts it as two presses and adds twice as much time to the timer.   I'm using Arduino IDE 1.01 with and Uno R3.  Any ideas why I'm getting this behavior? Here's my program

Code:
#include <Button.h>     // For pushbutton http://github.com/carlynorama/Arduino-Library-Button

#define WATER_FILL_BP_MIN    242000   // minutes added to water fill timer
#define WATER_FILL_PB    8            // Push-button for water fill
#define WATER_OUTPUT     7            // Adds water to pool
uint32_t WaterFillTimer;     // Timer to turn on water fill valve, adds 15 minutes every time pushbutton is pressed

Button btnWaterFill = Button(WATER_FILL_PB, LOW);    // Setup push button for water fill

void setup(){
  Serial.begin(9600); 
  pinMode(WATER_OUTPUT, OUTPUT);
  digitalWrite(WATER_OUTPUT, LOW);
  delay(100);
}

void loop(){
 
  // Check for water fill pushbutton, if detected and there is pressure in the line, add 15 minutes to timer
  btnWaterFill.listen();
  if ( btnWaterFill.onPress())
  {
    // Add time to water fill timer
    if(WaterFillTimer <= millis())  // need to check for pressure here becuse if valve is already open, pressure will be low
    {
      WaterFillTimer = millis() + WATER_FILL_BP_MIN;  // First time button is pushed
      Serial.println("Initial timer");
    }   
    else if(digitalRead(WATER_OUTPUT) == HIGH)
    {
      WaterFillTimer += WATER_FILL_BP_MIN;          // Timer is already on, add more minutes, but only if valve is already open
      Serial.println("Add more time");   
    }             
  } 

  if (digitalRead(WATER_OUTPUT) ==  HIGH)
  {
    Serial.print("water fill countdown:  ");
    Serial.println(((WaterFillTimer - millis()) / 60000.0));
    delay(100);
  }

  // Turn on water fill valve
  if(((long)(millis() - WaterFillTimer) <= 0))
  {
    digitalWrite(WATER_OUTPUT, HIGH);
  }
  else
  { // Turn Pump off
    digitalWrite(WATER_OUTPUT, LOW);
  } 
}
356  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.
357  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;}
}
358  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.
359  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.
360  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
Pages: 1 ... 22 23 [24] 25 26 ... 35