All posts by Zack Goyetche

dsPICduino

 

dsPic_Back

Abstract

As an attempt to start an open source project, I’ve designed a general purpose development board featuring Microchip’s dsPIC along side the ESP8266.

The Arduino has gained immense popularity due to its ability to allow hobbyists to incorporate embedded control/processing into their projects. I am grateful for the Arduino, as it inspired me to explore the field of embedded hardware and software design.

The purpose of the dsPICduino is similar to the purpose of the Arduino — that is, it serves as both a learning and development platform for the aspiring embedded developer. The dsPICduino offers a more immersive embedded experience by stepping away from the layers of abstraction provided by the Arduino ecosystem.

Features of the dsPICduino

  • WiFi station capability (ESP8266 running NodeMCU)
  • Break out of 42 general purpose digital I/O pins
  • Break out 15 analog channels
  • Break out of 12 high speed PWM channels
  • 12 bit DAC (accessable via I2C)
  • Break out of hardware SPI and I2C busses
  • USB to serial converter (FTDI)
  • Easily integrated to character/matrix displays via Parallel Master Port
  • Debugging LEDs and test points
  • Secondary tuning fork oscillator (32.768 kHz) for real time clock/calendar
  • Power over USB or DC barrel jack

Features of the dsPIC

  • Up to 70 MIPS (140MHz with PLL)
  • DSP math function library
  • Dual 40-bit accumulators, single-cycle 16 x 16 MAC, 40-bit barrel shifter, dual operand fetches
  • DMA
  • 10nA sleep current
  • (9) 16-bit timers, or (1) 16-bit and (4) 32-bit timers
  • Hardware Output Compare and Input Capture
  • Motor Control Peripherals with fast and flexible PWMs
  • 1MSPS 12bit ADC or (32) multiplexed analog inputs @ 10-bit
  • SPI, I2C, CAN, UART

Demonstrations

With WiFi and USB incorporated into the dsPICduino, projects can be easily integrated into IoT applications. The following GIFs demonstrate utilization of the USB to serial converter allowing a user to configure the WiFi module to connect to their local network.

termDemo2

Once connected, the WiFi module acts as a station on the network with internet access. From here, HTTP GET requests can be made to then scrape and parse HTML for weather and UNIX time data.

dspicWeatherTime

All of this functionality is complemented by the dsPIC’s ability to perform DSP functions that are useful in signal processing applications such as audio, motor control, and RF.

The following image is a plot of the magnitude of the complex array returned by the dsPIC (off loaded through the debugger) when using it to compute the FFT of a sampled 22 kHz sinusoidal signal on 4 analog channels.

FFT1

 

Code

Link to dsPICduino github repository

Hardware

3D Board model:dsPICv1_3dModel

2D Board layout:dsPICv1board

Schematic:
digitalSch

powerSch

Gerber files:
dsPICduino Gerbers Zipped

BOM:
dsPICduino Bill of Material .xlsx file

 

Bandpass Filter Design using Geffe’s Algorithm

Introduction

Analog filter design can be a tedious task, requiring frequency transformations, pages and pages of algebra, and many simulations to check that you are getting the response you designed for. Through the use of Geffe’s algorithm and Delyiannis-Friend circuits, bandpass filter design can be partially automated.

Delyiannis-Friend circuit with unity gain [1]:

friendCkt

The purpose of this post isn’t to detail the specifics behind Geffe’s algorithm, but rather to share with you a python script I wrote that will apply Geffe’s algorithm to a given set of input parameters, and output the required component values for each Friend circuit.

It is required that you have Python3 along with numpy, matplotlib, and scipy installed on your machine. The script can be executed through the Powershell if you are a Windows user by navigating to the directory where the Geffe_Friend_Bandpass.py file is located and then typing: python .\Geffe_Friend_Bandpass.py

Click here for the Python Script!

Entering Input Parameters

Upon execution, the python script will prompt you for some input parameters.

You are first asked for the maximum attenuation in the stop bands and the minimum attenuation in the pass band.

Then, you are asked to specify the pass band frequencies (f1 and f2) and one of the stop band frequencies (f3 or f4). The other stop band frequency is solved for automatically. See the following image [1]:

BPattenuation

geffe_image1

Parameter Details

The script will then return to you the information you had just entered, along with the minimum order filter required to meet your specifications.

geffe_image2_1

Butterworth Pole Locations

The locations of the poles are returned in both polar and rectangular format.

geffe_image3

Gain Information

The gain of each stage is normalized to unity, resulting in unity gain at the center frequency.

The script can be tweaked to create a filter/amplifier, or an additional amplifier can be added after the filter.

geffe_image4

Required Resistor and Capacitor Values

The script will automatically calculate reasonable component values for each Friend circuit.

Note that n operational amplifiers (Friend circuits) are required for an nth order filter.

geffe_image5

Click on the image to enlarge it, notice how the resistors and capacitors correspond to the output generated by the python script.

geffe_schematic

This example can be used as a general case, and the same arrangement will arise for any nth order output.

Auto Generated Bode Magnitude Plot

The script will then call on matplotlib to generate the bode magnitude plot of the filter. Interactive cursors have been added to allow for inspection of the pass and stop band frequencies.

geffe_plot

Plotting in LT Spice (AC Sweep)

Here is the frequency response of the circuit once it had been built in LTSpice:

geffe_lt_plot

Conclusion

So what is this script good for? Let’s say you wanted to build a circuit that required multiple analog bandpass filters, but don’t want to crank out all the math to calculate the component values.

For example, to create an analog audio spectrum analyzer,

you would need 8-10 bandpass filters to select for various bands of the audio spectrum. You could use this script to design 8 bandpass filters very quickly!

audioBandpassFiltersSch

audioBandpassFiltersPlot

Click here for the Python Script!

References

[1] E., Van Valkenburg M. Analog Filter Design. New York: Holt, Rinehart, and Winston, 1982. Print.