Show Posts
Pages: 1 2 [3] 4 5 ... 7
31  Using Arduino / Programming Questions / DS3234 RTC & Alarms on: December 11, 2011, 04:11:37 pm
Hi guys, I'm banging my head against a wall trying to figure this out and I'm sure it's a lot easier than what my brain is making of it... Needless to say, I really need some help!

I'm using this RTC based on a Maxim DS3234 RTC chip... http://www.sparkfun.com/products/10160

I'm using this guys library, https://github.com/maniacbug/RTClib

The library works fine, the device is keeping time properly, but I cannot figure out how to setup a simple alarm.... I want to turn pins high/low, etc at certain times. I don't really care about what day it is, just the time in 24hr format.

Like, If time == 1530{pinA, high}

Any advice on how to interface with this library to set specific times for alarms?  Here is the sample code...

Thanks!

Quote
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib

#include <SPI.h>
#include <Wire.h>
#include <RTClib.h>
#include <RTC_DS3234.h>

// Avoid spurious warnings
#undef PROGMEM
#define PROGMEM __attribute__(( section(".progmem.data") ))
#undef PSTR
#define PSTR(s) (__extension__({static prog_char __c[] PROGMEM = (s); &__c[0];}))

// Create an RTC instance, using the chip select pin it's connected to
RTC_DS3234 RTC( 8 ) ;

void setup () {
    Serial.begin(57600);
    Serial.println("RTClib/examples/ds3234/");
    SPI.begin();
    RTC.begin();

  if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    Serial.print("Setting time to... ");
    Serial.print(__DATE__);
    Serial.print(' ');
    Serial.println(__TIME__);
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
}

void loop () {
    const int len = 32;
    static char buf[len];

    DateTime now = RTC.now();

    Serial.println(now.toString(buf,len));
    
    Serial.print(" since midnight 1/1/1970 = ");
    Serial.print(now.unixtime());
    Serial.print("s = ");
    Serial.print(now.unixtime() / 86400L);
    Serial.println("d");
    
    // calculate a date which is 7 days and 30 seconds into the future
    DateTime future (now.unixtime() + 7 * 86400L + 30 );
    
    Serial.print(" now + 7d + 30s: ");
    Serial.println(future.toString(buf,len));
    
    Serial.println();
    delay(3000);
}

32  Using Arduino / Project Guidance / Re: Mega Terminal Shield? on: December 11, 2011, 10:10:48 am
Thanks, PDUNZ, but that product is geared towards the Uno board smiley-sad I have the same thing but in the wing style shield. They work on the Mega, but only for some of the pins. I am going to make my own terminal shield.
33  Using Arduino / Project Guidance / Re: Mega Terminal Shield? on: December 10, 2011, 06:51:42 pm
Ah, thanks CR. I was hoping there was a nice screw terminal shield for the whole board.
34  Using Arduino / Project Guidance / Mega Terminal Shield? on: December 08, 2011, 07:56:59 pm
How do you guys go about making solid connections on a Mega board without soldering? I found this, http://ruggedcircuits.com/html/quick_shield.html - but that doesn't do anything for the 28 digital pins... Would be nice if there was a terminal shield for at least half of those pins smiley-sad
35  Using Arduino / Project Guidance / Re: Using I/O pin to sink a current? on: December 07, 2011, 05:09:23 pm
I can't hook the switch up until my Mega board shows up tomorrow... I'm already out of pins on this Uno board and I still have a lot more to hook up.

Again, I guess you don't want any of us to ask what else you have hooked up to the UNO or attempt to help you optimize the hookup and reduce pins used either. Just I/O pin sink current is asked so only answers to that is needed?!

Bingo. Thanks.

The oscillation happens when you open the door and all the inside air comes out...The input temperature changes, the PID responds. The PID needs to know that the door is open and not to freak out. Enter the microswitch on the door. Door opens, microswitch tells arduino that the door is open and to freeze the integral until the switch is depressed again... Once the door closes then a 5min freeze on the integral starts.

Hope I'm not screwing you up on this but I find that as good as microswitches are, a latch-type Hall sensor and cheap magnet as used in security apps is far nicer and last for a larger chunk of forever. You don't need parts to make physical contact and wear out or dirt-up, the internals are solid state and the switching action is clean. However it's not good to mount the magnet directly on a steel door or frame, they do make mounting bits just to handle that.

Hall sensors are to microswitches like transistors are to tubes.


I know what you're talking about... You see them on doors/windows. That's a good idea and I'll definitely keep it in mind for my next prototype. I have micro-switches from work and I have other tiny dead-man switches laying around... But I want things to be as trouble free for my *hopefully* future customers and a latch-type Hall sensor would be good.

Thanks.
36  Using Arduino / Project Guidance / Re: Hydroponics Project on: December 06, 2011, 06:29:52 pm
You'll want a Mega board. I've been doing this same project for months now and the Uno doesn't have enough I/O pins.
37  Using Arduino / Project Guidance / Re: Using I/O pin to sink a current? on: December 06, 2011, 06:27:56 pm

I'm having to reset because the Arduino also does temperature control via PID algorithm, and sometimes when I open the door it screws the PID up and it way overshoots and then goes into an oscillation that takes a little bit of time to self-correct... So I will manually reset to help avoid that.

Rather than deliberately crashing the Arduino and trying to minimise the effects of that, I suggest you start by trying to correct the PID parameters. If it's oscillating, perhaps you don't have the derivative feedback set high enough. If you really can't sort that out then you could simply clip the control signal to around the normal steady-state condition so that it doesn't have as much authority to induce these transient overshoots. And if you can't even do *that* then fit a 'reset' switch which leaves the Arduino running but just tells you sketch to restart the PID algorithm.

Trying to come up with clever drivers that will hide the Arduino reset feels like a solution to the wrong problem.

The oscillation happens when you open the door and all the inside air comes out...The input temperature changes, the PID responds. The PID needs to know that the door is open and not to freak out. Enter the microswitch on the door. Door opens, microswitch tells arduino that the door is open and to freeze the integral until the switch is depressed again... Once the door closes then a 5min freeze on the integral starts.

I can't hook the switch up until my Mega board shows up tomorrow... I'm already out of pins on this Uno board and I still have a lot more to hook up.
38  Using Arduino / Project Guidance / Re: Using I/O pin to sink a current? on: December 06, 2011, 06:23:59 pm
Ok,

pinMode(11, OUTPUT);
digitalWrite(11, HIGH);

restart arduino, light comes on.

changed it to digitalWrite(11, LOW);

re-loaded arduino and bam light went out and the little Ardie Uno still lives lol.
39  Using Arduino / Project Guidance / Re: Using I/O pin to sink a current? on: December 06, 2011, 06:19:57 pm
Guys, this isn't a discussion about my PID parameters... I know what needs to be changed and what to do there.
40  Using Arduino / Project Guidance / Re: What is the best way for Arduino to determine if it's daylight? on: December 06, 2011, 04:03:09 pm
Hi flyingsteve, thanks for posting.  Turns out the one Bill suggested is only $1.50, 6 dollars cheaper.  Plus, I won't need to be sewing it into my clothes as that is what it looks like the Lilypad is for.  Thanks though!

A simple photoresistor will do the trick. I figured I'd show you that one since it gives a more specific sensor output right from the box... No tinkering required. Also, I thought you might mention the sewing part, but I hope you are only jesting... Of course you do not need to sew it to anything smiley

There is another one, http://www.robotshop.com/productinfo.aspx?pc=RB-Phi-13&lang=en-US

That measures in Lux... Very handy. But if you just need to know whether it's day time then ya, just use a photoresistor.
41  Using Arduino / Project Guidance / Re: Using I/O pin to sink a current? on: December 06, 2011, 03:56:30 pm
MarkT, could you please be a little more clear... Not that I'm stupid lol, but your "I believe" statement is confusing me smiley

I'm having to reset because the Arduino also does temperature control via PID algorithm, and sometimes when I open the door it screws the PID up and it way overshoots and then goes into an oscillation that takes a little bit of time to self-correct... So I will manually reset to help avoid that. I am adding in other components to freeze the integral on the PID & include a freeze-time so it won't do that anymore, but in either case if I should need to reset the arduino for whatever reason (Remember, this is for prototyping after-all) I don't want the lights to be going nuts.
42  Using Arduino / Project Guidance / Re: What is the best way for Arduino to determine if it's daylight? on: December 06, 2011, 09:23:53 am
http://www.robotshop.com/productinfo.aspx?pc=RB-Spa-72&lang=en-US
43  Using Arduino / Project Guidance / Re: Using I/O pin to sink a voltage? on: December 06, 2011, 09:22:10 am
However long it takes for the Arduino to reset when you push the reset button... So like, 2 seconds? I wasn't going to read the state of the pin, since the timing is control by an RTC... So when the sketch starts, if it's during the time for the lights to be on then that pin will return to 5V status, but the gates will still be energized & open anyway, if the lights are supposed to be off, then the gates would be closed and the arduino pin won't be sending voltage.

That's just the thought I came up with knowing that the mosfet gate takes no current, so the gate will stay energized until something external sinks the voltage... I don't see why the Arduino would have a problem sinking it's own current though. When I get home from work later I am going to take one of my spare Uno boards and just try it. I'd prefer to not have to get in to adding more resistors/cap @ this point in time.
44  Using Arduino / Project Guidance / Re: Using I/O pin to sink a voltage? on: December 05, 2011, 11:09:50 pm
I want the gates to stay in their current condition. If they are getting 5v from the arduino, and I reset the arduino, I want them to stay on... If they are off, they should stay off. Get what I mean? It's lighting in my terrarium and if the lights are on when I reset the arduino I don't want the mosfets going off... Which is why I was thinking it would be great if I could use the same arduino pins to send 5v to the mosfets and then when it's time, turn the mosfets off by sinking the voltage. There should be no more current going to the mosfets than the arduino can send out of it's pins. Each mosfet has it's own arduino pin, too...

CrossRoads, no I set the pinMode to INPUT... I'll do it as OUTPUT and try it. The Arduino can only send 40mA anyway, so it shouldn't have a problem sinking it's  own current, right? If need be, couldn't I put an resistor between the pin and it's mosfet to help reduce the current more?
45  Using Arduino / Project Guidance / Using I/O pin to sink a current? on: December 05, 2011, 09:13:46 pm
Hey guys, I am running a mosfet power circuit to turn some loads on/off and I'm using a resistor soldered in the circuit to sink the gate voltage, but I'd like to use my Arduino to control the mosfet and I want the gate to stay energized when I reset the arduino. Sometimes I need to reset it a few times a day, and I can't be having the devices go on/off like that...

What's the easiest way of going about this? I thought that when you set a pin to LOW, that it effectively turns it in to a ground? From my testing I see that it just turns the pin off. Would be nice if I could control the mosfet's some way in the code, like HIGH/LOW...

Any thoughts?

Thanks!

I had thought about using a capacitor on each mosfet, that way it would take longer for the pin to sink through the resistor while the Arduino is resetting?
Pages: 1 2 [3] 4 5 ... 7