Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 16:24 26 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Electronics : Spectrogram display - cheap but works well

Author Message
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1418
Posted: 01:34am 28 Jan 2022
Copy link to clipboard 
Print this post

I always wanted a better display of the frequency spectrum of things
compared with what I can get from the Rigol DSOs I have.

Finally got the urge to write some code, to use what I have at hand
so no extra cost. And all open source tools.

The program shows the freq spectrum of a signal in two ways.
One is what it is right now, with a vertical scale in dbV
(20 dbV = 10x difference)
and horizontal scale being the frequency.

The other is the spectrogram waterfall, with colours representing voltage.
This shows how the spectrum changes over time.

this is what it looks like



Bits you need:
a PC running Win10 or something. I had it working on the iMac running OS 10.9 too.
one Arduino Due (about $12 on ebay)

Results and specs:
Input voltage range 0.0 to 3.0V DC with respect to the Due's ground
0.0db = 1.0V signal, peak to peak.

4 K sample window
about 70 db signal to noise ratio
4 frequency ranges (5kHz, 25, 100 and 500kHz)

very decent update rate (see video here    )
14 Hz at 25kHz setting rising to 30 Hz at 100kHz
and then it's about 40Hz update with the 500kHz setting

(5kHz frequency range is very slow since it takes a long time
to get 4K samples at a 10kHz sample rate)

The Due has a 12 bit ADC and that means a signal to noise ratio of about 74 db
is the best you can hope for (the famous 6.02 x Nbits + 1.74db equation)
When the input gets near 3V p/p a bit of distortion appears, usually 2x and 3x
the main peak but this is only at -60db or about 1/1000th the peak's value.

It was huge fun to program and I am amazed how well it works.

Two programs to download and install. Processing4 and the Arduino IDE.
The spectrum program  is
due_fft_both_wide_buttons.zip

and the code for the Due is
high_speed_adc_due_buffer_handshake2.zip

If anyone tries to use this, you will need to alter the COM port name in the main
program to suit what it is on your computer.
wronger than a phone book full of wrong phone numbers
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2075
Posted: 09:27am 28 Jan 2022
Copy link to clipboard 
Print this post

   

very nice.

As first year apprentices we had to make all our own kit, from screwdrivers to frequency counters; "Build it don't buy it (within reason)" - an ethos that has become firmly ingrained and stays with me to this day. This really scratches that itch.
Edited 2022-01-28 19:31 by CaptainBoing
 
iannez
Newbie

Joined: 05/07/2019
Location: Italy
Posts: 23
Posted: 10:24pm 28 Jan 2022
Copy link to clipboard 
Print this post

Hi Poida!

cool :)

but exactly what type of application can serve?

A.
Cheers, Angelo
 
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1418
Posted: 02:09am 29 Jan 2022
Copy link to clipboard 
Print this post

Hi Angelo (good to hear from you)

the applications are mainly educational.
I have had to learn from scratch about FFT, sampling theory,
frequency domain verses time domain, digital filtering
and lots more.

The above thing is good for exploring all of the subjects.

I thought maybe someone here might find this program interesting.

for example, make a circuit to produce a sine wave.
It's likely the output will not be very pure and have small amounts
of other frequencies present. How measure this?
With the above program.

How good is that cheap function generator from aliexpress?
Is the sine wave clean? Is the output linear over frequency.
The FY6900 I bought has an output that falls rapidly after 1Mhz
but it cost $90 so you get what you get.

I am also still looking at the inverter design, in particular
the LC circuit that is the primary winding. We tune the LC to about 50Hz or more
for stable running.
Still there are harmonics present on the output.
The above program can show these harmonics and how they increase and decay
in time during the soft start. (paging Wiseguy! this might be useful for you
with that "grunt" sound issue)
The 50 and 100Hz peaks are not that easy to see but we want to see the changes over time and the absolute values when looking at the LC resonance and the toroid's remenant magnetic flux.

You can use this to see in a qualitative sense the EMI radiation
of the inverter. placing the input wire 5 cm near conductors will pick up
a lot of the 20kHz plus harmonics of the PWM.
We can learn what might reduce it, what happens if you put it in a metal box, etc.

The program has become more advanced after further work.
Now you can choose the sample size (512, 2K and 8K)
and also smooth the spectrum over time to squash the noise.

I also want to make it work with the STM32F103 based  "Blue Pill" microcontroller
This will take a fair bit of time learning that ADC hardware and it's DMA controller.
A Blue Pill costs about $4 and probably can sample data faster than the Due
wronger than a phone book full of wrong phone numbers
 
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1418
Posted: 02:13am 29 Jan 2022
Copy link to clipboard 
Print this post

Captain:

I had a good friend who did his EE degree back in 1978
and he had to build a proper power supply. Probably for to be used
in his further studies.
All discrete and analog. SCR crowbar was specified.
I recall being stoned, very stoned one night as he explained to me
parts of the design. Much laughter too. I miss him. He died from an OD.
wronger than a phone book full of wrong phone numbers
 
Warpspeed
Guru

Joined: 09/08/2007
Location: Australia
Posts: 4406
Posted: 03:22am 29 Jan 2022
Copy link to clipboard 
Print this post

I own two spectrum analysers, both are the old steam powered analog type. Both have inbuilt tracking generators that output a swept frequency at the exact frequency the analyser is looking at. With these I can do many different types of test and measurement.

By using the tracking generator, I can look at the frequency response of individual passive components or whole circuit networks. Ideal for finding unexpected resonances in components, testing various types of filters and amplifiers from audio to VHF.

As a tunable receiver, its handy for example, recently I wanted to measure the exact operating frequency of a radio remote control device, and was also able to look at the transmitted data bit stream direct from the transmitter.

The tracking generator in each also allows me to output a fixed non swept frequency at a known calibrated amplitude. One spectrum analyser I have goes from dc to 100 Khz, the other 8Khz to 3.5Ghz.

Neither are instruments I use very often, but sometimes it allows me to test and do things that would be very difficult to do any other way.
Cheers,  Tony.
 
wiseguy

Guru

Joined: 21/06/2018
Location: Australia
Posts: 1156
Posted: 04:38am 29 Jan 2022
Copy link to clipboard 
Print this post

Poida, I have been watching your post with interest but lately I have very little time to devote to my electronics passion, I am also working 2 days a week now - dont ask....

Since we moved to the new build my workshop has been shrinking and there also seems to be a lot more stuff in it. I have been making do with the sander, grinder, drill press, compressor, bender etc all sharing one power point and nothing bolted to the benches etc for over 18 months - it was all something I would get around to soon. About 6 weeks ago soon arrived and I have been busy installing lots of power points and bolting everything down that moved and a few things that didnt.  The sorting phase has also begun with a view to off loading so much "good stuff" that I might need one day (surely 20+ years is adequate time to wait for that one day ? ).

I have also found that when I am sorting I get slowed down by can it be fixed ratted adapted recovered painted buried or sold - sometimes that takes a while to inspect and decide....

Re my inverter - yes I wanted one with real grunt - I guess you need to be careful what you wish for..... I haven't given up on it, that is too easy, I will solve it but first I need order space and time, currently another work in progress.

I recently bought an electronics microscope with an 8" LCD like this & it works a treat.  I have decided that SMD capability is not really optional any more as through hole continues to become more extinct and SMD more entrenched and my eyesight more feeble it makes more sense.
Edited 2022-01-29 14:40 by wiseguy
If at first you dont succeed, I suggest you avoid sky diving....
Cheers Mike
 
iannez
Newbie

Joined: 05/07/2019
Location: Italy
Posts: 23
Posted: 09:55am 29 Jan 2022
Copy link to clipboard 
Print this post

Hello Peter,
I also like to hear from you !!!

I understand the applications!

It is a long time that certain to create a distortion meter with FFT etc ...
With Arduino it becomes difficult due to limited memory capacity and CPU even if you can create something for low frequency.

With BluePill STM32F103 or Blackpill STM32F411 all this becomes possible if you know how to write code as you do.

Blackpill is better than a whole bluepill except for the part ADC in which bluepill uses a differential ADC.

To program use STM32 core always in the IDE of Arduino:

https://github.com/stm32duino/arduino_core_stm32

Obviously it is also possible to use the register by hand as I had done when we had experienced with Nanoverter.

Now I'm also using the Teensy 4.1 always with Arduino IDE to play a little and try to rewrite Picoverter them above.
The problem here is that the manual is now 3000 pages!
And the register for timer/interrupt etc ... make crazy!

But studying is beautiful the same: D

I always follow you with super interest!

byee, A.
Cheers, Angelo
 
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1418
Posted: 04:41am 30 Jan 2022
Copy link to clipboard 
Print this post

added few things.



wronger than a phone book full of wrong phone numbers
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024