Learning PropForth
artkennedy
Posts: 174
What is the significance of the dictionary words that begin with a leading underscore? I notice that some of them have near duplicates without the _ ?
Comments
If you do have a reason to mess with the support words, the different weird characters can indicate particular things
@word - fetch the value of this word
$word - the address of this word (that we need for whatever it does
.word - display the outout on the command line
!word - store the value(on the stack) in this word
Sal has (internal) uses which he designates with these characters
_word
_word_
(word)
but I have not had need of these yet, and have not documented these much
To learn PropForth, it is recommended to read through the propforth.htm, and do the examples in to the order presented (which you seem to be doing).
Take it slow, and when you finish each example, stop and mess around a bit. See what you can change and predict the results.
If something goes wrong (it will if you are doing it right and playing with everything) besure to RESET the prop beofre each new experiment. RESET of Power Cycle is the only way to be sure the device is in the known-good state. Trying to undo weirdness won't work well for a novice.
PF5.5 leaves junk on the stack after an unsuccessful dictionary search (if you type msmweotry the prompt says "UNDEFINED WORD" and it leave a number on the stack. Do sc (stack clear) to clear the stack and continue. This was used for debugging in development and accidentally left in the release. It doesn't affect anything, it just a PITA and has been fixed in PF6
After you are done with Propforth.htm, look at the test scripts. These show the proper use of each function tested.
The serial tests will should you how to set up multiple serial connections. these will work prop to prop with just 1k resistors (or bare wiress if you are careful). They will also work using an RS232 chip, but you have to make your own circuit.
Ask many questions, the documentation is a little weak in places.
I happen to be the Parallax poster child for wanting to learn PropForth too quickly. It does take time to sort out Forth from the special features of Forth on the Propeller.
The simple fact that 8 Cogs share the Forth dictionary and in PropForth, and that each cog is capable of providing an independent serial interface make for a substantial additional learning curve over traditional Forth.
The good news is that the Propeller is likely the best fit for any small microcontroller with Forth, more power and more flexibility to do interesting things.
If you enjoy puzzles, this one is a real sweetheart.
I found that study of mainstream ANS Forth on a regular PC in parallel helped me learn more clearly what is the Propeller and what is the Forth. GForth is available for FREE download with excellent documentation for Linux, Windows, and Apple computers.
And the Propeller have 3 version of Forth with very different approaches to learning and support.. consider all.
@Professor Brain
Where does PropForth stand in support for Full Duplex? I have forgotten if it is only half-duplex.
PropForth runs one Cog to support an RS232 port for the terminal and makes the other 7 cogs available for specific tasks.
pfth has the Forth kernel and an RS232 driver included in every instance started on every cog.
Tachyon has half the serial with the Forth kernel on one Cog and the other half (I think the Rx) on its own Cog.
++++++++++++++++++
And so, there is a huge debate about which is best. If you want a multiple RS232 port setup to distribute control and data, I am not really clear on which might work best.
OK, this is the fun part.
IF you want to use fullDuplexSerial4port or any other object from the obex (what an unfortunate choise of name, that, already being used for Ir and bluetooth. but I digress), If you wish to use SPIN objects, uyou must use SPIN, not propforth.
If you want to use propforth, then you can only use propforth, not SPIN, at this time.
While Propforth STARTS as a spin program, it loads itself up and is now an optimized assembler program. It does things in a particular way for particular reasons, SPIN does things in a particular way for SPIN reasons, the two methods are not very compatible.
Please finish with the SPIN material before you tackle the propforth, least you confuse yourself. SPIN is NOT needed to learn propforth, beyond loading the devkernel.spin program. When you get to propforth, little if any of the SPIN stuff applies, but all or most of the PASM applies. But you don't need PASM either, until you start getting a bit advanced.
To your question-
One MIGHT write a set of routines to allow Forth to call SPIN, or SPIN to call forth (I think Peter said something about this) but in the case of propforth, that would take too much memory footprint and prevent the things that forth is indended to achive. So Sal never took this on. While possible, it was not found to provide any benefit.
Propforth itself can do serial everywhere. I think the word is terminal, you just define the Tx and Rx pins, and set the baud and you are talking. The basic test is loop-back; cog A talks to cog B and it echos back to the user interface cog 6. The demo is in the test suite. (I don't have access to my stuff so can't be more specific, perhaps somebody con help find the exact file).
The standard serial is Asynchronous, it works fine up to 230400 baud. Prop to prop you can use straight wires Rx to Tx, or use a 1k resistor. If you need to connect to RS232, just follow the data sheet (I did it, so its not TOO hard). Propforth also does synchronous serial, but you also have to use a clock line (and understand synchronous). This is also in the test suite, in the multi channel serial section.
Loopy and caskaz have done the most work with it (AFAIK) please tap into their experience.
You are the target audience. Ask lots of questions, take it slow, we will try to get you up to speed.
Remember- reset or power cycle after every mistake!!!!
I may have misstated how the PropForth RS232 serial works. I have had success with getting individual cogs to have additional RS232 ports. So there is one Cog for RS232 to your user terminal, and up to 7 other Cogs can deploy RS232 ports. I previously had a special need for serial half-duplex that I couldn't sort out. There was lots of discussion bout work arounds or the possiblity of using Tackyon for that particular snag.
The Serial loopback example that PropForth provides is a bit unusual. It does an internal loopback. I would have preferred a good example that requires you physically wire inputs and outputs externally to do a loopback. But it does work and with a few bits of modification of pin i/o, you can also do the external loopback to verify that you have serial RS232 ports reaching the outside world.
These days, I have mostly been using pfth... just because it is easier for me to read the original PASM code to use Forth as a bridge to learning to code in PASM. I suspect that pfth might accept Spin objects on some Cogs with careful integration. It might even accept having a 4x serial object, but the real devil is how you buffer and manage all the traffic. Without a real world need to drive sorting out the details, exploring the idea might get muddled down in expecting too much.
I have mentioned numerous times that eForth has a very good presentation for coding Forth on any microcontroller and is a useful study resource for what an ideal Forth Kernel must include. Everyone here as done something a bit different than the eForth ideal, but that just adds depth to the information.
Since you are our 'target audience' according to Prof. Braino, you may have to avoid a few pot shots in your general direction. Welcome.
The problem is that I still don't know how it is done in PropForth. For instance if I connect my hp48 calculator's serial port ( through an appropriate adapter, if needed ) to P25 and P26 how do I redirect the serial i/o to those pins? And do I then write i/o code as if the calculator is a stand-in for the terminal?
So, if open a serial port on my pins connected to my calculator and go "65 emit" does an "A" show up on the calculator ( if it is looking for input, of course )?
That is to say, is terminal i/o directed to the newly defined serial port?
a. I am now working with pfth ver 1.03, not with PropForth ver 5.5 What I am telling you is from earlier experience with PropForth. But I got frustrated with PropForth and decided I need something that had a smaller load of documentation to read. So I switched to pfth and its commitment to ANS Forth.
b. pfth won't deliver the kind of serial port additions you desire. PropForth can, but you do have to muddle through the PropForth tutorial on serial loop back to get a clear understanding of how it works. I.d have to fire up a Propeller in PropForth 5.5 and explore just to get started again.
c. I don't think you will have any problem with using a "65 emit" to get an "A" on your calculator display... once you have a solid grasp of how to start another serial port, at the right baud rate, and on the right pins, and on a separate cog in PropForth. I am sure I could do that in a day or so... if I wanted to. But I believe that ALL serial is 8N1 format .... maybe no other configurations available.
d. My present situtation is that I started mentoring a small short project in pfth with another newbie to Parallax back in March of last year. And he has still gotten me exchanging emails on a weekly basis to get him going. Unlike you, he never used Forth before. So I am not sure how much time I want to get into direct exchanges of 'how to' specifics, 'why is this not working', and 'what do I do next'.
But I hate to completely turn away anyone that is making an effort. PropForth or Tachyon are more suitable for your objectives at this point.. just because of the multiple serial i/o. On the other hand, Dave Hein has gotten pfth to actually play chess on the Propeller with the user... being ANS Forth compatible offers other horizons.
Your next step in PF5.5 is to find the Serial Loopback Tutorial and attempt to do all of it. As I mentioned it is an internal loopback between to cogs. These to cogs are passing Rx and Tx via an inverted share of a pair of i/o pins. One cog's Rx pin is the other cog's Tx pin and vise versa. That is a clever bit of demonstration that I consider absolutely useless in the real world, but you can then do the loopbacks with un-shared pins and verify you have several cogs doing serial RS232 at the ttl level.
Of course, for your caluclator, you will have to get from the ttl levels (which I believe are inverted) to true RS232.
By the time you finish will all that you pretty much should have a ton of ideas and questions that you will want to explore. But you will be a lot closer to really using the Propeller in Forth.
You don't happen to know a muralist by the name of Patrick Curtis do you?
Here is the serial loopback tutorial. There was a whole set of tutorials in PF 5.0. If you can't find them, I have a .zip of the whole version.
Hey hey Springfield! I'm sorry you lost your friend. Sounds like some good times. We arrived in '72 and I hired on at the Lane Transit District and "drove bus" until 2010. If you rode a bus in this area during that time there is a chance that we are old buddies. I wiped out in a canoe on the McKenzie once. Did that twice on the Willamette and helped a friend destroy his sailboat on a tree near Harrisburg. Yeehaw!
The Springfield Creamery is now close to the Eugene Airport for easy shipment of Nancy's Yoghurt and speaking of Keesey this very evening some friends and I are going to the McDonald Theater for the premier of "Oregon Experience: Ken Keesey", http://www.opb.org/television/programs/oregonexperience/ .
If you take the Propeller and add an SD micro SDcard holder to it, you can extend the capacity of the Forth dictionary to loading and unloading additional word definitions as required.
One of the beautiful things about Forth of the Propeller is a Forth word definition can be a specific task. The task can then start up a Cog, run and release the Cog for another task. Given that there are 8 cogs and 28 i/o pins available, several tasks can be deployed independently at the same it.
If 28 pins is not enought i/o, there are ways to get even more i/o by using a shift register to use 3 pins of serial i/o to convert to 8, 16, 24, or more pins of parallel i/o.
Suddenly you have a huge open-ended expansion ability.
While that HP calculator might be an interesting user interface, you might find yourself a lot happier with a conventional notebook computer and a direct USB to serial interface to the Propeller.
I use minicom for a terminal program; others use PuTTY, and others use Terraterm. The main advantage is you have a Querty keyboard for input and a full screen for output. You really will go alot slower inputing alphabetical input on an HP48. Besides, programs can be written and saved as text files on the notebook computer and they just 'cut and paste' into the Propeller.
Consider buying a used EEEpc if you are on a tight budget, and load up Debian Linux to compile .spin files via Brad's Spin Tool.
And good news . . . the clouds are beginning to part a bit for me in PropForth - yea!
BTW, in "tutorial-3.2 Serial Loopback.txt" this line appears:
1. Run tutorial-1.1 Standard Developent System.txt
I have been unable to find that file on the forum. Could you point me to it?
And the lines with "---" "+++" and "###" are puzzling. Are they from an earlier version of PF?
The Keesey showing tonight was a cool scene.
I had used HalfDuplex.
I communicated between propforth and servomotor.
http://forums.parallax.com/showthread.php/138399-Propforth-5.0-is-available-for-download/page23
#445
Sorry, KMR-P4's HP lost link.
New page is http://kondo-robot.com/product/kmr-p4.
I communicated between propforth and BeagleBoneBlack.
Only receiving boot-log from BBB.
http://forums.parallax.com/showthread.php/146693-Propforth-v5.5-is-available-for-download/page5
#87
The PropForth Tutorial series is part of a PropForth V5.0 zip file. I am not sure I can post it as a download here. But it is worth a try.
TutorialIndex.txt
No joy in Mudville. I had to download bits and pieces as I don't have the .zip file.
The Google Code home for PropForth should have all this stuff if available, or maybe Prof. Braino can give you a better resource.
http://code.google.com/p/propforth/
C:\Users\Art\Desktop\TECH\Propeller\PropForth\V5.5\misc\2013FEB23mygo V5.5 RC1.zip\mygo\V5.5\kernels\doc\DEPRECATEDtutorials
Just never thought they would be that deep - "mygo" ?!!
Well I've got 'em now and won't have to bother you any more on that score.
I've learned a few things and gotten a little more comfortable but it was going kind of slow so I decided to see what Tachyon is all about. I am back now, trying to get my hair to lie back down on my head.
We had a contest quite some time ago and I created added material to the 3.2 serial tutorial as part of my entiy. I was trying to interface a shared Rx/Tx from 5.0 volts into the Propeller's 3.3 volt. But that is not really important. The document will fill in some background on multiple serial ports in PropForth as the tutorials are very compact and not much explaination.
I wish I could write as much as I want to, but a bad neck limits me to only a few hours of keyboard work per day. So I just can't write all and everything about Forth down.
The really fun part comes when you create Forth words that actually start a Cog, deploy a task in Forth, and then free up the Cog for the next thing you want to do.
This kind of has the feeling moving from a 1 cylinder motorcycle (of a single CPU microcontorller), to an 8 cylinder hot rod (the Propeller, of course). There is absolutely no reason to allocate one cog to one task perpetually unless it is the glue that holds your whole concept together. Retrive your cogs after the task is complete.
I don't think that PropForth ever wrote a tutorial for task start and release; but I began to fool with it in pfth. And I thing Tackyon has been using it to do some heavy lifting of a Propeller LAN interface.
When you get brave and add a micro SDcard, the RAM boundary of 32K is not so significant.
9.1.213 fl
\ fl ( -- ) buffer the input and route to a free cog
9.1.214 fl_in
\ fl_in - pointer to next character for input
9.1.215 fl_lock
\ to ensure one fast load at a time
. . . particularly "fl". On page 25 of the PropForth manual I see it is entered from the prompt and there is not comment about what is the action.
If you wish to know them, you should read forth-souece-codes.
But generally user don't need to know 'fl_in','fl_lock'.
You only write 'fl' at top of source-list.
I think user cannot forth-code even if reading manual many times.
I recommend writing codes for "LED-blinking","pwm","stepper-motor-drive",etc.
I also recommend forth-souece-codes.