Pitch Sequencer for Tascam Porta 02 | PWM Microcontroller Tape Sequencer

by Tape_Tilde in Circuits > Audio

10994 Views, 64 Favorites, 0 Comments

Pitch Sequencer for Tascam Porta 02 | PWM Microcontroller Tape Sequencer

Tape Machine Pitch Sequencer | Tascam Porta 02 and Raspberry Pi Pico
Connected.JPG
DSC08424.JPG
DSC08444.JPG
Electronics.jpg
TascamOpenOnLap_Colour.jpg

This Instructables will teach you how to make a programmable pitch sequencer for any cassette tape machine, using Pulse Width Modulation (PWM) from a Raspberry Pi Pico. By the end of the project you will be able to add pitch and volume automation to your tape loops, using a custom OLED interface and a single rotary controller.

If you have been wanting to add a pitch mod to your tape machine but haven't been sure how, or if you're looking to upgrade your existing pitch mod, this tutorial will guide you through the process from start to finish, including some background theory, and links to scripts and resources.

For more information on the project, visit:

https://www.issacthomas.co.uk/cassettepitchsequenc...

Supplies

The materials list is super cheap and surprisingly simple! The total cost is less than £10!

BASIC MATERIALS

Raspberry Pi Pico ~ £3

Rotary Encoder KY-040 ~ £1.5

OLED SSD-1306 ~ £4

2N7000 N-Channel MOSFET ~ £1

Micropython Code Available Here

ADDITIONAL MATERIAL

If you want to add a volume gate you will need:

LED (doesn't matter what colour/size)

LDR

Heatshrink or Electrical Tape

If you want to make a case:

Any material you like!

You could look at making a 3D printed case, or even look at ways of mounting the circuit into the tape machine. If you end up making it an external module, then I suggest using 3.5mm jack cables to connect between the module and the tape machine.

You will also want:

Wire/Jumper cables

Breadboard

Soldering Iron

BACKGROUND CONCEPT

7EAE5590-5248-4207-89C5-C6E94D5E39F3.JPG

(Main Tutorial starts in Section 2 - feel free to skip ahead)

WHAT IS A PITCH MOD?

Pitch mods are an important part of cassette and circuit bending culture. The basic function of a pitch mod is to control the speed of the capstan drive motor, which in turn controls the playback speed of the tape.

There are many different ways of creating a pitch mod, however, it can often be confusing to design a pitch mod circuit without a strong electronics background. Especially as each tape machine is different and not often easy to find circuit diagrams for.

WHAT IS A SEQUENCED PITCH MOD?

Slowing down playback speed is a really common use of a pitch mod, as it is perfect for making dark ambient textures. However, most pitch mods are controlled using a switch or potentiometer and don't provide any level of autonomy. Although it's often really nice to just set the playback speed to as slow as possible and leave it set there, there is a whole avenue of melodic cassette looping that can be explored by sequencing different playback speeds over time. Therefore, this project was developed to explore using a microcontroller as a custom 8 step pitch mod sequencer that could be programmed to change the motor speed using different tempos and note values.

PULSE WIDTH MODULATION

PWM MOTOR TESTING
PWM Figure.jpeg
SimplePWM_Motor_Schematic.png
SimplePWM_Motor_Breadboard.png

WHAT IS PULSE WIDTH MODULATION (PWM)?

The simplest pitch mod circuit uses a variable voltage divider (potentiometer) in series between the positive wire of the motor to reduce the voltage fed to the motor. This is a type of analogue circuit, and is great in most cases. However, if you want to have a greater level of control, such as reducing the speed by discrete musical intervals, then a digital alternative is likely the best, and easiest option.

PWM is a technique used for mimicking analogue circuitry using digital signals. Since a digital signal is binary, and can only be on or off, the microcontroller can either send the full 3.3v out of the board, or nothing at all. However, if you quickly alternate between on/off, you create a square wave that can be used to control the average output voltage. The Duty Cycle, is the proportion of time in each PWM cycle that the square wave is outputting voltage. A lower duty cycle will produce a lower average output voltage.

MOSFET PWM CIRCUIT

Any of the Pi Pico GPIO pins can output 3.3v PWM, which can provide enough power to run simple circuits such as LED's, Buzzers, and low-power motors, but not enough to drive the 12v drive motor in the tape machine. This is not a problem, as the motor is already powered by the tape machine itself. Therefore, to control the voltage fed to the motor from the tape machine, we can use an N-Channel MOSFET.

An N-Channel MOSFET is a 3-pin transistor that works like a gate. The three pins are called the Drain, Gate, and Source (DGS). The Source is connected to the ground supply from the external power. The Drain is connected to the negative terminal of the motor, and the Gate, is connected to the PWM GPIO pin. Every time the gate is opened by the PWM signal, the Source ground current is allowed to flow out of the Drain pin.

GETTING STARTED WITH THE BUILD

Using the schematics above you can start to build a simple pitch controller for the motor, similar to the one in the video. I suggest using Thonny as an IDE for the Pico. I have provided a basic PWM Micropython script below for you to test!

Downloads

ADDING ROTARY CONTROLS

RotaryEncoder_bb.png
RotaryEncoder_schem.png

ADDING A ROTARY ENCODER

A Rotary Encoder is a device that detects the angular position and direction of a rotary shaft. It looks similar to a potentiometer, however, they function very differently. The rotary encoder is free to spin 360 degrees, and each full rotation will usually provide 20 different position values. The direction of the rotation can be used to adjust variables within a script, ultimately providing a very useful way to interface with the Pico. This project uses a KY-040 Rotary encoder, which also has an inbuilt push button.

The rotary encoder has 5 pins: Pin 1 is ground (GND); Pin 2 is positive voltage supply (VCC); Pin 3 is the Switch detection (SW); Pin 4 is the direction output that provides a pulse when the encoder is rotated (DT); and Pin 5 is the primary output that also outputs a pulse 90 degrees phase shifted from the direction pin (CLK). You can learn more about how they work here.

CONTROLLING MOTOR SPEED

To use the rotary encoder, connect the pins as shown in the breadboard diagram/schematic above. You will need to download this file from GurgleApps to use the Rotary encoder, as it provides some basic functions to get started with. Save this file into the /lib folder on the Pico. You can then use the RotaryEncoderPWM.py file that I have provided below to start using the rotary encoder to control the motor speed.

TUNING THE DUTY CYCLE

Duty Power Law.png

DUTY CYCLE TO FREQUENCY/MIDI NOTE CONVERSION

Now that the PWM can control the speed of the motor, we want to determine the correlation between duty cycle and playback speed. This will allow us to programme the speed of playback using MIDI Note values or frequency values.

To perform this test you will need to record a 1kHz sine wave onto a blank tape loop. Then, using the script from the previous step you need to record the duty cycle when the tape plays back at different frequencies.

I have provides a link here to an excel document to record and plot your results, as well as a PureData patch that you can use as a frequency analyser.

The output of your results will provide an exponential equation in the form Duty Cycle = K*e^a(x), where K is a constant, a is the power, and x is the desired frequency.

The value for my Tascam Porta 02 was K = 4454, and a = 0.002, but yours will likely be slightly different.

CONVERTING MIDI NOTES TO FREQUENCY

Now that we know the equation to obtain the duty cycle, we can convert MIDI Note Values to Frequency values to determine what the Duty Cycle should be for each musical note. This is simply calculated using the equation Frequency = 2^(desired note - 69)/12 * 440

Downloads

OLED SCREEN

pict20220425_164537_0.JPG
Final Breadboard_bb.png

OLED SSD-1306

The OLED SSD-1306 is a 128x64 pixel 0.96" i2C serial protocol display that can be used as a visual interface for programming the sequencer. To start using the OLED you need to import the Micropython SSD-1336 package in the package manager in Thonny, as well as a frame buffer script written by Paul Sokolovsky, available here. As before, save this script into the Pico's lib/ folder.

THREADING AND FRAME BUFFERS

A thread in coding is a single list of instructions. By default the Pi Pico can only process one thread at a time, however, by accessing the second core of the RP2040 chip, you can unlock a second thread to perform a separate task at the same time. This is useful for the OLED, as we can use threading to update the display whilst the first thread runs the main processing tasks. Although the main section of the project doesn't actually use threading, it does get used when running the splash screen when you turn the device on. The splash screen is created using a Frame buffer, which is a set of functions used to update the position of images over time. To add an image to the frame buffer, it must first be converted to a byte array, which can be done using the Image to Byte Array Script by NovaSpirit.

Again, you can test the OLED using the file provided below, following the breadboard diagram above.

Downloads

CREATING THE SEQUENCER

SEQUENCING NOTE VALUES AND TEMPO

Now that all of the hardware required to control the motor has been set up, we can start programming the sequencer. The sequencer interface that I designed allows the user to programme the 8 different MIDI note values and Tempo by selecting each parameter with the rotary encoder and adjusting them individually. These values are automatically saved to a text file so that they can be recalled whenever you close or open the script.

A small bar above each step shows the selected parameter, and a small bar below each step shows the current sequencer position. Pressing the button on the rotary encoder allows you to select each parameter, and then adjust its value individually. The sequencer is fixed to a crotchet note grid, where each step length is 60secs/BPM. Using the time.sleep() function allows the Pico to time when to perform each step.

EXTRA STEP: VOLUME GATE CONTROL

tASCAM vACTROL.jpg
VaCTROL.jpg
oPTOCOUPLER.jpg

WHAT IS A VOLUME GATE?

Gates are a binary trigger, that can either be on or off. They are used a lot in modular synthesis to control different parameters. For this build, I have created a gate circuit that turns the volume of the tape machine on or off. To do this I created a DIY Vactrol, which consists of an LED and a LDR (Light Dependant Resistor) cased inside some heat shrink. The resistance of the LDR decreases when light is shone directly on it. Therefore to control the volume output of the Tape machine, the LDR is connected to the output of the tape head, and the LED is connected to the Pico. In the sequencer, a small checkbox allows you to turn the volume of that step on or off. When the volume gate is on, the LED is turned on, lowering the resistance of the LDR, allowing the singal to pass through the tape machine.

MAKING A VACTROL AND BUILDING THE CIRCUIT

You can easily build your own vactrol by casing any LED and LDR into heat shrink or electrical tape. The LED should be connected to the ground of the pico circuit, and one of the GPIO pins, and the LDR should be connected in series to the positive output of the tape head. You can either use the binary GPIO output to control the LED (ie. LED.value(1) and LED.value(0) ), or you could explore using PWM as a volume envelop control.

CASING AND FUTURE DEVELOPMENTS

Casing.JPG
Top Down.JPG

CASING

I decided to wire the circuit inside a cardboard box, that managed to fit the breadboard inside perfectly. I also added a 5 volt power supply module to the breadboard, so that I could power the module from a mains power cable, or a USB cable.

To connect the sequencer module to the Tape Machine, I used 3.5mm TRS jack cables to transfer the PWM signal to the jack connectors housed inside the tape machine.

FURTHER WORK

In the future, I aim to add a MIDI input circuit to the module, that will read MIDI notes and velocity data, for monophonic control of the tape machine. I also aim to include a CV input that will convert 1 volt per octave control voltage to the corresponding playback speed. I hope you have enjoyed this Instructables, and please feel free to post any questions or comments below.