• Spring 2024 meetup in Calgary - tentative date Saturday, April 20/2024. Other regions are also discussing meet ups. If you want one in your area get going on organizing it! discussion
  • We are having email/registration problems again. Diagnosis is underway. New users sorry if you are having trouble getting registered. We are exploring different options to get registered. Contact the forum via another member or on facebook if you're stuck. Update -> we think it is fixed. Let us know if not.
  • Spring meet up in Ontario, April 6/2024. NEW LOCATION See Post #31 Discussion NEW LOCATION

FORTH Programming

jcdammeyer

John
Premium Member
The other day I stumbled across a facebook group on the FORTH programming language. Way back in the very early 80's I wirewrapped up a graphics video board for my S100 bus project. I created a program in FORTH for my kitchen reno. I made up objects like stove, fridge etc. and could move them around on the screen to test out layouts.

Anyway, I pulled out my two books and downloaded a couple of PC versions of the FORTH interpreters to be able to try the stuff in the books and reteach myself the language.

Although I had an 2016 version for the PIC series there's a new 2020 version in a zip file for more than just one PIC but also ATMEL processors. So I downloaded that and quite easily was able to get FORTH running on my ELS.

1678668860049.png

And after many screw-ups over the last couple of days finally got the LCD interface library correctly translated from Microchip C to FORTH.
ELS_WithFORTH.jpg

Next step. The keypad scanning code. That should go easier since I don't have to worry about LCD response timing.
I have no idea how I will handle the tree structured menus that make the current ELS so easy to repurpose for just about any project. May have to ask for help from the FORTH experts for that.
 

Dabbler

ersatz engineer
From a fellow FORTH programmer (dabbler, really) - wow. My cousin was one of the leading FORTH programmers in North America; he got me into it. Never did any commercial programs in it, though.
 

jcdammeyer

John
Premium Member
It's a pretty fuzzy picture which is a zoomed in scan of a 35mm print. The the general idea is the stove the fridge, the counter were all FORTH words with an XY position. And of course the burners on the stove were relative to the stove outline etc... Not sure if I still have the source code on an 8" floppy.

GraphicsDrawing.jpg
I used FORTH because it was the easiest to work with my wire wrapped upd7220 graphics chip and dynamic memory.

NEC_D7220_GraphicsF.jpg NEC_D7220_GraphicsB.jpg

Given that the FORTH for the PIC18 is limited to 64K and the C compiled code for my ELS exceeds that I don't know for sure if it will all fit as a FORTH program. But even if I just get the fundamentals working like the keypad, LCD, Beeper, MPG and I/O it can serve as a basis for other projects done in FORTH rather than the entire microchip MPLAB and C.
 

jcdammeyer

John
Premium Member
Quick update on the FORTH side of things. After a lot of work including digging into the PIC18 assembler code that makes up the FORTH I finally got my Timer 0 working although unfortunately in High Priority mode.

With the timer working and the TimerDevice code translated I once again have a blinky LED. However this time it's not done in the standard Arduino style of:
LED ON
Delay(100 ms)
LED OFF
Delay(900 ms)

Where everything just hangs during the delay routine. Instead I can have 8 timers and the code loops around testing to see if the timer is done and if not relinquishes to the next piece of code. Co-operative threaded multi-tasking.

Now I have a basic mainline and it's time to convert the keypad scan coding since now I can debounce buttons and have other things still working.

Remember the attached file is FORTH so may appear a bit 'strange............' But the heartbeat device does blink the LED correctly.
 

Attachments

  • mainloop.txt
    1.2 KB · Views: 1
Top