Close
0%
0%

Microbit Function Generator

A Function generator producing sine, sawtooth and pulses up to 1MHz using a Microbit, custom PCB and 3d printed box.

Similar projects worth following
145 views
0 followers
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.

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.

Story

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.

Digital waveforms

A digital sinewave waveform can be generated using shift resisters with weighted outputs.

Using two 4 bit shift registers we can generate 8 discrete up steps and 8 discrete down steps for symmetry.

For the first shift register.

With a resistor R on Q0 a current flows when QO 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 weighted current for each step counting up.

For the second shift register.

With a resistor R on Q3 a current flows when Q3 is high. If we place a resistor on Q2 that's R./2 then twice the current will flow when Q2 is high. Consequently, if we fit resistors of R/4 on Q1 and R/8 on Q0 then we have a weighted current for each step that reduces as the count increases.

If the summing point for both counters is connected to a load resistor each current step generates a corresponding voltage step.

The frequency of the output waveform = Fin/2^(n/2) where n = weighted outputs.

Therefore if Fin = 1KHz then the sinewave frequency will be 1000/16 = ~62.5Hz

Circuit Design

The circuit is designed using low voltage logic IC's (Shift register, Binary Counter, EXOR's and OpAmp) using DIL packages for ease of assembly.

The Sawtooth waveform is generated using a CD4024, 7 bit binary counter with binary weighted resistors connected to the 4 LSB outputs.

The clock input is derived from the MicrobIt at output P0.

The control for the clock frequency is provided by a 100k, 10 turn potentiometer with the main resistance connected between 0V and 3V and the wiper connected to P1 of the Microbit to provide a variable voltage (Vv) that is used to vary the frequency.

Vv = Rx/100k*3V where Rx is the resistance between the wiper and the connection to 0V

A POR (Power On Reset), is provided by a CR* network connected to the reset pins to ensure the Counters and the Registers power up in the low state.

*(The CR network pulls the Reset pin High on power up for ~1mS until the capacitor charges then its maintained low by the resistor).

The Binary Counter increments on each negative transition of the clock advancing one count from 0 to 15 then resets to 0 to repeat the cycle.

The result is a repetitive digital sawtooth wave.

The voltage at the summing point is fed to the non inverting input of one half of a dual Op-Amp configured as a non inverting amplifier.

A 5k (Rf) potentiometer is connected in the feedback path in conjunction with a 220R (Rp) to control the waveform output amplitude. Vgain = 1+Rf/Rp with Vgain from 1 to 24 enabling the output voltage to be controlled from ~0 to 3V.

The Shift Register transfers data on each positive transition of the clock and the last stage (Q3) of register 1 is connected to the data input of register 2 with its last stage (Q3) fed back to the data input of register 1.

At switch on all the registers are reset to zero but the inverter connected to the data input of register 1 sets each stage to a logic 1 on each clock transition. Giving a progressive increase in voltage.

Once the last stage of register 2 is set to 1 the data input is set to 0 by the inverter and each stage is successively set to 0. Giving a progressive reduction in voltage.

The result is a repetitive digital sine wave.

The voltage at the summing point is fed to the non inverting input of one half of a dual Op-Amp configured as a non inverting amplifier.

A 5k (Rf) potentiometer is connected in the feedback path...

Read more »

  • 1
    Build processes

    Enclosure Printing

    The individual elements for the enclosure were 3D printed with the following settings.

    Layer Height: 0.15mm

    Infill Density: 25%

    Infill Pattern: Tri Hexagon

    Base Adhesion: Brim

    PCB Assembly

    For ease of assembly mount the components with the lowest profile first progressing to those with the highest profile last.

    As this enables you to solder the components in on a flat surface which helps to hold them in place.

    Resistors.

    Bend the leads of the resistors at both ends with pointed nose pliers and insert the correct value between the holes in the board. The values are printed on the board to reduce errors in assembly.

    Solder the wires to hold in place.

    Sockets

    Insert the IC sockets paying attention to the pin 1 identification and solder in place.

    Ceramic Capacitors

    Bend the wires with pointed nose pliers if applicable to fit between the holes and prevent excessive stress on the component body and solder in place.

    Electrolytic Capacitors

    Bend the wires with pointed nose pliers if applicable to fit between the holes and prevent excessive stress on the component body and solder in place.

    Terminal Blocks

    Insert the pins through the board and solder in place.

    Before inserting the IC's visually check the board to ensure all the connections are soldered and that no solder bridges exist and/or with a DMM (on diode or resistance), check between + and - on the power terminal to ensure there are no short circuits.

    Once you are confident that no shorts or opens exist and that all the passive components are correctly placed its time to insert the IC's again making sure that they are correctly orientated and inserted into the correct socket.

    The names are printed on the board to reduce errors in assembly.

    Ensure ESD protective precautions are followed to prevent damage to the IC's during handling and insertion.

    Box Assembly

    There are a number of elements involved in the box assembly.

    Starting with the base the Breakout board is screwed to the shortest pillars. These are already printed with through holes allowing self tapping screws (M3 x 8mm max.), to be inserted from the top or bolts (M3 x 9mm min), to be inserted from the bottom and a nut fitted on the top.

    M/F 115mm jumper wires connect the Breakout board to the PCB terminal block and Display board.

    The connections from the Breakout board to the PCB are:

    P0 to CLK IP

    P1 to FCTRL IP

    3V to + & 0V to -

    Prior to fitting the PCB the OLED display needs to be connected.

    However, for this project the main edge connector is bypassed and right angle terminal pins are soldered to the I2C expansion port.

    The connections from the Breakout board to the Display board are:

    SCL (19) to SCL

    SDA (20) to SDA

    3V to 3V

    0V to 0V

    The connections to the switches are:

    Enable (Button A- P5)

    Range (Button B -P11)

    With the remaining connections for these two switches connected together at 0V.

    The PCB is fitted to the 27mm pillars with self tapping screws (M3 x 8mm) or bolts (M3 x 30mm).

    Proceed to connect the terminal posts, switches and potentiometers to the front panel.

    The pre-existing holes may need deburring or adjusting in size if different elements are used this can be accomplished with a file or drill as required.

    The front terminal posts are connected to the PCB at the terminal blocks.

    The potentiometers are connected to the terminal pins on the PCB and an anti turn hole may need to be drilled at the rear of the front panel panel as this is not pre-printed.

    Fit knobs appropriate to the potentiometers.

    Once the front panel elements are fitted the display needs to be set in place.

    Included within the box elements are two display slots these attach to the back of the front panel and hold the display in place.

    The upper holes in the slots only sit over the protruding edge of an M3 x 8mm nut and bolt whilst the lower holes are held in place by a nut and bolt that passes all the way through the front panel and the slot.

    However, due to the position of the connector across the top of the display board the display is set back from the opening in the front panel creating a gap. This gap is taken up by a transparent piece of Perspex 52mm x 52mm x 5mm in size.

    At 26mm x 5mm along the bottom of the Perspex block a 3mm hole both in the Perspex and coincident with the front panel is made and held together with an M3 x 10mm bolt.

    The right hand side panel has a 8mm hole to accommodate the USB plug but this may required widening subject to the size of the plug body.

    The box can be fully assembled using the pre-printed holes which align with their neighbouring edges and fixed with M3 x 8mm self tapping screws.

    Text Inlay

    The text is included as part of the 3D printing process for permanency and with the intention that each character will be filled in to create an inlay.

    Prior to filing in the characters some preparation may be required to remove excess material as a result of over extrusion which may create islands or barriers in the character. Use a scalpel or picking tool to remove these.

    The characters could be filled in with a variety of materials, paint, correction fluid, nail varnish or liquid epoxy resin. In this case epoxy resin will be used which will be a 2 part 1:1 mix.

    Epoxy resin pigment is added once the resin is mixed which for this project is a white pigment.

    Depending on the viscosity, the area and level of detail, drying time and ease of cleaning surfaces and material different application techniques can be employed.

    These may range from syringe, paint brush, spreader or dropper.

    The dropper technique using a skewer or cocktail stick will be employed were the stick is dipped into the resin and small drops of resin are transferred to the depression which will hold the resin in place once dry.

    Apply the drops in small quantities and build up the filling, if you over fill; the excess can be removed with a tissue, cotton bud paint brush or skewer.

    The greater the percentage of infill the smaller any bleed through around the character due to the reduction in voids. This bleed through my result in the resin being sucked out of the character being filled.

    You could repeatedly fill the character(s), or refill once the resin has set filled in local voids which my prevent further bleed.

    Once all the letters are filled in leave horizontally until the resin has cured.

    Another example of this technique can be found in a previous project: Micro Binary Clock

View all instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates