Recent

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

CM630

  • Hero Member
  • *****
  • Posts: 1197
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #30 on: June 27, 2024, 08:28:27 am »
The comm rate on your port is not correct.

It seems to be fine.

My previous feedback is for the EXE downloaded from github.
Now I build it from the source and it works‽ When I close it it shows two screens with errors, though.
I have connected one pin of a cheap sine generator to GND and the other to A0.
As you see, only the positive part of the sine is shown.
It would be a significant advantage if it was possible to use differential channels (A0 to A1 for example).
Also, I have come on some other oddities:
1. When I select channels 0; 1 and 2 the same is shown on all 3 channels. I suspected that it was because the other pins are floating, but when I disable chan 0 while 1 and two are on, I get no signal measured there (the generator is still on).
2. When I enable all channels and then disable them, I have channels A0 — A7 on the screen. Note that there are no check boxes for channels A6 and A7.
3. As seen from the image, the recorded peaks have different heights, I suppose it is due to a low refresh rate (the generator is not that bad). The frequency of the signal is about 260 Hz.
« Last Edit: June 27, 2024, 08:34:19 am by CM630 »
Лазар 4,0RC1 32 bit (sometimes 64 bit); FPC3,2,2

Thaddy

  • Hero Member
  • *****
  • Posts: 16198
  • Censorship about opinions does not belong here.
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #31 on: June 27, 2024, 08:57:57 am »
If you are sure the generator is good enough, then the problem is in the display code.
The over-shoots can be solved with a low-pass filter, just on the display data, and that data needs to be scaled correctly, i.e. in the integer domain. That can be caused by e.g. round instead of trunk. round can explain over-shoot!
But I suspect there are real over-shoots.
And that can be solved with my previous post.(-3dB)
« Last Edit: June 27, 2024, 09:04:08 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

CM630

  • Hero Member
  • *****
  • Posts: 1197
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #32 on: June 27, 2024, 09:06:48 am »
The signal is definitely not a sine (see images attached), but the amplitude is much more stable than that captured by LazScope.
I can connect a real generator, but I do not believe that there will be a difference in that aspect.
Лазар 4,0RC1 32 bit (sometimes 64 bit); FPC3,2,2

Thaddy

  • Hero Member
  • *****
  • Posts: 16198
  • Censorship about opinions does not belong here.
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #33 on: June 27, 2024, 09:14:40 am »
First one is definitly clipping, second one looks much better.
( that of course does not mean the data clips, but you can easily introduce a clipping effect when processing the data for display)
« Last Edit: June 27, 2024, 09:17:43 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

ccrause

  • Hero Member
  • *****
  • Posts: 970
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #34 on: June 27, 2024, 10:13:10 am »
My previous feedback is for the EXE downloaded from github.

Now I build it from the source and it works‽ When I close it it shows two screens with errors, though.
Please show errors, I will try and fix it.  IIRC I cross compiled the Windows release binary, if this is faulty I will rebuild it on Windows (although the release binary tested fine on Windows 10 Home).

Quote
I have connected one pin of a cheap sine generator to GND and the other to A0.
As you see, only the positive part of the sine is shown.
It would be a significant advantage if it was possible to use differential channels (A0 to A1 for example).
It is indeed possible on some of the AVR MCUs, but not the atmega328p (Arduino Uno/Nano). Another feature could be to enable the build-in ADC gain on the attiny x4 series.

Quote
Also, I have come on some other oddities:
1. When I select channels 0; 1 and 2 the same is shown on all 3 channels. I suspected that it was because the other pins are floating, but when I disable chan 0 while 1 and two are on, I get no signal measured there (the generator is still on).
Yes, floating pins.  When the channel 0 (with the active signal) is unselected, the ADC multiplexer does not connect that pin to the internal sample&hold capacitor, so there is no charge on the sample&hold capacitor when channels 1 & 2 are read by the ADC.

Quote
2. When I enable all channels and then disable them, I have channels A0 — A7 on the screen. Note that there are no check boxes for channels A6 and A7.
If no channels are selected the oscilloscope should effectively be stopped, but this is not currently enforced in the code. So definitely a bug.

Quote
3. As seen from the image, the recorded peaks have different heights, I suppose it is due to a low refresh rate (the generator is not that bad). The frequency of the signal is about 260 Hz.
I assume there is no signal conditioning outside the Nano? Then it may be due to high signal impedance, sampling frequency aliasing, or superposition of an external signal like mains.  Remember that a real oscilloscope has extensive signal conditioning circuitry to help minimize many of these effects.  In your other post it seems as if the signal range is about - 1.1 to +1.3V, however on the first screenshot the maximum voltage is around 500mV, maybe the signal generator impedance is too high for the ADC (> 10 kOhm)? 

ccrause

  • Hero Member
  • *****
  • Posts: 970
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #35 on: June 27, 2024, 10:22:52 am »
First one is definitly clipping, second one looks much better.
( that of course does not mean the data clips, but you can easily introduce a clipping effect when processing the data for display)
I rather think the images you are referring to should be seen as "reference quality" and should not be processed further (since it was captured with a "real" oscilloscope).  In my mind LazScope should try to reproduce the traces from a real oscilloscope as far as possible.  Software processing should only be used to correct artifacts due to the limited analog signal conditioning and ADC limitations of the AVR ADC.

Thaddy

  • Hero Member
  • *****
  • Posts: 16198
  • Censorship about opinions does not belong here.
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #36 on: June 27, 2024, 10:54:34 am »
But that is exactly what I explained or try to explain: the representation of the data in not correct. To correct that, you would need a filter. Not the data itself, but the display needs a filter. The data itself may very well be clean and correct. And a lpf is a one liner... as is scaling to -3dB.
So not affecting the real signal. You can never express the anologue domain in the digital domain without cheating. That's called sampling....that's what an ADC does.
But you know that....
« Last Edit: June 27, 2024, 11:23:57 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

CM630

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

Please show errors, I will try and fix it.
Quote
If I just open and close the app is shows LazScope Error1.png.
If I open it, connect to the Nano and take a few shots, when I close it I get LazScope Error2.png and LazScope Error3.png after it.
I have run strip.exe on the app, when I run it directly from the Lazarus IDE I get ever more error messages.


Yes, floating pins.  When the channel 0 (with the active signal) is unselected, the ADC multiplexer does not connect that pin to the internal sample&hold capacitor, so there is no charge on the sample&hold capacitor when channels 1 & 2 are read by the ADC.
I will connect a 10 kΩ resistor between A1 and GND, I suppose that shall make it show nothing when there is nothing on the input.
Лазар 4,0RC1 32 bit (sometimes 64 bit); FPC3,2,2

ccrause

  • Hero Member
  • *****
  • Posts: 970
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #38 on: June 27, 2024, 04:14:35 pm »
The "errors" you get is a memory report from heaptrace.  It did reveal a small memory leak when the serial handling thread was invoked and terminated, this is fixed in git.  The heaptrace option is now only active when the Debug build mode is selected in Lazarus.  All debug options are disabled for the release build modes, so a release build should not show the heap report (or any other error).

ccrause

  • Hero Member
  • *****
  • Posts: 970
Re: Lazarus oscilloscope - FPC firmware + Lazarus GUI
« Reply #39 on: June 27, 2024, 04:26:52 pm »
But that is exactly what I explained or try to explain: the representation of the data in not correct. To correct that, you would need a filter. Not the data itself, but the display needs a filter. The data itself may very well be clean and correct. And a lpf is a one liner... as is scaling to -3dB.
So not affecting the real signal. You can never express the anologue domain in the digital domain without cheating. That's called sampling....that's what an ADC does.
But you know that....
Thanks for the clarification, I initially misunderstood what you were saying.  DSP is not my forte...

 

TinyPortal © 2005-2018