My Tachyon Forth, new experience
in Propeller 1
I have to take a break from C, FlexBasic, FlexC, so on and so forth. I decided to give Tachyon Forth a 10th chance, or there about.
So far so good, I think I am getting a grasp on the way the stack is used and how to do arithmetic, the fourth way. I have tachyon5v7 installed, I guess that is the latest.
Before I go any further, one big question, as you make or create the new words, how do you save them? Or do they have to b e recreated every time the processor gets re-started? The other question, where is a listing of the built in Tachyon words? I guess that should do it for now.
Ray
So far so good, I think I am getting a grasp on the way the stack is used and how to do arithmetic, the fourth way. I have tachyon5v7 installed, I guess that is the latest.
Before I go any further, one big question, as you make or create the new words, how do you save them? Or do they have to b e recreated every time the processor gets re-started? The other question, where is a listing of the built in Tachyon words? I guess that should do it for now.
Ray
Comments
For all the latest documentation and howto and links etc, just go to the SourceForge site in my signature.
Here is a quick link to a link page.
Ray,
I use TerraTerm as my editor for TAQOZ. After I write and debug my definition using the editor, I copy & paste it into windows notepad as a text file and save it.
I will put collections of words used to do specific things or to build more complex definitions into the same file. For example, a group of general words/aliases that I usually use is in file "general.fth" (I am not very creative when it comes to naming things.)
Then when I want to use a specific group of words I just open the file in notepad and copy and paste to TerraTerm and it loads into TAQOZ.
The P2 version can load words saved to the SD card. I'm not experienced enough with the P1 version to know how to do that on the P1.
Tom
Something weird is going on, when I type in 'HIGH 26', the LED is not turning on. When I type in 'HIGH 27', then 26 turns on. Before using HIGH, do you have to do an OUTPUTS of the pin that you want to turn on? If that is the case how would create a WORD that does the OUTPUTS of the pin you want to use. I guess, something like 15 highpin? I am thinking some how the word gets the pin number that will need OUTPUTS. I think that I am still thinking C and trying to translate to Forth.
Ray
I am looking at the 'TACHYON Forth GLOSSARY', for example: the way you would use that is - '15 DUP', assuming you have 'a' on the stack, it would print out 'a' fifteen times.
In the Starting Forth, it shows examples that use 'REPEAT', I take it that Tachyon uses DUP instead. In a nutshell, using a Tachyon word, you always put what is going on the stack first, then the word.
Ray
Is their any special reason why Tachyon is all upper case words, you would think that upper/lower case could be used. Does that mean that you could have two words like 'spaces' and SPACES'.
Ray
If you read from left to right word by word and number by number without skipping ahead and "process" each word as it comes then you will get the sense of what the "parser" does..... almost nothing
What happens here?
TF5> 1234 --- ok
The value 1234 is pushed onto the stack.PRINT (or the dot symbol) prints the number on top of the stack (and drops or pops it)
TF5> PRINT --- 1234 ok
Try putting a couple of numbers on the stack.
TF5> 1234 1000 --- ok
Those two numbers are just sitting on the stack waiting to be used (not really, but they are there). So let's multiply them together and print the result.
TF5> * PRINT --- 1234000 ok
Are you starting to get the idea? It is not trying to figure out the line of text, it just figures out each word as you type, and compiles that word as soon as you hit the space bar. By the end of the line it has already compiled all those words and is ready to run them.
btw, REPEAT is not the same as repeat in Spin. Use it in a loop that begins with BEGIN and includes a conditional WHILE.
TF5> 0 BEGIN CR DUP . DUP 10 < WHILE 1+ REPEAT --- 0 1 2 3 4 5 6 7 8 9 10 ok TF5>
I thought I would try the old turn an LED on wait a few seconds and then turn it off. I tried:
: onoff 26 HIGH 2000 ms 26 LOW ;
Would not get past the ms. Tried ms both in upper and lower case, did not make a difference. I am thinking put the value on the stack and then the command, in this case ms.
I am starting to think in terms of the "stack", is where everything happens.
Ray
I had to make some modification to the Spin file to have it start up in 80MHz mode. I also had it loaded to the EEPROM, for a known method of reboot.
Now it seems like Tachyon is starting to get flaky after awhile. I am not sure if it is the FLiP that is protesting, or maybe something else is occurring.
I have three different terminal programs that I can use, just in case it is a terminal problem, but it seems the same problem occurs, on all of the terminals. And by flaky I mean when I type in something like FORGET sometimes it works and then it starts show that the command does not exist.
Anybody have a lead on where I can get the binary that will run on the FLiP. I thought I downloaded the correct binary, but that did not run.
Ray
Propeller .:.:--TACHYON--:.:. Forth V5r7 NEON 570190926.2300 *** MODULES *** Propeller .:.:--TACHYON--:.:. Forth V5r7 NEON 570190926.2300 3C94: EASYFILE SDHC card + FAT32 Virtual Memory File System V1.2 171024-0000 300E: TOOLS DEV TOOLS 1AC0: EXTEND Primary extensions to TACHYON V5 kernel - 200514-0100 FREQ = 80.00MHZ *** INITS *** MOUNT 42DA NO ROMS *** I2C *** $A0 EE/RTC I/O = 31 :UHUU 27 :U~~~ 23 :~~UD 19 :~~~~ 15 :~~~~ 11 :~~~~ 7 :~~~~ 3 :~~~~ INTERCOM: &05.78.32.55 @3,990 CODE:$4D86 = 19334 bytes NAME:$52DC = 8484 bytes DATA:$7849 = 825 bytes FREE: = 1366 bytes Data Stack (0) Mon, 01 Jan 2001 00:00:00 UTC *Card Error* -------------------------------------------------------------------------------- TF5>
I have an LED connected on P28 so I type this:
TF5> 28 HIGH 2000 ms 28 LOW --- ok
For 2 seconds the LED turned off and then back on (wired active low)BTW, there is no need to put this in a definition (such as onoff), it will run just fine from the command line which is useful for testing etc.
For the source you can go to Tachyon/P1/V5/kernel/tachyon5v7.spin but because this is the output of a script that builds the kernel you will have to manually enable the 80MHz section but commenting out (or removing) the #ifdef and #endif for this setting.
#ifdef 80MHZ _clkmode = xtal1 + pll8x _xinfreq = 10_000_000 ' <--- AUTOMATIC 5 or 10MHz operation change at boot sysfreq = 80_000_000 #endif
Tachyon automatically works out if it is a 5MHz or 10MHz crystal, so there is no need to change this setting.
Ray
BTW - which Prop tool are you using to load the Propeller?
Maybe if you just force it to stay on 5MHz like this:
LINE 11: _clkmode = xtal1 + pll16x LINE 12: _xinfreq = 5_000_000 LINE 2599: 'word _0,FETCH,w+10000,@UDIVIDE+s,w+8000,EQ,_IF+03 LINE 2600: 'SETPLL word w+@_setpll+s,@aLOADMOD+s,RUNMOD
The last two lines are just when it decides whether to call the setpll routine which we just comment out.The setpll routine was something that PhiPi wrote years ago and it shoudn't matter if it is an oscillator rather than a crystal either since this routine runs fine on my boards.
I did the binary first, loaded it with Propeller Tool, and nothing was happening. I noticed that the binary file size is 64K, what happens when you load it to a FLiP which is 32K?
I also made the recommended changes to the .spin file, loaded it, and was still getting the same flaky results.
I guess I have a copy of Tachyon that runs, but it does not run as expected. So, it looks like it might be time to move on, again. I was hoping to get a little bit more distance out of this run with Tachyon.
Now I have to sit back and rethink what the next step will be. Maybe I am using the wrong processor for the stuff that I am doing. At one point it is a shortage of program memory, at another point it is the lack of availability of some well documented software. Forums are great, but well written software documentation is even better. I know everything is free and open, so make do.
Ray
Have you tried loading on other software onto the Flip recently to check that it works?
ANYONE WITH A FLIP? CAN YOU PLEASE TRY LOADING THIS BINARY TO MAKE SURE IT WORKS.
Serial terminal at 115200. The binary is 64k but the loader will only ever load the first 32k anyway.
Propeller .:.:--TACHYON--:.:. Forth V5r6 NEON 560190915.1000 *** MODULES *** Propeller .:.:--TACHYON--:.:. Forth V5r6 NEON 560190915.1000 3BE8: EASYFILE SDHC card + FAT32 Virtual Memory File System V1.2 171024-0000 2F78: TOOLS DEV TOOLS 1A40: EXTEND Primary extensions to TACHYON V5 kernel - 190916-0730 FREQ = 80.00MHZ *** INITS *** MOUNT 4228 NO ROMS *** I2C *** $A0 EE/RTC $C0 unknown I/O = 31 :UHUU 27 :~~~~ 23 :~~~~ 19 :~~~~ 15 :~~~~ 11 :~~~~ 7 :~~~~ 3 :UU~U INTERCOM: &15.55.55.55 @2,000,000 CODE:$4CD4 = 19156 bytes NAME:$52F0 = 8464 bytes DATA:$7849 = 825 bytes FREE: = 1564 bytes Data Stack (0) Mon, 01 Jan 2001 00:00:00 UTC *Card Error* -------------------------------------------------------------------------------- ...
I use 'propeller-load' for programming because I haven't got a proper PROP PLUG, only an FTDI module which I've modified to output RTS to reset the P1 for programming.
My Propeller board is diy with a 5MHz crystal, with 64k eeprom on ports P28 and P29. The terminal is connected to P30 and P31. An SDcard is connected to P0 to P3. Peter's TACHYON.binary is set up for the SDcard on other pins. To get the SDcard to work I input on the terminal : &03.00.02.01 SDPINS . Then the SDcard is recognised and tachyon remembers the new pins.
1. How are you powering your board? Check the supply voltages on the FLiP are within spec.
2. How are you programming your FLiP?
3. If it does program ok and you get a boot up message, what happens when you run this simple soak test by entering on the terminal:
BEGIN WORDS KEY UNTIL
It should repeatedly output the word list to the screen until you press any key, then you should get the tachyon prompt waiting for more input from you.
Cheers, Bob G4BBY
So, what is wrong with the FLiP that I was using. This is the worst case scenario, it gets a program loaded and it runs, but it does not work as expected. I used the same USB cable for both units. The reason that I switched the FLiP modules is because the other one was running weird with a SimpleIDE C program that I created. Now I have a FLiP that runs as expected, using Tachyon, but it runs flaky with the very short SimpleIDE C test program.
Scratching my head, do I now have two flaky FLiP modules, that still run programs, in a flaky manner. I thought the FLiP was supposed to be a highly reliable unit.
Has anyone created a diagnostic program for checking out the FLiP module. What would have to be checked, the RAM or the processor itself, or something else.
I guess if the FLiP cost a dollar, I could buy them by the dozen, and just toss them as they start to work flaky.
Ray
1. Please follow my advice above
2. If you can run the Tachyon soak test for 1/2 hr or more, then the EEPROM, crystal, USB link and quite a lot of the CPU are OK.
3. Try that on both modules
4. Have you ever reliably run the SimpleIDE C test program? If not, it isn't a useful test of the hardware - and it may have a bug in it that causes a crash after some time. Try simple SPIN programs and see if they soak test OK.
5. If you are getting power from the USB port of a PC, are you sure the PC is capable of giving enough? Some USB ports have limited output. Some USB ports require a command to raise the output power. If your P1 gets starved of power momentarily that could lead to unreliability
One of the problems with the USB spec right from the beginning was this reliance on 5V power over a long cable and still expect to get 5V. It would have been a much simpler matter to supply say 12V and switch down at the load. That way the current and thereby the voltage drop would be much less, but even so, there is plenty of headroom in 12V nonetheless.
The only issue now is, when you load up the Tachyon 64K version, and it starts up, it turns on the p26 LED on the FLiP. It occurs on both FLiP modules, so it seems to be a software issue.
More test to be done.
Ray
If none of your USB cables fixed the power issue, it's more likely the computer USB power source is current limited slightly below that required by the P1. The P1 will draw more current, the more instructions per second it has to perform. Maybe your C test program drew that little bit more current than tachyon and so crashed the cpu after a random time.
TF5> 27 HIGH --- ok TF5> 27 LOW --- ok TF5> : onoff 27 HIGH 2000 us 27 LOW ; TF5> onoff --- ok
Below is what I see on boot up, man that is a lot of stuff, I think. What are the implications of:
FREE: = 1366 bytes
how many words can be developed from this.
Ray
2000 us is only 2 thousandths of a second, so too quick to notice. Try 2000000 us ( 2 s ), your led switching should be slow enough to see then.
1366 bytes is (I think) the free space available for new words. Most calls to a forth word will take 2 bytes. This doesn't sound much, but you will be surprised how much forth you can write into that space.
I wouldn't be surprised if you want more space ( and you are not using an SDcard ), type FORGET EASYFILE <enter>. Check the extra space then available using the shortcut key combination <ctrl> ?
Remember that FORGET <forth word> will forget that word and all words defined after that word. Very useful when you want to start over.
This gain in space is not permanent; if you power off and on, it is lost. The new space can be permanent if you save the tachyon image to EEPROM before switching off; just type BACKUP and wait for the 'spinning' symbol to stop.
The word RESTORE loads tachyon into the P1. The word REBOOT is just like switching the P1 board on, a total restart
Tachyon is a bit of an elephant inside a P1, it does occupy a lot of space. Nevertheless, quite complicated programs are possible. With TAQOZ in the P2, you have a very large memory space available for user programs and data. I'm looking forward to experimenting with that, but after some time getting used to Tachyon.
It surprises me how little the Propeller community uses Tachyon or Taqoz. If they really got behind it, helped flesh out the missing documentation, and discovered how powerful it was..... Peter Jakacki has achieved so much with it, partly because he's very inventive and enthusiastic, but partly because forth makes for a very efficient programming language when you know it well. It all depends how much effort you are willing to put into learning the language and giving yourself enough time to play with it to find out what works. That doesn't happen overnight! I recommend reading the 'Starting Forth' and 'Thinking Forth' books in Peters' dropbox. They explain a great deal, and simply.
BTW, When I need even more memory I start with the kernel, add EXTEND, FORGET TOOLS, add EASYFILE, then RECLAIM unused private dictionary words. With that I have enough free memory to add EASYNET with FTP and HTTP servers yet still have enough memory left over for an application too.
STARTUP MESSAGES: (line number for reference)
1 Propeller .:.:--TACHYON--:.:. Forth V5r7 NEON 570190926.2300 2 *** MODULES *** Propeller .:.:--TACHYON--:.:. Forth V5r7 NEON 570190926.2300 3 3C94: EASYFILE SDHC card + FAT32 Virtual Memory File System V1.2 171024-0000 4 300E: TOOLS DEV TOOLS 5 1AC0: EXTEND Primary extensions to TACHYON V5 kernel - 200514-0100 6 FREQ = 80.00MHZ 7 *** INITS *** 8 MOUNT 42DA 9 NO ROMS 10 *** I2C *** 11 $A0 EE/RTC 12 I/O = 31 :UHUU 27 :U~~U 23 :~~UD 19 :~~~~ 15 :~~~~ 11 :~~~~ 7 :~~~~ 3 :~~~~ 13 INTERCOM: &05.78.32.55 @3,990 14 CODE:$4D86 = 19334 bytes 15 NAME:$52DC = 8484 bytes 16 DATA:$7849 = 825 bytes 17 FREE: = 1366 bytes 18 Data Stack (0) 19 Mon, 01 Jan 2001 00:00:00 UTC 20 CARD: SL08G SD03.80 #050D.A260 2016/2 !C0FF.80AF 1,866us 21 FAT: #2545.ADF1 MSWIN4.1 TAQOZ FAT32 7,944,011,776 bytes (32kB clusters) 22 -------------------------------------------------------------------------------- 23 TF5>
DESCRIPTION:
1 Kernel version and build timestamp with first 2 digits same as the version. 2 EXTEND is running and firstly it lists the main extend modules that it finds (version is reprinted) 3 Code address of module and name plus a description 6 Reported frequency (uses a backup of the value stored at address 0, since this location gets "clobbered" easily) 7 Lists the INITS that are executed by the autostart routine BOOT 8 First init is MOUNT at code address $42DA 9 Search for ROMS in upper EEPROM (needs a *** to delineate it perhaps) 10 I2C bus scan and possible identificaton 11 First I2C device at $A0 (or alt 7-bit notation $50) is always EEPROM but some chips include RTC 12 List I/O pin states - U for pulled up, D for pulled dowm, H for high output, L for low output, ~ for floating input 13 INTERCOM is the built-in console networking but does not default to any particular values (could make it) Settings are group:id:txrx pin:tx en pin(RS485) and baud (normally 2000000) Pins >31 are invalid and unused so txrx>31 means INTERCOM is disabled 14 Current code pointer and size 15 Current name pointer and size (builds down towards code) 16 Current data pointer - this area is separate from code and names for variables and buffers 17 FREE memory between end of code and dictionary not including data area and buffers. The dictionary is packed and points to code, so it can be stripped of private or unwanted headers and compacted Code memory can be released through FORGET <name> which resets code back to there and forgets all names up to there inclusive. 18 Stack list (should always be empty at 0 items) (Note: this is probably redundant) 19 Timers and time and date and maintained in the background although they are reloaded at boot from hardware if present. 20 Init SD CARD and display CID, serial number, mfg date, OCR with msb set as a flag, then average random sector timing test result 21 Mount FAT32 and report 22 Normal escape key DISCARD and cancel any input response is also a useful delineator 23 Standard prompt - this can be changed by the user (i.e. NULL$ ID!)
My guess is that Peter just uses it to drive an LED on to show that Tachyon (and any user application ) has successfully started when there is no computer terminal connected
So I notice that three extensions to the kernel language are loaded EXTEND, TOOLS and EASYFILE.
If FORGET EXTEND is typed in, the free space for a user program jumps up to around 20 kbytes. However, the BACKUP word is lost because it was defined in EXTEND.FTH
If the EXTEND.FTH file is reloaded via the terminal, the free space is then around 7.6 kbytes. I notice that EXTEND.FTH contains a lot of non-essential extensions for driving certain chips and so on. So EXTEND.FTH can be reduced in size quite a bit to regain more user program space, remembering to keep the BACKUP facility so the system can be saved off to eeprom. A useful exercise would be to see how small an EXTEND.FTH can be made and still do BACKUP ;-)
I've been looking for the source code for the TOOLS module, but haven't found it - can anyone point me to it please? Perhaps I'm having a 'senior moment'
If you want to start over by forgetting EXTEND you should really do a COLD start, or hit ^Z^Z shortcut. This leaves the kernel ready to take EXTEND again, but normally that would be unnecessary. What you might want to do at a later stage but not while you are learning, is to FORGET TOOLS which will forget EASYFILE and many of the tools and leave 11.5k free. BUT, DON'T DO IT as there is no need to and it will only hamper you.
BTW, COLD itself does not wipe the EEPROM since that would require EXTEND. If you reset after a COLD it will fire up normally with EXTEND.