Shop OBEX P1 Docs P2 Docs Learn Events
Learning PropForth — Parallax Forums

Learning PropForth

artkennedyartkennedy Posts: 174
edited 2014-02-15 08:38 in Propeller 1
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 _ ?
«13

Comments

  • prof_brainoprof_braino Posts: 4,313
    edited 2014-01-10 04:39
    The ones WITHOUT the underscore are the ones we usually use. The ones with weird characters are support words; support words generally don't make much sense on there own, but are necessary to implement the word. This is in contrast with "atom words" like + @ ! etc that can be re-used in other functions

    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
  • prof_brainoprof_braino Posts: 4,313
    edited 2014-01-10 09:05
    I just ran across your other thread for RS232.

    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.
  • prof_brainoprof_braino Posts: 4,313
    edited 2014-01-10 09:07
    Also look at Loopy's and Rick's contributions in the downloads section of thje propforth wiki.
  • artkennedyartkennedy Posts: 174
    edited 2014-01-15 00:30
    Thanks Prof, I'm working on it. More questions soon.
  • artkennedyartkennedy Posts: 174
    edited 2014-01-15 00:57
    What I am struggling to understand right now is how to run fullDuplexSerial4port from Propforth. They are both spin applications, right? How does one do that. Do you load them both at the same time from the Propeller Tool? I am going through the Propeller Help Tutorial now - up to Spin lesson 8. Dealing with Spin and Propforth at the same time is trying to make my brain explode.

    :tongue:
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-01-15 03:15
    Hi,
    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.
  • artkennedyartkennedy Posts: 174
    edited 2014-01-15 11:09
    Hey, thanks. It's nice to have company. I first came to Forth about 30 years ago on one of the New Micro Inc. boards constructed just for Forth. It was a pretty nice environment and I wrote some fairly fancy code to control pumps and valves for a prototype solar heating system I had built. It worked quite well for a long time but the peripheral hardware I had designed and wired point-to-point was very complex so I wanted to build something simpler and with a better user interface. I flamed out several times on the "next version" due to the demands of "life" until I finally destroyed the system by redesigning the power supply just before a 30 day vacation trip. After a lot of false starts I have determined that the Propeller is the platform and by-gawd I'm gonna do it this time! Wish me luck and please stay tuned.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-01-15 11:48
    FYI, the RS232 serial port interface has been an interesting feature for the Propeller.

    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.
  • prof_brainoprof_braino Posts: 4,313
    edited 2014-01-15 14:22
    artkennedy wrote: »
    What I am struggling to understand right now is how to run fullDuplexSerial4port from Propforth. They are both spin applications, right?

    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.
  • prof_brainoprof_braino Posts: 4,313
    edited 2014-01-15 14:26
    artkennedy wrote: »
    ... first came to Forth about 30 years ago ... I flamed out several times ... I finally destroyed the system ...

    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!!!!
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-01-15 15:59
    I presume you mentioned the 4x serial port object because you need multiple RS232 serial ports. And while you may think you need full duplex, I am not sure that you is ultimately true, though it does seen fulll duplex is available in Forth on the Propeller.

    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.
  • artkennedyartkennedy Posts: 174
    edited 2014-01-15 23:21
    Fire away, Loopy. I'm sure I do not really need full duplex. I was just stuck on that because I was threading in a non-forth area and someone pointed me to fullDuplexSerial4port.spin. Then I got the idea that I had to get PropForth and .spin objects integrated somehow. Which lead to major confusion. I'm glad to know it is not possible - happy to stick with PropForth.

    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?
  • artkennedyartkennedy Posts: 174
    edited 2014-01-16 00:11
    Well, thar she blows. I found the serial word with its ability to set Tx and Rx pins. I had seen this before but with all the .spin stuff creating static between my ears I sorta lost it.

    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?
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-01-16 06:22
    Well, you backed me into a corner.

    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.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-01-16 06:38
    OMG, you are in Springfield, Oregon. I had a dear friend from there.. passed away though. His father owned the Roadway Inn near I-5. I have fond memories of fishing for trout on the McKenzie and the Willamette rivers. And of course there is the infamous Springfiled Creamery and the Merry Pranksters, etc..... swimming late night in the pool open 24hours/day for Weyerhauser employees after the taverns closed.

    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.
  • artkennedyartkennedy Posts: 174
    edited 2014-01-16 12:40
    Thanks for the tutorial. I'm sure it will help. Man, I know how hard it is to jump around among different implementations. I have quit this project several times over the years because it was so hard to code after such a long break but I am excited about the Propeller. I am about to achieve ignition.

    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/ .
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-01-17 01:51
    If you can sort of the RS232 tutorial, I have a bit more to extend that into a real world application. You may also talk to Peter J,, the Aussie that created Tackyon Forth for an alternative solution. He is doing a lot of very interesting stuff with Forth.

    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.
  • artkennedyartkennedy Posts: 174
    edited 2014-01-17 02:27
    One of the big goals is super low power and the hp48 does that. It also has a powerful real time clock system that can do things on schedules and the times themselves are subject to program modification etc. Also I am sure the calculator could send parameters and even forth commands to the Prop. Anyway I am pretty good with the hp user language which incidentally is a lot like Forth. It also has a good display and programmable menu system that should be quite useful in building a dedicated user interface.

    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.
  • mindrobotsmindrobots Posts: 6,506
    edited 2014-01-17 03:20
    The ---, +++ and ### were from an attempt to automate testing of Propforth. One is what is typed in, one is the response and the third is a seperator between steps or something like that. I don't havd the doc in front of me but once you figure out which is which, it is a little easier to read.
  • caskazcaskaz Posts: 957
    edited 2014-01-17 04:03
    Hi.
    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
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-01-17 05:28
    Hi,
    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/
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-01-17 05:39
    Just consider the ---. the +++, and the === stylistic window dressing of a text file. I think you can catch on to the difference in context that each represents.
  • artkennedyartkennedy Posts: 174
    edited 2014-01-18 02:15
    Oh, gawd . . . I finally found the tutorials buried in the 5.5 zip under
    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.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-01-18 09:01
    Well, you got a lot farther than I did with V5.5. I simply didn't want to deal with MyGo so I removed those files.. never considered looking for the tutorials therein.

    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.
  • artkennedyartkennedy Posts: 174
    edited 2014-01-18 22:21
    Oh, damn! Now I remember. This is Forth. You actually have to understand a lot before you can do anything of importance. That's ok, it's worth the effort. I'm on it . . .
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-01-19 06:11
    Hi Art,
    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.
  • artkennedyartkennedy Posts: 174
    edited 2014-01-19 21:41
    Thanks for the informative comment Loopy. Keep 'em coming. I feel for you with that neck pain. I drove public transit bus here for 37 years and my neck started hurting so much that I took a hand mirror to work with me to use at a certain railroad crossing where I had to look 'way back to my left. I was pretty lucky though when they finally exrayed my neck and found the inflamed nerve the doc just had me tale a lot of Aleve for a while and I'm much better now. It also helps to be retired. Hang in there.
  • artkennedyartkennedy Posts: 174
    edited 2014-01-19 23:36
    I am not clear on what this does . . .

    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.
  • caskazcaskaz Posts: 957
    edited 2014-01-20 00:19
    Hi.
    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.
  • artkennedyartkennedy Posts: 174
    edited 2014-01-20 00:21
    What are the meanings of the terms "Blocking" and "Non-blocking" in the manual?
Sign In or Register to comment.