I apologize for the confusion: this is a battery-powered application.How far away will this sign be from a mains outlet?
If it is only a short distance you could use a mains timer to control a relay to switch the sign on and off.
It's my guess the easiest thing to do is to have it trigger on when the ambient light condition gets to a preset lower limit (= dark) then a simple countdown timer to run it for X hours before turning it back off and resetting the sensor. Light during the day would put it back into an "armed" condition waiting for dark once again. Not too terribly hard to design with a flip flop and a divider IC incorporting a simple RC oscillator if precision isn't required.Not precisely:
Situation 1: Turn on when it gets dark and work until 3am
Situation 2: Turn on when it is 8pm and work until 3am
Thank you marshallf3!It's my guess the easiest thing to do is to have it trigger on when the ambient light condition gets to a preset lower limit (= dark) then a simple countdown timer to run it for X hours before turning it back off and resetting the sensor. Light during the day would put it back into an "armed" condition waiting for dark once again. Not too terribly hard to design with a flip flop and a divider IC incorporting a simple RC oscillator if precision isn't required.
If I get a chance I'll draw a crystal circuit that will be on for 3 hours per day, no other bells and whistles. I don't do µC, I do fixed circuits. I have enough other projects I'm not interested in climbing that learning curve.
A crystal type timer is always better than RC. Do you have an alarm clock with a battery backup? Ever notice how fast it drifts with the power off? This is a good example of an RC oscillator. A crystal will be a minute or two off per day (worst case, typically much better), an RC oscillator can be 30 minutes off per day (though this can be tweaked). To some extent text equipment helps a lot to calibrate it.
A lot of µC types use crystal oscillators. This helps their accuracy too.
The non-technical explanation of what I want comes in two parts as there are two different (but closely related) projects that I am trying to shape with the help of this thread (its coming together though...slowly):
ProjectOne: A simple sign that stays on for as long as possible and can be built cheaply as possible
- LEDs will be inserted into the "cells" of a 9.5"x5.5" (~24cm x ~14cm) "clear" Coroplast (signboard/corrugated plastic/political sign board):
- The Coroplast will be stenciled with a Fusion Plastic black spray paint
LED SPECS:
- Will use 4-8 RBG LEDs that do what is called "slow flashing" (no logic circuit required - it is built into the LEDs) exactly as shown in this video: http://www.youtube.com/watch?v=epoVPB6wOuo
LED Size: 5mm
LED Color: water clear
Voltage: 3.2-3.6V
Current: 20mA
View Angle: ~ 25degree
Luminous Intensity: 5000-5500mcd
- The Coroplast sign will be attached to metal objects outside with 2-4 N35 (or stronger) 1cm x 1mm cylindrical rare-earth (neodymium) magnets to be glued directly to the Coroplast sign
- I want the sign to last for 14 days, but only care for it to be lit up after dark (or 8pm) and stay on until 3am.
ProjectTwo: An animated sign that does an "old neon sign flicker effect" at random intervals that can stay on as long as possible and can be built as cheaply as possible
Same as ProjectOne, but it animates the sign in the same manner as the neon sign in this video at random intervals: http://www.youtube.com/watch?v=2Uxk70BjH68&NR=1
NOTES:
- I am planning to make at least 1000 of these signs
- I have no idea how to power ether one of the two proposed designs...nuclear fusion anyone?
- I am curious if a buck-boost LED driver circuit would be able to (significantly) increase the life of the battery.
- How to synchronize the RBG slow-flashing LEDs (especially with out the use of the micro controller; especially for ProjectOne)?
- No idea what components I will be using yet, other than the LEDs outlined above
- Using capacitor-backed circuits
- Using timer circuits
- Using dark-detecting circuits
- Weatherproofing: soaking the circuit board in epoxy would do? Any better ideas?
- There is no planned maintenance for these signs, if only a battery change (which is not even something I am planning on as there is low chance of recovering these signs after placement)
- Using the PIC10f200 PIC10f202 pic12f508 PIC12F509 (I could not figure out the difference between the last two, what is it?) for "animation" (the broken-neon-sign-random-flashing effect) (I've purchased EasyPic6 dev platform)
I think you have an ambitious project myself. I'm pretty sure I couldn't do it with your specs (mostly cost), but there is more than just technical knowledge. Your going to have to negotiate for your parts, whatever they may end up being.
If I were you I'd build one. The ideal sign, the way you want the others to look, then looking for ways to reduce costs. It may mean you don't have the colors you want, or maybe some of the features, but you'll have an idea what it will take along with a breakdown what every feature actually costs.
Historically there have been companies that really made George ($1 Bill) squeak when building their product. If a part cost 5¢ vs. the ideal part that cost 50¢ they tried to make the 5¢ part work. I'm thinking of the old Commodore computers. It is a knack very few have.
A thought just occurred to me, I've posted my article LEDs, 555s, Flashers, and Light Chasers (blog, current edition). Chapter 8 has a way to make 20 LEDs blink in a pseudo random fashion. Maybe you can use it.
My rewrite (which is incomplete) has a flicker section. LEDs, 555s, Flashers, and Light Chasers (forum edition) Chapter 12 will go over how to take a radio (AM or FM, doesn't matter) and use the audio to make a flicker that might match your idea of a neon light. If you could find a cheap source of audio generators like radios maybe you can do something with it.
Just a couple of thoughts.
There are contract manufacturers out there that will do about anything if it involves enough volume, and for a lot less than the hassles of setting up, training and tending to an employee base. The place that makes my PC boards, Advanced Circuits up in Colorado, has ties with firms like this.
Trust me, I've marketed a couple of projects in far smaller volume than what you're talking about and assembly, even with help, gets old pretty darn fast.
If it's potentially patentable or copywrite protectable (and this appears to be) you'd better take some steps to make sure nobody else takes your idea and runs with it even if you have to beg for some venture capital somewhere. Think of what China + Kinko's could do with this idea.
PS: Are we getting any royalties from this?
Hi Markd77, thank you for answering my questions!I can answer a couple of questions.
- The difference between the PIC12F508 and 509 is that the 508 has 512 words of program memory and 25 bytes of RAM, the 509 has 1024 and 41. I wouldn't worry about the 2K code size of the free compiler, it should be plenty.
- I don't think there is any way to synchronise the RGB leds with the built in flashing.
- I was thinking that you could use an external crystal with the 12F508/9. You would still have 3 outputs but they would then be able to keep time accurately enough to not need any daylight sensing.You would just program them so that when powered up they are set to 5pm (for example) then turn them all on at 5pm on the day you set them up. Once you get started programming them you will find a 24 hour timer is fairly easy. The disadvantage to this is that if you went to change the batteries you would have to do it at the correct time of day.
- All of these micros are very low power even when they are running a program. Compared to 7 hours of LED power, the amount the micro would use in a day would be almost unnoticable.
There was no sarcasm coming from me. I'm not sure if that is what you meant.Sarcasm, sometimes it doesn't come across well.
Writing is easy for me, you get to do the hard work.
Like I said, you need to do a sketch of the LEDs layouts and describe what you want them to do. Then I (or someone else) can show you ideas to make them do what you want. This goes under the build a prototype idea. Even if the first one is perfect (and cheap) there are always improvements that suggest themselves after the fact that will reduce costs or improve quality.
Another thought has occurred, you may want two sets of batteries, one for the timer (long lasting and won't loose it's place) and another for the LEDs (relatively high current and short lived).
If you could find solar cells you could charge up a small supercap (think high efficiency battery) to power up the LEDs during the day. It would also be your daylight sensor. The timer could last months off of the separate batteries while the LEDs would be dependent on sunlight energy harvesting (but they would last a really long time).
list p=12F675
radix hex
title "Timelapse"
#include <p12f675.inc>
__config _CP_OFF & _BODEN_OFF & _MCLRE_OFF & _PWRTE_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT
cblock 0x20
count
count2
delay16bitH ;8 hours is 0x7080 seconds = 0x3840 2 second interrupts
delay16bitL
sinecount
sinecurrent
sinecopy
ADRESHcopy
W_TEMP
STATUS_TEMP
eetemp
GPIOtemp
mode ;0 off 8 hours, 1 on until GP3 button,
;2 off until light off, 3 on 10 minutes
;mode 3 at power on
endc
org 0x2100 ;initial values for timer H and L bytes (10 seconds)
de 0x00,0x0a
;
;----------------------------------------------------------------------
org 0x000
goto init
org 0x004 ;interrupt goes here
MOVWF W_TEMP ; Copy W to TEMP register,
SWAPF STATUS, W ; Swap status to be saved into W
MOVWF STATUS_TEMP ; Save status to STATUS_TEMP register
;ISR : :
; Interrupt Service Routine
;test interrupt source
btfss INTCON, GPIF ;pin change, any activity change to mode 2
goto TMRinterrupt
movlw 0x02
movwf mode
bcf GPIO, 2 ;led off, wait for lights out
goto endint
TMRinterrupt
btfsc mode, 0
goto mode1or3
btfsc mode, 1
goto mode2
goto mode0
mode1or3
btfss mode, 1
goto mode1
;mode3 by elimination ;light on for 10 minutes
bsf GPIOtemp, 2 ;LED on
movf GPIOtemp, W
movwf GPIO
movlw 0x01 ;count down for 10 minutes
subwf delay16bitL, F
btfss STATUS, C
subwf delay16bitH, F
subwf delay16bitH, W
btfsc STATUS, C
goto endint
movlw 0x01
subwf delay16bitL, W ;w=1
btfsc STATUS, C
goto endint
bcf GPIO, 2 ;10 minutes up turn off LED
clrf mode ;mode 0, 8 hours off
movlw 0x38 ;set delay = 8 hours = 0x3840
movwf delay16bitH
movlw 0x40
movwf delay16bitL
goto endint
mode1
goto endint ;GPIO interrupt changes to mode 2
mode2 ;wait with LED off until room light turned off
bcf GPIOtemp, 2 ;LED off
movf GPIOtemp, W
movwf GPIO
bsf ADCON0, 1 ;start conversion
call delay1ms ;way too long
movlw 0x96 ;test brightness
subwf ADRESH, W
btfss STATUS, C
goto endint
incf mode, F
movlw 01 ;10 minutes = 0x0258 sec = 0x012C x 2 sec ints
movwf delay16bitH
movlw 2C
movwf delay16bitL
goto endint
mode0
; incf mode, F
bcf GPIOtemp, 2 ;LED off
movf GPIOtemp, W
movwf GPIO
movlw 0x01 ;count down for 8 hours
subwf delay16bitL, F
btfss STATUS, C
subwf delay16bitH, F
subwf delay16bitH, W
btfsc STATUS, C
goto endint
movlw 0x01
subwf delay16bitL, W ;w=1
btfsc STATUS, C
goto endint
incf mode, F ; count finished, mode 1
endint
; should configure Bank as required
;
SWAPF STATUS_TEMP,W ; Swap nibbles in STATUS_TEMP register
; and place result into W
MOVWF STATUS ; Move W into STATUS register
; (sets bank to original state)
SWAPF W_TEMP, F ; Swap nibbles in W_TEMP and place result in W_TEMP
SWAPF W_TEMP, W ; Swap nibbles in W_TEMP and place result into W
; CLRF TMR1L ; Clear Low byte, Ensures no rollover into TMR1H
; movlw 0xC0 ;set up timer1
; movwf TMR1H
; clrf TMR1L
clrf INTCON ;clr interupts
bsf INTCON,PEIE ;timer1 interrupt on
bsf INTCON, GPIE ;gpio change interrupt on
bcf PIR1, 0 ;clr tmr1 interrupt flag
retfie
init ;initialise stuff here
movlw B'00000111'
movwf CMCON ;comparitors off
movlw B'00001111'
movwf T1CON ;enable timer1 external LP crystal
BSF STATUS, RP0 ; Bank 1
movlw B'00010001'
movwf ANSEL ;AN0 analog and Fosc/8 for 4MHz
bsf PIE1, 0 ;timer1 int enabled
; BSF STATUS, RP0 ; Bank 1
clrf OPTION_REG ;
movlw B'00001000'
movwf IOC ; interrupt on change pin GP3
bcf STATUS, RP0 ; bank 0
movlw B'01001000' ; enable timer 1 interrupt and gpio change (not GIE yet)
movwf INTCON ;
CLRF TMR1L ; Clear Low byte, Ensures no rollover into TMR1H
clrf TMR1H
movlw 0x02
movwf mode
CLRF GPIO ; Initialize GPIO by
; clearing output
; data latches
BSF STATUS, RP0 ; Select Bank 1
MOVLW B'00100001' ; Value used to
; initialize data
; direction
MOVWF TRISIO ; Set GP<4-1> as output, GP0 input
BCF STATUS, RP0 ;bank 0
movlw B'00000001'
movwf ADCON0 ;left justified, A/D on, AN0, ref VDD
movlw D'75'
movwf sinecount
bsf INTCON, GIE ;enable interrupts, then sleep
sleeploop
sleep
nop
movlw 1
subwf mode, W
btfss STATUS, Z
goto sleeploop ;if mode 1 goto main
main
; bsf ADCON0, 1 ;start conversion
; call delay1ms ;way too long
movf sinecurrent, W
movwf sinecopy
bsf GPIOtemp, 2 ;LED on
movf GPIOtemp, W
movwf GPIO
LEDon
decfsz sinecopy, F
goto LEDon
movf sinecurrent, W
movwf sinecopy
bcf GPIOtemp, 2 ;LED off
movf GPIOtemp, W
movwf GPIO
LEDoff
incfsz sinecopy, F
goto LEDoff
decf sinecount, W
btfsc STATUS, Z
movlw D'75' ;reset if one (wastes 1 space in lookup)
movwf sinecount
movf sinecount, W
call sinetable
movwf sinecurrent
movlw 1
subwf mode, W
btfss STATUS, Z
goto sleeploop ;if not mode 1 goto sleeploop
goto main
sinetable
addwf PCL, F
nop ;never going to happen
retlw D'128'
retlw D'139'
retlw D'149'
retlw D'160'
retlw D'170'
retlw D'180'
retlw D'189'
retlw D'198'
retlw D'207'
retlw D'215'
retlw D'222'
retlw D'229'
retlw D'235'
retlw D'241'
retlw D'245'
retlw D'249'
retlw D'252'
retlw D'254'
retlw D'255'
retlw D'255'
retlw D'254'
retlw D'253'
retlw D'250'
retlw D'247'
retlw D'243'
retlw D'238'
retlw D'232'
retlw D'226'
retlw D'219'
retlw D'211'
retlw D'203'
retlw D'194'
retlw D'184'
retlw D'175'
retlw D'165'
retlw D'154'
retlw D'144'
retlw D'133'
retlw D'123'
retlw D'112'
retlw D'102'
retlw D'91'
retlw D'81'
retlw D'72'
retlw D'62'
retlw D'53'
retlw D'45'
retlw D'37'
retlw D'30'
retlw D'24'
retlw D'18'
retlw D'13'
retlw D'9'
retlw D'6'
retlw D'3'
retlw D'2'
retlw D'1'
retlw D'1'
retlw D'2'
retlw D'4'
retlw D'7'
retlw D'11'
retlw D'15'
retlw D'21'
retlw D'27'
retlw D'34'
retlw D'41'
retlw D'49'
retlw D'58'
retlw D'67'
retlw D'76'
retlw D'86'
retlw D'96'
retlw D'107'
retlw D'117'
retlw D'128'
delay1ms: ;
movlw 0xFF
movwf count
loop1ms
nop
decfsz count,F
goto loop1ms
return ;delay20ms
end