Author Topic: Old dog, new tricks - learning electronics  (Read 4770 times)

0 Members and 1 Guest are viewing this topic.

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9921
  • Country: us
Re: Old dog, new tricks - learning electronics
« Reply #25 on: December 15, 2020, 12:48:47 am »
Row elimination and substitution methods - much easier on the eyes:

https://youtu.be/XOJgzW4P7T8
https://youtu.be/YriMMWbndn0

« Last Edit: December 15, 2020, 12:50:35 am by rstofer »
 

Offline casterleTopic starter

  • Regular Contributor
  • *
  • Posts: 129
  • Country: us
Re: Old dog, new tricks - learning electronics
« Reply #26 on: December 15, 2020, 01:50:45 am »
Row elimination and substitution methods - much easier on the eyes:

https://youtu.be/XOJgzW4P7T8
https://youtu.be/YriMMWbndn0
I just watched the first of these - very useful (and understandable) - thanks again. I've got more than enough to keep me busy for the foreseeable future!
 

Offline RoGeorge

  • Super Contributor
  • ***
  • Posts: 6620
  • Country: ro
Re: Old dog, new tricks - learning electronics
« Reply #27 on: December 15, 2020, 02:37:28 am »
firmware (is that what you call FPGA code?).

I have no idea what's been written for it by others, but even if no one has turned the device into something entirely different, I'll bet I could learn FPGA coding with it as well.

It is called bitstream.  The fundamental difference between an FPGA and a micocontroller(MCU)/microprocessor(CPU) is that in an FPGA one loads a schematic diagram, while in an MCU one loads a program.

You can think about the FPGA as being a bunch load of unconnected logic gates and flip-flops, and the bitstream is in fact a long list of connections, that tells the FPGA conect this pin from this NAND gate to that pin from that D-type flip-flop, and so on.  Once all the interconnections are made according to the bitstream, that's it, the schematic is loaded and the FPGA will just sit there reacting to input signals.

An FPGA does not execute a program instruction by instruction, like an MCU does, an FPGA simply reacts to input data (please do not nitpick here about the possibility to have a CPU core inside a FPGA, this is irrelevant for the moment and will only add confusion).

There is no order of execution in an FPGA, all its gates and flip-flops are doing their thing as long as they are powered.  On the contrary, an MCU executes instructions in order, fundamentally speaking one after another.  An MCU is a serial machine, while an FPGA is a parallel machine (please don't nitpick here about multicore processors or SIMD instruction in modern CPUs).

My point is, while both the FPGA and the MCU are using ASCII text files for their sources
- the FPGA text "code" describes a schematic diagram, and the toolchain converts that schematic into a bitstream, which is a list of electrical interconnections to be permanently made inside the FPGA
- the MCU/CPU text source "code" describes an algorithm, and is converted into machine code, sometimes called firmware, which is a step by step list of instructions to be executed by the MCU/CPU (again, it's a bird eye view, please don't nitpick here about interpreters or just in time compilers being different from compiled code, and so on)

MCU:    text program -> firmware -> MCU executing machine code step by step
FPGA:   text schematic -> bitstream -> FPGA fixed schematic reacting all the time to inputs in no particular order




To get back on topic, a sound card can be more than enough for basic AC circuits study without buying an oscilloscope or a signal generator.  There are programs to turn the sound card into an oscilloscope, into a signal generator, into a spectrum analyzer or into an AC voltmeter upon wish.  There are many free tools that can do all that, for example this one:
https://www.zeitnitz.eu/scope_en

A solderless breadboard is very handy during hands-on learning or experimenting with physical components.

Even if you prefer experimenting over simulating, from time to time you will still need to simulate a circuit or an idea, and the best tool for that will be LTspice, also free.

Same, Python or LabVIEW (LabVIEW is now free for home use) or almost any other language can control the soundcard and make plots, charts and so on.

For the language, one of the best choices will be Python, probably the most productive programming language ever (I am using it with Spyder as IDE).  Since we were talking about sound card and plots, this is an example that reads a wav file, then plots the waveform and the spectrogram, all in less than 10 lines or so:

Code: [Select]
#!/usr/bin/env python3

from scipy.io import wavfile
rate, x = wavfile.read('test_mono.wav')

from matplotlib import pyplot as plt
fig, (ax1) = plt.subplots(1, 1)
ax1.plot(x); ax1.set_title('Raw audio signal')

fig, (ax2) = plt.subplots(1, 1)
ax2.specgram(x[:, 0]); ax2.set_title('Spectrogram');

# avoid subplot (title) overlaping
plt.tight_layout()

Or maybe you are a Linux user and prefer to pipe some bytes into aplay to make  ;D (sorry for the pun) a signal generator straight from the command line:
Code: [Select]
.LOG

00:15 2020.01.12
================
Created proj "P079 - Sound with aplayer C and Makefile" after founding an example of a 1 kHz audio generator
[url]https://www.eevblog.com/forum/testgear/question-cheap-pure-sine-wave-genertor-1khz/msg2866736/#msg2866736[/url]



Contentents of Makefile:
------------------------
all : sin
./sin | aplay -r 48000 -c 2 -f S16_BE

sin : sin.c
gcc -o sin sin.c -Wall -pedantic -O4 -lm



Contentents of sin.c:
---------------------
#include <stdio.h>
#include <stdint.h>
#include <math.h>

int main(int argc, char *argv[]) {
    int i = 0;
    while(1) {
       double angle = i * 2 *M_PI / 48.0;
       double s = sin(angle);
       uint32_t u_sample = (s+1.0) * 16384;
       int32_t i_sample = u_sample - 16384;

       putchar((i_sample>>8) & 0xFF);
       putchar((i_sample>>0) & 0xFF);

       putchar((i_sample>>8) & 0xFF);
       putchar((i_sample>>0) & 0xFF);

       i = (i == 47 ? 0 : i+1) ;
    }
}



00:35 2020.01.12
================
sin.c and Makefile example files in folder:
    '__Pnnn/P079 - Sound with aplayer C and Makefile/Software/'
   
    cd '__Pnnn/P079 - Sound with aplayer C and Makefile/Software/'
    make
   
It works!
:o)
« Last Edit: December 15, 2020, 03:13:23 am by RoGeorge »
 
The following users thanked this post: xrunner

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9921
  • Country: us
Re: Old dog, new tricks - learning electronics
« Reply #28 on: December 15, 2020, 03:46:15 am »
I have no idea what's been written for it by others, but even if no one has turned the device into something entirely different, I'll bet I could learn FPGA coding with it as well.

You can use your ADALM 2000 as a logic analyzer (within its capabilities) as well as digital IO (LEDs and switches).  You WILL need a logic analyzer if you play with FPGAs - my favorite toys.

For the newer Artix 7 chips (and others supported by Vivado), Xilinx Vivado has an internal logic analyzer so nothing is required.  The thing about external logic analyzers is that you need a LOT of channels, 32 isn't always enough and that means you tie up at least 32 pins which, depending on the chip, may limit what you can design and debug.

The thing to remember about FPGA programming is that it is logic.  A single clock edge may change a million flops and this is why you see a bazillion decoupling capacitors all around the chip.  EVERYTHING happens in parallel and this is totally unlike typical code.  Keeping all those balls in the air inside your head becomes a challenge.

In my view, FPGA boards should have a LOT of gadgets.  I want LEDs, 7 segment displays, slide switches and push buttons.  I certainly want the opportunity to single-step the clock and I probably want to display operating conditions on the LEDs.  So, my favorite board at the moment is the 100T variant of Digilent's Nexys A7 board

https://store.digilentinc.com/nexys-a7-fpga-trainer-board-recommended-for-ece-curriculum/

The Basys 3 board is a possibility but it uses a much smaller chip and while I wouldn't run out of logic, I might run out of BlockRAM.  Nevertheless, I have one...

https://store.digilentinc.com/basys-3-artix-7-fpga-trainer-board-recommended-for-introductory-users/

If you want to mess around with FPGAs, there are some great sites but I like VHDLwhiz.com

https://vhdlwhiz.com/free-resources/

I have finished both of the 'for pay' courses just because I could.  The author spends a lot of time on simulation and that is a topic about which I know nothing.  Worth every penny!  At least to me...

There are a number of free tutorials and they are all high quality.  Highly recommended.

Nandland is another good choice - there is a relatively inexpensive FPGA board for their tutorials...

https://www.nandland.com/

Perhaps https://www.fpga4fun.com/

For retro arcade games:

https://www.fpgaarcade.com/

I built a version of PacMan about 15 years ago:
https://www.fpgaarcade.com/kb/pacman/

If you think computer language wars (C versus C++ versus ADA versus Fortran, etc) get out of control, try opening an FPGA language thread!  You have a choice of Verilog, System Verilog and VHDL (realistic choices, not some proprietary internal Berkeley language).  Go ahead, open a "Which HDL Should I Use" thread.  I dare you!

 

Offline casterleTopic starter

  • Regular Contributor
  • *
  • Posts: 129
  • Country: us
Re: Old dog, new tricks - learning electronics
« Reply #29 on: December 15, 2020, 05:18:11 am »
Thanks for all the FPGA info. They've always seemed like magic - writing code (or something) that creates hardware on the fly.

When I was looking at the DAD2 I noticed their FPGA products but didn't look closely. The Nexys A7 looks like a good place to start when I'm ready.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf