You can use almost any FPGA. But should you?

A reader wrote:

Will the Digilent Arty S7-50 FPGA board handle all of the WebFPGA labs in LAoE?

It could be overkill, but it’s on  sale for 20% off and has some expansion capabilities that interest me. Plus, someone might get it for my birthday. 😀

My response:

There is no reason the Arty S7-50 should not work with all the labs except the ones in Chapter 18S which are Lattice iCE40 specific. We don’t use any fancy features of the FPGA, and the Spartan 7 has way more logic cells than the iCE40. You would, of course, have to use the Xilinx/AMD development tools. In addition, you would have to run wires from the Arty board to your breadboard.

Honestly, though, the magic of the WebFPGA is the simplified zero-install development environment. I can tell you when I first tried FPGA development I spent way more time struggling with the development tools than actually learning to use FPGAs. Xlinx was particularly annoying because there were multiple separate tools for each step of the process and when something did not work figuring out where the problem was was exhausting. (The developers of the tools also exposed EVERY parameter controlling their operation so finding the relevant one was very difficult.)

Since you are putting together your birthday request list, why not add the WebFPGA. (I just added a solder rework station to mine.) If you do decide to try the labs with the Arty board, let me know how it goes.

Read More

The Parts Lists now include parts organized by Lab

A reader suggested “[it] could be very good to have the list organized by lab directly.”

My response: A great suggestion. Both the Analog and Digital parts lists now include a list of parts organized by the lab they are used in.  The HTML and Excel versions include a tab at the bottom of the page that selects between the parts organized by function and parts organized by lab.  The PDF versions have the parts organized by lab as a extra page at the end of the documents.

Read More

Why not use the new built-in Arduino debugger for microcontroller development?

A reader pointed out that:

“The [the SAMD21 alternative] Arduino Zero not only comes with a preinstalled debug header, it comes with the debug hardware included. There is no additional debug hardware required at all. You can debug directly using the Arduino IDE.

Although more expensive than the other M0+ boards, it turns out cheaper in total as you don’t need the debug hardware.”

My response:

When I created the new microcontroller lessons in summer 2020 the debugger IDE was not available (except as a beta).  I did try it out at the time but had trouble getting it to work.  Even now, the Arduino IDE debugger is still somewhat limited – offering only high-level access (at the C code level) and tied to the Arduino ecosphere. It also is limited to a small number of boards without the hardware debugger (it was even fewer then).   Also, I prefer (for pedological reasons) to be able to examine disassembled code and raw memory (see Figure 25S.3 in the book – reproduced below).  At the time, the J-Link EDU Mini was only $13 (it has gone up significantly to $60 since then) so I did not see it as cost impediment.  In my opinion, the Segger debugger is much more representative of modern development/debugging environments and I still feel it provides a better introduction to serious embedded systems development.  It also interfaces well with the Segger embOS RTOS, which I believe is one of the two most important contributions in the second half of the new edition of LAoE (the other being finite state machine software and hardware design concepts).

Seeger IDE state of microcontroller after program loading

Finally, I want readers to consider a microcontroller just another component in a circuit/product design.  The traditional Arduino footprint of the Arduino Zero is not well suited to breadboarding. (See image below.)  I only considered breadboard compatible microcontroller boards in developing the book’s embedded systems labs; however, I did include the  Arduino Zero in the list of alternatives microcontroller boards in Chapter 22O. See https://laoe.link/LAoE_Chapter_22O.pdf, Section 22O.1.2.2, where I also note that the debug header is included (but it may no longer be populated based on the current images on the Arduino store web site).

That said, my undergraduate course used the Arduino environment because it was an easy and fast way to learn embedded systems.  The purpose of this book was to go beyond that into professional development tools, hence the switch to the Segger tool chain.

Arduino Zero and breadboard to test code in book using EDBG and Arduino IDE

I did recently try the internal Atmel Embedded Debugger (EDBG) hardware on the Arduino Zero board with both Segger Embedded Studio and the Arduino IDE (Version 2).  It does not work with Segger Embedded Studio, which only supports J-Link.  There is a no longer supported firmware update for EDBG boards that makes them look like they have an on-board J-Link but the Arduino Zero is not listed as supported and I did not try it. (It requires you to install Atmel Studio.) Your mileage may vary. Please let me know if you get it working.

I was able to compile and test all the exercises in Lab 22L using the Arduino IDE and the Arduino Zero EDBG.  You must remove or comment out the line

  #include "samd21.h"     	  // add to use CMSIS

in each program or you will get a compile error.

Arduino IDE debugging Chapter 22L blink delay function program

Nevertheless, the Arduino IDE supports CMSIS and all the code compiled and ran.  The Arduino IDE runs the SAMD21 at full speed (48Mhz) so you have to slow down the  Delay() routine (I changed the DELAYMUL value from 60 to 6000)  to see the LED blink.

However, when I tried the Chapter 23 Labs, the programs would not compile because the internal Arduino support code already set the SysTick_Handler() to its own interrupt service routine.

C:\Users\David\AppData\Local\arduino\sketches\35BDD63E14BC04C0ACBA81EB7D1B6C1F/..\..\cores\arduino_samd_arduino_zero_edbg_7ab4d6888def7306e779da082f31f5d6\core.a(cortex_handlers.c.o): In function `SysTick_Handler':
C:\Users\David\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.14\cores\arduino/cortex_handlers.c:171: multiple definition of `SysTick_Handler'
C:\Users\David\AppData\Local\arduino\sketches\35BDD63E14BC04C0ACBA81EB7D1B6C1F\sketch\JLink_Blink.ino.cpp.o:D:\Users\David\Documents\Arduino\JLink_Blink/JLink_Blink.ino:37: first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1

Since the embedded system lessons in Learning the Art of Electronics program the SAMD12 “bare metal” (i.e. as though they have control of the entire microcontroller), the lessons in the book conflict with similar code in the Arduino environment. So, while the Arduino Zero should work fine when used with the Segger IDE and J-Link (which do not load the Arduino support code) to implement the lessons in Chapters 23 through 27 in the book, the Arduino Zero will not work with all the lessons when used in the Arduino IDE environment even though the Arduino IDE does support CMSIS.  Looking at the Arduino init() function,  Arduino enables all the SERCOM peripherals (SERCOM0 through SERCOM5), the Timer/Counters (TCC0 – TCC2 and TC3 – TC5), and  the ADC and DAC, so the book code that tries to use these peripherals is likely to conflict with Arduino code.

Read More

How many do I buy of Parts List items without a quantity specified?

A reader asked “I uploaded the BOM [Bill of Materials, i.e., the Parts List] to DigiKey. For the parts where no quantity is specified, does that mean any amount between QTY 1 and QTY10 works?  I see a considerable price drop when QTY10 are ordered, but I am not sure I need too many left-over parts considering that I am not planning to specialize in analog circuits (of course, that thought may change as I complete the labs).

My response:  Many of the resistors and capacitors in the parts lists do not have a value specified in the “Qty Needed” column because we aren’t really sure how many you need and we expect  you to buy a kit of resistors and capacitors, not purchase individual values.  This is because in some cases it either does not matter much which value you use (for example, pull up resistors in the digital labs) and in others you choose the value based on what works in the circuit.  For example, in the filter circuits and the LM555 oscillator, you can use [almost] any resistor and capacitor value that gives you the correct time constant.  So a 1k resistor and 100nF capacitor should work as well as a 10k resistor and 10nF capacitor (both result in an R * C time constant of 100uS).

With only the exception where we have specified a quantity of a particular part, we assume you will purchase a kit of most popular values, which usually includes at least 10 of each value – more than enough for the experiments in the book.   (The 100uF polymer capacitor used in the switching power supply is a special low ESR  [Equivalent Series Resistance] part so it has a quantity but the rest of the capacitors are pretty much generic so do not have quantity specified — but you could use a generic part in the switcher lab and still get an understanding of how switching voltage regulators work, you would just lose some efficiency.) Most of these types of parts make no sense to buy in single quantities – they are too expensive – but a quantity purchase makes little sense for an individual user. A kit is much more economical than buying individual parts for individual use. OTOH, someone stocking a university lab may prefer to buy the values listed at the quantity pricing which is why we have specified particular part numbers –  but in reality, there are dozens of other parts numbers for each of the parts we list that would work as well.

Read More

A reader was confused by the units in the power problem of 1W.2

A reader writes “On Page 47, we’re asked to calculate the smallest 1/4W resistor to be put across a 5V supply. The solution gives P=V^2/R which is correct, but the formula after says R=25^2/0.25 which gives an answer of 2k5 ohms. Not the actual answer which should be R=5^2/0.25=100 ohms.”

I responded:

I see why you are confused but the “V2” in the formula in the solution are the units for the value “25.”  The “V” in the units is squared but the “25” has already been squared (5 V* 5V = 25 V*V=25 V2).

Annotated formula of 1W.2 Resistor power dissipation problem explaining units notation.

Since this example occurs early in the book, we are trying to show how electrical units relate to each other and we want to encourage students to include the units with values in their calculations.

Units only calculation of power dissipated in a resistor to find smallest value possible without overheating device.

In teaching this stuff we find students often do not carry units though their work and they miss obvious mistakes as a result. (For example, had this calculation used “5V,” the result would have been inverse amps, not Ohms, but if we had written just “5” without the units the mistake would have been less obvious).

Checking units is an easy way to catch errors, particularly when one is still unfamiliar with a subject (although even with years of experience I still include units in my calculations as a check against a mistake). It is too bad we don’t have a symbol for volts-squared, since that would have avoided the confusion.

Read More

Someone asked about N.O. and N.C. contacts on a microswitch

A watcher of my 16N.1.3 Debouncing a Switch with a Set Reset Flip Flop video was confused by the switch having both Normally Open (N.O.) and Normally Closed (N.C.) contacts.  He was used to pushbutton switches which are usually only N.O.  Indeed, most pushbutton switches are Single Pole, Single Throw (SPST) with two contacts and a shorting bar that is held open by a spring so the contacts are open circuit, and then the contacts are shorted together when the user presses the pushbutton.  (There are N.C. pushbutton switches and pushbuttons with multiple contacts, either SPDT or DPST but they are less common.)

Microswitches (miniature snap-action switches), on the other hand, are usually (almost always?)  SPDT with a common terminal and both a N.O. terminal and a N.C. terminal.  See Figure 16L.6 in LAoE or watch the video referenced in Footnote 7 on that page that has a visualization of how a microswitch works and shows the reason we use it for the switch bounce demonstration.

A diagram of a microswitch

Microswitches often include a lever arm to reduce the actuation force and are typically used as mechanical limit switches; they are rarely human actuated like a SPST pushbutton switch.

 Image courtesy of Benjamin D. Esham

The SPST microswitches that I have seen are actually SPDT switches with the N.C. terminal missing or cut off.

See  https://en.wikipedia.org/wiki/Miniature_snap-action_switch for more information.

Read More
As an Amazon Associate I may earn from qualifying purchases on some links.