Old dog, new tricks - learning electronics - Page 1
Forum section: electronics / beginners

author: casterle
author_rank: Regular Contributor
timestamp: December 13, 2020, 01:24:19 am
content: I'm a retired software dev with lots of experience programming to the metal. I had some basic electronics training in the Navy (50 years ago!). As a software contractor I provided my own tools, so I've got some test equipment at hand. Now I want to learn much more about electronics as a hobby.I want to be able to follow a curriculum so I learn logically and don't miss important concepts. I want to learn at at my own pace, and of course in concert with this I will be experimenting along with the wonderful EEVBLOG and other videos on YouTube that have led me so strongly in this direction.I don't have some equipment that will be needed or at least useful. In my explorations I've found a couple of hardware devices that seem well suited to this approach:The Analog Devices ADALM2000 (https://tinyurl.com/y3yefx7y)The Digilent Analog Discovery 2 (https://tinyurl.com/y5exsg4l)The ADALM2000 has a little brother which is too limited. I've also looked at the Red Pitaya, but it's pricy and seems more of a niche product. Other suggestions are welcome. I don't really care about the respective merits of these units as test equipment - my only concern is how much I can learn.Searching EDU sites for PDF files (and thus labs), the DAD2 is used quite a bit more often than the ADALM so there are many more potential classes from universities around the world. I've looked at some of these documents and they're exactly what I'm looking for (some, of course, are not).On the other hand, ADI has gone all-in on educational resources (https://tinyurl.com/y3a5c2db). They have dozens of courses that use their device.If you have experience with one of these devices as an educational tool, which would you choose?Thanks!P.S. I've been told elsewhere that I should avoid hardware entirely and start with textbooks. That's not how I learn best - I want towork through labswith accompanying lessons explaining what I'm doing and why.

author: KWKolb
author_rank: Contributor
timestamp: December 13, 2020, 03:07:04 am
content: I suggest looking at the course materials and find the style and cadence of teaching that most suits your style at this point, rather than get lost in comparing value and price points.

author: casterle
author_rank: Regular Contributor
timestamp: December 13, 2020, 05:20:46 am
content: Quote from: KWKolb on December 13, 2020, 03:07:04 amA good suggestion. I've looked at what's available for each product and, while there's more content for the DAD2, I have found sufficient material for either of the two. It seems to come down to two things: price and availability.The ADI with parts kit is about half the cost of the DAD2 without the parts - not a determining factor, but I can buy a lot of parts for $200. More importantly, I can get an ADALM2000 in a few days whereas it will probably be a couple of months for the DAD2.I've pulled the trigger on the ADALM2000.

author: tchicago
author_rank: Regular Contributor
timestamp: December 13, 2020, 05:50:44 am
content: If you want to build up a good fundamental base, look up the 3-part course called "Circuits and Electronics" at edx.org, it is a class from MIT. It is free if you don't want a paper certificate. It is taught by one of the best educators I've ever seen. I am a software engineer with electronics engineering college background from 25 years ago, and I practice electronics hobby at home. Although I knew most of this, I took this course a few years ago. It was a pure joy, and a bonus of a refresher on modern stuff that happened electronics since my college.

author: Ed.Kloonk
author_rank: Super Contributor
timestamp: December 13, 2020, 06:56:26 am
content: Quote from: casterle on December 13, 2020, 01:24:19 amIt's only a suggestion, but since you have mentioned that you are primarily a software guy and for some reason have limited access to hardware, whatever that means...May I recommend that you set up yourself a nice software SPICE simulation environment? Since you said that you want to go along at your own pace, the internet is, IMO, perfect to suit your goals.After 2020, most educators have realized that structured curricular is a dead duck. Everything you need to know is on the web, when you're ready to absorb it.

author: HB9EVI
author_rank: Frequent Contributor
timestamp: December 13, 2020, 06:27:44 pm
content: The Adalm devices are nice tools, but I don't really see what purpose it should serve you; most people using it here are ham radio operators.If you need something to get into electronics, it's a multimeter. that's a wiser decision than the Adalm2000.since you're coming from the software domain, I wouldn't promote to work software based only; the chance that you get lost again in the software world is too big.for electronics it's essential to work with hardware, with real transistors, resistors and capacitors; these are cent articles and if one spits out the magic smoke you get a new one.a save bet to get into the business are the two books:- The Art of Electronics- Learning the Art of Electronicsimho they're about the best text books there are about electronics. Whenever you take one in hands, you'll end up spending hours reading in it.

author: casterle
author_rank: Regular Contributor
timestamp: December 13, 2020, 07:04:30 pm
content: Quote from: HB9EVI on December 13, 2020, 06:27:44 pmThe purpose of the ADAML is to provide test equipment I don't have in a cheap package. I've got a far better meter than I need (HP 34401A) as well as a couple of handhelds.Quote from: HB9EVI on December 13, 2020, 06:27:44 pmAgreed. Which further attracts me to the ADAML as ADI has built a reasonably priced kit of parts so every lab can be completed without hunting for the right part.

author: rstofer
author_rank: Super Contributor
timestamp: December 13, 2020, 07:21:57 pm
content: I don't know anything about the ADALM2000 but it seems that the Scopy software doesn't have a "demo" device. If it does, I didn't find it. The Digilent Waveforms software does have a "demo" device so you can play with all the features without spending any money.I learn more from labs than books. I can spend an entire day with a 0.1 ufd capacitor and a 10k resistor playing with them in the time and frequency domain. Just wire up a low pass filter and run the Bode' plot. Notice how the -3dB point is exactly where the book says it will be. BTW, just try to get a real Bode' plot out of a scope. Even the Siglent approach of linking an AWG to the scope doesn't produce anything close to a real Bode' plot. See attached. You have no idea what I went through to get a plot like this back in undergrad (about '72).You might look into Digilent's Real Analog coursework. There are lectures, notes and labs. They tend to use the AD2 but it's all the same.https://learn.digilentinc.com/classroom/realanalog/w2aew has some great videos as does Dave. Look for Dave's Fundamental Fridays videos.Analog Devices also has a large series of course work which I expect is developed around the ADALM2000 but workable in any other environment. It looks very interesting!https://wiki.analog.com/university/courses/electronics/labsA lot of people really like the Art of Electronics (lectures), Learning The Art of Electronics (lab work) and the X Chapters (corrections and additions to Learning...). I find books related to theory to be quite boring, I prefer to see the results in real hardware.Absolutely, install LTspice (free). Simulation isn't hardware but it has a place.There are hundreds of threads on DMMs but count on needing at least 3 over some period of time. You have a good start.Of course, the ADALM2000 can serve as 2 DMMs, among many other things.You absolutely want to play with hardware. That Analog Devices program looks VERY interesting!I don't know much about ham radio, I use my AD2 and Digital Discovery as logic analyzers and as a way to display very elementary circuits. It is absolutely the best learning device on the planet. That's why they're out of stock since students can't go to the real labs. Put an AD2 and laptop in your backpack and you can work anywhere.

author: casterle
author_rank: Regular Contributor
timestamp: December 13, 2020, 07:25:11 pm
content: Quote from: tchicago on December 13, 2020, 05:50:44 amI started to watch a few minutes of the first lecture this morning - I had a hard time stopping! I think I'm going to enjoy learning from this talented instructor!

author: rstofer
author_rank: Super Contributor
timestamp: December 13, 2020, 07:44:45 pm
content: Khan Academy has an Electrical Engineering curriculum in addition to the mathematics program for which they are world famous.https://www.khanacademy.org/science/electrical-engineering#introduction-to-eeAt some point, math becomes a stumbling block for most budding EEs. Things just don't stay linear very long. Once we throw in capacitors and inductors, the math gets heavy. Khan Academy can help. Or, skip it and let LTspice do the work.For those with a programming background, you can have a lot of fun with MATLAB or Octave. Extra credit if you solve partial differential equations in Fortran. Python has libraries for everything. I suspect that Python is the right way to go at the moment.Here's another highly regarded book:https://www.amazon.com/Electronic-Principles-Albert-Malvino/dp/0028028333

author: casterle
author_rank: Regular Contributor
timestamp: December 13, 2020, 07:46:45 pm
content: Quote from: rstofer on December 13, 2020, 07:21:57 pmI do as well.Quote from: rstofer on December 13, 2020, 07:21:57 pmI looked for something like this for the AD2 but didn't find it. Thanks for the link.Quote from: rstofer on December 13, 2020, 07:21:57 pmI blame Dave for my current interest in electronics.Quote from: rstofer on December 13, 2020, 07:21:57 pmThis, along with the scarcity of AD2s, led me to decide on the ADI device. I was downloading ADI coursework and prerequisites and as I recall, LTSpice was on the list.Had the AD2 been readily available I probably would have gone that direction. But in the long run, I may be better off with the ADAML due to its open 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.

author: casterle
author_rank: Regular Contributor
timestamp: December 13, 2020, 08:00:06 pm
content: Quote from: rstofer on December 13, 2020, 07:44:45 pmI just looked at the EE classes at Kahn; I'm not sure how to think about the math. I've never been good at math, or at least never liked it enough to become good at it. Can I learn practical electronics without learning the math?For example, when I was in nuke school in the Navy, we learned what was to me some steep math early on. This enabled us to understand the physics involved in nuclear reactors and their peripheral systems so we had a foundation upon which to build. Once that foundation was in place, we never had to think about the math again to progress. Can a tool like LTSpice substitute for the math in this case?

author: rstofer
author_rank: Super Contributor
timestamp: December 13, 2020, 08:37:16 pm
content: Quote from: casterle on December 13, 2020, 08:00:06 pmAt the hobby level there are a lot of equations just handed out without derivation. Plug and crunch as my grandson would say.Nobody is good at math unless they do it every day. LTspice is certainly a help as is MATLAB with Simulink and any of a bunch of programs. There are other tools that can be discussed as the need arises. wxMaxima comes to mind.It seems reasonable to expect everybody to be able to solve simultaneous equations because you can't get far with Kirchhoff or Thevenin without solving them. But they are usually sparse matrices and can be solved with row elimination. Google for it!A little algebra like Vout=Vin(1-e-t/Tau) where Tau is the time constant equal to R in Ohms times C in Farads, will come up early on with capacitors and some form of scientific calculator will be a help. See the blue trace in the attached. I'm pretty sure this is the time domain project with my favorite 0.1 ufd capacitor and 10k resistor.It really depends on how far you want to go with the topic. One way is to just learn what you need to know when you need to know it.I think one of the reasons I like lab experiments it that they reinforce a rather obscure concept like the capacitor charging circuit. Note that in 6*Tau the blue trace in the first attachment has just about reached the maximum. You can also write a quick little program to solve that equation for various values of 't' and plot the results. MATLAB or Octave is your friend:Code:V0 = 1; % assume a supply voltageR = 10000; %10k OhmsC = 0.1*10^-6; % 0.1 ufdTau = R*C;t = linspace(0,8*Tau);Vchg = V0 * (1 - exp((-t/Tau)));Vdis = V0 * (exp((-t/Tau)));plot(t, Vchg)grid onhold onplot(t,Vdis)ylabel("Voltage")xlabel("Time - seconds")%there is a known bug in 'legend', the [h,~] is a kludge to work around it[h,~]=legend("Charge Voltage","Discharge Voltage");figure(gcf) % or shg command - pull plot to topfor Tau = 0:6pct_charge = V0 * (1 - exp((-Tau))); %percent charget1 = -log((1-pct_charge)); % my versiont2 = log(1/(1-pct_charge));% book versionfprintf("%% Tau = %.0f Percent Charge = %5.2f,\t t1 = %7.3f, t2 = %7.3f\n", ...Tau, 100*pct_charge,t1,t2)end% output% Tau = 0 Percent Charge = 0.00,t1 = -0.000, t2 = 0.000% Tau = 1 Percent Charge = 63.21,t1 = 1.000, t2 = 1.000% Tau = 2 Percent Charge = 86.47,t1 = 2.000, t2 = 2.000% Tau = 3 Percent Charge = 95.02,t1 = 3.000, t2 = 3.000% Tau = 4 Percent Charge = 98.17,t1 = 4.000, t2 = 4.000% Tau = 5 Percent Charge = 99.33,t1 = 5.000, t2 = 5.000% Tau = 6 Percent Charge = 99.75,t1 = 6.000, t2 = 6.000See second attachment. The important part is that Tau=1 ms and the charge is 63.21% Note especially that the X axis is time in seconds times 10-3. In other words, milliseconds. This notation was chosen by MATLAB and I didn't change it.I think that this type of programming might be useful.

author: rstofer
author_rank: Super Contributor
timestamp: December 13, 2020, 09:00:37 pm
content: Simulation... It's not real, you know!Here's the thing: You should be able to look at a circuit, make a few rough calculations and get an understanding of what is happening. You should have a pretty good idea what is going to happen before you do the experiment on the breadboard or in the simulator. The breadboard will give you "real" answers. They may be a bit off due to the effects of the breadboard itself but this won't be a worry at low frequencies. If you built the circuit correctly, what you see is what you get. Transistor Beta is a classic example: The specs might say it's anywhere between 100 and 300 - that's kind of a big range and collector current versus base current will show the difference - dramatically. BTW, that's why those differential scope inputs on the ADALM2000 are so important. You need to measure base current by measuring the voltage drop across the base resistor and that's a differential measurement. You might also want to measure collector current by measuring the voltage drop across the collector resistor. Again, a differential input is helpful. More on differential inputs later...But the simulation could be all over the place. The simulator correctly analyzes the circuit it sees but that might not be the circuit you intended. How do you know? And it will usually pick some arbitrary Beta which isn't at all like the transistor on your breadboard. You can iterate over values of Beta I believe. We could with the IBM Electronic Circuit Analysis Program I was using back in '70 or so.Something else to think about: Differential inputs come standard on the scope inputs of the ADALM2000 and AD2 (and AD). People have to pay extra for differential probes for regular scopes and they aren't cheap! Well, in the case of the AD2, they are differential right up until you use the BNC adapter board where the shell of the BNC gets connected to ground and the inputs are no longer differential.

author: rstofer
author_rank: Super Contributor
timestamp: December 13, 2020, 09:51:02 pm
content: I see where two of the experiments at the Analog Devices site are nearly identical to the plots I attached above:https://wiki.analog.com/university/courses/electronics/rc_transient_responsehttps://wiki.analog.com/university/courses/electronics/lp_hp_filtersI think that anybody who works through the examples given at the site will have a darn good understanding of electronics:https://wiki.analog.com/university/courses/electronics/labsI like the Raspberry Pi and I like running my Analog Discovery 2 on the same Pi where I am generating signals like I2C and SPI that are headed to off-board devices. I'm using the platform to debug signals generated on the platform itself.Highly recommended kit:https://www.amazon.com/Freenove-Raspberry-Processing-Tutorials-Components/dp/B06W54L7B5I have a terminal window open to run the various experiments and the Waveforms application open to see the various signals. The AD2 will decode SPI and I2C (plus UART and parallel) and this is quite handy.Waveforms and the AD2 are not required for using the kit but they add a lot to the experiments.

author: casterle
author_rank: Regular Contributor
timestamp: December 13, 2020, 10:04:56 pm
content: Quote from: rstofer on December 13, 2020, 09:00:37 pmOf course the EE's I worked with used MATLAB routinely, but given its price and my limited need I've never looked at it. A script-driven tool could be very useful. I'd never heard of wxMaxima or Octave before but I'm downloading them as I type. Here a link to an interactive tool that looks to be along the same lines:http://www.falstad.com/circuit/index.htmlExperiments using real parts is important for a reason I'd never considered until a few weeks ago. I was watching one of Dave's videos in which he pointed out the importance of consulting the datasheet from the specific manufacturer of that part. I'd just assumed that all parts with the same number from all trustworthy manufacturers would work identically.Quote from: rstofer on December 13, 2020, 09:00:37 pmThat's something I hope to learn to do. Thanks again!

author: casterle
author_rank: Regular Contributor
timestamp: December 13, 2020, 10:17:38 pm
content: Quote from: rstofer on December 13, 2020, 09:51:02 pmI'm looking forward to getting started.Quote from: rstofer on December 13, 2020, 09:51:02 pmI ordered the ADALM2000 which has a different app, but I've got 3 monitors on my main workstation for a nice roomy layout.

author: rstofer
author_rank: Super Contributor
timestamp: December 13, 2020, 10:25:33 pm
content: That MATLAB program I posted above is known to work on Octave. The X axis scale is different and I should thicken up the traces but, hey, it works unchanged.For wxMaxima, here is a script that is known to work. Use Cell->Evaluate All Cells to run the script.Code:R:6.8*10^3$ /* 6.8k resistor */C:10*10^-6$ /* 10 microfarad capacitor */Tau:R*C; /* time constant Tau=R*C */SixTau:6*Tau;Vapplied:100$ /* applied voltage is 100 to make% scale on graph *//* equation for Vout(t) */Vout(t):=Vapplied*(1-%e^(-(t/Tau)))$t(tau):= tau * Tau$ /* graph x axis is in units of Tauconvert to units of t for calculation */plot2d([Vout(t(x))], [x,0,6], [y,0,Vapplied],[xlabel,"Tau" ],[ylabel,"% Charge"],[gnuplot_postamble, "set grid;set title 'Capacitor Voltage';"])$The syntax of wxMaxima is a little odd, at first, but you get used to it. Look at the 2d attachment.

author: rstofer
author_rank: Super Contributor
timestamp: December 13, 2020, 10:40:24 pm
content: The Home License for MATLAB is $149 and the add-ons like Simulink are $45. I hesitate to use the word 'just'. These are perpetual licenses but there is an annual subscription fee of about 50% if you want to keep up with releases.https://www.mathworks.com/products/matlab-home.htmlWhere my grandson attends university, MATLAB is a required subject in the first semester. They use it for everything in all of the STEM programs. I really wish such tools had been available when I was in school about 50 years ago. Some concepts just can't be visualized on a slide rule.Until you come up with a need for SimuLink which requires MATLAB, I would think you could get along quite nicely with Octave. Free is good!But I'm not going to give up MATLAB!

author: rstofer
author_rank: Super Contributor
timestamp: December 13, 2020, 11:45:48 pm
content: Here is an interesting thread on mesh analysis of an AC circuit. Lots of imaginary numbers demoted by %i. Pay attention to orolo's replies. He really gets the math.https://www.eevblog.com/forum/beginners/mesh-analysis/I have a wxMaxima solution at the very end. Pretty clean considering everything.https://www.eevblog.com/forum/beginners/mesh-analysis/150/This isn't a 'day one' problem but it does show the utility of wxMaxima in solving a large set of equations.

author: casterle
author_rank: Regular Contributor
timestamp: December 14, 2020, 03:45:34 am
content: The thread on mesh analysis, or anything else involving imaginary numbers, is something I am not ready for. As far as MATLAB goes, last time I looked they only had student and standard licenses. But since GNU has provided Octave I need not worry.Perhaps my attitude will change, but I see math more as a necessary evil and less as an enjoyable challenge.

author: rstofer
author_rank: Super Contributor
timestamp: December 14, 2020, 05:14:18 am
content: Quote from: casterle on December 14, 2020, 03:45:34 amYou won't run into this kind of thing until you start working with AC circuit analysis and that will be a while. The need for complex numbers comes about when dealing with phase shift. Look at that Bode' plot I posted above. The bottom trace is the phase shift and it's 45 degrees at the -3dB point. Much later on you will run across why this is true but, for now, it's only a curiosity. Don't give it a moment's thought. I just wanted to post a decent wxMaxima example that the entire group played with a while back.QuoteI posted a link above for the Home License of MATLAB. There is no reason to go there until you want to start using SimuLink. Octave will do the job just fine. There is a book related to MATLAB and Electronics that might be useful at some point. It should work with Octave:http://ee.hacettepe.edu.tr/~solen/Matlab/MatLab/Matlab%20-%20Electronics%20and%20Circuit%20Analysis%20using%20Matlab.pdfQuoteI enjoy playing with the tools. I remember struggling with this stuff back in the early '70s where we had no tools other than a slide rule. It would have been much less of a struggle with modern tools. Today's students don't realize how good they have it.Nobody likes the math and, for the hobbyist, not all that much is actually required. Those textbook problems, like Simon's Mesh Analysis above, seldom come up in the hobby world. They are problems designed to make things more difficult. "The Art of Electronics" has, as its claim to fame, a limited math approach to electronics. That's why so many hobbyists like the book and its companions.I hated the math in school. I gave up completely on analog circuits and spent my time concentrating on digital. "Every idiot can count to 1" - Bob Widlar (very famous analog engineer at National Semiconductor)

author: casterle
author_rank: Regular Contributor
timestamp: December 14, 2020, 07:53:12 pm
content: Quote from: rstofer on December 14, 2020, 05:14:18 amGood. I never understood 'imaginary' numbers and with luck that won't change.Quote from: rstofer on December 14, 2020, 05:14:18 amThank you. A quick glance led to a surprise - matrices. I started to realize the power of matrix math watching a video in which it was used. I have no idea how it works, but I'm far more interested in this than in complex numbers with their mysterious imaginary friends. Do I need to understand matrices *before* MATLAB will be of use?Quote from: rstofer on December 14, 2020, 05:14:18 amGiven what you've shown me WRT MATLAB, perhaps my attitude is already getting better.I, too, enjoy tools. I remember when Lotus 123 first came out - I had absolutely no use for a spreadsheet (or so I thought), but it fascinated me and I played with it for probably hundreds of hours, to the point that I made some good money as a consultant.Quote from: rstofer on December 14, 2020, 05:14:18 amI have avoided analog electronics for the same reasons as you. It was Dave and other generous teachers on YouTube that motivated me to try again. Others have recommended "The Art of Electronics", but you're the first I recall mentioning the limited math - time to take a look!

author: rstofer
author_rank: Super Contributor
timestamp: December 14, 2020, 10:08:16 pm
content: MATLAB -> MATrix LABratory -- of course it uses matrices! Even a simple variable is treated as a 1x1 array.No, MATLAB isn't just for matrix math, you can even do a bunch of calculations from the command window. Values that you set are saved in the Workspace window. So, you can define variables and save/change their values and chain as many commands as necessary to calculate some result. But you really don't want to do that for anything other than the most trivial calculation.You really want to create a script because, when it doesn't work, you can edit just the offending lines of code and run again. Using the command line, you may need to reiterate several steps to get intermediate values before getting the final solution.A long time ago ('88), I was involved with the design of a semiconductor plant. I wanted to verify pipe sizing on the Deionized Water branch and return lines by assuming certain flows to drain (water leaving the system) and certain flows to return. Water must remain above 100 fpm in all pipes and so on. This is across the entire production floor, in all the aisles. Hundreds and hundreds of feet of pipe and I have forgotten how many branches but it seemed like a lot.I modeled the system in Excel and got it to balance in two iterations. I don't recall how I did it but I'm guessing "Method of Residuals" that was taught in grad school for heat transfer from a hot spot. All part of a required Numerical Analysis course.In any event, it worked, the flows were correct, the return pipe was necessarily smaller than the supply pipe and so on.In thinking about it today, it isn't unlike a bunch of parallel branches containing a series of resistors with an applied voltage and solving for currents (flow rate). I didn't think of that at the time... The point is, Excel was a matrix and this was a matrix problem. Each cell was an element of a much larger matrix.You just never know when these tools will be exactly the thing you need. Of course, things were a little more limited 30 years ago.One thing that comes up in MATLAB is creating a matrix where one wouldn't think. Consider plotting a sine wave: All we need is a series of points to plot as a function of x: y=sin(x). So, I give sin a value for x and it returns the sin(x). If I give it a bunch of values, I get the results that should be a sine wave.MATLAB just about forces you to make x a vector of values, as many points as you want in the result. Then sin(vector x) returns a similar vector of sin(x) values and we plot the vector x and y for as many points as are in the original x vector. In Fortran, we would step through a bunch of values, in MATLAB, the values are already in the x vector. C would also be step by step and C++ would hide everything in a class.Here is a little sine wave example. Note how few lines of code are required and how the fact that x and y are vectors doesn't even come up. That single statement y=sin(x) is magic! In one line of code we took values of x, all 101 of them, took the sin of x and stuffed the values in the y vector - all 101 values.Don't let vectors and matrices be some kind of bug-a-boo. They are a natural way of expressing certain operations.If you get into Kirchhoff's Laws, you will be doing matrix arithmetic to solve several equations in several unknowns. You can solve directly with MATLAB/Octave or by hand using row reduction. Here's a video and there is a part 2 to go along with it.https://youtu.be/9LYVi-n-6JwThis stuff may be tedious but it isn't hard.Code:x=0:2*pi/100:2*pi; % create vector x with values of 0 to 2*pi and% 100 intervals - 101 elementsy=sin(x); % create vector y with values y(x) = sin(x)% 101 elements - computed in a blink of an eyeplot (x,y) % plot the curveylabel('Sine Function') % label the Y axistitle('SIN(x)') % add a titleaxis([0 2*pi -1.5 1.5]) % set the x and y axis limitsshg % show the graph% notice how the x axis runs from 0 to about 2*pi% and the y axis runs from -1.5 to +1.5I forgot the output plot, now attached

author: rstofer
author_rank: Super Contributor
timestamp: December 14, 2020, 11:49:09 pm
content: Where we're going with this stuff...I created a little circuit with 2 voltage sources and 3 resistors. We label the drawing with an assumed current flow direction. We start at ground, go up through a battery (assume a voltage gain) and go through all the resistors from + to - as labeled. These are all voltage losses. The interesting resistor is R1 where both currents are flowing and the voltage is a function of both. The sum of the gains and losses around a mesh is zero. That's the basic point of Kirchhoff's Voltage Law.You can see the Mesh1 and Mesh2 equations from Kirchhoff's Voltage Law in the code. Define the 2 meshes, set up the matrices and solve. Print the results! That's about all there is to it.Code:syms I1 I2Mesh1 = 28 - 4*I1 - 2*I1 - 2*I2 == 0;Mesh2 = 7 - 1*I2 - 2*I2 - 2*I1 == 0;[A,B] = equationsToMatrix([Mesh1, Mesh2],[I1, I2]);X = linsolve(A,B);fprintf('%s %6.3f %s\n','I1', X(1), 'Amps', ...'I2', X(2), 'Amps');% results% I1 5.000 Amps% I2 -1.000 Amps The assumed CCW current flow is wrong,% the current is actually flowing into V2Notice that I2 is negative. This means that my assumed current flow direction is wrong and the battery is actually being charged from V1 at a rate of 1A. It's ok to make an error in direction, the sign of the result will fix everything. The trick is: if the current passes through a resistor from + to -, it will result in a voltage drop. Looking at just I1, starting at ground, we have a gain of 28V, a loss of 4 Ohms * I1, a loss of 2 Ohms * I1 and a loss of 2 Ohms times I2 (both currents pass through R1 and the voltage drop is R1 * (I1 + I2).Keep this post in mind when you get into Ohm's Law and Kirchhoff's Laws. You absolutely need Kirchhoff's Laws, you can't even begin to discuss op amps without Kirchhoff's Current Law (KCL).I have also attached the LTspice file.

author: rstofer
author_rank: Super Contributor
timestamp: December 15, 2020, 12:48:47 am
content: Row elimination and substitution methods - much easier on the eyes:https://youtu.be/XOJgzW4P7T8https://youtu.be/YriMMWbndn0

author: casterle
author_rank: Regular Contributor
timestamp: December 15, 2020, 01:50:45 am
content: Quote from: rstofer on December 15, 2020, 12:48:47 amI 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!

author: RoGeorge
author_rank: Super Contributor
timestamp: December 15, 2020, 02:37:28 am
content: Quote from: casterle on December 13, 2020, 07:46:45 pmIt is calledbitstream. 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 thebitstreamis 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 thebitstream, 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 aschematicdiagram, and the toolchain converts that schematic into abitstream, which is a list of electrical interconnections to be permanently made inside the FPGA- the MCU/CPU text source "code" describes analgorithm, 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 stepFPGA: text schematic -> bitstream -> FPGA fixed schematic reacting all the time to inputs in no particular orderTo 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_enA 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:#!/usr/bin/env python3from scipy.io import wavfilerate, x = wavfile.read('test_mono.wav')from matplotlib import pyplot as pltfig, (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) overlapingplt.tight_layout()Or maybe you are a Linux user and prefer to pipe some bytes into aplay to make(sorry for the pun) a signal generator straight from the command line:Code:.LOG00:15 2020.01.12================Created proj "P079 - Sound with aplayer C and Makefile" after founding an example of a 1 kHz audio generatorhttps://www.eevblog.com/forum/testgear/question-cheap-pure-sine-wave-genertor-1khz/msg2866736/#msg2866736Contentents of Makefile:------------------------all : sin./sin | aplay -r 48000 -c 2 -f S16_BEsin : sin.cgcc -o sin sin.c -Wall -pedantic -O4 -lmContentents 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/'makeIt works!:o)

author: rstofer
author_rank: Super Contributor
timestamp: December 15, 2020, 03:46:15 am
content: Quote from: casterle on December 13, 2020, 07:46:45 pmYou 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 boardhttps://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.comhttps://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/Perhapshttps://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!

author: casterle
author_rank: Regular Contributor
timestamp: December 15, 2020, 05:18:11 am
content: 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.