Recent

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


ccrause

  • Hero Member
  • *****
  • Posts: 946
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #16 on: March 25, 2023, 06:09:37 pm »
A new version of the 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.

Thaddy

  • Hero Member
  • *****
  • Posts: 15680
  • Censorship about opinions does not belong here.
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #17 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)
« Last Edit: March 25, 2023, 06:44:20 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

Fred vS

  • Hero Member
  • *****
  • Posts: 3346
    • StrumPract is the musicians best friend
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #18 on: March 25, 2023, 07:42:47 pm »
A new version of the 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
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

ccrause

  • Hero Member
  • *****
  • Posts: 946
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #19 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 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.

CM630

  • Hero Member
  • *****
  • Posts: 1169
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #20 on: June 21, 2024, 08:38:11 am »
Are there chances to run it on more accessible devices like Nano/BluPill/BlackPill/Esp32?
Лазар 3,4 32 bit (sometimes 64 bit); FPC3,2,2

Thaddy

  • Hero Member
  • *****
  • Posts: 15680
  • Censorship about opinions does not belong here.
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #21 on: June 21, 2024, 10:00:18 am »
It may be helpful to hard or soft clip the output with a small and cheap in compute IIR filter in software. It can also be solved if the software is written for, say, -3 dB instead of 0 dB. That is how hardware analog mixers usually work. Since the overshoot is small, try hard clipping (which is simply min/max). All of this won't help if the real waves are distorted: Most simple devices have just ADC 12 bit resolution, that may also be an issue.
« Last Edit: June 21, 2024, 10:19:09 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

ccrause

  • Hero Member
  • *****
  • Posts: 946
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #22 on: June 21, 2024, 12:23:53 pm »
Are there chances to run it on more accessible devices like Nano/BluPill/BlackPill/Esp32?
The data transfer protocol is very simple, so the display side (GUI) can be re-used.  The firmware however needs to be rewritten for the different controller types, since the ADC and USART interfaces are quite different.  The firmware logic is very basic (configure ADC channels, fill buffer with ADC data, transmit buffer over serial, wait for next serial command). With more computing power one could implement more sophisticated features such as improved triggering (slope detection, trigger delay).

Which Nano are you referring to? The Arduino Nano uses an atmega328p, which is supported.

The ESP32 ADC performance is not great, however it adds the option to transfer data over wifi.

Thaddy

  • Hero Member
  • *****
  • Posts: 15680
  • Censorship about opinions does not belong here.
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #23 on: June 21, 2024, 12:34:31 pm »
Slope detection is not necessary, but i would advise a simple 1 pole low-pass filter.
(that is just one state) I have code for that, if required.
« Last Edit: June 21, 2024, 12:36:58 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

CM630

  • Hero Member
  • *****
  • Posts: 1169
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #24 on: June 22, 2024, 04:37:52 pm »
Are there chances to run it on more accessible devices like Nano/BluPill/BlackPill/Esp32?
The data transfer protocol is very simple, so the display side (GUI) can be re-used.  The firmware however needs to be rewritten for the different controller types, since the ADC and USART interfaces are quite different.  The firmware logic is very basic (configure ADC channels, fill buffer with ADC data, transmit buffer over serial, wait for next serial command). With more computing power one could implement more sophisticated features such as improved triggering (slope detection, trigger delay).

Which Nano are you referring to? The Arduino Nano uses an atmega328p, which is supported.

The ESP32 ADC performance is not great, however it adds the option to transfer data over wifi.
Yes, I meant Arduino Nano. Are there any instructions on how to build the BIN for the Nano? Could I flash it through the USB port?
IMHO, uploading BINs for the supported devices might be useful.

I think I like the Blue/Black pills more than the Nano.
« Last Edit: June 22, 2024, 04:40:10 pm by CM630 »
Лазар 3,4 32 bit (sometimes 64 bit); FPC3,2,2

ccrause

  • Hero Member
  • *****
  • Posts: 946
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #25 on: June 23, 2024, 08:35:39 am »
Yes, I meant Arduino Nano. Are there any instructions on how to build the BIN for the Nano? Could I flash it through the USB port?
IMHO, uploading BINs for the supported devices might be useful.
There are prebuilt firmware images for several controllers, including atmega328p. Note that the prebuilt images are built for specific clock frequencies, the atmega328p image is built for 16 MHz clock, which is standard for Uno and Nano boards.

To build a firmware image requires a cross compiler for AVR, and AVR binutils for your host system.  You can build your own cross compiler or (probably much easier) use fpcupdeluxe to do the heavy lifting. And a copy of avrdude to flash the firmware.

Uno/Nano boards should have the Arduino bootloader installed, so flashing over USB should be possible using e.g. avrdude on Linux:
Code: Text  [Select][+][-]
  1. avrdude -c arduino -p m328p -P /dev/ttyACM0 -D flash:w: sampler-atmega328p-16MHz.hex
On Windows the serial port will be something like COM3.

Quote
I think I like the Blue/Black pills more than the Nano.
More horsepower, but also more complex.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11771
  • FPC developer.
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #26 on: June 23, 2024, 11:13:21 am »
I once played around with this project:

https://www.elektormagazine.com/magazine/elektor-201602/28826

though that was because of the network connectivity (with Wiznet W5500).

Note that the project went through a few revisions (in the Dutch version),  and I don't know if this is the final one. Firmware was on github iirc. So some researching required.

But no FPC doesn't support that chip (33e MU/MC series), to my big regret

In the end however I needed a logic analyser more than a scope, and I currently have a dslogic U2 basic

CM630

  • Hero Member
  • *****
  • Posts: 1169
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #27 on: June 26, 2024, 02:19:44 pm »

I have flashed an Arduino Nano with https://github.com/ccrause/LazScope/releases/download/v0.2/sampler-atmega328p-16MHz.hex.
Then I run the Windows executable and connected it to the USB port of the Nano.
When I press “Connect” it says Connecter to COMxxx.
Then I check “Running” or “SingleShot” or both - nothing happens, but it says “Comms timeout”.
Two or three times I got some short waveform, and again “Comms timeout”.
I connected an UART cable instead of the USB - it cannot connect.
Лазар 3,4 32 bit (sometimes 64 bit); FPC3,2,2

Thaddy

  • Hero Member
  • *****
  • Posts: 15680
  • Censorship about opinions does not belong here.
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #28 on: June 26, 2024, 03:00:30 pm »
The comm rate on your port is not correct.
If I smell bad code it usually is bad code and that includes my own code.

ccrause

  • Hero Member
  • *****
  • Posts: 946
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #29 on: June 26, 2024, 10:27:52 pm »

I have flashed an Arduino Nano with https://github.com/ccrause/LazScope/releases/download/v0.2/sampler-atmega328p-16MHz.hex.
Then I run the Windows executable and connected it to the USB port of the Nano.
When I press “Connect” it says Connecter to COMxxx.
This is encouraging, it means that the Nano received and responded to the character 'e', meaning that at least nominally the serial communication is working.

Quote
Then I check “Running” or “SingleShot” or both - nothing happens, but it says “Comms timeout”.
Two or three times I got some short waveform, and again “Comms timeout”.
Checking "Running" without checking "SingleShot" should result in updating of the displayed trace a couple of times per second.  Checking "SingleShot will only display a single trace, then stop.

The serial communication may be marginally acceptable, leading to occasional data errors. You can also test the serial communication with any regular serial communication program/terminal.  After connecting to the serial port, send the 'e' character, the firmware should echo an 'e' back.  This is the initial handshake between the GUI and firmware.  You can also send an 's' character to the Nano, this requests a data frame from the firmware.  Expect a block of binary data as a reply.
Quote
I connected an UART cable instead of the USB - it cannot connect.
This should also work, although it should not be necessary since the USB port on the Nano is also a USB-serial converter.

There may be some latent problems on Windows, I only briefly tested the GUI on Windows. Just about all the development happened on Linux.

 

TinyPortal © 2005-2018