Recent

Author Topic: Free Pascal for a small electronic program  (Read 1935 times)

devEric69

  • Hero Member
  • *****
  • Posts: 652
Free Pascal for a small electronic program
« on: February 06, 2026, 02:51:51 pm »
Hello,

I'm posting this message as part of a "feasibility study" for a program on a "Raspberry Pi" with "Raspbian" (now called "Raspberry Pi OS"). For your information, I've just spent a few years working with PHP and JavaScript (commercial extension for an already existing PHP program). Therefore, my knowledge of the Free Pascal ecosystem is somewhat rusty.

The program's specifications is to write a program (with Pascal Object, if possible; no GUI needed, just the "console mode" with some parameters), a program that will be called through the network. The said caller will order to ask a set of 8 sensors (ex.: DS18B20, be it could be another; not yet tackled) to read a temperature in [° Celsius]. This set of 8 sensors will be connected to the Raspberry Pi's pins. Then, the said Raspberry Pi's console program should write the 8 said responses (T°C):
 - each in their own file (formally timestamped and numbered) on the hard drive of the Raspberry Pi;
 - while alerting the more complex (with GUI) calling program of the said written files (2 communication channels for security).

I've been a little thinking, "brain storming" %), about the specifications, hence my questions:
 - can MSEide be installed on the Raspberry Pi?
 - can MSEide "use ‘MultiLog’", ‘MultiLog’ which is designed to perform IPC (Inter Process Communication): it would be useful for the Pi's program to communicate with the calling application over the network (calling application being running on a remote Linux workstation; there will therefore be a need of a shared folder on the local Pi)?
 - are Lazarus on Linux (EDI with GTK or Qt or fpGUI over X11) and ‘MultiLog’ package on one side, and MSEide on Pi (EDI with MSEgui over X11, aimed with fpGUI over X11 (if a tiny GUI should appear)) and ‘MultiLog’ on the other side, plus a shared folder in the middle of the two sides, be all sufficient for the mentioned specifications above (requirement of "Synapse" package too? or would anything else be necessary, in addition to what I have said?)?
 - is there an interpreter (translator) available in the Free Pascal ecosystem to convert header files (if any use of an API written in C or C++ appears) towards the Pascal's conversion of the said header files?

PS: the goal would be to enable a novice electronics engineer (who knows C\C++ but not necessarily its "cousin" language Pascal) to get started in the simplest way possible.

Regards.
« Last Edit: February 06, 2026, 03:04:21 pm by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

dbannon

  • Hero Member
  • *****
  • Posts: 3744
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Free Pascal for a small electronic program
« Reply #1 on: February 07, 2026, 04:58:35 am »
Eric, I have a raspberry pi app that reads five DS18B20 sensors, writes result to file, plots those results into a graph displayed on a web server. https://github.com/davidbannon/SolarHotWater/tree/master/Raspicapture

The DS18B20 are great, no calibration needed and can tolerate quite long cables. But reading is is a bit slow, sequential.


...
I've been a little thinking, "brain storming" %), about the specifications, hence my questions:
 - can MSEide ....

I use FPC and Lazarus, not MSEide (do that have their own mailing list or forum ?). When developing, I use sshfs on the Pi to mount the directory my code is in and a minimal bash script to compile.  That way, the code can live in my laptop and get the benefit of a fast response from eg, codetools. But Lazarus will run on a more recent Pi, just a bit slower.

I have used samba both to and from a Pi without problems but fiddly to setup.

I have no idea what Multilog is and not much more knowledge about MSEide !

[/quote]
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

cdbc

  • Hero Member
  • *****
  • Posts: 2687
    • http://www.cdbc.dk
Re: Free Pascal for a small electronic program
« Reply #2 on: February 07, 2026, 07:06:42 am »
Hi
MSEIde is the handy-work of the late Martin Schreiber and I think continued / maintained by our own @Fred vS. It's an alternative to Lazarus & LCL and it lives on, on github...
I believe it will do just fine with this task, seen from the perspective, that Martin was an engineer ...and a Swiss one at that  8)
Give Fred a holler, I'm sure he can tell you more...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

devEric69

  • Hero Member
  • *****
  • Posts: 652
Re: Free Pascal for a small electronic program
« Reply #3 on: February 09, 2026, 10:21:44 am »
Hello @dbannon\David,

I've read your project on Github (with the collector, pump, etc): it's much more comprehensive than I thought when I was starting reading it! You explain that it's just like a "personal draft", but in my opinion it's a sound and clear professional basis for getting started with temperature sensors, even for someone who isn't an electronics engineer and is starting from scratch.  I've bookmarked your project (to be honest, I don't think I'll be doing any more Pascal this year (I must finish my PHP + JavaScript project), but I'll probably come back to it next year). Whatever happens, I've got my answer: I'll clone your Github when I'll switch to my Pascal project mentioned above. Concerning the IDE, I like the idea of compiling from a desktop or laptop PC and then, copying and pasting the compiled binary towards the Raspberry Pi's shared folder (especially since there are events around the compilation progress status): I'll do the same. Honestly, for me, your project is brilliant, and it will be the first stepping stone for the idea I've in mind: I'll bother you with pull requests to your Github repository (I've ordered some DS18B20 sensors this week-end to motivate myself :)).



Hello @cdbc\Benny,

Before reading the response concerning @David's project, I had no preconceived ideas. I knew @Martin's (Swiss engineer) story: it's a touching one. @Fred vS is right: his IDE is a "card to play" as a ‘spicy’ electronics-oriented free Pascal IDE (I've remembered me @Martin's demonstration project before to post in this forum, demonstration project which was electronics-oriented, hence my question here). Amho, this lightweight MSEide is all the more relevant when paired with the Raspberry Pi-style nano-computers family. Anyway, if I'll use a Raspberry Pi with an X11 graphics layer (@David didn't go that far, since he chose direction towards Raspberry Pico, which is only a microcontroller, not a computer), I'll probably go so far (installing the said MSEide on it: it could be useful for increasing my autonomy (a context rid of the laptop), like a "Swiss Army knife", which is handy  ;)).

Regards.
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

cdbc

  • Hero Member
  • *****
  • Posts: 2687
    • http://www.cdbc.dk
Re: Free Pascal for a small electronic program
« Reply #4 on: February 09, 2026, 11:35:12 am »
Hi Eric
Well, I wish you fair winds with your project and I'm looking forward to hearing more about your progress  8)
Atm. I'm playing around with 'fpGUI', in an attempt to explore something lighter than the "Big Iron", i.e.: Qt - GTK et.al. I really like that too, it's on github...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

dbannon

  • Hero Member
  • *****
  • Posts: 3744
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Free Pascal for a small electronic program
« Reply #5 on: February 10, 2026, 09:20:55 am »
...Concerning the IDE, I like the idea of compiling from a desktop or laptop PC and then, copying and pasting the compiled binary towards the Raspberry Pi's shared folder ....

No, simpler than that. Setup the project on your laptop (that has a ssh server installed), then, still in the comfy chair, ssh to the 'pi'. Install FPC and then sshfs and use that to connect to your project working directory.  No copy and pasting, compile and test directly on the Pi, edit on the laptop.

Debugging does not work quite so well....

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

avra

  • Hero Member
  • *****
  • Posts: 2584
    • Additional info
Re: Free Pascal for a small electronic program
« Reply #6 on: February 11, 2026, 02:03:26 pm »
Look at these for further inspiration:
https://ipkwena.blogspot.com/2016/01/raspberry-pi-temperature-sensor.html
https://github.com/RaspberryFpc/DS18B20-FPC-Pi-GUI

FYI, Typhon projects could be converted to Lazarus using ct2laz tool from my signature.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

dbannon

  • Hero Member
  • *****
  • Posts: 3744
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Free Pascal for a small electronic program
« Reply #7 on: February 13, 2026, 02:24:49 am »
https://ipkwena.blogspot.com/2016/01/raspberry-pi-temperature-sensor.html

Interesting avra.  I note you (?) load the file w1_slave and parse it rather than reading the file 'temperature' which contains just the temperature it self. Is the a reason for that ?  Is the content in w1_slave more stable perhaps ?

Code: Bash  [Select][+][-]
  1. dbannon@logger:~ $ cat /sys/bus/w1/devices/28-001414a820ff/w1_slave
  2. df 02 55 00 7f ff 0c 10 fa : crc=fa YES
  3. df 02 55 00 7f ff 0c 10 fa t=45937
  4. dbannon@logger:~ $ cat /sys/bus/w1/devices/28-001414a820ff/temperature
  5. 45937

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

avra

  • Hero Member
  • *****
  • Posts: 2584
    • Additional info
Re: Free Pascal for a small electronic program
« Reply #8 on: February 14, 2026, 11:16:36 am »
I note you (?) load the file w1_slave and parse it rather than reading the file 'temperature' which contains just the temperature it self. Is the a reason for that ?  Is the content in w1_slave more stable perhaps ?

Sorry, that is not my code so I can not comment. I used DS18B20 with microcontrollers, but not with Pi. Anyway, Pi code was on my radar - so I shared URLs with you.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

devEric69

  • Hero Member
  • *****
  • Posts: 652
Re: Free Pascal for a small electronic program
« Reply #9 on: February 14, 2026, 06:19:36 pm »
@avra: Thank you for sharing the URL.

I've received the DS18B20s sensors. For information, I'm absolutely not an electronic engineer at all, so the path leading to work with a microcontroller (such as "Raspberry Pico") is not for me. On the other hand, compiling Lazarus on a "Raspberry Pi" in order to have an ‘in situ’ debugger can be done (I've read that some people do this), but it'll take several minutes each time :o! So, Lazarus seems to me, to be more dedicated to consolidating data on a remote desktop or laptop PC.

> "Debugging does not work quite so well...."

I would like to have a comfortable debugger installed on a Raspberry Pi itself, nevertheless. So, installing MSEide-MSEgui (then installing FPC and X11) would allow me to compile and debug the binary adapted\dedicated to the ARM architecture of the Raspberry Pi, directly: seems to be the path I would follow. Btw, with the "return of the `brainstorming and spicy` dream team" (@Greame + @Fred vS), I might find last year, maybe, one or some informatics components in order to model the GPIO' real-time status of the electronic assembly (with some little movements (just with few labels-numbers or pseudo-colored-leds)), over some virtual battery(?), virtual common sensors (?), virtual electrical wire(?), virtual pins(?), etc…, taken from some dedicated electronic components palette 8). It would be comfortable to display (via the X11 graphic server) if the binary has hung up or not, and if so, where exactly?

(It's just a suggestion, not a request; I'm trying to influence, for sure (I know, without having the means to do so; but, who knows all? :D) Happy New Year, everyone (a bit late)! And maybe… will I tell you all next year, who knows? (in any case, I'm working for it)

Regards.
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

dbannon

  • Hero Member
  • *****
  • Posts: 3744
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Free Pascal for a small electronic program
« Reply #10 on: February 15, 2026, 10:36:13 am »
This thread prompted me to look a bit further into how to read the DS18B20 sensor. Turns out that the linux kernel module provides a way to trigger all sensors in the array to start a conversion, simultaneously, this speeds up the conversion significantly, especially if you have more that just a few sensors.

Normally, reading the sensor, either the w1_slave or temperature file, triggers a conversion for that sensor. So, you step through all of them, one by one. A conversion takes 800mS or so so it soon ads up.

But by writing 'trigger' to the therm_bulk_read file in the /sys drive, they all convert, when that is finished, you can read each one much quicker. My tests also indicate that the reads might be a bit more stable too.

Demo attached.

Only down side is that to write to that therm_bulk_read file, you need to alter its permissions down in the /sys directory, not hard but necessary.

Davo 
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

devEric69

  • Hero Member
  • *****
  • Posts: 652
Re: Free Pascal for a small electronic program
« Reply #11 on: February 16, 2026, 06:13:48 pm »
Thank you @dbannon\David.
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

 

TinyPortal © 2005-2018