Forum Update - Announcement about May 10th, 2018 update and your password.

Tachyon NEON V5 (FAT32 and Ethernet Servers in 32kB EEPROM!)

2

Comments

  • MJBMJB Posts: 991
    edited March 29 Vote Up0Vote Down
    @MJB - Check out V5.2 as I am using that for testing with Ethernet.

    there might still be some alphas left in V5.2 - here just comment
    ... searched - did not find others
                 ' malphae the exponents equal
                  if_c      shr     manA, expA
                  if_nc     shr     manB, expA
    
  • Peter JakackiPeter Jakacki Posts: 7,047
    edited March 31 Vote Up0Vote Down
    Current NEON 32k binary with full EXTEND plus EASYFILE. Load this up with Spin tool or BST etc and it will automatically handle 5 or 10MHz crystals to operate at 80MHz. Connect a serial terminal (TeraTerm or minicom etc) at 115200-8N1.

    If you want to enable the SD card on your board just specify the pin numbers prefixed by & and each pin separated by a decimal point in IP format as &ce.miso.mosi.clk so that if CE = P25 and card data out = P24 and card data in = P27 and clock = P26 then enter:
    &25.24.27.26 SDPINS
    
    and this will be locked into EEPROM so it will automatically mount on reboot or manually type "MOUNT"
    The card detect is built into every SD card as a pull-up on CE so there is no need for a separate card detect input.

    Because this is a standard 32k image it is missing the ROMS but most casual users won't need these although it is easy enough to start with a fresh compile etc.

    NEON-180331.png
    1762 x 1336 - 65K
    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Tachyon Forth News Blog
    TAQOZ documentation
    Brisbane, Australia
  • I thought I'd play a little bit and convert my VGA Breakout game across to V5. Turns out that the code fits into 1kB and the source is less than 250 lines long.

    breakout.jpg
    TACHYON V5
    
    { BREAKOUT for 32x15 VGA text
    Updated for V5 NEON
    Code bytes used = 1020
    }
    
    TIMER duration
    
    --- square wave output audio pin
    pri audio	10 ;
    
    --- hitting a wall sound
    pub BONK			audio APIN  300 HZ 50 duration TIMEOUT ;
    
    --- palette to suit game
    TABLE gamepal
    	$0800.0800 ,	$0808.0000 ,	$F000.F000 ,	$F0F0.0000 ,
    	$8000.8000 ,	$8080.0000 ,	$2000.2000 ,	$2020.0000 ,
    	$8800.8800 ,    $8888.0000 ,    $2800.2800 ,	$2828.0000 ,
    	$5400.5400 ,    $5454.0000 ,    $A800.A800 ,    $A8A8.0000 ,
    
    --- palette colors
    0        := red
    1        := grn
    2        := blu
    3        := yel
    4        := mag
    5        := cyan
    6        := gry
    7        := wht
    
    --- back of the brick wall - leave room for the ball to bounce behind
    3        := backwall
    
    
    $7F00        := bram
    $03FC        := bval
    
    byte score
    byte balls
    
    pri BRICKS? ( -- cnt )
    	score C~
    	backwall cols * 2* screen + FROM 2 BY
    	cols 4* FOR I C@ 14 <> IF score C++ THEN NEXT
    	;
    --- calculate how many bricks have been removed and display
    pri .SCORE
    	BRICKS?
    	grn HUE cols 7 - 0 VXY
    	VGA score C@ .AS" ###/128"
    	<CR> balls C@ .AS" # balls"
    	;
    
    --- ball position variables
    word	bx
    word	by
    word	abx
    word	aby
    
    pri bdir 	0 >N ;
    
    --- initialize the brick wall with 4 rows of random colored bricks/tiles from backwall (gap)
    pub WALL	0 backwall VXY cols 4* FOR RND 8>> 7 AND HUE 14 VCHAR NEXT ;
    
    { The ball is drawn with a single character but by using codes which force the driver to access RAM
    for the font we can have finer movement by drawing a ball character dynamically in x 16x32 matrix
    Use code $3FA to access table at $7E80
    This routine is essentially the same as VCHAR but optimized for directly writing without scroll
    Execution time: 48.8us
    --- 10-bit character
    }
    pub VCHAR! ( ch -- )
    	--- (color << 1 + c & 1 )
    	DUP 1 AND color C@ 2* +
    	--- form color field
    	2* 1+ 9 <<
    	--- merge 7 msb of data
    	SWAP 1 ANDN +
    	--- current screen position
    	row C@ 5 << col C@ +
    	DUP 960 <
    	--- write to the screen word & inc column
    	IF 2* screen + W! col C++ ELSE 2DROP THEN
    	;
    
    
    TIMER balldly                            --- timeout leads to next ball movement
    word speed
    
    
    --- rebound translation table looks up the corresponding rebound direction ( 7 into left returns with 9 )
    TABLE rebound
    ---    0   1   2   3   4   5   6   7   8   9
        0 | 7 | 8 | 9 | 6 | 5 | 4 | 1 | 2 | 3 |             --- bottom/top rebound
        0 | 3 | 8 | 1 | 6 | 5 | 4 | 9 | 2 | 7 |             --- left/right rebound
    
    --- lookup the table for the rebound action & sound
    pub BOUNCE ( table-offset -- )	rebound + bdir + C@ ' bdir C! BONK ;
    pri BALL@ ( -- word )		bx W@ 2/ 2/ by W@ 3 >> cols * + 2* screen + W@ ;
    
    --- read the contents of the screen cell/tile where the ball will be next
    
    pub NOBALL
    	bx W@ 2/ 2/ by W@ 3 >> VXY
    	$20 VCHAR!
    	;
    
    pri !BALL
    	NOBALL
    pri NEWBALL
    	64  bx W! 60  by W!
    	50 speed W! 1 ' bdir C!
    	--- delay serving 1st ball for 1.5secs
    	1500 balldly TIMEOUT
    pub BALL
    	--- limit ball x
    	bx W@ cols 2* 2* MIN bx W!
    	--- limit ball y
    	by W@ rows 2* 2* 2* MIN by W!
    	--- bounce off special tiles (not blank or alphanumeric)
    	BALL@    >B 20 'z' WITHIN NOT IF 0 BOUNCE EXIT THEN
    	--- bounce off bottom
    	by W@ rows 3 << 1- =>  IF 0 BOUNCE EXIT THEN
    	--- bounce off top
    	by W@ 1 < IF 0 BOUNCE EXIT THEN
    	--- bounce off left wall
    	bx W@ 0= IF 10 BOUNCE EXIT THEN
    	--- bounce off right wall
    	bx W@ 2/ 2/ cols => IF 10 BOUNCE EXIT THEN
    \ pub DRAWBALL ( -- )
    	--- plot ball as 4x4 block - 185us
    	wht HUE bx W@ by W@
    	--- address the screen position for the tile - 17.2us
    	OVER 2/ 2/ OVER 2/ 2/ 2/ VXY
    	--- maps to programmable char at $7E80 - 63.6us
    	bval VCHAR!
    	--- generate a dot in the correct x position - 7.8us
    	SWAP 3 AND 2* 2* 2* $AA SWAP <<
    	--- wipe the character clean - 64.6us
    	bram 128 ERASE
    	--- calculate y position in character - 8.4us
    	SWAP 7 AND 4 << bram + ( mask addr )
    	--- create the pattern
    	SWAP OVER ! DUP 4 + 12 CMOVE
    	;
    
    --- setup constants for ball x and y movement increments which contain 2 fractional bits
    1    := abxcon
    1    := abycon
    
    pri BALL+! ( x y -- )
    	NOBALL
    	by W+! bx W+!
    	BALL
    	;
    
    --- Check if ball is ready for next movement and proceed
    pub ?BALL
    	--- ready yet?
    	balldly TIMEOUT? 0EXIT
    	--- yes, set next timeout period
    	speed W@ balldly TIMEOUT
    	--- proceed using the ball direction
    	bdir SWITCH
    	7 CASE abxcon NEGATE abycon NEGATE BALL+! BREAK
    	9 CASE abxcon abycon NEGATE BALL+! BREAK
    	1 CASE abxcon NEGATE abycon BALL+! BREAK
    	3 CASE abxcon abycon BALL+!  BREAK
    	;
    
    
    --- paddle xy
    byte px
    byte py
    
    --- two characters that make up the paddle
    $8E88        := mypad
    $2020        := nopad
    
    --- draw the paddle
    pub PADDLE ( shape -- )		yel HUE px C@ py C@ VXY W>B VCHAR VCHAR	;
    
    
    --- PADDLE MOVEMENTS
    pub L    		px C@ IF nopad PADDLE px C-- mypad PADDLE THEN ;
    pub R    		px C@ cols 2 - < IF nopad PADDLE px C++ mypad PADDLE THEN ;
    
    --- check to see if the ball has hit the paddle and which change it's direction based on the edge hit
    pub ?PADDLE		mypad PADDLE ;
    
    pri NEWPADDLE		rows 1- py C! 15 px C! mypad PADDLE ;
    
    pub GAMEOVER            red " GAME OVER" ( 11 8 TEXTBOX ) CON CONSOLE ;
    
    pub NEWGAME
    	VGA CLS NEWPADDLE NEWBALL WALL
    	7 0 VXY 2 HUE PRINT"  TACHYON BREAKOUT "
    	3 balls C! score C~
    	;
    
    pri FASTER		speed W-- ;
    pri SLOWER		speed W++ ;
    
    --- game control keys ---
    pub GAMEKEY
    	KEY ?DUP 0EXIT
    	SWITCHES
    	'Z' L   	'X' R
    	'z' L   	'x' R
    	'+' FASTER   	'-' SLOWER
    	'B' !BALL  	$0D NEWGAME   	$1B GAMEOVER
    	;
    
    pub ACTION
    	--- make it speed up proportionaly to the score
    	130 score C@ - 3 / speed W!
    	GAMEKEY
    	?BALL
    	?PADDLE
    	duration TIMEOUT? IF MUTE THEN
    	.SCORE
    	--- testing: autostart a new game
    	score C@ 128 = IF NEWGAME THEN
    	;
    
    pub BREAKOUT
    	!VGA
    	audio APIN MUTE  0 duration TIMEOUT
    	gamepal colors 64 CMOVE
    	NEWGAME
    pub RESUME
    	30 FLOAT
    	VGA BEGIN ACTION AGAIN
    	;
    
    END
    1395 x 776 - 65K
    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Tachyon Forth News Blog
    TAQOZ documentation
    Brisbane, Australia
  • what about TAQOZ? just five days left...

    Mike
    I am just another Code Monkey.
    A determined coder can write COBOL programs in any language. -- Author unknown.
    Press any key to continue, any other key to quit

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
  • Hi Peter,

    I've loaded up the v5.2 binary, and run the refactored stepper motor code, works fine.

    Thanks for your advice about refactoring, by the way structuring the code in a semi-naturalistic way is one of the intriguing things about Forth. I'm very much a Forth noob of course, so it will take some time for me to acquire any degree of skill. I have an electronic copy of Brodie's Starting Forth, so that should help :)

    One thing I am having trouble with is applying the v5.2 EXTEND code (I want to remove the LCD, VGA and KEY modules as I don't need them). I commented out the first line with \ <space> as directed, Ctrl-A to select all the code, and pasted into the minicom windows as I did with v4.7. I noticed the system throwing up errors as the file was processed:
    ...  \                                                                                  
    ...                                                                                     
    ...  TACHYON V5   Propeller .:.:--TACHYON--:.:. Forth V5r2 NEON 520180323.2200          
    0100   ok                                                                               
    0200   ok  ???  ???   ok                                                                
    0300                                                                                    
    0400                                                                                    
    0500   ok  ???   ok                                                                     
    0600                                                                                    
    0616  ??? in s at CLKFREQ                                                               
    0632  ??? in M at 1M      �                                                             
    0700   ok            �                                                                  
    0726  ??? in $= at FALSE    
    etc.                                                            
    

    My line delay is set to 30ms (I upped it from 15ms to see if it had any effect).

    Any ideas?

    A>

  • A> Now that looks like you might actually have to load in the kernel with the Prop tool or similar, and then paste EXTEND. Perhaps I've made some change but at least try that. I even tried COLD (or ^Z^Z) and loaded EXTEND back in without incident.

    Of course you could simply FORGET VGATEXT and that will remove all the other modules including the extra tools, which you could reload again and BACKUP.

    Which terminal emulator are you using btw? I run minicom in Linux with 8ms line delay.

    I have to mention though that V5 doesn't try to convert case, at least I haven't decided yet if it is as good as an idea it once seemed anyway. But for larger blocks of source it is more efficient to have them beginning with TACHYON and terminated with END.

    Don't miss clicking on my "Use the Forth" logo to take you to the links and intros etc.
    Cheers!
    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Tachyon Forth News Blog
    TAQOZ documentation
    Brisbane, Australia
  • lmclarenlmclaren Posts: 99
    edited April 29 Vote Up0Vote Down
    Hi,

    I am seeing the same problem as A>

    I have a fresh build, I had to compile as I am using a 12MHz xtal.
    I loaded Extend without a problem but when I try to load EASYFILE it get errors and it then a hang.

    I have tried different serial delays, different serial programs, different editors to clean up files (I was concerned that there may have been hidden chars) but not joy.
    I have even tried archive versions of EASYFILE etc.

    I am using Terraterm from windows atm.

    The only thing from standard is that I did not load VGA from EXTEND as I am using only a serial console.

    Any suggestions?

    ...
    
      Propeller .:.:--TACHYON--:.:. Forth V5r2 NEON 520180323.2200
      *** MODULES ***  Propeller .:.:--TACHYON--:.:. Forth V5r2 NEON 520180323.2200
    3386: TOOLS            DEV TOOLS
    30DE: CHARLCD          BUFFERED CHARACTER LCD
    1982: EXTEND           Primary extensions to TACHYON V5.2 kernel  - 180322-1300
    
    AUTORUN BOOT 3076
    FREQ = 96.00MHZ
    *** INITS ***
    *** ROMS ***
    E01C: VGA32x15    848
    E37C: UART        464
    E55C: HSUART      560
    E79C: F32        1900
    *** I2C ***
    $A0 EEPROM
    I/O =  31 :UHUU 27 :~~~~ 23 :~~~~ 19 :~~~~ 15 :U~~~ 11 :~~~~ 7 :~~~~ 3 :~~~~
    INTERCOM:
    
    CODE:$3A2A = 14378 bytes
    NAME:$5A2E = 6610 bytes
    DATA:$75FF = 239 bytes
    FREE:      = 8196 bytes
     Data Stack (0)
    Mon, 01 Jan 2001 00:00:00 UTC
    --------------------------------------------------------------------------------
    ...
    ...
    ...
    ...
    ...
    ...
    ...
    ...
     ..  IFDEF EASYFILE
    ...
    ...
    ...
    ...  TACHYON V5   Propeller .:.:--TACHYON--:.:. Forth V5r2 NEON 520180323.2200
    0085  ??? in *SDCS at cspin
    0100                        þ
    0198  ??? in SDDAT! at =dtk
    0200                        þ
    0248  ??? in SDWR at =dtk
    0250  ??? in SDWR at BLKSIZ
    0284  ??? in RDSECT at BLKSIZ
    0300                          þ
    0312  ??? in SECTOR at =dtk
    0352  ??? in FILE at #files þ
    0361  ??? in FILE# at #files
    0394  ??? in FSIZE at @FSIZE þ
    0400                         þ
    0500  ???  ???   ok
    0550  ??? in @BOOT at fatptr
    0636  ??? in MOUNT at #files þ
    0639  ??? in MOUNT at BLKSIZ þ
    0700  ???                    þ
    0834  ??? in FSTAMP at @FTIME
    0835  ??? in FSTAMP at @FDATE þ
    0910  ??? in FreeClusters? at BLKSIZ
    0925  ??? in ClaimClusters at endcl  þ
    0931  ??? in FirstCluster at @FCLST þ
                                        ÞÞÞäin FirstCluster at @FCLSTH
    0980  ??? in FPUTB at BLKSIZ                                       þ
    0986  ??? in FPUTB at BLKSIZ þ
    1000                         þ
    1043  ??? in FCREATE$ at @ATR
    1045  ??? in FCREATE$ at @CDATE
                                    ÞÞÞäin FCREATE$ at @CTIME
    1049  ??? in FCREATE$ at @FCLSTH                          þ
                                     ÞÞÞäin FCREATE$ at @FCLST
    1100                                                       þ
    1153  ??? in -FERASE at BLKSIZ
    1154  ??? in -FERASE at BLKSIZ þ
    1189  ??? in APPEND at BLKSIZ  þ
    1200                          þ
    1234  ??? in _FCOPY at BLKSIZ
    1300                          þ
    1306  ??? in cd$ at @ATR
    1447  ??? in .DIR$ at @ATR
    1464  ??? in .FNAME at @ATR
    1468  ??? in .FNAME at @ATR þ
    1483  ??? in .DIR at @ATR   þ
    1487  ??? in .DIR at @FSIZE
    1489  ??? in .DIR at @FDATE þ
                                ÞÞÞäin .DIR at @FTIME
    1491  ??? in .DIR at @CDATE                       þ
                                ÞÞÞäin .DIR at @CTIME
    1500                                              þ
    1512  ??? in lsdirs at BLKSIZ
    1516  ??? in lsdirs at @ATR   þ
    1558  ??? in .UTIME at @FTIME
    1574  ??? in (.LIST) at @FSIZE
    1575  ??? in (.LIST) at @FDATE þ
    1600                           þ
    1607  ??? in .FILES at #files
    1760  ???                     þ
    

  • Ahhh, that's what happens when I get distracted in the middle of changes. I decided to rename some common Tachyon words such as == which I use for constants and rename it to := instead but I hadn't updated EASYFILE. So try it now as it compiled fine after that. If you want to free up some memory then do a RECLAIM and then a BACKUP.
    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Tachyon Forth News Blog
    TAQOZ documentation
    Brisbane, Australia
  • Hi Peter,

    I'm having trouble building v5.2 from the dropbox .SPIN file (TACHYON5r2.SPIN) in PropellerIDE. Error message is:
    /home/ajs/Downloads/tachyon_v5.2.spin(639:1) : error : Expected a local symbol
    Line:
    :4                      and       X,#maxlen
    Offending Item: :4
    

    v4.7 builds fine, v5.1 reports the same error. I'm using PropellerIDE version 0.33.3 on linux.

    Cheers

    A>
  • Peter JakackiPeter Jakacki Posts: 7,047
    edited April 30 Vote Up0Vote Down
    A> I've got an old version 0.38.5 in Linux from 2015 that I just tried and works but maybe there are bugs in your version 0.33.3?
    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Tachyon Forth News Blog
    TAQOZ documentation
    Brisbane, Australia
  • CtlAltDelCtlAltDel Posts: 7
    edited April 30 Vote Up0Vote Down
    Yes, you're right - I compiled it with BST, no problems. Loaded it into my DAQiri system and pasted in EXTEND (minus VGA/LCD/KEY), again no problems. 9k free!
  • Thanks Peter, the new version of EASYFILE sorted the problem.

  • lmclarenlmclaren Posts: 99
    edited May 1 Vote Up0Vote Down
    Hi again Peter,


    Regarding: "pub ESC? ( -- flg \ true if an escape has been pressed ) "

    From a few examples and the reference page ESC? sets a flag when ESC is pressed, but if I try to use it it get:

    ESC? ??? in PROX at ESC?

    I have looked through the EXTEND code but can not see it, has it changed? Is there a current reference?

    My current config:
    *** MODULES *** Propeller .:.:--TACHYON--:.:. Forth V5r2 NEON 520180323.2200
    3A2A: EASYFILE SDHC card + FAT32 Virtual Memory File System V1.2 171024-0000
    3386: TOOLS DEV TOOLS
    30DE: CHARLCD BUFFERED CHARACTER LCD
    1982: EXTEND Primary extensions to TACHYON V5.2 kernel - 180322-1300


    thanks


  • lmclaren wrote: »
    Hi again Peter,


    Regarding: "pub ESC? ( -- flg \ true if an escape has been pressed ) "

    From a few examples and the reference page ESC? sets a flag when ESC is pressed, but if I try to use it it get:

    ESC? ??? in PROX at ESC?

    I have looked through the EXTEND code but can not see it, has it changed? Is there a current reference?

    I'm not sure what code you may be compiling but you can easily define an ESC?
    pub ESC? ( -- flg )   lastkey C@ $1B = ;
    
    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Tachyon Forth News Blog
    TAQOZ documentation
    Brisbane, Australia
  • Thank you Peter,

    I am still getting my head around Forth, from what i can tell ESC? is in quite a few examples and is mentioned in the "Glossary of Tachyon words"
    https://docs.google.com/document/d/1gkSgKPYidRnhLaqgT7gfNyuhiTuWt-9tNRQC4epr7k4/edit#heading=h.i7dx3hi7lcst

    I may be misunderstanding how to read this but I think it is telling me it comes from EXTEND?

    I appreciate the assistance.

    best regards

    Lee



  • lmclaren wrote: »
    Thank you Peter,

    I am still getting my head around Forth, from what i can tell ESC? is in quite a few examples and is mentioned in the "Glossary of Tachyon words"
    https://docs.google.com/document/d/1gkSgKPYidRnhLaqgT7gfNyuhiTuWt-9tNRQC4epr7k4/edit#heading=h.i7dx3hi7lcst

    I may be misunderstanding how to read this but I think it is telling me it comes from EXTEND?

    I appreciate the assistance.

    Hi Lee,
    Some versions may have certain words, others don't, either because there are many ways of doing this, or they were't used often enough. However there are definitely core words that are essential too that are always there. ESC? is not of the latter but because it is so simple I can add it back into EXTEND :)

    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Tachyon Forth News Blog
    TAQOZ documentation
    Brisbane, Australia
  • It is not a problem for me to re add now as you have shown me the code, I was just trying to work out if there is a master list with the code so if any are missing I can add as needed.

    I have gone back to the V4 and had a look around but could not find but again I am a babe in the woods so may be looking in the wrong places.

  • lmclaren wrote: »
    It is not a problem for me to re add now as you have shown me the code, I was just trying to work out if there is a master list with the code so if any are missing I can add as needed.

    I have gone back to the V4 and had a look around but could not find but again I am a babe in the woods so may be looking in the wrong places.

    No problems, I added it back in and it is useful for terminating listings and test loops though. Each new version of Tachyon is done for a reason, and V5 builds on the V4 which changed over from bytecode to wordcode, mainly for handling the address space more efficiently for larger programs. But V5 compacts the dictionary a fraction more, simplifies some other things while making more hub space available for code. This way V5 can squeeze in EASYFILE and EASYNET while avoiding having to compress the dictionary into upper EEPROM. Besides, it has a simple decompiler built-in! Type "HELP ESC?" and it will decompile the word and pause on any EXIT it comes across where you can decide to let it continue or hit a key to stop it.
    584A 5284 0 ESC?
    
    5284: $00C4
    5286: C@
    5288: $001B
    528A: =
    528C: EXIT
    

    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Tachyon Forth News Blog
    TAQOZ documentation
    Brisbane, Australia
  • Hmm, I must be doing something wrong, I have added the code for ESC? but I can't get it to match, I am running this program:

    : D2 BEGIN 16 HIGH 17 LOW 200 ms 16 LOW 17 HIGH 200 ms ESC? UNTIL ;

    I am expecting the pins to toggle until I hit ESC but it never stops.

    I thought my terminal (TeraTerm) may not be sending escape, i tried CTL[ as well so I added this:

    pub XXX? ( -- flg) lastkey C@ 88 = ;

    and changed the test to:
    : D2 BEGIN 16 HIGH 17 LOW 200 ms 16 LOW 17 HIGH 200 ms XXX? UNTIL ;

    I am expecting the loop to break when I hit X but again no joy.

    What am I doing wrong?

    thanks!
  • I wrote this as a test, I was expecting the first 13 but I tried other keys after the program was running and it does not update lastkey, from what I read in the docs, lastkey is filled from the RX buffer, have I misunderstood?

    thanks

    ... : D4 BEGIN lastkey C@ DECIMAL . 200 ms ESC? UNTIL ;
    ...
    ... D4 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 1
  • Peter JakackiPeter Jakacki Posts: 7,047
    edited May 2 Vote Up0Vote Down
    @lmclaren - my bad, I see that previous versions directly wrote to the lastkey variable from the serial cog but I cut this bit of overhead out for later versions which then incorporated the ping-pong Propeller networking software referred to as the "intercom".

    The advantage of reading lastkey was that it was non-invasive by not using up a character from the serial receive buffer. However if you don't mind that then define ESC? as:
    pub ESC? KEY $1B = ;
    

    Test it out...
    BEGIN SPINNER ESC? UNTIL
    
    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Tachyon Forth News Blog
    TAQOZ documentation
    Brisbane, Australia
  • Thanks, I will give it a whirl

  • Hi Peter,
    I have it running now, thank you.

    I have noticed that the delays are out, eg a 20 mS is measuring as 16mS, a 100 mS is measuring as 80 mS.

    I am running a 96Mhz clock.

    best regards

    Lee
  • Hi Peter,

    Do you have a 'roadmap' for where you want to take v5? The reason I ask is that I think Tachyon deserves a much higher profile (along with the Propeller itself!), and I wonder if the key to that might be documentation. I note that you have a couple of documents, "Introduction to Tachyon" and the Tachyon glossary, which would be an excellent place to start for a full manual. I'd be happy to assist. What are your thoughts?

    I'm currently in the middle of designing a new hardware revision of my data acquisition system, but I expect to be making much fuller use of Tachyon soon!
  • CtlAltDel wrote: »
    Hi Peter,

    Do you have a 'roadmap' for where you want to take v5? The reason I ask is that I think Tachyon deserves a much higher profile (along with the Propeller itself!), and I wonder if the key to that might be documentation. I note that you have a couple of documents, "Introduction to Tachyon" and the Tachyon glossary, which would be an excellent place to start for a full manual. I'd be happy to assist. What are your thoughts?

    I'm currently in the middle of designing a new hardware revision of my data acquisition system, but I expect to be making much fuller use of Tachyon soon!

    If you want you can edit those documents and others, I'd be happy to have some help. I can pm you an edit link if you like.

    But now that P2 is so close I wonder whether I would use P1 in many new designs. This may be the end of the Tachyon road for the P1 but a whole new super expressway for the P2. Nonetheless, Neon is a powerful and refined implementation of Tachyon for the P1 and even if it doesn't have the profile it should have along with the Propeller, we are not the ones missing out :)


    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Tachyon Forth News Blog
    TAQOZ documentation
    Brisbane, Australia
  • CtlAltDelCtlAltDel Posts: 7
    edited May 14 Vote Up0Vote Down
    Hi Peter,

    A couple of questions regarding your VGA Breakout code:

    1. TABLE - this keyword doesn't appear in the glossary. Looking the code, I'm assuming it copies the a hub memory address to a variable, which can be used as a reference to the series of compiled literals that follow? And that the address corresponds to the address of the first compiled literal in hub memory?
    TABLE gamepal
    	$0800.0800 ,	$0808.0000 ,	$F000.F000 ,	$F0F0.0000 ,
    	$8000.8000 ,	$8080.0000 ,	$2000.2000 ,	$2020.0000 ,
    	$8800.8800 ,    $8888.0000 ,    $2800.2800 ,	$2828.0000 ,
    	$5400.5400 ,    $5454.0000 ,    $A800.A800 ,    $A8A8.0000 ,
    

    So in this case, the variable 'gamepal' holds the address of the compiled literal $0800.0800, and you access elements in the table by adding an offset to gamepal?

    2. colors - appears to be the destination for a copy of the gamepal table, but I don't see a definition for colors anywhere?
    gamepal colors 64 CMOVE
    
    Cheers
  • TABLE creates a variable in code memory without any extra memory allocated, a bit like the traditional 0 VARIABLE -4 ALLOT would. So all that gamepal comes back with is the address in code memory of that array and it's up to code to index into it but in this case it overwrites the color table that is defined in the VGATEXT module in EXTEND.
    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Tachyon Forth News Blog
    TAQOZ documentation
    Brisbane, Australia
  • Hi Peter,

    Thanks for your help thus far. I took some time out from PCB routing to sit down with Tachyon again. I've modified the stepper code to be able to step in either direction, e.g.
    100 CCW MTR.STEPS
    
    or
    25 CW MTR.STEPS
    

    I'm also driving the stepper in half-step mode as the manufacturer recommends, which means there are 8 phase patterns per step. I created a table of the phase patterns, and index from the start to the end of vice versa, depending on direction:
    0 := CCW
    1 := CW
    
    --- utility function to write a byte to an I2C chip register
    pub IO! ( data reg -- )		$40
    pub TCA! ( data reg dev -- )	<I2C I2C! I2C! I2C! I2C> ; 
    
    word ratems 
    --- set the step but also make sure the I/O is initialized
    pub MTR.RATE ( ms -- )		ratems W! 
    --- Set I2C bus pins for stepper card, initialise TCA9535 ports 0 & 1 to output, set all outputs low
    pub MTR.INIT ( -- )           
    	7 6 I2CPINS 
    	0 2 IO! 
    	0 3 IO! 
    	0 6 IO! 
    	0 7 IO! ; 
    
    --- Bit patterns for driving 28BYJ-48 in half-step mode
    TABLE phases
       $02 | $06 | $04 | $0C | $08 | $18 | $10 | $12 |
    
    --- set motor phase outputs on port 0 of TCA9535 and delay for programmed speed
    pub MTR.PHASE ( phase -- )	2 IO! ratems W@ ms ;
    
    --- Do a single complete step
    pub MTR.STEP ( -- ) 8 SWAP 0= IF phases FROM 1 ELSE phases 7 + FROM -1 THEN BY FOR I C@ MTR.PHASE NEXT ;       	
    
    --- Turn on activity LED for motor, run for <steps> steps in the specified direction (CW or CCW), at set rate between phase outputs 
    pub MTR.STEPS ( steps dir -- )
    	3 HIGH
       SWAP
       FOR
          DUP
          MTR.STEP
       NEXT
       DROP
       0 MTR.PHASE
       3 LOW ; 
    

    I would be interested in your comments, as I guessing this can be done more efficiently than the approach that I have taken.

    Cheers

    Andrew

    P.S. I'm compiling a list of glossary edits, once it is sufficiently long we might go over it...
  • Hi Andrew,

    Well done so far, please bear with me as I try to share some of the things I have found that helps with writing Forth software.

    Compiled languages encourage you to use all_kinds_of_long_names but one of the things I like about Forth is that the name becomes part of the language. More correctly though, the name becomes the language in that you end up programming with these new names. If well chosen and thought out then it will feel and read natural but all too often the structures of conventional languages that were forced upon us are in turn forced upon Forth so that the Forth vocabulary has not been "extended" or enhanced at all. What we end up with is "code" in need of decoding.

    So you find that to move the motor slowly in a clockwise direction you end up typing/coding:
    20 MTR.RATE
    200 CW MTR.STEPS

    Now that's not so bad, It works, but could you express what you want to do more naturally like:
    SLOW 200 RIGHT
    then perhaps
    FASTER 400 LEFT
    This is also a lot easier to type in interactively and now the language has been extended and enhanced. The code can also be its own comments.
    --- utility function to write a byte to an I2C chip register
    pub IO! ( data reg -- )		$40
    pub TCA! ( data reg dev -- )	<I2C I2C! I2C! I2C! I2C> ; 
    
    long mdir	word ratems	byte phase
    
    --- Bit patterns for driving 28BYJ-48 in half-step mode
    TABLE phases   $02 | $06 | $04 | $0C | $08 | $18 | $10 | $12 |
    
    --- set the step but also make sure the I/O is initialized
    pri THROTTLE ( ms -- )		
    	1 MAX ratems W! 
    --- Set I2C bus pins for stepper card, initialise TCA9535 ports 0 & 1 to output, set all outputs low
    	7 6 I2CPINS 
    	0 2 IO! 
    	0 3 IO! 
    	0 6 IO! 
    	0 7 IO! ; 
    	
    --- speed control
    pub SLOW 			10 THROTTLE ;
    pub FAST 			1 THROTTLE ;
    pub FASTER 			ratems W@ 2/ THROTTLE ;
    pub SLOWER 			ratems W@ 2* THROTTLE ;
    
    --- set motor phase outputs on port 0 of TCA9535 and delay for programmed speed
    pri COILS ( phase -- )		2 IO! ratems W@ ms ;
    --- Do just one tiny phase change step 
    pub STEP ( -- ) 		phase C@ 7 AND phases + C@ COILS   mdir @ + phase C+! ;
    
    --- Turn on activity LED for motor, run for <steps> steps in the specified direction (CW or CCW), at set rate between phase outputs 
    pub STEPS ( steps  -- )		3 HIGH FOR DUP STEP NEXT 0 PHASE	3 LOW ; 
    pub LEFT 			1 mdir ! STEPS ;
    pub RIGHT			-1 mdir ! STEPS ;
    
    pub DEMO
    	SLOW 200 LEFT	FAST 200 RIGHT 
    	SLOWER 500 LEFT FASTER 500 RIGHT
    	;
    

    Add TURNS or DEGREES so you can say LEFT 45 DEGREES or 8 TURNS if positioning is more important than speed and movement.
    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Tachyon Forth News Blog
    TAQOZ documentation
    Brisbane, Australia
  • Hi Peter,

    I am running:
    Propeller .:.:--TACHYON--:.:. Forth V5r2 NEON 520180323.2200
      *** MODULES ***  Propeller .:.:--TACHYON--:.:. Forth V5r2 NEON 520180323.2200
    3A2A: EASYFILE         SDHC card + FAT32 Virtual Memory File System V1.2 171024-0000
    3386: TOOLS            DEV TOOLS
    30DE: CHARLCD          BUFFERED CHARACTER LCD
    1982: EXTEND           Primary extensions to TACHYON V5.2 kernel  - 180322-1300
    
    AUTORUN BOOT 3076
    FREQ = 96.00MHZ
    *** INITS ***
    MOUNT 4068
    *** ROMS ***
    E01C: VGA32x15    848
    E37C: UART        464
    E55C: HSUART      560
    E79C: F32        1900
    *** I2C ***
    $A0 EEPROM
    I/O =  31 :UHUU 27 :~~~~ 23 :~~~~ 19 :~~UD 15 :U~~U 11 :~~~~ 7 :~~~~ 3 :~~~~
    INTERCOM:
    
    CODE:$4D64 = 19300 bytes
    NAME:$5A96 = 6506 bytes
    DATA:$7845 = 821 bytes
    FREE:      = 3378 bytes
     Data Stack (0)
    Mon, 01 Jan 2001 00:00:00 UTC
    CARD: SL08G SD03.80 #300D.D49A 2016/3 !C0AF.4040 1,648us
    FAT: #03B7.98D0 mkfs.fat boot        FAT32   66,060,288 bytes (0kB clusters)
    
    --------------------------------------------------------------------------------
    


    I am trying to run the example:
    First we define these I/O lines that we need as constants and pass this to the PING routine to keep it general-purpose so we can use any I/O.        
    
    #P16        == TRIG        --- high output to trigger ping
    #P17        == ECHO        --- signal received input, measure high time
    
    Now we can create a general-purpose PING function that accepts the pins we want to use and returns with the time in microseconds.        
    
    pub PING ( trig echo -- us )
      MASK 3 COGREG!                                 --- setup WAITPxx mask (in Tachyon cog registers )
      DUP HIGH >R R> LOW                         --- 10us trigger (dummy cycles)
      (WAITPEQ) (WAITPNE)                         --- detect high period as these also capture the CNT into cogregs
      0 COGREG@ 1 COGREG@ -                         --- calculate high period from lo to hi and hi to lo captures
      CLKFREQ #1,000,000 / /                 --- convert cycles to us
      ;
    



    I am getting errors with the COGREG! and the (WAITPEQ) and (WAITPNE).
    I can not see where COGREG! is defined, I can find references in the documentation but it does not seem to work.

    I am not sure if the WAITPEQ etc have changed names, are they now WAITHI and WAITLO?

    thank you.
Sign In or Register to comment.