"Forth of the Forth" Challenge (in December)

NEW LINK! Forth of the Forth Challenge page
As mentioned in mindrobots thread "Forthers-Thanksgiving-Challenge-it-s-all-about-the-projects-baby!!!" I am upping the ante by also including my own challenge which anyone can enter (except myself) and I am offering not only a 1st prize but also a 2nd and a 3rd ...... and of course we have to have a 4th prize.
Since this is the inaugural challenge the deadline for entries will be the 4th of December instead of April as I am hoping to do this again next year (with P2 hopefully). As long as the entry is in before the "4th" is over everywhere in the world (I think that's Honolulu time). The conditions for the inaugural challenge will be kept simple and so as not to add anything or take anything away from what I previously stated in the Thanksgiving Challenge thread I am copying the conditions here:
1st Prize is a P1145 "SongBox" board with a "Puppy Prop" module, QVGA Touch screen, USB and Bluetooth modules, matched enclosure and 4GB microSD and 4GB SD cards. The board includes stereo jacks for audio in (Sigma Delta) and audio out as well as RS-485 and USB style PS/2 connector. Power is either via the USB module or a micro USB socket.

Details of the 2nd, 3rd, and 4th prizes will be appended to this post shortly but they will all be Propeller products of some kind.
BTW, even if you have already submitted your project to the Thanksgiving Challenge, feel free to enter it in the "Forth of the Forth" challenge.
As mentioned in mindrobots thread "Forthers-Thanksgiving-Challenge-it-s-all-about-the-projects-baby!!!" I am upping the ante by also including my own challenge which anyone can enter (except myself) and I am offering not only a 1st prize but also a 2nd and a 3rd ...... and of course we have to have a 4th prize.
Since this is the inaugural challenge the deadline for entries will be the 4th of December instead of April as I am hoping to do this again next year (with P2 hopefully). As long as the entry is in before the "4th" is over everywhere in the world (I think that's Honolulu time). The conditions for the inaugural challenge will be kept simple and so as not to add anything or take anything away from what I previously stated in the Thanksgiving Challenge thread I am copying the conditions here:
Conditions are that this is based around a Propeller chip of course and that you use any Forth for the application code with assembler kept to an absolute minimum (remember, we are showcasing Forth). The application should be stand-alone and ready to run from power-up. Points given for readability so factor out those functions into smaller words and choose a name that describes it well and fits in well with how it is used. Additional points for keeping extraneous hardware to a minimum.
The time frame until Thanksgiving is probably a little short for this particular challenge so how about we set it for the 'Forth" of December 2012? Now if we had another one for the "Forth of the Forth" then that would be a very easy date to remember. We will see how we go with this one first.
Since time is short I won't impose any more conditions, just get to it and may the Forth be with you!
1st Prize is a P1145 "SongBox" board with a "Puppy Prop" module, QVGA Touch screen, USB and Bluetooth modules, matched enclosure and 4GB microSD and 4GB SD cards. The board includes stereo jacks for audio in (Sigma Delta) and audio out as well as RS-485 and USB style PS/2 connector. Power is either via the USB module or a micro USB socket.

Details of the 2nd, 3rd, and 4th prizes will be appended to this post shortly but they will all be Propeller products of some kind.
BTW, even if you have already submitted your project to the Thanksgiving Challenge, feel free to enter it in the "Forth of the Forth" challenge.
Comments
Great prizes! Hey, that looks almost like a commercial project :0) is there any way the losers would be able to buy one of the sweet Song Boxes???
Two Forth contests, folks! That should be enough to bring the Forth Faithful ut of the woods and maybe also draw some non-Forthers into the pool!!
BTW, have you noticed that the top 6 posts in this forum are all about Forth!
But fear not, I am pretty sure that I can come up with something interesting. I might even finish the project this time.
I wanted a project that would fit the seen by the majority of the Forumistas....not a serious tool meant for not very serious projects...or something that is mostly a figment of the imagination and as useful as most figments.
So, with a PPDB and Tachyon, I've come up with the Single Digit Clock!!! Yes, to prove the economy of Forth code, I'm making a clock with a single digit! It was going to be a QuickStart with a single large digit but delivery circumstance and Radio Shack's complete lack of LED displays have caused me to embrace my PPDB.
I've got the display working and just need to either get the DS1302 RTC on the PPDB working under Tachyon or else just let the Propeller keep time....I mean really, how much accuracy do you need with only one digit??
Video as soon as possible.
Come on, folks, time is running out, it's almost the FORTH of December!!!!!! The deadline approaches!!!!
Don't fear though, if you miss this Forth challenge, there's another just around the corner (maybe even prizes if I find a sponsor).....I promise it will be TIMELY!!
Is this one of those ones where you have to move your head from side to side or walk past to see it out the corner of your eye!!? Or is it in fact a count-down timer for the 21st? That would be timely!
Now, now, we mustn't ruin the surprise!!!
By the way, I finally have my Tachyon environment squared away and it's brilliant!! The LOOKUP word is near genius!!
Hopefully, my project write up will be a good tutorials in application development in Forth....or not.
Yes, timely indeed!! :0)
This is NOT going to be a continuation of the chopstick printer. And it will be in PropForth. And I hope it to be useful and informative to new PropForth users.
Anyway, we need more contestants or I will win a prize just by the default of too few entires. At this point, even if I enter, there will be two prizes that go unclaimed.
Forth is fast, fun, and furious. Or maybe I am just furious and Forth is fast and fun.
Come Forth you undeclared.
Working hard to pull this off. It is a lot of testing and writing.
Midway is an hour earlier (GMT-11) than Honolulu even so it might be one of the the last places where it would still be the 4th of December when every other place is the 5th. The point is, just submit your entry by the 4th while it is still the 4th somewhere in the world. For instance you are in Taiwan which is GMT+8 so therefore you have another 19 hours after the the 4th in Taiwan to submit an entry (I think that's right). If your project is near completion but not quite finished then submit it anyway, you will be allowed a little bit of extra time to complete it. This isn't a rigid regulated by law competition but a Forth for fun competition, remember, Forth is fun. Try to polish the code to increase your chances. That is besides being functional it should have form, and a certain "elegance" either in it's simplicity and clarity or in it's innovate approach to the task for instance.
I suffered a few rather interesting and unexpected setbacks and sorted out some rather gnarly problems. In the end, there may not be much to show for it, but the competitions are working their magic as learning experiences.
Of course everyone now knows that Parallax is running yet another contest with even more prizes that has deadline near Christmas , Dec 20th.
http://forums.parallax.com/showthread.php?144156-CONTEST-Hack-The-Halls!
I just finally got the last of the PropForth code to behave in actual testing.
So it seems, that I just have to type up a few corrections and this is ready to go. I just may make that 6am deadline and comply with 12 Midnight Honolulu time.
But now that I think of it, the guys in the USA have an advantage over me, it is still only December 3rd.
So be it. At least it is nice to finish something.
We need staggered start times!
Until Forth becomes very famous there is no "Forth of December" on the 4th day.
It probably doesn't matter much since there are 4 prizes, and up until now there have only been 3 responders to this thread. So you and I can battle it out for 4th place.
So, if you enter you win, assuming no one else pops up. I'll let you take the honors for our non-participation:)
\ ############################################################################ \ # toggle.fth - This program starts up a Forth cog that toggles P15 \ # \ # Copyright (c) 2012 Dave Hein \ # MIT Licensed \ ############################################################################ create cogstack 80 allot \ Allocate data stack space create cogreturn 80 allot \ Allocate return stack space create delaycnt 80000000 , \ This variable controls the blink rate hex \ This word toggles bit P15 every "delaycnt" cycles : toggle 8000 dirasetbit cnt@ \ Set P15 for output and get CNT begin delaycnt @ + waitcnt \ Wait "delaycnt" cycles 8000 outasetbit \ Set P15 delaycnt @ + waitcnt \ Wait "delaycnt" cycles 8000 outaclrbit \ Clear P15 false \ Load FALSE so UNTIL loops back until ; decimal create cogconfig \ Forth cog config structure ' toggle >body , \ Get execution token for TOGGLE cogstack , \ Initial value of stack ptr cogstack , \ Empty value for stack ptr cogreturn , \ Initial value of return ptr cogreturn , \ Empty value for return ptr \ This word starts a cog running the TOGGLE word : starttoggle forth @ cogconfig cognew ; \ +-------------------------------------------------------------------- \ | TERMS OF USE: MIT License \ +-------------------------------------------------------------------- \ Permission is hereby granted, free of charge, to any person obtaining \ a copy of this software and associated documentation files \ (the "Software"), to deal in the Software without restriction, \ including without limitation the rights to use, copy, modify, merge, \ publish, distribute, sublicense, and/or sell copies of the Software, \ and to permit persons to whom the Software is furnished to do so, \ subject to the following conditions: \ \ The above copyright notice and this permission notice shall be \ included in all copies or substantial portions of the Software. \ \ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, \ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF \ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. \ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY \ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, \ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE \ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ +------------------------------------------------------------------
@Dave: that's a lot of code just to toggle a pin!! This is how we blink an LED in another cog in Tachyon:
: BLINKY BEGIN #12 PINSET 100d ms #12 PINCLR 100d ms AGAIN ;
' BLINKY 4 RUN
My display words are working fine, I can decompose and compose number (pack and unpack) but for some reason my DS1302 just isn't working.
I'm sure it's something silly or something I don't understand about Tachyon, yet.
If anyone cares to look and/or is familiar with the DS1302, any suggestions would be appreciated.
\ \ DS1302 on PPDB \ Routines based on SPIN Example \ \ CE on Pin 17 \ I/O on Pin 18 \ CLK on Pin 19 \ \ DS1302 Command codes %10000000 CONSTANT rdsecreg %10000001 CONSTANT wrtsecreg %10000010 CONSTANT rdminreg %10000011 CONSTANT wrtminreg %10000100 CONSTANT rdhrsreg %10000101 CONSTANT wrthrsreg %10000110 CONSTANT rddatereg %10000111 CONSTANT wrtdatereg %10001000 CONSTANT rdmonreg %10001001 CONSTANT wrtmonreg %10001100 CONSTANT rdyrreg %10001101 CONSTANT wrtyrreg %10001110 CONSTANT rdctrlreg %10001111 CONSTANT wrtctrlreg %10111110 CONSTANT rdbrstreg %10111111 CONSTANT wrtbrstreg DECIMAL : DS1302_ENABLE ( pin -- ) 19 MASK OUTCLR MASK OUTSET ; : DS1302_DISABLE ( pin -- ) MASK OUTCLR ; : DS1302! ( data -- ) 18 MASK OUTPUTS \ set I/O PIN to OUTPUT 18 MASK SWAP \ set up the I/O pin on DS1302 (pinmask data -- ) 19 MASK OUTCLR \ force CLK lo 8 FOR SHROUT 19 MASK OUTSET NOP 19 MASK OUTCLR NEXT DROP DROP ; : DS1302@ ( -- data ) 18 MASK INPUTS \ set I/O PIN to INPUT 18 MASK 0 8 FOR SHRINP 19 MASK OUTSET NOP 19 MASK OUTCLR NEXT SWAP DROP ; : SET_SECONDS ( packed -- ) wrtsecreg DS1302! DS1302! ; : GET_SECONDS ( -- packed ) rdsecreg DS1302! DS1302@ ;
Even with a single digit clock, I can tell time is running out!!
You have to stop thinking in PropForth when you code in Tachyon. Tachyon is much cleaner and simpler if you just use the Forth.
Firstly:
Use constants for the I/O and define as masks in the first place
#P17 |< CONSTANT CE
#P18 |< CONSTANT I/O
#P19 |< CONSTANT CLK
Second:
: DS1302! ( data -- )
I/O OUTPUTS \ set I/O PIN to OUTPUT (normally redundant but needed for SHROUT)
I/O SWAP \ set up the I/O pin on DS1302 (pinmask data -- )
CLK OUTCLR \ force CLK lo
8 FOR SHROUT
CLK OUTSET
NOP
CLK OUTCLR
NEXT
2DROP
;
Thirdly:
: DS1302@ ( -- data )
I/O DUP INPUTS \ set I/O PIN to INPUT
0 ( mask data -- )
8 FOR SHRINP
CLK OUTSET
NOP
CLK OUTCLR
NEXT
NIP
;
Forth'ly:
Where are you using the chip enable? BTW, Don't bother defining words for these when they are very simple operations. Either say:
CE OUTCLR or CE OUTSET
Now, I'll leave the rest up to you...
BTW:
My second entry is a joint entry of Nick Lordi and myself. We started back in October. Nick presented me with a basic design for a breakout board for Propeller Platform for microMega's 64 bit Floating Point Co-process a small toolbox 2 dozen words to manipulate it.''
Our project is the completion of the breakout board, containing the FPU64, a Digilent PmodSF2 16 megabyte high speed serial flash, and a Parallax uSD card slot.
That done, the rest of the project is I have the FPU and the uSD running and about a third of the FPU's vast power evaluated .
I have become something of a Tachyon Forth Evangelista with this project. Even the 30% of the chip I have explored would have taken 2-3 times longer on any other Forth. Being able to build and run loops on the fly saves enormous time.
Below is the loadmap and all the files are in the zip
Propeller .:.:--TACHYON--:.:. Forth V21121114.1330 NAMES: $5BB1...7499 for 6376 (17644 bytes added) with 21061 bytes free CODE: $0000...357F for 7319 (0731 bytes added) with 19073 bytes free CALLS: 0447 vectors free MODULES LOADED: 34F5: BBR.fth Brian's Shortcuts - 20121203.2100 32A4: uMfpu64.fth Floating Point Math Chip Toolkit - 20121203.1900 2FF7: FPU64opcodes.fth List of opcodes as constants - 20121203.2000 2F50: LCD.fth small serial LCD toolset on pin 6 - 20121203.1200 279E: SDCARDmod.fth SD CARD Toolkit - 121023.2200 2713: SPI.fth Generic SPI Driver - 20121021.0000 1840: EXTEND.fth Primary extensions to TACHYON kernel - 121113.1200 ----------------------------------------------------------------
It as so easy to do things with TF that I made a shout out for "the other forth'
My newest Propeller Platform Through Hole board, you may remember, has two Atmel megabit EEPROMs giving a total of 256KB, or in other words slots for 8 boot images. Now slot 0 ($0000) is the default boot. Slot 1 ($8000) is used by Peter''s BACKUP/RESTORE commands ( the short story is, if you do a backup and TF detects you have at least a 64K EEPROM, it, first, copies the boot image in slot 0 to slot 1, then writes the new boot image from RAM to slot 0. The RESTORE command will restore the last image from slot 1 to slot 0 and reboot.
Now, the PropPlat TH has six(6) more slots, 2 thru 7 ($10000 through $38000) and TF has a copy EEPROM command ... EECOPY ( src dest bytes -- ) . Now both of these projects involved multiple files and changing one file from late in the load can be a real drag. RESTORE lets you back up one step. BUt judicious use of EECOPY gives you the power to step back to any of six milestones for the price of two dozen seconds of EECOPY time.
This also saved me much time in copy/pasting that didn't have to be done.
Hopefully, the added practical information will make more users interested in trying PropForth.
Peter tries to claim that Tachyon is easier to use, but I am not yet sure. It just might be that PropForth is just struggling to make their documents something other than 'dry as a bone' technical presentations.
In sum, it has gotta be fun and Tachyon does seem to be ahead in making it so.
Lots of time re-reading and re-typing. All the code has been tested with real hardware.
The bottom-line is still that I like to use my Propeller intereactively.... learning is more interesting.
Operations that change the depth of the stack require all of the stack locations to be shuffled. An operation such as ADD will leave one less item on the stack, so all of the other stack locations must be copied toward the TOS. Operations such as DUP and OVER will leave one more item on the stack, and the rest of the stack items have to be copied to the next stack location.
The version of Tachyon that I looked at uses 12 locations for the data stack, 18 for the return stack and 8 for a loop stack.
As I said before, the toggle code is intended to demonstrate the functionality of starting a Forth cog. It allows for quite a bit of flexibility, and would be even more complex if the programmer wanted to pre-load the Forth cog stack with parameters and provide an exit routine that automatically stops the cog. I'll probably write a program that demonstrates that capability. I'll also provide a few more words that hard-code stack sizes to make it simpler to start a Forth cog.
Hmmm... I know nothing about Forth programming but I would think it would involve a lot of pushing and popping so shuffling the stack every time seems like it might be cumbersome. I guess if it's done at COG speeds it's pretty fast though.