Lazarus

Programming => Embedded => Operating Systems => Embedded - AVR => Topic started by: ccrause on June 30, 2019, 10:15:20 pm

Title: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: ccrause 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.
Title: Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: jwdietrich 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?
Title: Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: lucamar on June 30, 2019, 11:37:20 pm
Sounds quite impressive. Congratulations! ;D
Title: Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: kupferstecher 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.
Title: Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: d.ioannidis 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 (https://github.com/dioannidis/fp_ethernet_enc28j60.git). What do you think, will be possible to send the data via ethernet ?

regards,
Title: Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: ccrause 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 (https://github.com/dioannidis/fp_ethernet_enc28j60.git). 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).
Title: Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: Thaddy 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!!
Title: Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: wp 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?
Title: Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: Thaddy 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...
Title: Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: wp 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".
Title: Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: ccrause 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.
Title: Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: Paul Breneman 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!
Title: Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: fred on July 07, 2019, 03:06:03 pm
Great!
Now I have to look for my Arduino and find time :)
Title: Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: GAN on July 07, 2019, 10:34:31 pm
Congratulations!

Can you add this to the wiki? https://wiki.freepascal.org/Lazarus_Application_Gallery (https://wiki.freepascal.org/Lazarus_Application_Gallery)
Title: Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: ccrause on July 08, 2019, 09:56:49 am
Congratulations!

Can you add this to the wiki? https://wiki.freepascal.org/Lazarus_Application_Gallery (https://wiki.freepascal.org/Lazarus_Application_Gallery)
Thank you.  Done.
Title: Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: ccrause on July 27, 2020, 09:05:39 am
Congratulations!

Can you add this to the wiki? https://wiki.freepascal.org/Lazarus_Application_Gallery (https://wiki.freepascal.org/Lazarus_Application_Gallery)
Thank you.  Done.

Updated wiki link: https://wiki.lazarus.freepascal.org/Projects_using_Lazarus_-_Hobby_software#LazScope
Title: Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: ccrause on March 25, 2023, 06:09:37 pm
A new version of the LazScope (https://github.com/ccrause/LazScope) project has been released.  A few bug fixes and an 8 bit mode was added.

Attached an example trace of a middle C note played on a laptop and captured over the headphone jack.
Title: Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: Thaddy on March 25, 2023, 06:19:53 pm
Nyquist?
https://en.wikipedia.org/wiki/Nyquist_frequency

The graph overshoots so the sampling is not correct. Not good for your ears. Just like my Marshall 130 watt clone is not good to my ears: London City, just from 1966 1969, made in Amsterdam. The latter is less painful than sampling overshoots and more mellow, but too loud.

Anything recorded like that can be thrown away.

What it shows is ear problems and a bad mixer (human, not table)
And even if it is called "concert pitch" it is waaaaay to high. (My Piano tuned at 402, which is low, but more natural)
Title: Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: Fred vS on March 25, 2023, 07:42:47 pm
A new version of the LazScope (https://github.com/ccrause/LazScope) project has been released.  A few bug fixes and an 8 bit mode was added.

Attached an example trace of a middle C note played on a laptop and captured over the headphone jack.

Hello Ccrase.

Out-of-the-box, brilliant, nice and fast.

Big wow + congrats.

Fre;D
Title: Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
Post by: ccrause on March 25, 2023, 07:57:05 pm
Nyquist?
https://en.wikipedia.org/wiki/Nyquist_frequency
The sample frequency is about 63 kHz, so should be fine for capturing a 261 Hz sine wave.

Quote
The graph overshoots so the sampling is not correct. Not good for your ears. Just like my Marshall 130 watt clone is not good to my ears: London City, just from 1966 1969, made in Amsterdam. The latter is less painful than sampling overshoots and more mellow, but too loud.

Anything recorded like that can be thrown away.
This is a "pure" sine wave sample file, played via my laptop sound chip and sampled with a simple wire via blocking capacitor and DC offset resistor divider (https://github.com/ccrause/LazScope/blob/master/images/DC_offset_circuit.png) connected to a headphone jack.  Most of the noise in the plot is probably due to either low quality onboard amplifier or ambient electromagnetic interference picked up by the unshielded probe wire.  Note that even a Rigol DS1102E oscilloscope with a proper shielded probe shows significant noise for this, so the problem is probably somewhere between the sound chip and the location of the probe.
TinyPortal © 2005-2018