Sharing variables , 1302 timing chipp clock
Hi people , need some help again ,
im tring to get the propeller chip to toggle a pin to set some lights to go on ,
but I want to do this at a time interval
. the big problem is that the time variables are in a diferent cog and I seem to be not getting it right
tryed to do it with lock , cause I know ther wil be data collisons if i don"t but can't get it right
please let me know if you seen the problem
cog 0 main method
THe pin toggle code
ANd the time stamp code's
im tring to get the propeller chip to toggle a pin to set some lights to go on ,
but I want to do this at a time interval
. the big problem is that the time variables are in a diferent cog and I seem to be not getting it right
tryed to do it with lock , cause I know ther wil be data collisons if i don"t but can't get it right
please let me know if you seen the problem
cog 0 main method
PUB main dira[21..22]~~ outa[21..22]~~ LCD.Init( E, RS, RW, DBHigh, DBLow ) {LCD init} LCD.usDelay( 5_000 ) {LCD init} LCD.Clear {LCD init} cognew(init,@stack) repeat repeat until not lockset(statusSemId) time if second < 30 set else reset lockclr(statusSemId) waitcnt(clkfreq + cnt)
THe pin toggle code
PUB set outa[22]~~ waitcnt(clkfreq/20 + cnt) outa[22]~ waitcnt(clkfreq/20 + cnt) return PUB reset outa[21]~~ waitcnt(clkfreq/20 + cnt) outa[21]~ waitcnt(clkfreq/20 + cnt) return
ANd the time stamp code's
PUB init statusSemId := locknew rtc.init( 20, 19, 18 ) {timekeeper init} repeat repeat until not lockset(statusSemId) rtc.readTime( @hour, @minute, @second ) 'read time from DS1302 rtc.readDate( @day, @month, @year, @dow ) lockclr(statusSemId) waitcnt( clkfreq + cnt ) PUB time LCD.RawSetPos( $01 ) {display time on first row lcd} LCD.PrintStr( decx(hour,2) ) LCD.Printchr( ":" ) LCD.PrintStr( decx(minute,2) ) LCD.Printchr( ":") LCD.PrintStr( decx(second,2) ) LCD.RawSetPos( $0B ) {display date on first row lcd} LCD.PrintStr( decx(day,2) ) LCD.Printchr( "/" ) LCD.PrintStr( decx(month,2) ) LCD.Printchr( "/") LCD.PrintStr( decx(year,2)) return
Comments
Your stack may not be large enough. Try doubling it in size. Also try doing a lockclr before calling cognew.
maybe it totally wrong.
maymee I see it bad but isint it supose to be a simple code ??
hope to hear from you
Next time, be sure to post your entire program including declarations and constant definitions. You also need to describe what the program does and doesn't do. Just saying it's not right or it doesn't work is not helpful.
lets start with what i'm trying to acomplis .
I have a lcd 20*4 , 4 pushbuttons , a 1302 timekeeping chip , and some ssr relay,s conected to the propeller.
The project was to create a menu structure on the lcd display, time and date where always on the first low of the lcd , and the other rows I used to scroll tru the different menu's .
in the menu's i have to be able to adjust the time of the 1302 timechip, and set the on and off time . for an it to trigger the light .
at first i had the problem of getting my time into the chip , no figured that out via the form ( previous post) turnd out that i had to adress the variables with byte[@ variable ] .
as that was finished , i created some var to hold the time to set the light to on and off. but I doesn't work
the problem i think is in the sharing the variables *** I want a diferennt cog to monitor the time and compare it to the alarm time to trigger .
so the trigger is not working correct to let the lights go on or off.
so the code works like this , the main method starts , where it controles the lcd enso , the different menus are enterd the same way so I'm gonna put only one or it will get to big
the I go to the sub menu 2 where this codes continues
ANd the pice of code where i allready got help with on the form , here is where I set in the time via the display and the pushbottons , and after that it gets trasnferd to the 1302 chip to set the time And the changing of the variables
beside thos theres the code that's reads the time and displays it
and then there is the pice of code where the problem is , this pice of code get's lauched in another cog, and should activate of disactivate the lights.(alarm on /off)
but it ain't doing just that. \
I hope this time my problem is understandable enoug to get some usefull advise on how to get it working, advise in any form is a plus *** i am learning myself to work with this prop but it's proving allot of fun and just can't stop imagining the possibilities , i
hope to get this sorted out
igor