Recent

Author Topic: Lazarus oscilloscope - FPC firmware + Lazarus GUI  (Read 1149 times)

ccrause

  • Full Member
  • ***
  • Posts: 183
Lazarus oscilloscope - FPC firmware + Lazarus GUI
« on: June 30, 2019, 10:15:20 pm »
I am exited to have build a first useful project integrating embedded controller (atmega328P on Arduino Uno board) and desktop app using only FPC as compiler and Lazarus as IDE!  The controller collects 1200 10 bit samples in a buffer, which is then transmitted to a PC over serial/USB.  The desktop app collect the data and display it in a TChart.

Note that this post is not really about yet another Arduino oscilloscope (Github alone lists 153 projects for Arduino oscilloscope) - I'm exited by having the option of a Pascal toolchain from firmware to desktop software.

jwdietrich

  • Hero Member
  • *****
  • Posts: 1032
    • formatio reticularis
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #1 on: June 30, 2019, 11:01:24 pm »
This is very interesting. Did you program the embedded controller in Pascal or Object Pascal, too? Can you provide a link to the software, its description or a paper about it?
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.0.2 | FPC 3.0.4 | PPC, Intel, ARM | macOS, Windows, Linux

lucamar

  • Hero Member
  • *****
  • Posts: 2025
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #2 on: June 30, 2019, 11:37:20 pm »
Sounds quite impressive. Congratulations! ;D
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

kupferstecher

  • Sr. Member
  • ****
  • Posts: 294
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #3 on: June 30, 2019, 11:46:08 pm »
Nice!

I did something similiar with an STM32, also programmed in FreePascal. But not as sophisticated as yours: No trigger, fixed ports and only single shot.

Dimitrios Chr. Ioannidis

  • Jr. Member
  • **
  • Posts: 83
    • Nephelae
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #4 on: July 01, 2019, 12:23:15 am »
Congrats Christo !

Does continuously sends live the data via uart ?

I'm finishing the driver for the enc28j60 ethernet controller. What do you think, will be possible to send the data via ethernet ?

regards,
Dimitrios Chr. Ioannidis
http://www.nephelae.eu

ccrause

  • Full Member
  • ***
  • Posts: 183
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #5 on: July 01, 2019, 07:12:16 am »
This is very interesting. Did you program the embedded controller in Pascal or Object Pascal, too? Can you provide a link to the software, its description or a paper about it?
Firmware is pure Pascal, it isn't sophisticated enough to warrant OP.  Code: https://github.com/ccrause/LazScope

Does continuously sends live the data via uart ?

I'm finishing the driver for the enc28j60 ethernet controller. What do you think, will be possible to send the data via ethernet ?
Not really live streaming, it is more a packet of data on request protocol. The GUI requests a data packet from the controller, the controller then read the ADC until the data buffer is full, then sends the data buffer to the GUI.

I think it will be easy to update the firmware to communicate over ethernet (if the ethernet driver can allow a say a 100 millisecond gap to collect and  pack the ADC readings).

Thaddy

  • Hero Member
  • *****
  • Posts: 8965
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #6 on: July 01, 2019, 08:45:22 am »
I did something similar, but probably less complete for KOL. NoteTChart is actually a very, very slow component, so I wrote my own (in 2003) with a ~ 10 millisecond resolution and a 64 bit buffer.
I have always loved these kind of projects. Good job!!
Most people that want to use threading should learn to patch their jeans first: use a needle.

wp

  • Hero Member
  • *****
  • Posts: 6235
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #7 on: July 01, 2019, 10:33:27 am »
TChart is actually a very, very slow component, so I wrote my own (in 2003)
Why do you think that TAChart is "very, very slow". Did you apply it properly? And the first commit for TAChart in the Lazarus repository is dated 2007. So how could you say in 2003 that TAChart is slow?
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Thaddy

  • Hero Member
  • *****
  • Posts: 8965
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #8 on: July 01, 2019, 10:37:02 am »
I did not write TAChart, I wrote TChart... which is around since Delphi 1..... And slow.
The author of TAchart must have thought the same thing....Reading is an art...
« Last Edit: July 01, 2019, 10:43:24 am by Thaddy »
Most people that want to use threading should learn to patch their jeans first: use a needle.

wp

  • Hero Member
  • *****
  • Posts: 6235
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #9 on: July 01, 2019, 10:51:43 am »
Reading is an art...
Yes, and I am aware that I am not the best in it. But in this case your post was misleading because the main chart component of both Delphi and Lazarus is called "TChart". "TAChart" is the name of the entire charting library of Lazarus while that of Delphi is called "TeeChart". So, it was not clear that you mean "TeeChart" when you were talking of "TChart".
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

ccrause

  • Full Member
  • ***
  • Posts: 183
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #10 on: July 06, 2019, 06:04:59 pm »
Rearranged main form, serial port can now be selected from dropdown list.  Baud rate could be changed if firmware runs over slower connection. GUI tested on Linux Mint 19.1 and Windows 10.

Paul Breneman

  • Sr. Member
  • ****
  • Posts: 290
    • Control Pascal
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #11 on: July 07, 2019, 01:28:25 pm »
Rearranged main form, serial port can now be selected from dropdown list.  Baud rate could be changed if firmware runs over slower connection. GUI tested on Linux Mint 19.1 and Windows 10.

Fantastic!  What you've created and the new embedded forum sections made my day!
Regards,
Paul Breneman
www.ControlPascal.com

fred

  • Full Member
  • ***
  • Posts: 151
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #12 on: July 07, 2019, 03:06:03 pm »
Great!
Now I have to look for my Arduino and find time :)
Started with OmegaSoft Pascal on OS-9/68k , now Lazarus 2.0.4 / FPC 3.0.4 on Windows 7

GAN

  • Full Member
  • ***
  • Posts: 224
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #13 on: July 07, 2019, 10:34:31 pm »
Congratulations!

Can you add this to the wiki? https://wiki.freepascal.org/Lazarus_Application_Gallery
Lazarus 1.8.4 FPC 3.0.4 Linux Mint Mate 17.2 x86_64 GTK-2
Zeos 7.1.3 - Sqlite 3.8.2

Foro Lazarus en español http://forum.lazarus.freepascal.org/index.php/board,73.0.html

ccrause

  • Full Member
  • ***
  • Posts: 183
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #14 on: July 08, 2019, 09:56:49 am »