Tag Archives: Homebrew

Parts Store On A Chip (CPLD / FPGA) – CPLD’s in the Shack

My “go to” tool when breadboarding is often an evaluation board with a Xilinx CPLD. A complex programmable logic device (CPLD) is a programmable logic device with complexity between that of PALs and FPGAs, and architectural features of both.

A CPLD is like a Digikey catalog on a chip. It includes simple logic devices like ANDs, NANDs, ORs, NORs, and XORs. There are Flip-Flops, FIFOs, MUXs, Counters, Compares, Latches, pull ups, pull downs, tri-state I/O, Schmitt triggers, and the list goes on and on. A small device has 64 user I/O ports and larger devices can have 100s of ports.

CPLD - A wide range of devices is available.
Figure-1 A wide range of devices is available.

Figure-1 is the pallet of available parts. The Category Logic is selected; the first 13 device showing are ANDs ranging from 2 to 5 inputs. An “and1b1″ is a simple AND with one standard input and 1 inverting input. There are also designs for RS-232/422, SPI, I2C etc on the web that are constructed from the pallet devices.

Once a symbol is placed on the schematic you can right click on the device and see its description and logic table. Most of the time the VHDL code is also available for editing if desired. Knowledge of VHDL or Verilog is not required to design at the schematic level. The schematic symbols are connected by placing a wire or bus between ports.

Ports can be configured into various I/O Standards. A “bank” can be configured for 5.0-volt logic and another bank can be 3.3V, 1.8V or 1.2V which is useful if you need “Glue Logic” between one standard and another.

The best part is it is very easy to take advantage of this capability. There are numerous eval-boards priced from $3-$15 for a board like the one in Figure 2.

$10 CPLD evaluation board
Figure-2 $10 CPLD evaluation board

At the $50 mark, you can get a board with LED lights/digits, buttons, switches, pots, etc.

At higher price points you can get USB, GB Ethernet, HD-LCDs and HMDI ports but they may be beyond schematic level designs and will require VHDL or Verilog skills.

In contrast, there is the dead bug (Figure 2a) approach. The disadvantage to this approach is you must have the “bugs” on hand, the clock rate is limited to a few MHz due to wire length (CPLD clock speed can be > 125MHz), and “edits” are done with a soldering iron with the power off instead of a text editor with the circuit running.

Two dead bugs
Figure-2a Two dead bugs

The software tool to configure the CPLD is the Xilinx ISE WebPack which is a free download and a programming dongle that can range from $15 and up. Many boards include the programmer on the board eliminating the need for a dongle, all that is needed is a USB cable to the PC.

I have designed a small device in Figure-3 as an example. There are 3 distinct circuits. I have included an inverter for those times you have a signal that needs to be inverted, an 8 bit counter with a parallel output, and a Flip-Flop that shares the input with the inverter circuit.

Design ready to download onto a CPLD
Figure-3 Design ready to download onto a CPLD

The example shows an Inverter/Flip-Flop circuit and a counter circuit. They are independent of each other. The ability to have a large number of independent parallel circuits gives CPLD/FPGA an advantage over microprocessors in certain applications, especially DSP circuits.

The Xilinx ISE tool will produce a block diagram (Figure-4) of the circuit.

CPLD Top Level Block Diagram
Figure-4 Top Level Block Diagram

By clicking on the block diagram you can open the detailed circuit (Figure-5), further, the complex elements within the circuit can be expanded.

 

Detail Schematic produced from synthesized CPLD design
Figure-5 Detail Schematic produced from synthesized CPLD design

These are not a “redraw” of the original schematic. They represent the final design after the schematic was translated into HDL by ISE and a circuit design synthesized from the HDL code. This process is transparent to the user.  This capability is very useful when designing in HDL. It allows you to discover errors in the code quickly.  It is easier for many hardware designers to “debug” the firmware code by following wires on a schematic.

A CPLD board can be very useful in the Ham Shack when positive control is needed. In situations with multiple antenna switches, band switches, and amplifier keyer lines where control logic is important a CPLD design is a great approach. Once the required logic and lockouts are determined the logic design can be completed at the schematic level and the CPLD configured.

The CPLD uses Combinational Logic, it is completely deterministic. Even with a lot of care, a microprocessor has the potential to fall into a disallowed state that could potentially damage equipment. By using hardwired logic this becomes nearly impossible without an actual hardware failure.

If you find an error or change your station simply change the schematic and re-flash the CPLD. (The days of one-use fused link logic are behind us).

Xilinx ISE includes the capability to write a test bench where you describe the full range of inputs and it will display the corresponding output states and timing in Logic Analyzer style. The displayed data is based on actual physical device timing constraints and will allow you to trap switching glitches and logic errors.

While I have focused on CPLDs everything written above can be applied to FPGAs. The different is 100% transparent except the cost may be slightly higher for a small FPGA evaluation board. The first step up from a CPLD in the Xilinx line would be a Spartan device which has considerably most resources and higher performance. While schematic input is an easy place to start ISE is a widely used tool for both VHDL and Verilog HDL coding. It is hoped you would at least dabble in HDL once you have a board.

I have described getting started with CPLDs as easy. I find it much easier than coding in C where just keeping the tool set happy with its countless libraries that must be on the correct path and 100 other ways to generate errors.  I enjoy coding in VHDL, for me, it is easier to “think” in terms of wires and buses. With that said there are a few minor hills to get over to start using ISE to configure a CPLD/FPGA.

Here are the three largest issues:

  1. ISE WebPack is four 2 GB files. An 8 GB total download of compressed .tar files.
  2. The process of generating and downloading the free license can be a challenge, and then you get to install it.
  3. Getting an inexpensive aftermarket programming dongle to be recognized by ISE and the PC can require patience.

Once the program is installed and working the rest of the issues are nits. As a hardware designer, I consider them nits.

  1. You can only attach one wire to a port pin if you want more than one it must be to a buffered pin.
  2. The logic must be deterministic, in short, you cannot have two outputs tied together unless it is through a AND, OR or similar. Each connection must have a clear “true or false” state.
  3. The ports you defined in the schematic must be routed to a pin on the CPLD. This is accomplished with a .ucf or User Constraint File. The constraint file format looks like this: NET “name” LOC = “P(pin number)”;  That is it.

The following is part of the Constraint file for the schematic shown in Figure 3 and is compatible with the eval-board shown in Figure-2.

# This is an example of a constraint file
NET "Flip_Flop_Output"LOC = "P5";
NET "Clock"LOC = "P30";
NET "Inverter_In"LOC = "P7";
#NET "P7"LOC = "P1";
'#' indicates the line is commented out and is ignored

Most boards are supplied with a constraint file so you know which pins go to the switches and LEDs, and which ones you can use. If their names are P1, P2, P3 in the constraint file and you have named your ports Clock, Clear, and Count you will hang up on an error. The same is true if you do not use ports P7-P64 in the design and leave them un-commented in the constraint file. If it is in the design it must be in the constraint file, and vice-versa.

  • There is a short list of special Key words to include CLK, CLR, and NET. These and other Key words must be avoided until you get past the basics and understand their use.

ISE does a good job of providing a Web link for errors in ISE. The linked page will tell you the problem, likely cause, and the solution.

Here is a schematic of a 4 digit display, it still has 44 user pins available.

CPLD used to drive a 4 Digit Display
Figure-6 CPLD used to drive a 4 Digit Display

 

 

 

 

 

 

 

 

If nothing else ISE is a great way to draw schematics.

If you are interested in adding CPLDs and FPGAs to your tool kit I would be more than glad to get you set up and give you a short tutorial.

Hamilton,  K1HMS

Show Your Love for Amateur Radio on Feb. 14

February 14, 2017, now represents two important days: Valentine’s and Nashua ARC’s Feb Tech Night! Nothing else says love like telling that special someone — you want to solder some electronics 🙂

Back by popular demand (and good reviews from others) is our kit building night. Everyone had a blast on Election Night building the Pixie kits, and on V-day, we are going to work on a DIY oscilloscope known as the DSO138. (It is mere coincidence FYI that our kit building nights have fallen on holidays, of sorts).

The nice thing about this kit, of course, is being able to visualize some of the basic waveforms used in electronics. The kit does come with a square-wave test signal, but we will also have a signal generator present to visualize more complicated waveform.

Building this kit is an excellent opportunity to hone those soldering skills, brush up on electronics theory, and add another fun toy to your growing (or perhaps overflowing) collection. The price point is definitely fair for an oscilloscope and may help you figure out if you’ll want a more sophisticated one down the road.

We had about 15 people last time, so I think this time, it’d be great to expand that number to 20 (or more)! Buy a kit here, and join us in February! Looking forward to seeing you.

Brian, AB1ZO

Moxons in the Attic (Part 3)

Well, another month has gone by on my two-band attic Moxon antenna project.  If you recall from last month, I was left with a perplexing matching problem with the 15M antenna while the 17M one works fine.  I had to figure out how to come up with a way to chase down what was causing the problem.  I guess this just proves that there is no such thing as a simple, straightforward antenna project.

So, with a can of suds as brain fuel, I sat down to methodically list what to do and rule out possible causes.  As a starting point, I connected a 1:1 balun to the 15M and a no-balun, connection to the 17M beam.  This time, I decided to do all measurements from the shack so that losses from the shack coax would be taken into account.  SWR checks on each antenna were consistent with earlier measurements, namely an SWR <2:1 on 17 and 15 meters using the 17M Moxon while rising to 4.4:1 – 6.0:1 across the band when switched to the 15M beam.

Ameritron RCS-4 Antenna Switch
Ameritron RCS-4 Remote Antenna Switch

The next step was to rule out any leakage inside the RCS-4 remote switch.  I decided to try this step because I was suspicious of the current design of the RCS-4.  I had used one for about 20 years in good ol’ NH weather without a problem.  The new unit, however, felt light.  The relays in the remote unit were too quiet for my liking, and an AC power pack replaced the internal power supply from the old unit.  I moved the 17M connection to the last position on the switch so that it was on a separate relay from the 15M antenna and measured.  No change.  I then disconnected the 15M antenna from the switch, leaving it open, and measured.  Again, no change.  I connected a jumper across the 15M connector to short the antenna elements together and measured both bands on the 17M antenna.  As observed earlier, the 17M beam works fine on both bands, indicating the 17M Moxon does not see the 15M one.

OK, so now what?  It was clear the 15M beam was being influenced by the 17M one.  I decided to check the phasing between the two beams wherein the center and shield sides of the coax were connected to the respective sides of each beam.  The casual observer will recall a demonstration by Dale, AF1T of what happens when stacked beams are fed in-phase or out-of-phase.  However, since I’m operating on two different bands, why do I want to do this?  The answer: electromagnetic behavior is complicated; just ask J. C. Maxwell.

To do this, I connected a center insulator that has an integrated PL-259 connector to the 15M beam.  I had used this connector in the past and it was already marked for the shield and center conductor sides.  I checked the balun connections that I had removed from the 15M beam, found the shield side on the first try, and marked it.  I installed the balun on the 17M beam which now represented the opposite of the previous antenna connections.  My rationale for doing this was that a direct, non-balun connection showed a good match on 17M.

Measurements from the shack on the 15M beam now showed an average SWR of ~3.3:1 across the band, better than before but not great.  Measurements on the 17M beam when tuned to 15M, however, were clearly worse with an average SWR of 4:1.  Measurements on 17M were also degraded with the SWR above 2:1.  Clearly, the antennas were not happy with this arrangement.  I decided to disconnect the 15M beam from the RCS-4 switch based on the noticeable change observed on the 17M beam, and remembering that the 17M beam did work before on 15 meters.  When I tuned the 17M beam across 15 meters, the SWR jumped to 8:1.  I was now suspicious of what effect the balun was having on antenna behavior.  Why should the performance be significantly worse with a balun when compared to the simple split feed of the center insulator?

I pulled the insulator and the balun off the antennas to check the connections again.  I was surprised to find that the center insulator showed an open-circuit for the center conductor side.  Even more surprising was the fact that the balun showed the same thing, meaning NO CONNECTION to one side of each antenna.  I looked at the lugs for each device where the center conductor was and noticed that they were loose.  Furthermore, the PVC plastic around each lug had been melted from my efforts to remove old wire and solder from the lugs.  Murphy, you struck again!

In desperation, I took a hacksaw to the top of the center insulator connector to check the center wire inside.  I found it to be intact so I then removed the eye-bolt and replaced the lug with a new one.  The connection to the PL-259 center conductor now worked.  I could re-use the “topless” insulator since it would be in the attic and not exposed to rain.  I scrutinized the same lug on the balun and figured the melted PVC plastic, as in the case of the center insulator, must have formed an insulation between the lug and the eye-bolt to the balun center conductor.  I scrounged around the junk box and found another PL-259-equipped center insulator I could use.

I trudged back up to the attic and reinstalled the center insulators on each beam and scrambled back to the shack to measure things.  This time, SWR for the 17M Moxon was flat across the 17M band vice over 2:1 before.  Performance on 15 meters for the 17M beam was now down to 2.2:1 which was certainly better than 8:1.  The 15M Moxon, however, still showed slightly greater than 3:1, indicating some interaction was still going on, or still a mismatch.  Now what?

As I pondered what could be happening, I remembered something about RF chokes around the coax jacket to prevent common-mode interference.  I recalled my education about rejecting common-mode interference from a presentation by Chuck, W1HIS, aka, Doctor “Ferrite”.  Chuck is the de facto High Priest of Common-Mode Exorcism to prevent RF from entering the shack via feed lines and anything else that comes into the shack.  (By day, Chuck is an MIT professor emeritus.  The Dr. Ferrite title has been bestowed upon him for his prolific use of ferrite chokes throughout his house.  He hates RF noise.)

Admonishing my transgression, I grabbed a couple of ferrite cores from my junk box and scurried up to the attic.  I wrapped as many turns as possible of the RG-8X coax line from the shack until there was no more slack on the attic floor.  I also wrapped a few turns of the coax from the 15M Moxon around a core.  Sadly, there was no change when I checked each beam from the shack.  Well, at least I was relieved that I did not appear to have RF sneaking back into the shack and playing tricks on me.

OK, what next?  As I pondered what to do it occurred to me that the antennas were fed in-phase wherein the shield side of each antenna was the same.  The logical next step was to feed them out-of-phase.  I removed the center insulator for the 17M Moxon and reversed the leads so that the coax center conductor was now under the shield side of the 15M Moxon.  A sweep of the 17 and 15-meter bands while feeding the 17M Moxon showed an SWR under 2:1 for each band.  Switching to the 15M Moxon and sweeping the band still showed the perplexing behavior of SWR greater than 3:1.  I did a sweep of several MHz above and below the 15-meter band to determine if the 15M Moxon might be resonant elsewhere but it was not.

Well, at this point it looks like I can operate two bands with the 17M Moxon so it is not a total loss.  I am back to where I started in terms of performance of the antennas except the flaky balun is gone for 15 meters.  I checked how the EZNEC pattern looks when operating at 21 MHz with the 17M antenna and it does not look much different from 18 MHz.  On the bright side, I can always use the tuner in the K3 to make the 15M Moxon play right for the band, giving me some flexibility if I can hear a station better on one antenna than the other.  Like I said, the electromagnetic behavior is a complicated phenomenon.

Ed, K2TE

Radio Amateurs Developing Skills Worldwide