Shop Learn
Thoughts about a local HybridEditor for Forth on a Microcontroller — Parallax Forums

Thoughts about a local HybridEditor for Forth on a Microcontroller

This is something like thoughts and not a completed project.

Some time ago several people in this forum stated, that it would be good to have a self-hosted system for P2. - Actually with Tachyon we have got a compiler and an assembler and an operating system. Nevertheless I found myself using an editor on my PC instead of a local editor. The host is connected to Tera Term running on a PC. I use Notepad++ with syntax highlighting, code folding and with a function list (which is a word-list here) for forth source code. And this editor is just too good in comparison to the very simple "Starting Forth Line Editor" or a simple text editor http://www.murphywong.net/hello/lf.htm.

So I have been asking myself, how could an editor be done with forth, that is still simple and compact (Notepad++.exe has 5.9MegaBytes.....), but good enough, that it would be attractive to use it instead of Notepad++ or similar editors.
The benefit should be, that iterative interactive testing of single words - which is the strong side of forth- would be better supported.

After some thinking about these features "syntax highlighting, code folding, function list" I came to the conclusion, that similar things should be possible with a forth block editor but with additional information displayed together with the block screen. Monitors are bigger nowadays. The active block screen can be seen as the unfolded part of the text. The source code is divided into consecutive blocks, which build a region of blocks. There is plenty of room for very many source code blocks.

The picture shows the actual state of the "HybridEditor". It consists of 4 parts:
1. A list of the 40 last words of the dictionary. (Starts at the top with "fw2")
2. A list of the first lines of colon-definitions preceded, with the block number of their source code. (starting with "40 sgr") This list is generated scanning the region of blocks and is something like the function list or the folded part of the text.
3. The screen listing of the active block number 41 with syntax highlight.
4. A line editor with the active line number 6 at the bottom.

TeraTerm allows to use the mouse to copy text, which can be pasted at the cursor position. No cursor movement with the mouse here.
The line editor can be entered and left easily. Then the interactive environment can be used for additional editor commands like "find" or to save or compile the code.
At the moment the editor has about 500 lines of source code.

Comments, ideas, suggestions?
Christof

Comments

  • Comments: This is a great topic. Completely in line with my own interest (a standalone, self contained P2 development system).
    Ideas: as simple as possible for the start, just syntax highlighting, the rest at a later time
    Suggestions: spread the word to other forth forums - the idea is so appealing I'm sure it'll get some attention. I have linked to your post here.

  • ErNaErNa Posts: 1,672
    edited 2021-11-19 14:19

    Hi Christof, this is a good initiative. Peter has created a rudimentary editor to write to file, flash, ram in his TAQOZ system but just when I started to digg through the source code and immediate commands he decided to move to another forum. I can not follow as I do not like the idea of a facebook account.
    That said: My main obstacle is the need for a connector to the "real" world of PC's, that is mostly to the windows environment. I have to use PC's as a HMI and to load and store data as to have a link to the www. Pointed to 8th I decide to use this forthy language and it turns out that it was the right decision, Ron seems to be a forth soul like Peter, he just took another path. I'm now sorting out my main tasks and surely will be more active here.
    So, yes, your proposal is good. Are you already willing to share your code for a joined effort? Others may follow if there is some progress.
    @Maciek : just the link you provided: and that Peter reacted immediately. So we are on track

  • @ErNa said:
    Hi Christof, this is a good initiative. Peter has created a rudimentary editor to write to file, flash, ram in his TAQOZ system but just when I started to digg through the source code and immediate commands he decided to move to another forum. I can not follow as I do not like the idea of a facebook account.
    That said: My main obstacle is the need for a connector to the "real" world of PC's, that is mostly to the windows environment. I have to use PC's as a HMI and to load and store data as to have a link to the www. Pointed to 8th I decide to use this forthy language and it turns out that it was the right decision, Ron seems to be a forth soul like Peter, he just took another path. I'm now sorting out my main tasks and surely will be more active here.
    So, yes, your proposal is good. Are you already willing to share your code for a joined effort? Others may follow if there is some progress.
    @Maciek : just the link you provided: and that Peter reacted immediately. So we are on track

    Hi ErNa,
    at the moment my project is to measure and analyse, what our gas central heating or its controller does, with the goal to reduce energy consumption. For this project only very few GPIOs are needed for very slow temperature sensors but there is great benefit to have WLAN. So for this project I use ESP32 boards, running local Forths. The boards can contact each other using Forth as the protocol and get (sensor) values from another board over WLAN. At the moment this "HybridEditor" study is running on such a system. ESP32 and P2 are very much restricted systems compared to a PC (while much more powerful than a minicomputer at the beginning of Forth times). So I am looking at something very simple/compact. Using 8th on a PC, where you have a full blown IDE "as competition" seems to be a quite different thing?
    At the moment I am asking myself, what benefit for my projects (!!) could a completely standalone Forth computer (with P2?) have with it's own vga monitor and keyboard. Perhaps it should have two console tasks, as I will always want to transfer data to/from my PC preferably over WLAN?
    What is the setup towards you are working?

  • ErNaErNa Posts: 1,672

    Hi @"Christof Eb."
    8th is not a full blown IDE. 8th is just a FORTH with extensions (wrappers) to the modern world of IT of everything. I'm now looking to find a certain forum and in doing so I found this https://reddit.com/r/Forth/comments/q9sum8/which_forth_do_you_guys_use_for_normal_day_to_day/ where 8th is mentioned. Also I found: https://dev.to/bugmagnet/8th-language-release-v19-08-16lm https://community.arm.com/arm-community-blogs/b/embedded-blog/posts/8th-a-gentle-introduction-to-a-modern-forth etc. But I was looking to find a discussion similar to this one https://reddit.com/r/Forth/comments/573lmq/8th_is_it_forth/ where purists just destroy anything like in real live.
    So I contacted Ron and we start to run a project. I know great guys in my local area and over the world that are not perfectly working together. It needs some glue logic, that is: there has to be a commercial aspect to fill the fridge. Chip, Peter, Ron and other unnamed here fit to this pattern.
    The show stopper to me is the missing interface to the PC, a.k. MicroSoft world. That link is 8th to me. So let us join our efforts. I will send Ron KISS board and all I imagine he will need to locally realize the prototyping of TAQOZ-8th projects. Funny: I also have to measure my heating as I plan to install a heat pump and drive the heatpump over daytime with the PV cells I have on may roof, store the heat into a water tank and heat the flat when the sone doesn't shine...
    But I want to use the P2 intensively, measuring moisture, temperature, controling the valves in the rooms, detection open windows, smoke, handling the shutters, having a noise detector to alarm etc. And all connected to the WLAN and accessible using one APP on all the modern gadget like smart phone, tablet, PC, ....

  • Hi ErNa,
    so I understand, that you plan to use P2 as the centre controlling unit, with multiple sensors and actors connected to it. I assume with SD-card as local mass storage. Do you plan to have a local console with VGA and keyboard directly connected to P2 or do you plan to connect to the forth console task with some sort of serial connection using PC as a console terminal? (I still did not get, where 8th comes in.)
    (((I have been thinking about heat pumps together with PV cells these days too. If the goal is to heat up water for energy storage, and if it is true, that the "Leistungszahl" / "COP" is decreasing for high differential temperature, and the service life of an expensive heat pump is ???15 years only??? Then I wonder, if it is better to invest the money into more PV-cells to directly heat the water and have a system, which has low efficiency but is much more simple....)))

  • ErNaErNa Posts: 1,672
    edited 2021-11-21 17:23

    I want to have the control system connected to the "common" devices, that is, your phone, your tablet etc. 8th allows platform independ programming. "Write Once Run Everywhere". I will have the same setup as @ManAtWork 's mini testing units. He has a little interface board and there is a display. But I see the need for WLAN too. To me is critical that FORTH is the language and the processing nodes are connected so new words can be distributed and the whole system will be one cluster of parallel FORTH tasks.. As it has to be.

    By the way: there is no reason why a heat pump should stop running if properly designed. The COP is smaller the higher the temperature is. So the water tank must be filled in layers and according the energy supply the higher layers can be heated electrically, the lower via the heat pump. And: as the efficiency of the PV panels is about 20% it means, at least 60% of the energy is warming the backside of the panels and if the incoming air to the HP is preheated by 10° the COP will go up by 1, approximately.....
    That is an interesting field of research..

  • Ok, to connect from mobile or tablet to a controller, I use the terminal program "connectBot" (others did not work fully) on Android, which brings the same serial terminal functionality as TeraTerm on the PC. With this ( ANSI colour text based) setup it is not necessary to do any programming on these sides. My programs are only running on the Forth controller. PC or tablet or mobile phone are just dumb terminals. WLAN just provides a simple (RAW Telnet) serial connection here. So for example this HybridEditor here can be used directly on the tablet without any additional programming. - Perhaps this simple approach might be useful for you too. It is "Write Once Run Everywhere" for a lazy guy like me....

  • @"Christof Eb." said:
    ...So for this project I use ESP32 boards, running local Forths. The boards can contact each other using Forth as the protocol and get (sensor) values from another board over WLAN. At the moment this "HybridEditor" study is running on such a system....
    At the moment I am asking myself, what benefit for my projects (!!) could a completely standalone Forth computer (with P2?) have with it's own vga monitor and keyboard. Perhaps it should have two console tasks, as I will always want to transfer data to/from my PC preferably over WLAN?

    Interesting. Looks to me like you intend to run a mesh of forth powered sensors that exchange data between themselves over WLAN. Why would you like to have it to be so complicated ? Are not all of these sensors within the reach of the same network ?

    If these forth powered sensors are based on different platform (different forth or hardware) than the main console (a standalone forth computer with VGA and keyboard), then I can't see much benefit coming from having one such computer. The optic changes completely if the forth computer and the forth powered sensors use the same hardware, be it an esp32 or a P2 because in that case you can use the forth computer twofold - as a management console for the sensor nodes and as a development platform for them too. That is exactly the reason I am interested in such a device (P2 based, standalone TAQOZ powered computer with a vga display and a keyboard) that could run 24/7 drawing as little power as possible when not human operated.

    It is quite possible to have a KISS board extended with the necessary components (a WLAN interface, a VGA and a PS2 connectors, an RTC for precision timing) to form such a computer. In that sense having a simple but sufficiently capable and comfortable editor would be beneficial.

  • ErNaErNa Posts: 1,672

    I was bringing up this 8th info not to hijack this thread but to just point to the fact, that there is a more global aspect in such a development that can be taken into account....
    So let us see, what will be the outcome of this beginning.

  • Hi ErNa,
    no problem about hijacking! I am always learning here and I did have a look into the 8th homepage (once again). At this very moment I do not think, that I have a project which is calling to use 8th, but there might come an opportunity sometime.... In any case it is interesting, that someone is trying to bring together Forth and modern GUI. ((These days I had a look into FreePascal which is multiplatform too, and there is a Forth scripting language for this. FreePascal/Lazarus seems to be a tool too, to create GUI in a simplified way. FreePascal is available for several microcontrollers too and it supports multiple threads, so I think multiple cores could be supported somehow. I tried to find out, if it would make libraries accessible for P2, but the number of them seem to be limited. ))

  • @Maciek said:
    ....
    Interesting. Looks to me like you intend to run a mesh of forth powered sensors that exchange data between themselves over WLAN. Why would you like to have it to be so complicated ? Are not all of these sensors within the reach of the same network ?

    These ForthNodes can do multitasking. As a background task they do measurements, do preprocessing like averaging and do local data-logging into their block file system.
    The foreground task is an interactive console task which can be accessed via WLAN either by a terminal or by any of the other ForthNodes at a time. If you log in with a terminal, you can edit blockfiles, view log data, interpret, compile, ....
    In parallel to the background task and the foreground task there is a ftp file server running on each ForthNode, which can be accessed with FileZilla. You can upload and download files. Additionally the ForthNodes have NTP internet date and time, which is very useful for data logging. So in my setup the HybridEditor is running on each ForthNode. If I develop and test new words, I do use a separate ForthNode, because I do not want to disturb the processes too much.
    I think, when there is need to have a P2 due to more time critical tasks, I will bring it into the setup as a subsystem to the ESP32 as interfacing to the WLAN ( console+ftp+ntp) is more complex. I do use libraries of others here of course.

    What I like in the setup is, that no central file server (MQTT, for example) is needed and that you can always use the interactive Forth. Yes, it is a bit complicated, but it has proven to be rather reliable.

  • @"Christof Eb." said:

    These ForthNodes can do multitasking.
    ...
    So in my setup the HybridEditor is running on each ForthNode. If I develop and test new words, I do use a separate ForthNode, because I do not want to disturb the processes too much.
    ...
    What I like in the setup is, that no central file server (MQTT, for example) is needed and that you can always use the interactive Forth. Yes, it is a bit complicated, but it has proven to be rather reliable.

    Thank you. I do understand it better now. Not exactly what I have initially figured but if the setup you have works for you the way you like it, it means it's perfect....for now :) . And you can reconfigure it at any time to accommodate new need if you desire so.

Sign In or Register to comment.