• Scam Alert. Members are reminded to NOT send money to buy anything. Don't buy things remote and have it shipped - go get it yourself, pay in person, and take your equipment with you. Scammers have burned people on this forum. Urgency, secrecy, excuses, selling for friend, newish members, FUD, are RED FLAGS. A video conference call is not adequate assurance. Face to face interactions are required. Please report suspicions to the forum admins. Stay Safe - anyone can get scammed.

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.webp


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.webp


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.
 
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.
 
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.webp

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.
 
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

Back
Top