Microbit Function Generator
Introduction: Microbit Function Generator
Waveform generation may not immediately spring to mind with regard to the Microbit as it is a digital device.
However, with the addition of some external logic, waveforms other than pulses can be generated.
This will be realised with a Function Generator, which is a signal generator that produces different types of waveforms.
In this case these waveforms will be sine, sawtooth and pulse with the pulse frequency adjustable over the range 0 to 1MHz.
This project is an enhancement to an earlier project previously published:
Microbit Pulse Generator - Variable Ranges
The enhancements are a custom designed PCB to carry out the D2A conversion for the Sine and Sawtooth waveforms complete with independent outputs and independent amplitude control.
With the addition of an OLED display to indicate range, frequency and output status.
All housed in a custom 3D printed enclosure.
Supplies
MicroBit V1 or V2
Kitronik View Display
SPST Momentary Switch - Qty 2
Dual 4mm Banana plug socket - Qty 3
Potentiometer 5k - Qty 2
Potentiometer 100k
Potentiometer Knobs 6.4mm shaft - Qty 3
Microbit Breakout Board
Jumper Wires M/F - Qty 23
15k Resistor* - Qty 3
27k Resistor* - Qty 3 (Closest available value to 30K)
57k Resistor* - Qty 3 (Closest available value to 60k)
120k Resistor* - Qty 3
100k Resistor
200R Resistor - Qty 2
150R Resistor
330R Resistor
*Resistors 1% tolerance or better.
100nF Capacitor - Qty 6
100uF/10V Capacitor
CD4024 (7 stage Binary Counter)
CD4015 (Dual 4 bit shift register)
CD4030 (Quad 2 input EXOR) alternatively an CD4070 which has the same pinout and function.
MCP602 (Dual Op Amp)
2pin PCB Terminal Strip - Qty 6
8Pin DIL Socket
14Pin DIL Socket - Qty 2
16Pin DIL Socket
M3 x 8mm (screws/bolts) - Qty 32
M3 x 10mm (screws/bolts)
M3 x 30mm (screws/bolts) - Qty 2
Clear/Transparent Perspex - 52mm x 52mm x 5mm
2 part epoxy resin or paint for the text inlay (Optional)
Tools
Pointed nose pliers
Cutters
Soldering Iron
Solder
Screwdriver
Taper Drill 2mm -12mm
Needle files
3mm drill bit
3d Printer
Fine modelling blades
Cocktail sticks or Skewers
Step 1: What Is D2A Conversion
D2A is the process of converting a digital signal into an analogue signal
A digital signal is binary in nature occupying two distinct logic states of high and low or with worst case voltages of ~3V* and 0V with reference to the Microbit.
*(The supply voltage tolerance means that the voltage will vary between Microbit's and for the exact voltage should be measured with a DMM and this substitute in calculations.)
Other logic systems have different equivalent voltage levels that represent logic high or low.
In reality rather than a specific voltage being used to define a logic input state its defined from a threshold value.
A High (1) level >=VIH (70% of 3V) and Low (0) level <=VIL (30% of 3V)
Where VIH =Voltage Input High, VIL = Voltage Input Low
By comparison a true Analog signal can have an infinite number of values and varies continuously with time.
The Analog signals will be sine and sawtooth waveforms.
But how will the conversion for each of these waveforms be accomplished.
Step 2: Digital Sawtooth
A digital sawtooth waveform can be generated using a binary counter with weighted outputs.
Using a 4 bit binary counter we can generate 16 discrete steps
With a resistor R on Q0 a current flows when Q0 is high.
If we place a resistor on Q1 that's R/2 then twice the current will flow when Q1 is high.
Consequently, if we fit resistors of R/4 on Q2 and R/8 on Q3 then we have a binary weighted current for each binary step.
The resistor values following an ideal weighting would be 120k, 60k*, 30k & 15k.
*No preferred resistor value exists for 60k as a single value the closest is 59. 134