UPC EETAC Bachelor's Degree in Telecommunications Systems and in Network Engineering. Bachelor's Degree in Aerospace Systems Engineering EEL

Lab7

PRJ1  

Laboratory 8

 Pulse width modulation (PWM), D/A conversion, analogue outputs, analogue filters

Lab9

[23/4]

1. Specifications

Our first goal is to generate analogue voltages using (1) PWM techniques and (2) specific D/A chips. For instance, DC, triangular, ramp and sinusoidal waveforms at different frequencies.

We also aim conditioning analogue outputs (1) filtering high frequency noise associated to the D/A conversion process and (2) generating current outputs to drive devices such analogue panel needle meters or 4-20 mA current loops.

We can complement the previous LAB7 circuit adding a real-time clock circuit chip (RTC) and also an EEPROM memory for saving data and parameters permanently. 

Symbol and block diagram

Fig. 1. Block diagram of several analogue output circuits from Arduino.

Single power supply 5V

Active 0dB first-order filter (-20 dB/dec), 5V rail-to-rail operation, cutoff frequency fC= 100 Hz.

Active 0dB second-order Butterworth response filter (-40 dB/dec), 5V rail-to-rail operation, cutoff frequency fC= 100 Hz

Modify and enhance the previous application LAB7 so that in a new state (waveforms) the following voltages and currents are calculated:

- Output VO6 generates the same analogue voltages acquired at VS1

- Output VO5 drives the needle panel indicator coil from 0 to 100%

Drive a 1 mA = IFS needle panel indicator from VO9.

Analogue values will update every TD = 2 s (distribution CLK period).


PWM signals

Pulse-width modulation Wikipedia page.


Digital to analogue converter peripheral

Digital-to-analog converter Wikipedia page.


Low-pass filer design

Wikipedia LPF reference.

Example of passive and active filter circuits.

Other references: Thomas, R. E., Rosa, A. T., Toussant, G. J, "The Analysis and Design of Linear Circuits", 7th ed, John Wiley & Sons, Inc., 2012

 TI, TLV237x: Rail-to-Rail input and output operational amplifiers with shutdown

TI, SBOA231: Single-supply, 2nd-order, multiple feedback low-pass filter circuit

TI, SNOA224A: AN779 National: A basic introduction to filters - active, passive, and switched capacitor

TI, SLOA049D: Active Low-Pass Filter Design.

Proteus: an introduction to active filters (ref.)  


Current sources and voltage to current converter.

Let us drive a moving coil panel meter type SD38/0-1MA. as shown in Fig. 2. The meter scale can be customised to any quantity and span as shown in this reference page.

Analogue needle meter

Fig. 2. Panel analogue needle meter.

Let us drive the coil with a voltage controller current source. This are useful references from Texas Instruments on the design of Howland current sources (1), (2).


Real-time clock and EEPROM.

Using the I2C bus, it is easy to add other convenient modules to our prototyping board. For instance, the DS3231 RTC Module that also includes a 32 kbit EEPROM memory.

DS3231 module

Fig. 3. DS3231 RTC Module.

2. Planning

Hardware

The idea is to continue expanding our previous project LAB7 adding jumpers to three specific pins so that they can be available as analogue outputs disconnecting the LED.

For example, we can connect a D/A converter type MCP4921 by means of the SPI bus.

MCP4921

Fig. 4. MCP4921 breakout (12-bit D/A) for Arduino (ref. including the circuit).

Or instead, in a similar way, an external D/A type MCP4725 can be connected by means of the I2C bus.

MCP4725 Microchip breakout board

Fig. 5. MCP4725 breakout board (12-bit D/A) for Arduino or Raspberry Pi circuits.

Arduino circuits will include the D/A and the analogue filters.

Output filters and SPI D/A converter

Fig. 6. Arduino connections to add analogue filters to the three PWM outputs 5, 6, and 9, and also an MCP4921 breakout board.

To design the 1st-order LPF5 and LPF6, as shown in Fig. 7 we can choose between two models based on OpAmps. We need to analyse its transfer function H(s) in the Laplace domain in order to locate the pole in the required position on the real axis of the left half of the s-plane diagram.

First-order active filterç

Fig. 7. First-order active LPF.

To design the 2nd-order LPF9 we can choose a multiple-feedback configuration as represented in Fig. 8. We need to calculate its transfer function H(s) and be able to locate the conjugate poles so that the frequency response is maximally flat in the bandpass (Butterworth response). 

Second-order LPF

Fig. 8. This is a proposed second order low-pass filter (-40 dB/dec).

To design a voltage to current converter (or transconductance amplifier) we can use the Howland current source shown in Fig. 9 and adjunct it to our requirements to drive the needle panel indicator proposed in Fig. 2. 

Voltage controlled current source

Fig. 9. An example idea on the design of a voltage controlled current source.

 


Software

Function analog_write() function to generate analogue signals.

Interfacing SPI MCP4921 chip, example page.

Interfacing I2C MCP4725 chip, example page.

To start experimenting with analogue output generation we will add another state "waveforms" to our FSM.

Project location:

C:\EMC\LAB8\Temp_LCD_DA\(files)

 

3. Development and 4. testing

Hardware

Fig. 10 shows the virtual simulation first-order filters: filters_freq_response_1st_order.pdsprj.

This is the virtual simulation second-order filters: filters_freq_response_2nd_order.pdsprj.

Second-order filter

Fig. 10. Second order filter captured as a subcircuit in Proteus. It can be tested using instruments and advanced graphical analysis. To obtain the filter frequency response we can simplify the OpAmp using it ideal model.

This is the virtual simulation of the voltage to current converter: Howland_current_source.pdsprj.

Fig. 11 shows the new board enhanced from LAB7 including the digital to analogue new blocks. It includes the software program: Temp_meter_LCD_DA.zip.

Temperature meter with LCD and D/A signal generation

Fig. 11. Application captured in Proteus. Ready for simulation and a first version of the PCB design.


Software

We have to add a new state to generate correctly the D/A signals at the given distribution CLK.

 

Fig. 12. Modified state diagram.


Topics in EMC

 

 

5. Prototyping

We can proceed enhancing the previous LAB7 PCB prototype board adding the analogue filters and the Howland current source as shown in Fig. 13 (LAB8_PCB_v2.zip).

3D view of the top layer

Fig. 13. 3D view of the prototype board completely wired. Only the cooper GND plane is yet to be connected.

 

6. Reporting

Modify and enhance the application so that in the new state (waveforms) another voltage is calculated:

- Output VO9 generates an analogue voltage corresponding to the mean value of the three analogue inputs.

Finally, while the FSM is running, generate an audible 1 kHz sinusoidal waveform output VO from the SPI D/A converter.

 


Annex: Fourier series of a PWM waveform

We can represent a rectangular PWM waveform using a Fourier series, an infinite number of harmonic.

Fourier series of a PWM waveform
Waveform Fourier series PWM

Fig. 1. Fourier representation of a PWM waveform (ref.)

In this way, it is easy to visualise how choosing correctly the cutoff frequency of a LPF we can generate the waveform mean value.

Spectral representation

Fig. 2. Mean value of the PWM waveform filtering all the harmonics.