Need help with time counter an video out
Joar
Posts: 3
I hope some of you genius can help me with this.
I guess it's not so wery difficult... but I'm quite new to spin.
A firend of me has told me that this is a hopeless project... He is all into Atmel. But I think propeller / spin is more interesting. I like the video out option.
Here is my code:
As you can see I want a delay at power on, while displaying at text.
After this it sets pin [noparse][[/noparse]16] high, for switching another video signal to the monitor.
This part I got working.
The next I whant is to count the power on time (aprox in min, and I know my code is useless for this...)
And I need it to be stored in EEPROM when it looses power (one pin goes low), and read from EEPROM at next power on and continued to count.
For making the readout easy i need it to be put out on the monitor.
I guess it's not so wery difficult... but I'm quite new to spin.
A firend of me has told me that this is a hopeless project... He is all into Atmel. But I think propeller / spin is more interesting. I like the video out option.
Here is my code:
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ text : "tv_text" PUB start | count waitcnt(clkfreq + cnt) dira [noparse][[/noparse]16] := 1 text.start(12) Repeat Count From 5 To 0 'For every loop, Count decrements by one sec. text.out(13) 'Ny linje text.out(13) text.out(13) text.str(string(" Text 1")) text.out(13) text.out(13) text.out(13) text.str(string(" Text 2")) text.out(13) text.out(13) text.out(13) text.out(13) text.str(string(" ")) 'Sends a text string to the video monitor. text.dec(Count) 'Sends a numeric value to a video monitor. waitcnt(clkfreq + cnt) text.out(0) 'Blank screen text.start(12) repeat Count from 0 to 50000000 outa [noparse][[/noparse]16] := 1 text.out(13) text.out(13) text.str(string(" Time ")) 'Send a text string and counts number text.dec(Count) waitcnt(clkfreq + cnt) text.out(0) 'Blanks screen
As you can see I want a delay at power on, while displaying at text.
After this it sets pin [noparse][[/noparse]16] high, for switching another video signal to the monitor.
This part I got working.
The next I whant is to count the power on time (aprox in min, and I know my code is useless for this...)
And I need it to be stored in EEPROM when it looses power (one pin goes low), and read from EEPROM at next power on and continued to count.
For making the readout easy i need it to be put out on the monitor.
Comments
To start this up do a "COGNEW(countUp,@timeStack)" and it will maintain a minutes clock indefinitely. Saving the clock to EEPROM depends on whether you want to use the EEPROM for other things. You'd like to have "countUp" record the time every time the minutes increments, but, if other parts of your program are using the EEPROM, you need to lock it so that the "countUp" routine doesn't try to use the I2C bus or EEPROM at the same time some other routine is using it.
Post Edited (Mike Green) : 9/13/2009 10:38:20 PM GMT
Somewhere at the beginning of your program, you'd need to put
If the power goes off or other Propeller reset occurs, when the program is reloaded from the EEPROM, the value of "minutes" will be the value last saved.
You can call "saveTheTime" as often as you like. It will only write a value to the EEPROM if the time has changed and only if "saveTheTime" has been called at least twice.
Post Edited (Mike Green) : 9/13/2009 10:39:30 PM GMT
I'll read and try later today (and tomorrow..).
The power loss, is every time the user pull the power plug...
The counter is only for my use if the "customer" tells me that "the s hit only worked for 5 hours", then its good to know that the "s hit" has been powered up for 105 hours.
This user I dont trust for pressing a power button. When they are finished filming they will most likely pull the plug or stop the generator.
The timing is not a problem (I hope), I was thinking about connecting some parts directly from 12V and into one input pin. When this drops below 10V it's loosing power but if I have a capasitor on the 5V (or 3,3V) this will keep the power for the time it need for writing.
This I'm planning to use in a "field camera unit" or something like that. The users are smart as a bread when it comes to electronics...
Can anyone explain how i get the counter up on the lcd?
I only get "0"
2) In the last "repeat" in your main method, you've got "waitcnt(clkfreq)". It should be "waitcnt(clkfreq + cnt)"
3) Calling "text.start(12)" twice in your program doesn't do what you may think it does.· First it stops any existing video driver which causes the screen to blank.· Then it starts up a new video driver and clears the screen buffer.· Best thing is to only call "text.start(12)" at the beginning of your program.
Post Edited (Mike Green) : 9/16/2009 1:06:15 AM GMT