31.5' C translates to about 86 F current OAT is 102 F. We live in Arizona where daytime temps are high andutility rates are even higher. My project is an Energy management system that never allows more than one AC unit (we have 3) to be on at one time. Oure rates are based upon the max usage during any prime time hour.
Next time I am on the computer, I will try the $50 0 RTC. Made an interesting discovery today, if prop plug connected to my device and the computer powered off, the prop will not run. With computer on and Tera term not on, prop will not run. Any ideas why?
Jim
This has always been the problem with those boards that have onboard usb serial but no provision for maintaining the signals in their default state when usb power is removed. Probably what's happening is that the rxd is dragged low which is a break condition that Tachyon detects as a request to reset.. over and over. I suppose i could add a float check on the break detection to disregard this undesirable condition that happens with all these usb equipped parallax boards.
Thanks for the overview of your project. I think even you get over these little good you should be coasting along. I'm thinking of visiting the grand canyon next year.
Thanks Peter. I figured there was some kind of an explanation like that. I discovered it when I fired up the prop with the computer shutdown and the cock was not running. I do hope that you have the opportunity to visit the canyon next year. I will look forward to the opportunity to meet you for an eyeball conversation.
A question regarding parsing the minutes out of the hhmmss from TIME@ ''##'' will that do it?.
Jim
Thanks Peter. I figured there was some kind of an explanation like that. I discovered it when I fired up the prop with the computer shutdown and the cock was not running. I do hope that you have the opportunity to visit the canyon next year. I will look forward to the opportunity to meet you for an eyeball conversation.
A question regarding parsing the minutes out of the hhmmss from TIME@ ''##'' will that do it?.
Jim
Remember that there is no lexing or parsing in Forth, each word must either be a number or a string or already in the dictionary or being created. Just let Forth do the work for you like this:
... 123456 100 / 100 MOD . 34 ok
Apply the same technique to the time to extract the minutes, that is divide it by 100 to get hhmm and then strip the hours by applying a modulus 100 which is effectively the remainder if you divide by 100. If you have a question, try it out first. In fact TIME@ just reads a 32-bit counter that is incremented every millisecond. In fact you could even read this variable directly and extract the minutes like this:
... .TIME 17:36:19 ok
... time @ 60,000 / 60 MOD . 36 ok
So we read the millisecond "time" and divide it by 1000 to get seconds and by 60 to minutes (60,000 total) and then strip the hours with a 60 MOD.
Peter,
I never think of using the MOD function to solve numeriic parsing problem. I can create a Minutes word that uses 60,000 MOD and 60 MOD and use that in my IF statement. I figured out that if I check for <20 Miinutes and >40 what is left is between 20 and 40 with no need for a complicated function to extract that.
Last night I let the CLOCK run over night. at 2300 hours it was fine. At 0500 this AM it look liked it was stuck trying to reset an 00:00:00. it would show the hours as 00 and the minutes and seconds would increment a little bit and try to reset. I will use that clue and try 235900TIME! and see what happens from there. Will also do the DUMP and see if it gives me any further clues. With getting a Temperature reading that is Reasonably close, I think I am reading the clock chip, just don't know if time function is correct. Will let you know when I get back on the computer.
Tried TIME@ 60,000 mod . And got mixed results. I assumed you ment TIME@ not TIME @.
Was trying to create a MINS word.didn't quite work. I realize if I get a 4 digit number begining with 10's of minutes, that is good enough as I can always compare with a 4 number such As <2000 or >4000.
Jim
Jim, I include actual terminal captures including the "..." prompt and the "ok" response so they are exactly what they are and you can always copy and paste that part of the line to be sure. There's nothing complicated about a division and then a mod and if you used it more than once in your code then I would probably make it a function too.
time @ 60,000 / 60 MOD
I copied and pasted this from the previous post and I've put extra spaces in it ( not a problem normally ) so that you can clearly see the name of the variable "time" being fetched "@" and with 60,000 divide "/" this then with 60 perform a modulus operation "MOD".
pub MINS@ time @ 60,000 / 60 MOD ;
So "time" and "@" is not the same as "TIME@".
Just set the time AND date and day anyway then without disturbing it dump the RTC registers. Do they look right as per the datasheet register map? (seconds, minutes, hours, etc). No? Store some values to a register and dump it again. Did it work? These are just sanity checks, you shouldn't have to do them normally but you are trying to find out whether you have a real or good DS3231 RTC chip or something different. I've got a DS3231 on my clock on the bench here and it ticked over and re-synchronized at midnight properly.
In fact I just checked it now and on the same line told it to print the time and dump the actual registers. Yours should look somewhat similar.
Peter,
First of all I must apologize for not reading and understanding your post showing me how to set up the minutes. I totally missed the lower case time, and jumped to confusions. No wonder I got it wrong! I cut and pasted your line of code and it works perfectly. When I figure out how I am going to do the actual output. I should have my program ready to test. I will need to set up 3 output masks, %001, %010 and %100 depending upon meeting the correct answers to day and time. Initially I will test my logic with print statements then with LEDS and finally with the actual conttrol relays.
Now on to the problem of the RTC, I set DATE! TIME! and DAY! and did a dump exactly like you show in your post. My RTC dump looks nothing like yours. In your dump I see the time, day and date clearly displayed in the first 7 characters of the dump. Mine look nothing like that. Mine look the same as the Screen copy I had a couple days ago. I am begining to think hardware issues. I may try this RTC on a different CPU board or try rewiring my breadboard connections to see if that resolves the issue. Or I may be casting about trying to figure out where to find another RTC.
I thank you for your support, and hope that I don't try your patience too much.
Jim
By the way, what is your time zone UTC + ?.
Jim - I'm always relieved when we stop running around in circles. It certainly is looking like a hardware thing. What is the part number on the chip? Do you have pullups on the I2C bus? What happens when you write different values such as $FF and 0. Does it look like this?
No, don't have pullups on I2C. Will add them and check again. 3.3 k ok? I was going to ask you if you had any connections to other pins. At work now, will do this tomorrow AM.
Jim
3k3 is fine, the absolute minimum requirement for most devices is at least a 10k pullup on SDA but preferably one on SCL as well and I prefer lower values if the lines run off-board, sometimes 2k2 even. The pull-up on the SCL is not always used and the reason is since most drivers drive the SCL line all the time. But while it is rare these days for slave chips to stretch the SCL line I know that the L3G4200D gyro chip drives the SCL low for stretching but Tachyon and most drivers don't support this directly.
The strange thing is that the temperature registers seem to be reporting fine when you dump the RTC registers. Did you try those two test lines?
First by writing $FFs to the registers
Good morning Peter,
Installed 3.3k pullups on SDA & SCL and all of a sudden I have clear communication with the clock. It rolls over at midnight changing the day and date correctly. Next test is to see if the battery backup is doing its thing correctly. I will power the clock down now and go eat breakfast. When I return to the clock, the unit will get powered back up and we will see if the clock functions as it should! Thanks for all the help.
Jim
Having issues with time keeping. Software clock loosing time after 2 hours. Will let it all run for 24 and see. Will in meantime check out RTC part number. And do an RTC dump.
Jim
Issue is a problem with pullups, clock keeps perfect time
Will run it for several days. May have to reinstall Tera Term as I am getting a bunch of characters with. Bit8 set. When I do a screen copy to a text editor the scrambled chars become normal. I have had issues with it in the past. I will let you know what I find.
Jim
If it has pullups then I can't see that being an issue. Out of curiosity I'd really love to see a clear photo or two of your setup. Maybe the problem is obvious once seen.
I've seen TeraTerm switch character sets to garbage characters but try sending a 14 or 15, i forget which, but that restores the character set. Of course, why the garbage in the first place?
14 EMIT or even just type a ^N or ^O. I will be able to check this shortly but obviously there is a hardware or software problem for this garbage on the display.
It's a 14 EMIT that changes TeraTerm's character set and a 15 EMIT that brings it back again. Make sure you don't take the photo too close where it's all blurred because hopefully we will be able to see what the problem is, if it's hardware (and don't change stuff for the photo).
Peter,
I got a photo of the board but have not figured out how to compress it to be able to attach it to the forum. Will do so as soon as I figure it out.
Jim
If I wish to "borrow" the SERLCD in another cog, say 4 can I issue the 3 cog stop and after use is done reissue a CLOCK Commad and have it restart?
Jim
Jim - any phone can crop and or resize a photo as usually the image viewer includes simple edit functions. If it is backed up to the cloud then the other way is simply to share a link to that photo. I'm especially interested in seeing your setup because it sounds like a hardware problem plus you were trying to use I2C without pullups but the EEPROM normally has pullups anyway etc. There is no problem with the software, it works. It is a very simple loop and I have confirmed that it works fine on my end on top of which I have been running a much more complicated version day after day. We need to look at the hardware.
If your clock code doesn't have the cog number locked in as in "3 RUN:" then yes but one cog won't work better than another so this is a dead end.
This is the default cog usage list here:
0: Tachyon console
1: Serial receive
2: Tachyon background timing functions
3..7: Tachyon IDLE (ready to receive a job with RUN or RUN: etc).
Ok,I never thought of just cropping the photo. That did it. Editing post from ipad. I am now sure that the last issue I had with the clock was hardware. I had tried to add the Parallax altimeter to the I2C buss and the pullups got moved and caused a bad reading on a bootup. Ran the clock for over 24 hours in current configuration and the time remained spot on. Battery backup failed when I tried it, I need to check battery, connections etc. The thoughts about stopping cog 3 from cog 4 and restarting it was an idea I had about sharing the display with a PB setting routine. Actually planning on using parallax 5 way switch to set the clock. I will use a second serial display to test all of the routines for clock setting then see if I can figure out how to insert into CLOCK. Does Tachyon have a builtin button debounce?
Does the Source for extend show how you Wrote the I2C read/write routines for RTC? I have another project on the shelf that I will be able to work on in OCT as I have a couple weeks of vacation comming and will spend it dog sitting and PROPELLERing.
I see in looking at expanded photo, the pullups are very slopply installed and could be sometimes shorting. I will clean that up right a way. Will also get rid of extra wires on I2C that were put in to test another piece of hardware. Even though pullups are sloppy, the clock now runs flawlessly. Sorry I put you through so much software handholding for a hardware issue.
Jim
I see in looking at expanded photo, the pullups are very slopply installed and could be sometimes shorting. I will clean that up right a way. Will also get rid of extra wires on I2C that were put in to test another piece of hardware. Even though pullups are sloppy, the clock now runs flawlessly. Sorry I put you through so much software handholding for a hardware issue.
Jim
Hey Hey Hey - but look at all the stuff you learned!
Conversely, when everything goes smoothly it's great but we don't learn much either. As long as we get it working in the end and we have fun and learn.
Yes, I learned a vast amount. Cleaning up the pullups and getting rid of the misc. wiring even allowed the battery back to start working. I have the rest of my program for the actual control worked out and will be entering and testing it later today. Still thinking about how I am going to set the clock with the 5 way switch. I think a state machine with cursor left right, digit increment and decrement will be the way to go. I will keep you posted on my other steps as I go along. By the way, if I download the listing of extend, will I be able to learn how you went about writing the commands to the RTC?
Later,
Jim
Once those DS3231s are set they should only need minor adjustment occasionally so I would prioritize the setting as a simple up/down by seconds. Debounce is actually very easy because all you need to do is accept any active signal but only poll it every 10 to 100ms or more. In your case as long as a switch is active you just keep repeating maybe five times a second and perhaps increasing the rate the longer it is held. As soon as you detect it has been released you can reset the rate and add an exit delay of maybe 500ms. Up/Down could be the +/- adjustment with left/right cycling through the units and push might be a quick exit while in the selection mode perhaps. Push can double as a menu button if you have some more functions you need setting.
Personally I would just skip these fiddly controls and add a Bluetooth serial module and access via a Bluetooth serial terminal app. I have one called "Serial Bluetooth Terminal" and it also has buttons that you can apply "macros" to.
IF do something
ENDIF
SWITCH MINS@
CASE = 0 ctlac 0 3 PINS! BREAK
CASE >40 shop 0 3 PINS! BREAK
CASE <20 dstairs 0 3 PINS! BREAK
ustairs 0 3 PINS! BREAK
1 second
AGAIN
am I going to get the results of:
0 minutes all off
1 to 19 minutes dstairs on
20 to 39 minutes ustairs on
40 to 59 minutes shop on?
I ask as I will not be able to get near the computer today to try it. Did try some IF statements yesterday and got a bunch of errors, so woke up this morning thinking OH I can use a switch case after I have fallen through the IF statements.
Jim
Trying to save a ROM (SIDCOG) to 5.4. All seems to work, I get the 'Saving to EEPROM' message, but no ROMS displayed on reboot.
I'm using a FLiP chip if that makes a difference-
@GHarris - I just tried this on 5.4 and pasted in the sidcog.hex file and it worked fine. What I did notice though was that I get a count of 069B which is the correct size yet your's shows $01FB as if you only had an incomplete hex file. Make sure you have line delay set to around 12ms but for a test I set mine to zero and while it dropped characters the count was still 061F.
Funny thing though, I just noticed your kernel version V5x4 which was one I used for testing so I removed that into a testing folder. Try the standard 5r4.
Comments
Next time I am on the computer, I will try the $50 0 RTC. Made an interesting discovery today, if prop plug connected to my device and the computer powered off, the prop will not run. With computer on and Tera term not on, prop will not run. Any ideas why?
Jim
Thanks for the overview of your project. I think even you get over these little good you should be coasting along. I'm thinking of visiting the grand canyon next year.
A question regarding parsing the minutes out of the hhmmss from TIME@ ''##'' will that do it?.
Jim
Remember that there is no lexing or parsing in Forth, each word must either be a number or a string or already in the dictionary or being created. Just let Forth do the work for you like this: Apply the same technique to the time to extract the minutes, that is divide it by 100 to get hhmm and then strip the hours by applying a modulus 100 which is effectively the remainder if you divide by 100. If you have a question, try it out first. In fact TIME@ just reads a 32-bit counter that is incremented every millisecond. In fact you could even read this variable directly and extract the minutes like this: So we read the millisecond "time" and divide it by 1000 to get seconds and by 60 to minutes (60,000 total) and then strip the hours with a 60 MOD.
I never think of using the MOD function to solve numeriic parsing problem. I can create a Minutes word that uses 60,000 MOD and 60 MOD and use that in my IF statement. I figured out that if I check for <20 Miinutes and >40 what is left is between 20 and 40 with no need for a complicated function to extract that.
Last night I let the CLOCK run over night. at 2300 hours it was fine. At 0500 this AM it look liked it was stuck trying to reset an 00:00:00. it would show the hours as 00 and the minutes and seconds would increment a little bit and try to reset. I will use that clue and try 235900TIME! and see what happens from there. Will also do the DUMP and see if it gives me any further clues. With getting a Temperature reading that is Reasonably close, I think I am reading the clock chip, just don't know if time function is correct. Will let you know when I get back on the computer.
As always I thank you for your wisdom and advice.
Jim
Was trying to create a MINS word.didn't quite work. I realize if I get a 4 digit number begining with 10's of minutes, that is good enough as I can always compare with a 4 number such As <2000 or >4000.
Jim
I copied and pasted this from the previous post and I've put extra spaces in it ( not a problem normally ) so that you can clearly see the name of the variable "time" being fetched "@" and with 60,000 divide "/" this then with 60 perform a modulus operation "MOD". So "time" and "@" is not the same as "TIME@".
Just set the time AND date and day anyway then without disturbing it dump the RTC registers. Do they look right as per the datasheet register map? (seconds, minutes, hours, etc). No? Store some values to a register and dump it again. Did it work? These are just sanity checks, you shouldn't have to do them normally but you are trying to find out whether you have a real or good DS3231 RTC chip or something different. I've got a DS3231 on my clock on the bench here and it ticked over and re-synchronized at midnight properly.
In fact I just checked it now and on the same line told it to print the time and dump the actual registers. Yours should look somewhat similar.
First of all I must apologize for not reading and understanding your post showing me how to set up the minutes. I totally missed the lower case time, and jumped to confusions. No wonder I got it wrong! I cut and pasted your line of code and it works perfectly. When I figure out how I am going to do the actual output. I should have my program ready to test. I will need to set up 3 output masks, %001, %010 and %100 depending upon meeting the correct answers to day and time. Initially I will test my logic with print statements then with LEDS and finally with the actual conttrol relays.
Now on to the problem of the RTC, I set DATE! TIME! and DAY! and did a dump exactly like you show in your post. My RTC dump looks nothing like yours. In your dump I see the time, day and date clearly displayed in the first 7 characters of the dump. Mine look nothing like that. Mine look the same as the Screen copy I had a couple days ago. I am begining to think hardware issues. I may try this RTC on a different CPU board or try rewiring my breadboard connections to see if that resolves the issue. Or I may be casting about trying to figure out where to find another RTC.
I thank you for your support, and hope that I don't try your patience too much.
Jim
By the way, what is your time zone UTC + ?.
Jim
The strange thing is that the temperature registers seem to be reporting fine when you dump the RTC registers. Did you try those two test lines?
First by writing $FFs to the registers Some bit will always read zero btw.
now all the first 14 registers show read 00
Installed 3.3k pullups on SDA & SCL and all of a sudden I have clear communication with the clock. It rolls over at midnight changing the day and date correctly. Next test is to see if the battery backup is doing its thing correctly. I will power the clock down now and go eat breakfast. When I return to the clock, the unit will get powered back up and we will see if the clock functions as it should! Thanks for all the help.
Jim
Jim
Will run it for several days. May have to reinstall Tera Term as I am getting a bunch of characters with. Bit8 set. When I do a screen copy to a text editor the scrambled chars become normal. I have had issues with it in the past. I will let you know what I find.
Jim
I've seen TeraTerm switch character sets to garbage characters but try sending a 14 or 15, i forget which, but that restores the character set. Of course, why the garbage in the first place?
I got a photo of the board but have not figured out how to compress it to be able to attach it to the forum. Will do so as soon as I figure it out.
Jim
Jim
If your clock code doesn't have the cog number locked in as in "3 RUN:" then yes but one cog won't work better than another so this is a dead end.
This is the default cog usage list here:
0: Tachyon console
1: Serial receive
2: Tachyon background timing functions
3..7: Tachyon IDLE (ready to receive a job with RUN or RUN: etc).
Does the Source for extend show how you Wrote the I2C read/write routines for RTC? I have another project on the shelf that I will be able to work on in OCT as I have a couple weeks of vacation comming and will spend it dog sitting and PROPELLERing.
Jim
Jim
Hey Hey Hey - but look at all the stuff you learned!
Conversely, when everything goes smoothly it's great but we don't learn much either. As long as we get it working in the end and we have fun and learn.
Later,
Jim
Personally I would just skip these fiddly controls and add a Bluetooth serial module and access via a Bluetooth serial terminal app. I have one called "Serial Bluetooth Terminal" and it also has buttons that you can apply "macros" to.
Jim
Continuing on, if I do this:
am I going to get the results of:
0 minutes all off
1 to 19 minutes dstairs on
20 to 39 minutes ustairs on
40 to 59 minutes shop on?
I ask as I will not be able to get near the computer today to try it. Did try some IF statements yesterday and got a bunch of errors, so woke up this morning thinking OH I can use a switch case after I have fallen through the IF statements.
Jim
Trying to save a ROM (SIDCOG) to 5.4. All seems to work, I get the 'Saving to EEPROM' message, but no ROMS displayed on reboot.
I'm using a FLiP chip if that makes a difference-
Thanks, George
Funny thing though, I just noticed your kernel version V5x4 which was one I used for testing so I removed that into a testing folder. Try the standard 5r4.
SIDCOG.HEX