Another silly idea from laserhawk64...

laserhawk64

Senior Member
This one I might actually BUILD this year...

I saw this post on HackADay, and (as is often the case with such posts) I thought, "That is waaaaaaaay overcomplicating things!"

Could I do something similar (artificial sunrise machine) with a Picaxe 08M (not M2), an RTC (maybe this one?), and a servo (like this?)?

I've got a rotary dimmer switch to spare, that isn't a problem.

Basically, the idea (in case one doesn't want to click the HaD link) is that the Picaxe, at a time set by the RTC, starts (very slowly) turning the dimmer switch, via servo, until full brightness is achieved. Should take 30-60min to get there.

I don't necessarily need a display or config buttons; I can re-config it from a laptop if it's going on too quickly or slowly. I've got a clock already (and a few to spare) so I'm not planning on replacing it -- this is strictly an automated dimmer, it does not display the current time.

A button to turn it off is easily sourced from Radio Shack. (I'm thinking the "off" button could be implemented as a one-shot sorta thing, i.e. "if on, then when button pressed, turn off; else ignore button" -- and presto! no debounce needed.)

Make sense? or am I spouting whotsit again?
 

westaust55

Moderator
Should be do-able.
Good to see (hoping) that you are not proposing to do 230/240 Vac wiring but use the servo to control the rotary dimmer as done on HaD.

For the RTC, you may find the DS3232 more accurate than the DS3107.
 

laserhawk64

Senior Member
Re: voltage... 120 here (I'm in the States -- I used to travel a bit before the hard times came, hence the slight bit of British language patterns). Definitely not hooking mains up to a Picaxe, though -- servo-controlled dimmer all the way.

Re: RTC, I can't solder SMT; I'm not really all that great with through-hole, even -- so I'm limited to prebuilt modules on Sparkfun, eBay, and the like. The one linked was chosen primarily for its cost. As long as it's within five or ten minutes of accurate, it will be fine.
 

westaust55

Moderator
Yes the Ds3232 does cost a bit more but it is available on breakout boards:
http://item.mobileweb.ebay.com/viewitem?itemId=221075336193&index=1&nav=SEARCH&nid=43885061634
Similar to the DS1307 module you gave a link to.
You are tentatively trading price and accuracy against a need to adjust the RTC time more frequently to ensure you wake up at "sunrise" at the same time over an extended period.
I know the DS1307/DS1338 in my PiCAXE Experimenters box does drift over time but have not logged the degree of drift/error.
 

AllyCat

Senior Member
Hi,

Yes that sounds "do-able", provided that the servo produces enough torque to rotate the dimmer knob (but not so much that it destroys something if it overruns).

You're absolutely correct that you need a RTC (the PICaxe internal clock is no way good enough). I've little experience of RTC modules, but I would expect anything sold as a RTC to have "good enough" accuracy for the application. Make sure you understand how (or if) the PICaxe will talk to it.

However, are you aware that the calculation of "sunrise" from "GMT" (or in your case EST) is not trivial? Firstly, of course, the length of the day (or night) varies throughout the year. But also, the sun is not always at its highest at "noon" but varies over a band of about half an hour, so sunrise/sunset "wander" correspondingly. For example, see The Equation of Time, probably not too difficult using lookup tables in the PICaxe.

Cheers, Alan.
 

techElder

Well-known member
Just the noise from this contraption would wake me up! I'd never get to "see the light" in the morning.

I'd be looking at X-10 type of remote control with a dimmer switch in the room lighting circuit. Even that wouldn't be ABSOLUTELY under control.
 

westaust55

Moderator
From post #1

"with a Picaxe 08M (not M2), an RTC "

No I2C on the 08M.

e
Also only 256 bytes of program memory space.
Based on some past code by hippy to bit bang i2c on an 08M part that will take around 91 bytes of program space,
An 08M2 is definitely in order to achieve "do-able"
 

Buzby

Senior Member
OK, my take on how to do it !.

The servo is a noisy method, and requires some Heath Robinson constructions. Not very cool.

X10 is prone to all kinds of weird misbehaviors, I'm never using it again !.

Keeping with the idea of using a commercial dimmer, I would use the same type as I put in my son's bedroom.

This is a touch dimmer, but with IR control as well.
It uses any IR remote controller, not tied to a specific protocol. It has a very simple 'learn' ability.

( Similar type here : http://www.diy.com/nav/fix/electrical/switches-sockets/white-switches-sockets/dimmers/-specificproducttype-1_gang_dimmers/Varilight-Intelligent-Touch-Remote-Dimmer-1-Way-White-9289686?skuId=9299385 )

Put one of these in place of your normal wall switch, then send IR from PICAXE anywhere in room.

Cheers,

Buzby

EDIT : Just looked closer at the link I posted, "Superior trailing edge technology provides the optimum dimming solution."

EDIT 2 : Further idea. Fit the PICAXE into a normal bedside clock, with IR LED poking out of the case. When the normal alarm goes off, trigger IR to operate remote lamp. No need for PICAXE timekeeping.
 
Last edited:

laserhawk64

Senior Member
Another idea -- this will work if the 08M has PWM output somewhere. (I've found one reference that it does, and several that it does not.) PWM a power transistor (MOSFET or otherwise) and hook that transistor up to this --> https://www.sparkfun.com/products/9656

I'll figure out a proper heatsinked mount for that LED later!

I'd want to limit the input to 3.2v 700mA if I'm understanding the datasheet correctly -- although it can go up to 1a current, it says that's a bad idea if you want to do it for more than 60sec once in a blue moon. (Exact language "... limits are specified when applied singularly and for device operation not to exceed 60 seconds."

At 350mA, this produces 80 lumens. At 700mA, it should produce +/- 160 lumens. (I realize that there's an efficiency curve at work there, hence the "+/-".) That's bright enough for me.

Works?
 

eclectic

Moderator
1. The 08M definitely HAS a PWMout output Pin 2
See Manual 1.

Where did you see "references" that it has not?

2. How will the 08M know what time to turn on/off?

e
 

laserhawk64

Senior Member
1. NVM, my bad. I did a google search "08m pinout" and the thumbnails of the first three image results looked the same. First image does not mention PWM. Went back and they're all different, mostly showing the PWM out. Oops.

2. Still trying to figure that one out. It occurs to me that I could set up something where an alarm clock, instead of triggering a buzzer, triggered this contraption. Or I could go for one of these, but the idea really is to keep this as cheap as possible.

EDIT: would this thing be compatible? Obviously I'd need a SIPO shift reg in between, but hey, if it works, it works. Shift registers are cheap, yo.
 

Paix

Senior Member
@Laserhawk64, It sounds like an artificial sunrise machine, to wean you back to life each morning during the long winter nights.

The non-visual route would be to drink a pint (UK not US) or half a litre of water at bed time. You won't need to clock to gently stir you from your sleep. There is no guarantee that you won't trip over something in the dark of course with the fluid mechanism . . . On the other hand, if you get a malfunction and blind yourself with a full on high intensity LED pointing the wrong way, you could similarly have a tripping over experience.

Have fun and good luck. :)
 

Buzby

Senior Member
.... the idea really is to keep this as cheap as possible.
A few points :

You already have a PCB for the 08, and an 08 to go on it.

You already have a few clocks. The RTC board you linked to is $20.

The definite lowest cost solution is put the 08 board into an existing clock, and let the clock do the timekeeping.

Then use the 08 to drive an IR LED. Full interface is just 1 resistor and the IR LED, total cost less than $1.
This option needs a retail IR sensor light switch, cost about $15.
It will also need an interface to the clock alarm. Could be just a resistor, or maybe need an optoisolator, allow $2 for this.
Total cost of project about $18.
( This is also the least complex to build, with no PSU problems, or cases to find. )

The high power LED option might squeeze in a little cheaper, but I doubt it.
It will definitely need LED drive circuitry, a PSU, a box, etc.

If you really are going to build a sunrise lamp, decide on your plan. and we will help.
 

russbow

Senior Member
Simple. I have one of these, from back when the USB cable was included. I want to use it for something!
Well, you could use it to try a bit of picaxe programming - maybe flash a LED or two. Helps the learning curve.
 

laserhawk64

Senior Member
@Buzby: I have a collection of wall warts, so providing (eg) 5v for logic and 3.2v for an LED is not hard. I've got at least one that's rated 5v 2a, which should work perfectly here. The RTC in the edit is $6.53, and the question then becomes one of interfacing. Shouldn't be too hard, it's all memory access and timings. That said, TBH, if I can find an IR dimmer for less than $15 I'd be inclined to go that route -- I've got at least one TV remote that's beyond repair so I can pull the IR LED from that. Interface from the clock is the doozy, though, as I've no idea how the buzzer is triggered. If it's a repeating pulse (or PWM to a piezo "speaker") then that's going to be a little bit of fun to figure out, interface-wise. One thing's for sure, though -- I've no shortage of cheap alarm clocks here! (I've even got one that's a largish cube with a cassette player and radio in it -- but I can't quite figure out how to open it up to reveal its secrets...)

EDIT: sorry, russbow, but LEDs are tremendously boring to me. Yes, it's a start, but it's the difference between going to the local Wal*Mart (~1-1/2 miles) and going to the moon. I'd rather try for the moon and spend a while getting there, than be satisfied with the local Wal*Mart. (But then I've always been kind of the "spaced out" type [g] )
 

laserhawk64

Senior Member
Hey, that's pretty clever. So I'd have the timebase, and then just increment a variable in the Picaxe's metaphorical head, one pulse from the timebase per increment? That would be pretty easy to implement...
 

Kecked

Member
Did this

I did what you wt to do using 28x2, lookup table, making a pin go high that triggers a second chip tat goes through a cycle. Wen it goes low it reverses. This is for my fish tank. I use pwm out to run led drivers. Time Is read off i2c. It was pretty simple to do.

Make i2c clock and lookup table. I used one value for a month. October needed two because time changes so fast.
Compare time to table. If equal than Make a pin go high or low based on what you want for sunrise or sunset.

Second chip looks at input for the signal to do sunrise or sunset. Play with the times to ramp a for next loop that increments the width of a pwm output. I used three loops nested to start different colors to sim rise or set. I also set it up so when the cycle for rise complete the main lights Come on via an optoisolator. You get the idea.

If you try using a math co to calculate rise/set and make it work let me know.
 

ja_mes_87

New Member
Would putting a Light Dependent Resistor (LDR) behind your curtain and using a voltage divider circuit be out of the question? (LDR and a 100k will have minimal current drain and all you need to do is set the light limit for when the light level outside is sufficient) There's a lot of talk about time keeping and sunrise times etc. Why not use the actual sun rising to trigger it? that way you'll be 100% with the timing. I'm assuming about $2.00 for a LDR and a resistor. Just use the 5V supply for the Picaxe.
 

AllyCat

Senior Member
Hi,

Jose's basic idea is excellent, but IMHO the "extensions" are rather questionable. Firstly, if you only want HH:MM data then omit the extra diodes (OR gate) and just divide one of the pulses by 30 for each minute. Secondly, whilst some Red and IR diodes may "regulate" at 1.6 - 1.8 volts, some may drop significantly more or less. If you happen to want an "ON" LED display, then indeed tap off the volts from the LED, but otherwise just use two normal (e.g. 1N4148) diodes in series, which will give 1.3 volts similar to a single AA cell. Finally, that PNP modification appears to have three diodes (including the transistor's base junctions) pointing into a "node", so where does the current flow?

If you try using a math co to calculate rise/set and make it work let me know.
Personally, I wouldn't bother with a coprocessor, it should be quite possible with a standard PICaxe. Basically, just combine three sine waves (or maybe a few more for better accuracy) with periods of a day, 6 months and a year. For non X-series there are various ways to calculate sine-waves of adequate accuracy, or just use a lookup table (either for a sine wave, or just interpolate between sunrise times every few days over a year).

Why not use the actual sun rising to trigger it? that way you'll be 100% with the timing.
It appears that I was probably mistaken in my early post, the OP doesn't want to simulate "sunrise" at its actual time, but to emulate a "sunrise" at some other time.

Cheers, Alan.
 

laserhawk64

Senior Member
@AllyCat -- you probably were mistaken, then! I get up at 10:30am-11am when I have sunlight around (it's worth noting that I'm rather perpetually unemployed). I want to move from my disabled mother's former bedroom, back to my bedroom which has no windows, being smack in between two bedrooms, a hall, and an attic. I've been known to sleep a LOT later than 11 in that room!

So I want something that will start some "daylight" (however realistic) going, at about 10am and at full brightness at 11am. (...and a button to cut it off once I'm up -- no need to be wasting even a dime a day of electricity!) That, AND an alarm clock loud enough to wake King Tut, should be enough to get me the bleep out of bed at a reasonable time.

TBH, I don't care if it cuts on at 10:05 and hits full power at 11:05. Same for 9:55 and 10:55. I won't know the difference. Honest.

What I do need is something dead simple and dead cheap. I don't mind fancy high-power LEDs, as long as they're (relatively) cheap, and the rest of it is fairly simplistic. Dimmable CFLs are nice and (sometimes) full-spectrum, but they are awful expensive, so that's not a place I'd like to go. Then again, the advantage of an LED is that it should last a decade or two... ;)
 

AllyCat

Senior Member
Hi,

IMHO the simpest solution to the timing (and sound alarm) issue is use an existing (off the shelf) electronic alarm which produces a sufficiently high sound level. Then use a PICaxe to produce a 23 hours delay, ready for the next day (which it should be able to do within about 10 minutes accuracy), and then ramp up the illumination, using whatever method you prefer (provided that it's safe, i.e. no direct connections to mains voltages).

Cheers, Alan.
 
Top