pfth - An ANS Forth Interpreter for the Prop

1567810

Comments

  • iammegatroniammegatron Posts: 38
    edited 2013-12-08 - 18:32:19
    Dave Hein wrote: »
    Compiled Forth code usually references absolute addresses, so I'm not sure if J1 code compiled on a PC would work on a J1 VM running on the Prop. It would be a completely different Forth interpreter than pfth, so it would require quite a bit of work to get it running on the Prop.

    In my view, the best way to use pfth is under spinix where there is an OS for editing Forth source files and downloading from a PC. You could also run sdpfth, which works with an SD card, but is a stand-alone system.

    As I mentioned in post #261, bufser.fth will provide a similar functionality as PropForth's fl command. If you are using pfth without an SD card you would need to include bufser.fth in the Spin file using the FILE directive. You would then run bufser to load the buffered serial driver. When you want to download some code you would first run bufferit, and then paste the code into the serial terminal. After the code is pasted in type the ESC key to terminate bufferit. You then have to run evalbuf to compile the buffered text. I haven't used this in a while, so I'll check it to make sure it still works.

    Thanks for the answer. Forth's interactive programming method is very attractive. By typing "16 pinhi" to set a DIO high is very useful. In the spirit of "make-your-own-forth", I'd like to implement J1 forth VM on propeller, as a learning process of course.

    I am struggling with "interactive". Because if I have the J1 forth compiler running on the PC, I lose interactivity. It becomes what Peter called "sealed" code. On the other hand, if I make J1 compiler running on propeller, it could slow it down.

    It's a big design choice dealing with interactivity. That's why I am eager to learn how you would deal/or have dealt with it.
  • Dave HeinDave Hein Posts: 6,045
    edited 2013-12-08 - 18:46:46
    The J1 CPU is a very simple 16-bit stack-based processor. It should be fairly easy to write a J1 VM and run it in a cog. Then you would just need to get the Forth binary that runs on the J1. There may be existing J1 emulators that run on other processors that you could use for a guide. I sounds like you have a VM that runs on a PC.

    EDIT: To be honest, I don't see an advantage to running a J1 VM on the Prop. You will be limited to a 16-bit machine with only 16K of RAM. The return and data stacks are only 32 or 33 deep. It wouldn't support any of the Prop-specific features. The only useful feature is that you could run code compiled on the PC's J1 VM.
  • Dave HeinDave Hein Posts: 6,045
    edited 2013-12-09 - 13:58:50
    I looked at the J1 VM a bit more. It's pretty interesting. It looks like the code is compiled under gforth, and then run on J1. I found it interesting how he was able to switch vocabularies on gforth, and develop a J1 assembler and compiler under it. It demonstrates the power and flexibility of ANS forth. I might try to implement the J1 compiler in pfth some day. The J1 VM should be very easy to build. Something else to add to the TODO list. :)
  • Martin_HMartin_H Posts: 4,050
    edited 2013-12-09 - 17:16:01
    I also looked through the J1 pages and it's pretty impressive. He claims it gets 100 MIPS versus 0.1 MIPS for a typical 8 bit embedded Forth. What would be interesting to know is the cost per MIP because an AVR is about $3 and a Propeller around $10. So what does an FPGA cost?
  • KC_RobKC_Rob Posts: 465
    edited 2013-12-09 - 18:19:20
    Martin_H wrote: »
    I also looked through the J1 pages and it's pretty impressive. He claims it gets 100 MIPS versus 0.1 MIPS for a typical 8 bit embedded Forth. What would be interesting to know is the cost per MIP because an AVR is about $3 and a Propeller around $10. So what does an FPGA cost?
    He says it fits easily on a small Xilinx FPGA, so I would guess that, conservatively, we're looking at $8 low quantity.
    J1 is a small (200 lines of Verilog) stack-based CPU, intended for FPGAs. A complete J1 with 16Kbytes of RAM fits easily on a small Xilinx FPGA. Some highlights:
    • Extremely high code density. A complete system including the TCP/IP stack fits in under 8K bytes.
    • Single cycle call, zero cycle return
    • Instruction set maps trivially to Forth
    • Cross compiler runs on Windows, Mac and Unix
    Basic software includes a sizeable subset of ANS Forth and a portable TCP/IP networking stack.

    The CPU was designed to run Forth programs very efficiently: the machine’s instructions are so close to Forth that there is little benefit to writing code in assembler. Effectively Forth is the assembly language. J1 runs at about 100 Forth MIPS on a typical FPGA. This compares with about 0.1 Forth MIPS for a traditional threaded Forth running on an embedded 8-bit CPU.
  • Martin_HMartin_H Posts: 4,050
    edited 2013-12-09 - 19:01:13
    That makes the $ per MIP pretty compelling. So I can see why he created it.
  • twm47099twm47099 Posts: 851
    edited 2014-01-25 - 20:27:25
    "What is the real Forth?".....
    Programability at its utmost.

    I...

    Getting into faster and faster baud rates for the serial i/o has seemed another oddity for me. The Propeller can only fit 32K, so what is the need to feed it code at 115,200 baud? Are we just getting too greedy? Are users just naively demanding faster and faster speeds when they don't really know that what they have is adequate?

    A slower baud rate for the sake of loading will not lower the speed at which the program runs internally. If your serial port is only used as a user interface, why bother with 115,200 baud and crashes? 19200 baud is adequate until you have a true need for higher rates.

    If the Propeller is being overrun by the data feed, PuTTY and other serial terminal programs (TerraTerm or Minicom) do offer the ability to add delays after each sent character and after each sent line. I suspect that these delays might help some increases in load speed.

    I downloaded the latest version of pfth today and tried cutting and pasting some definitions I had in text files. Initially it didn't work; when I did the paste I got garbled characters (using TerraTerm). I was using my QS board and don't have an SD adapter for it. Then I remembered this post. I tried to change the baud rate to 9600 in one of the fth files (fds.fth) and reloading pfth. That didn't work; the baud was still 115200, but at the time I didn't feel like following up looking at the other files loaded at startup. So I added 10 ms delays after each character and line in TerraTerm. It still types faster than I do, and cut and paste works.

    Thanks again to the folks on this forum for interesting and useful software and helpful advice.

    Tom
  • twm47099twm47099 Posts: 851
    edited 2014-02-09 - 20:15:42
    I've tried extending propwords.fth to add counters. But it doesn't work.
    I think I am loading the correct values into ctra and frqa to turn on an LED (pin 16) at half power on my Quickstart board using Single ended - Duty mode.

    Code below
    After I type 'gocounter', nothing appears to happen. I do get the pfth 'ok', but no LED lights up. When I type ctra@ frq@ . . I get the values that were loaded using ctra! and frqa!.

    Here's the code, and I would appreciate any help.

    Thanks
    Tom

    ( Propwords2 -- adds counters -- CTRA and CTRB )
    
    hex
    
    ( Registers )
    
    : ctra@ 1f8 cog@ ;
    : ctra! 1f8 cog! ;
    : ctrb@ 1f9 cog@ ;
    : ctrb! 1f9 cog! ;
    : frqa@ 1fa cog@ ;
    : frqa! 1fa cog! ;
    : frqb@ 1fb cog@ ;
    : frqb! 1fb cog! ;
    : phsa@ 1fc cog@ ;
    : phsa! 1fc cog! ;
    : phsb@ 1fd cog@ ;
    : phsb! 1fd cog! ;
    
    1000000 constant scale256 
    10000 constant pinmask16
    18000000 constant ctrdutyse
    
    ( countermode -- dutycycle single-end - apin 0 )
    
    variable ctrmode
    
    
    ( select ctr apin use this method  )
    : ctrapin ( pin -- ) ctrmode @ or ctrmode ! 
    ; 
    
    : duty>frq
      scale256 * 
    ;
     
    \ Start counter turn on Led (P16) 1/2 brightness
    
    : gocounter
    80 duty>frq frqa!
    ctrdutyse ctrmode !
    10 ctrapin
    ctrmode @ ctra!
    pinmask16 dirasetbit
    ;
    
    
    
  • Dave HeinDave Hein Posts: 6,045
    edited 2014-02-10 - 07:30:34
    I don't have a QuickStart card, but I tried it on P15 on my C3 card, and it seems to work OK for me. After you run gocounter try typing the following:
    hex
    10000000 frqa!
    40000000 frqa!
    80000000 frqa!
    
    Does the LED change brightness? It does on my C3.
  • twm47099twm47099 Posts: 851
    edited 2014-02-10 - 09:13:58
    Dave Hein wrote: »
    I don't have a QuickStart card, but I tried it on P15 on my C3 card, and it seems to work OK for me. After you run gocounter try typing the following:
    ...
    Does the LED change brightness? It does on my C3.

    Dave,
    Thanks for the help. I tried the values you suggested, and the LED stayed dark. But knowing that the code worked I tried a few things.

    I tried a spin program from the propeller education manual that sweeps from 0 to full power and the LED did change brightness, and that worked but seemed to go to zero brightness sooner than I expected.

    Then I wondered about the QuickStart Board's LEDs since they have a built current limiting resistors (240ohm) and the education manual calls for 100 ohm.

    So I set frqa to $FFFFFFFF and the LED turned on. I tried lower values and found that I could not see the LED lit if I set frqa to less than about $80F00000.

    Thanks again,
    Tom
  • artkennedyartkennedy Posts: 164
    edited 2014-02-17 - 10:00:46
    This is awesome, Loopy. I'm going to save it somewhere I can easily find and reread.
    Public education is not real learning in the truest sense. Much of it is baby-sitting. The American system has actually set the bar pretty low. If you graduate from high school, you can make change at a 7/11 or write down a phone message for someone else.

    If you don't graduate from high school, you have to move furniture or dig ditches for a living.

    Nearly all that the USA educational system offers could be finished by grade 9, but students are kept in school for another 3 years as child labor laws don't want them taking jobs away from older folks.

    Most of us would have benefted greatly and matured more by finishing school at grade nine and learning about work and responsiblities at a much younger age. But instead, the movie and music industries exploit high school and university as periods of self indulgence.

    Still, really teaching and teaching well is both personally and materially rewarding.

    Try to be part of something good, rather than accept something as necessarily bad. It is the only way for the world to not get worse, and possibly get better.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-02-18 - 23:59:09
    @artkennedy
    Nothing to really do with pfth, which just happens to be my Forth of preference on the Propeller. So much of education has gotten into lots of hype about empowerment and achieving goals. It would be wonderful to just see it reliably produce people that could see clearly and think for themselves about the world around us.

    I prefer pfth just because it chose to adhere to ANSI and allow the support of a lot of good books to help the user rather than be creative and leave the new user adrift to understand the reasons behind non-standard features.

    In other words, there is a lot of continuity with what other have done in Forth.

    I do admit that Tachyon may still have a bit of an edge with speed and ehancemets, or that PropForth might try to expand into multiple Propeller machines.

    But there is a nice bit of sanity in that one can learn how the Forth Dictionary, the inner interpreter, the outer interpreter, the Data Stack, the Return Stack, and so on are all represented in a more or less standard way. One can actually read the .spin file and appreciate the way the components are working in harmony.
  • twm47099twm47099 Posts: 851
    edited 2014-03-02 - 18:50:10
    Martin_H wrote: »
    Dave, I read through this thread, downloaded pfth, read the readme, and installed it. It looks good, but do you have any examples of servo control using a background cog? The ability to save the workspace? I'd like to try my inverse kinematics code..

    @ Martin

    I've been working through the Prop Education Kit manual turning the Spin concepts into pfth words. I have a set of words that I use to control 2 servos in a background cog using counters. I am using pins 10 and 11 for the servo control lines on my Quickstart board. The 2 servos I am using are not matched (one is a 180 degree servo, the other a 150 degree) so the control values are different. I also had to get each servo to its starting position separately since I had been using the 5 volts from the QS board (from the USB port) and the current draw had caused the prop to reset. I've since used a separate 6v supply for the servo power.

    The first set of words are my basic definitions for using counters. After that is an example for running the servos. It can be run in either the main cog or in a separate cog. To run in main cog, enter the number of cycles, space, servo2 . To run in a newcog enter the number of cycles, space, gocogservo2. The code is pretty well commented (I apologize to forth experts who could probably do the code in a couple of lines).

    Tom

    decimal
    variable pinbits 
    
    : clrpinbits  0 pinbits ! ; 
    : mkpinbits  ( n -- ) 
      1 swap lshift pinbits @ or pinbits ! ;
    : microsec  ( n -- n * microsecs, eg n = 1,000,000 -> 1 sec ) clkfreq@ 1000000 / * ;
    
    hex
     ( CTRa, CTRb Words )
     ( Registers )
    
    : ctra@ 1f8 cog@ ;
    : ctra! 1f8 cog! ;
    : ctrb@ 1f9 cog@ ;
    : ctrb! 1f9 cog! ;
    : frqa@ 1fa cog@ ;
    : frqa! 1fa cog! ;
    : frqb@ 1fb cog@ ;
    : frqb! 1fb cog! ;
    : phsa@ 1fc cog@ ;
    : phsa! 1fc cog! ;
    : phsb@ 1fd cog@ ;
    : phsb! 1fd cog! ;
    
    1000000 constant scale256 
    10000 constant pinmask16
    0ff0000 constant pinmask16-23
    0ffffffc0 constant 0apin
    0ffff81ff constant 0bpin
    0fc7fffff constant 0plldiv
    
    \ --------------
    decimal
    
    2 constant ctrpllse        \ CTRx mode: PLL single ended (+1 = differential)
    4 constant ctrncose        \ CTRx mode: NCO single ended (+1 = differential)
    6 constant ctrdutyse       \ CTRx mode: Dutycycle single ended (+1 = differential)
    
    variable ctrcmd   ( counter command )   
    
    : clrctrcmd  0 ctrcmd ! ;           ( clear ctrcmd )
    : setctrmode  ( mode# -- ) 26 lshift ctrcmd @ or ctrcmd ! ;
    : setplldiv ( n -- ) 23 lshift ctrcmd @ or ctrcmd ! ;
    : setctrapin ( apin# -- ) ctrcmd @ or ctrcmd ! ;
    : setctrbpin ( bpin# -- ) 9 lshift ctrcmd @ or ctrcmd ! ;
    : ldctra ( --  )  ctrcmd @ ctra! ;    
    : ldctrb ( --  )  ctrcmd @ ctrb! ;    
    : duty>frq  ( duty -- )  scale256 * ;
    : xctra  0 ctra! ; ( stop ctra – ctrcmd not clrd )    
    : xctrb  0 ctrb! ; ( stop ctrb – ctrcmd not clrd )   
    : clrapin ctrcmd @ 0apin and ctrcmd ! ;  ( zero the apin bits )
    : clrbpin ctrcmd @ 0bpin and ctrcmd ! ;  ( zero the bpin bits )
    : clrpll ctrcmd @ 0plldiv and ctrcmd ! ;  ( zero the plldiv bits )
    
    \ #############################################################################
    \ #  cycles two servos, 1 on pin 10 w CTRa, 2 on pin 11 w CTRb
    \ #  to run in a separate cog - enter 'n gocogservo2' where 'n' is the desired number of cycles
    \ # 
    \ # (c) T Montemarano 2014 based on cogstart method by Dave Hein, MIT license
    \ #
    \ ##############################################################################
    decimal
    
    variable xyz    ( counter for begin-repeat )
    variable tt  ( storage for cnt )
    variable maxcycles  ( number of repeats )
    
    : servo2  ( maxcycles -- )
              ( cycles two servos, 1 on pin 10 w CTRa, 2 on pin 11 w CTRb)
              ( can be run in a separate cog - use 0counter.fth 'startcounter2' )
    
      clrctrcmd                \ set up ctra
      ctrncose setctrmode      \ mode: NCO single end
      10 setctrapin            \ pin 10
      1 frqa!                  \ 
      ldctra                   \ load ctra register
    
      clrctrcmd                 \ set up ctrb
      ctrncose setctrmode       \ mode: NCO single end
      11 setctrapin             \ pin 11
      1 frqb!
      ldctrb                    \ load ctrb register
    
      clrpinbits 10 mkpinbits 11 mkpinbits 
      pinbits @ dirasetbit        \ pins 10 11 to output
      65 -10 * microsec
      phsa!
      3 ms
      200 -10 * microsec
      phsb!
      3 ms
      1 xyz !                     \ initialize 'begin' counter
      cnt@ tt !
      begin
        xyz @ maxcycles @ < while    \ test begin-repeat condition
          200 70 do                \ cycle 'a' from 0.7 to 1.9 ms
            i -10 * microsec 
            phsa!                   \ load ctra phase register
            200 70 +  i - -10 * microsec   \ cycle 'b' from 1.9 to 0.7 ms
            phsb!                   \ load ctrb phase register
            20 ms                   \ delay till end of 20ms cycle
          loop
          200 70 do
            190 70 +  i - -10 * microsec   \ cycle 'a' from 1.9 to 0.7 ms 
            phsa!
            i -10 * microsec               \ cycle 'b' from 0.7 to 1.9 ms
            phsb!
            20 ms
          loop
         1 xyz +!                          \ increment ' begin' counter
      repeat
      10 0 do
       135 -10 * microsec phsa! 2 ms       \ center servo A
       150 -10 * microsec phsb! 2 ms       \ center servo B
       13 ms                               \ = 20ms - 2*(1.35 + 2) 
      loop
      xctra xctrb                          \ turn off ctra and ctrb
      cogid 0 > if cogid cogstop then  \ if run in a new cog release the cog
    ;
    
    
    create cogstack6  80 allot     \ Allocate data stack space For 'servo2' 
    create cogreturn6 80 allot     \ Allocate return stack space
    variable cognum6
    
    create cogconfig6              \ Forth cog config structure
      ' servo2 >body ,             \ Get execution token for SERVO2
      cogstack6 ,                  \ Initial value of stack ptr
      cogstack6 ,                  \ Empty value for stack ptr
      cogreturn6 ,                 \ Initial value of return ptr
      cogreturn6 ,                 \ Empty value for return ptr
    
    \ This word starts a cog running the SERVO2 word -- 'n gocogservo2'
      
    : gocogservo2 ( n -- )  ( n is maxcycles )
    
      maxcycles ! forth @ cogconfig6 cognew dup cognum6 !  
      ." 'servo2' started in cog number " . ." cogid stored in cognum6" cr 
    ;
    
    
  • twm47099twm47099 Posts: 851
    edited 2014-03-02 - 19:09:20
    @ Dave,
    I've been using pfth for a couple of months and am trying to understand how to use the sd card version. My experience with operating systems is very limited and dated (Windows and before that MSDOS and CPM); my experience with assembly language is limited to 8080 code, and that a long time ago.

    I connected the Parallax micro SD card adapter to the Quickstart board, and changed the pin definitions to match in the sdpfth Spin file. I used a 2 Gig microSD card.

    When I loaded the Spin file, I tried to connect to TeraTerm (the way I normally do), but I never got the normal 'ok'.
    A couple of questions:
    1. Is sdpfth supposed to be usable with the terminal program on the PC? If so, any ideas why it didn't work for me? I noticed that fds.fth is not set to be loaded from the Spin file.

    2. Or is sdpfth supposed to be for auto loading of forth files from the sd card. If so could you give an example of how a file 'test.fth' on the sd card would be loaded and run? Can fds.fth be loaded from the sd card and be used get communication through TeraTerm?

    Once I try to use ospfth (under spinix OS ?) I expect to have a lot more questions.

    Thanks
    Tom
  • Dave HeinDave Hein Posts: 6,045
    edited 2014-03-03 - 05:07:42
    If you're using pins 10, 11, 9 and 25 the SD driver will think this is a C3 card, and it will use a serial clocking method for the chip select. Change one of the pins, and that might fix the problem.
  • twm47099twm47099 Posts: 851
    edited 2014-03-03 - 09:58:32
    Dave Hein wrote: »
    If you're using pins 10, 11, 9 and 25 the SD driver will think this is a C3 card, and it will use a serial clocking method for the chip select. Change one of the pins, and that might fix the problem.

    Dave,
    When I tried the SD version I mentioned above I had changed the pin definitions in the con section of sdpfth.spin to:

    DO = 25
    CLK = 26
    DI = 24
    CS = 27

    Those matched the pins on the Quickstart board that I had attached to the micro SD card adapter (unless there is a switching of pins required? e.g. DO on the adapter connects to DI on the prop ?? I've had that confusion when using a bluetooth adapter until I realized that "IN" on the bluetooth = "OUT" on the Prop, but I assume that is not the case for the SD adapter- is that correct?)

    When I ran the spin file with those settings shown above I had the problem noted in the previous posting.

    I appreciate your help
    Tom
  • Dave HeinDave Hein Posts: 6,045
    edited 2014-03-03 - 10:47:28
    I suspect the mount is failing. Copy the attached file to your pfth directory, build it and try running it to see what it prints out. It calls the mount routine that I use in sdpth.
  • twm47099twm47099 Posts: 851
    edited 2014-03-03 - 12:35:17
    Dave Hein wrote: »
    I suspect the mount is failing. Copy the attached file to your pfth directory, build it and try running it to see what it prints out. It calls the mount routine that I use in sdpth.

    Dave, I tried the test and the SD mounted successfully. I tried sdpfth.spin again and I was not able to use an editor to communicate with the prop (never got the 'ok' either on terraterm or PST.)

    I tried the SD tutorial from the Parallax C Learning System tutorials. It worked.

    Any ideas?

    Thanks
    Tom
  • Dave HeinDave Hein Posts: 6,045
    edited 2014-03-03 - 12:55:18
    Can you run pfth.spin? Does it work OK with TeraTerm?

    Try setting the verbose variable before including the sd.fth file. It will look like this.
                  file      "propwords.fth"
                  byte      13, " 1 verbose !", 13
                  file      "sd.fth"
    
    This will print out the contents of sd.fth as it's compiling it.
  • twm47099twm47099 Posts: 851
    edited 2014-03-03 - 13:18:58
    Dave Hein wrote: »
    Can you run pfth.spin? Does it work OK with TeraTerm?

    Try setting the verbose variable before including the sd.fth file. It will look like this.
                  file      "propwords.fth"
                  byte      13, " 1 verbose !", 13
                  file      "sd.fth"
    
    This will print out the contents of sd.fth as it's compiling it.

    Dave,
    I can run pfth.spin and it works ok with TeraTerm.

    I added
    byte      13, " 1 verbose !", 13
    
    as you show above , but I don't get any printout in either PST or TeraTerm.

    I tried adding the above code to pfth.spin between the load of toggle.fth and primes.fth and I did get a printout in PST.
    I also tried with TeraTerm (connecting with TeraTerm and pressing the reset button on the QS board), and I did get a printout of the primes words as they loaded.

    Still no joy with sdpfth.spin

    Tom

    Tom
  • Dave HeinDave Hein Posts: 6,045
    edited 2014-03-03 - 13:35:52
    Well, let's try commenting out a few things. First try commenting out the FILE statement for linux.fth. If that doesn't work try commenting out the FILE statement for sd.fth. If that doesn't work comment out the call to spi.mount_explicit. That should work since you now have something that's similar to pfth.spin.

    If you have to comment out spi.mount_explicit to get it to work then the mount is failing, and we would need to try a few more things with sdtest to figure it out.
  • twm47099twm47099 Posts: 851
    edited 2014-03-03 - 14:28:00
    Dave Hein wrote: »
    Well, let's try commenting out a few things. First try commenting out the FILE statement for linux.fth. If that doesn't work try commenting out the FILE statement for sd.fth. If that doesn't work comment out the call to spi.mount_explicit. That should work since you now have something that's similar to pfth.spin.

    If you have to comment out spi.mount_explicit to get it to work then the mount is failing, and we would need to try a few more things with sdtest to figure it out.

    I commented out the FILE statement for linux.fth. I can connect with TeraTerm. What next?

    Tom
  • twm47099twm47099 Posts: 851
    edited 2014-03-03 - 14:41:47
    Dave,
    After I loaded sdpfth.spin (with linux.fth commented out), I loaded linux.fth using the cut and paste method. That seems to work.

    Can I now use this version of pfth to 'include filename' ?

    Thanks
    Tom
  • Dave HeinDave Hein Posts: 6,045
    edited 2014-03-03 - 15:01:41
    Well that's good news. Maybe there's not quite enough Spin stack space with linux.fth included. I get 41 longs of stack space when I do an F8 on the Prop Tool. Is that what you get? That's a bit tight, but it works OK for me. Maybe mount is using more stack space with your SD card for some reason. We could free up a little more stack space by reducing the padding buffer just before the FILE section. This is 100 longs, but I think it will work with 50. You could try reducing that to see if it works with linux.fth.

    linux.fth provides the LS, CAT, CP and RM words, which are used to list the file system, type text files, copy files and remove files. These aren't necessary, but they are useful. linux.fth also contains a CP1 word that I used when pfth only supported a single open file at a time. CP1 is no longer needed, and you can remove it from linux.fth. That would free up a few bytes for the stack.

    Since you can boot up with sd.fth you should be able to access the SD card, and use the INCLUDE command. You can copy all of the *.fth files to the SD card, and then use INCLUDE to load a file from the card.

    EDIT: I was typing this comment before I saw your last one. So yes, you should be able to run include now.
  • twm47099twm47099 Posts: 851
    edited 2014-03-03 - 15:31:19
    Dave,
    Thanks for your help. It all works now. I will try your suggestions regarding stack size.

    I saw that at the end of ospfth.spin there is a line:
    byte      " switch include _startup.fth", 13
    

    Is that used to load a file from the sd? (either the file referred to or an immediate 'include filename' in the filename specified in that line. If so can the include statement be used as an auto start? I'm wondering if I could use that to have a program start after a reset when it is not connected to a PC through the USB port?

    Thanks again,
    Tom
  • Dave HeinDave Hein Posts: 6,045
    edited 2014-03-03 - 15:56:46
    Yes, you could add a similar line to sdpfth.spin so that it would automatically include a file on startup. _startup.fth is specific to spinix because it changes to the working directory that the user issued the command from, and it can include files that were specified on the command line. However, you can create your own statup file that could run automatically.

    Note the "switch" word causes the input source to switch from the FILE input to console input, so you must the include after the switch, and before the carriage return character, 13.
  • twm47099twm47099 Posts: 851
    edited 2014-03-03 - 16:14:18
    Dave,
    Thanks again. I've been able to add an include word to the spin file and that file includes a number of my utility files. It works very well.

    Tom
  • Dave MatthewsDave Matthews Posts: 89
    edited 2014-03-05 - 12:09:17
    I sure have enjoyed all of these FORTH threads. Many, many years ago that was my preferred programming language, I loved the interactivity and expandability. Today I sampled a few of the propeller based FORTHs available and was very impressed, and soon became nostalgic. Here is a picture of my Brodie book...
    1024 x 768 - 84K
  • mindrobotsmindrobots Posts: 6,506
    edited 2014-03-05 - 12:48:46
    Your Brodie looks well loved! Mine went missing and had to be replaced by a newer one.
  • Dave MatthewsDave Matthews Posts: 89
    edited 2014-03-05 - 13:24:28
    I was consulting with a company that required me to learn FORTH, and was given an assigned reading list. The Brodie book was one of them. I think this was 1980 or so. In the following 15 years I produced a few commercial FORTH based commercial products, and a bunch of fun applications. Around that time the Radio Shack Color Computer was popular, and a FORTH eprom cartridge was available for that computer. That was fun!

    As a beginner FORTH was easy to master because of the well written and entertaining Brodie book. Other FORTH reference material I read at the time was more advanced, but bone dry. Leo Brodie made me laugh! I once recited a snipped of FORTH code that I had written at a cocktail party because it was so alliterative and fluid, it went over well as I remember.

    By the time the propeller came out I had been away from embedded controllers / processors for about 15 years. I found the SPIN language to be a perfect match for me, and I have decided to stick with it to gain some element of mastery of the language. But after having run the code examples, TACHYON in particular, I felt right at home. I expect I will do some development with FORTH on the propeller in the future, if just for old time's sake...oh, and translating some of my early fun FORTH projects to run on the propeller!
Sign In or Register to comment.