LED circuit HELP for a Guerilla/Creative Marketing Campaign

marshallf3

Joined Jul 26, 2010
2,358
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
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.
 

Thread Starter

ZigZag

Joined Jul 22, 2010
264
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.
Thank you marshallf3!

Please excuse my gross unfamiliarity with the components. I used Wikipedia and Google to get an idea of how to use the components you've mentioned together to achieve the intended result and here is what I've come to understand (please let me know if that is deluded):

1. The circuit is triggered (armed?) by a dark-detecting circuit
2. The [main] circuit is executed
2a. the divider_IC (a simple RC_oscillator - as I do not need precision) turns on acting as a timer and counts down (how?) until a set point after which it
3. triggers the flip_flop that resets this loop and everything reverts back to step 1


:confused:

I do not understand how IC_dividers work, and how they can be substituted with simple RC_oscillators
 

Wendy

Joined Mar 24, 2008
23,415
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.
 

Thread Starter

ZigZag

Joined Jul 22, 2010
264
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.

Bill, I'm not sure if I'm missing something or you have mistyped it, but Situation 1, was a circuit that was timed from 8pm to 3am (that is 7 hours).
 

marshallf3

Joined Jul 26, 2010
2,358
Most crystal oscillators start out at a fairly high frequency, dividing them down into hours might take more than one divider stage IC. If you use 1% resistors and 1% NPO/COG caps in the oscillator it should be accurate enough for your purposes, They're really easy to set up, there's already an ascillator stage built into a 4060, check out the data sheet. You've got the circuit pretty well figured out too.
 

Wendy

Joined Mar 24, 2008
23,415
Let me know what you need. Like I said, no bells an whistles. The 24 hours timer is one circuit, the duration on is another.
 

Thread Starter

ZigZag

Joined Jul 22, 2010
264
This thread is all about figuring out what I need. It has been a long, fun, and adventurous journey (spanning many tangents) in which I have invested a lot of time [and money] thus far, but unfortunately still failed to get a good technical outline of what the two circuits I am looking to build will look like.


So, the truth is, technically-speaking, I still do not know what I need. And Bill, I know you are very busy, and because I do not yet know what I need, I do not want to waste your time. I just don't know...


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:
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)
 
Last edited:

Wendy

Joined Mar 24, 2008
23,415
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 look 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.

Batteries is probably going to be your biggest problem (not the only one). Long life batteries cost. My typical cost for a AA battery is around 25¢, your going to need at least 2, probably more. Buck boost power supplies won't really help, since they have losses that will shorten the batteries life. The simpler the better (and probably more efficient). I suspect the minimum voltage for your electronics is 4.5V, however there are ways to make LEDs light up off of a lot less. A joule thief uses 1½VDC, but you are also wanting logic for the bells and whistles.

While I don't have the experience with microcontrollers, I recognize they will give you the biggest bang for your buck. They can be programmed to do things with no extra components, so a major cost drain will be removed.

As for lighting special effects, KISS rules (Keep It Simple Stupid). The simpler your special effects the easier and possibly cheaper.
 
Last edited:

Thread Starter

ZigZag

Joined Jul 22, 2010
264
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.


Cost is no longer a set dollar amount, but nevertheless a huge/very important part of the success metric of this project
 

Wendy

Joined Mar 24, 2008
23,415
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.
 

Thread Starter

ZigZag

Joined Jul 22, 2010
264
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.

Thank you Bill, I'm reading through it now.
 

Markd77

Joined Sep 7, 2009
2,806
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.
 

marshallf3

Joined Jul 26, 2010
2,358
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? :)
 

Thread Starter

ZigZag

Joined Jul 22, 2010
264
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? :)

marshalf3,


There is no "employee base" - there is just soldering gun and I; I have some friends in Shenzen - I'm sure they will help if I want to make 10,000 of these in the future. Maybe by that time I can get some investors and can go there personally. I always dreamed of visiting HK!

I am promoting a free service that my company makes - so you see this is not a separate product that I plan to make money on. I love all things hardware, but unfortunately do not have much knowledge or experience to come up with anything on my own. This was a great opportunity for me to learn a hobby I've always dreamed of and promote a free service (that has no ads, or any other revenue model) that my company has worked for about two years to create. When I mean my company, it is my best friend and I, bootstrapping (working a full time job AND working on business full time). This project's budget is literally coming out of our fridge money. When I stressed as cheap as possible earlier it was because we cuddled around one space heater all last winter because we didn't have the money to go to a coffee shop like we did the year before when it got really cold.

I am doing this out of love of doing this. Why are you helping me? Isn't that for the same reason? Oh, and in the case it is not, I hate to break it to you, but no royalties for you or anyone else, my friend ;) Oh, and I know you are just busting my balls so it is all good.

On a serious note, I do want to roll this out before everyone gets settled into their first semester (fall), so I really appreciate when you or anyone on here is helping me. Thank you. :rolleyes:
 
Last edited:

Thread Starter

ZigZag

Joined Jul 22, 2010
264
I can answer a couple of questions.

  1. 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.
  2. I don't think there is any way to synchronise the RGB leds with the built in flashing.
  3. 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.
  4. 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.
Hi Markd77, thank you for answering my questions!


  1. I was looking through the datasheets and did not notice that difference between 508 & 509 - silly me! I understand why 2k size is irrelevant!
  2. If there is no way to sync the slow-flashing RBG LEDs - then I hope they look pretty cool doing their thing at random!
  3. The crystal+12f508/509 sounds like a good idea to eliminate a component, although I think its cost would be minimal, but EVERYTHING HELPS. This may be a problem when it comes to putting online 1000 of them at the same time or sending them to my friends in other cities to put up for me. I didn't really think about this problem - so I appreciate that you got me onto thinking about it.
  4. I see the point that you are making about the power-draw of the microcontrollers.


Do you have any ideas how to power these things? How many button cells will I need or how many AAA bats? Maybe even 2 AA? What do you think? do you think that the buck&boost controller would be worth my time? These are some really pressing questions at the moment. Rough estimates and ballpark figures would do just as well...I kinda want to order some batts!
 
Last edited:

Wendy

Joined Mar 24, 2008
23,415
Sarcasm, sometimes it doesn't come across well. :rolleyes:

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).
 

Thread Starter

ZigZag

Joined Jul 22, 2010
264
Sarcasm, sometimes it doesn't come across well. :rolleyes:

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).
There was no sarcasm coming from me. I'm not sure if that is what you meant.

I read through the FE of your ebook (chapters 8&12), but I was unable to comprehend much of anything. I mean I don't even know how 555 ICs work, so I figured I'd have to set aside some time to read the whole thing.

I think this is exactly what I should do at this point anyway: I think I will be able to draw a basic circuit that you are asking for after that. It is a very easily readable guide.

I think two separate battery packs is a brilliant idea!

I don't think that I can justify the expense of a solar cell unless it can recharge the LED battery pack. Even then, the cost of rechargeable may put me over (I'm thinking about the retail prices for AAA & AA, so I'm sure I will be surprised how cheaply I can source them for). This is definitely something I will investigate.
 

Markd77

Joined Sep 7, 2009
2,806
I just remembered this: (I'm not sure how I forgot it because I use it every day).
The PIC (12F675) is similar but has analog capabilities and a few other tricks like an extra timer and the ability to use an external crystal for timing but still use the internal oscillator for code execution. The 508/509 always runs code at the external crystal frequency if a crystal is used.
None of these are really necessary - I just like making things complicated.

It turns a fairly bright LED on for 10 minutes when I turn my light off so I can find my way across my room. It then waits in low power mode for 8 hours and then flashes the LED in a doomed attempt to wake me up.
It is probably a good example of some of the things you are trying to do; it uses a high accuracy crystal to keep time and senses light. It also does software PWM dimming of the LEDs in the flashing mode. All in 225 program words (147 without the table for the sine wave flashing).
Rich (BB code):
    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
 

Attachments

Top