Difference between revisions of "Adding Encoders"

From ZynthianWiki
Jump to navigation Jump to search
Line 30: Line 30:
 
=====Power Supply=====
 
=====Power Supply=====
 
{| class="wikitable"
 
{| class="wikitable"
|+ Caption text
+
|+ Raspberry Pi GPIO Pins
 
|-
 
|-
 
! Odd Pins !! Function !! Function !! Even Pins
 
! Odd Pins !! Function !! Function !! Even Pins

Revision as of 17:44, 16 February 2025

Encoders can be added to the Raspberry Pi to provide zynthian with an interface designed to drive the Graphical User Interface, and act as parameter controllers for any device managed by the zynthian. This is one of the zynthians key features and allows control of almost any parameter of the Audio engines that it manages.

There are a number of ways of implementing the basic zynthian encoder interface, and these have developed alongside the project. The techniques used in the early Version One days have been supplanted by more recent design and a software environment has been constructed that allows these differing approaches to be integrated with no difference between the implementations.

1 Encoders directly connected to GPIO Pins

This is the original approach used from the start the Encoder were connected directly to GPIO pins on the Raspberry Pi.

1.1 Connecting via the GPIO Pins.

The raspberry Pi has a 40 pin connector that provides access to a level of connection not generally available to the PC world. This allows Digital devices to be connected to a Raspberry Pi and the Pi can both receive and transmit information to these devices as digital Data. +3.3V or 0v in electrical terms.

This connector will probably exist as a standard for a considerable length of time, such is the electronic infrastructure that has grown around it. Indeed competitor boards, would dare use anything else so it's become ubiquitous, in a similar fashion to the IBM edge connectors carried on long after the company had stopped making PC's themselves.

Here's a site devoted to it.

Pi GPIO


1.1.1 Considerations

You will need to connect wires from the raspberry Pi pins to the encoders. Given it is recommended to connect capacitors across the encoder connections to reduce the bouncing that occurs when mechanical switches open and close and this is best done at the encoder end, some people construct daughter boards for each encoder with connections and sockets that are connected by Du Pont Wires with sockets on both ends. These socket based wires do work but they can easily be knocked off the pins if there is cable flexing, so it is probably better to get either a 40 pin ribbon cable or Pi ex pander board with solder pads to allow you to remove the device entirely from the Pi. This is important because you might want to transfer the Pi to do something else in later life, or more likely as you are constructing the enclosure you might well want to separate them for testing with a multi-meter, which is a tool that isn't exactly essential in these sorts of activities, but if you are new to soldering, is the authoritative way of checking that electrons actually do get from the point you believe they originate from to the place where they are going to make something happen.

1.1.2 Pins on the Pi

There are several different types of Pin presented on the Raspberry Pi 40 pin connector. The important thing to know is that there are two voltages present on a raspberry pi and genuine damage can be done to the device if this is ignored. One of the corner pins is +5Volts and this is the voltage supplied by the USB Power connector this MUST Not be connected to any of the other pins. they live off 3.3Volts and this should be honoured.

1.1.2.1 Power Supply
Raspberry Pi GPIO Pins
Odd Pins Function Function Even Pins
Pin 1 3v3 Power 5v Power Pin 2
Pin 3 - 5v Power Pin 4
Pin 5 - Ov Ground Pin 6
Pin 7 - - Pin 8
Pin 9 - - Pin 10
Pin 11 Ov Ground - Pin 12
Pin 13 - Ov Ground Pin 14
Pin 15 - - Pin 16
Pin 17 3v3 Power - Pin 18
Pin 19 - Ov Ground Pin 20
Pin 21 - - Pin 22
Pin 23 - - Pin 24
Pin 25 Ov Ground - Pin 26
Pin 27 - - Pin 28
Pin 29 - Ov Ground Pin 30
Pin 31 - - Pin 32
Pin 33 - Ov Ground Pin 34
Pin 35 - - Pin 36
Pin 37 - - Pin 38
Ov Ground - - Pin 40
1.1.2.2 Pins not to use
1.1.2.3 General GPIO pins
1.1.2.4 Specialized GPIO Pins
1.1.2.5 Addressing

2 Encoders connected using a MCP23017 chip

As an interface grows ( when 4 user definable switches were added to V3 (?) we had already moved away from the direct encoder route in favour of a much more efficient way of reading encoders and switches, which passed off some of the effort to another piece of silicon. The MCP23017 16 port I2C multiplexer. This board meant the communication between the Raspberry Pi and this 20 pinned chip could be handled by only a few wires at the Pi end, and a standard form of communication called I2C.

The zynaptik-3 board from zynthian provides all the interfaces for encoders and the extra switches introduced, along with MIDI interfaces and Control voltage and digital ins and outs which represents the official implementation of this sort of approach.

3 Other nefarious methods

Other methods can be accomodated using the zynthian's inbuilt Control Device interface.

4 But what is an encoder?

It's a rotating control designed to provide similar functionality to a control known as a potentiometer which most people meet as a volume control. A way of easily controlling some parameter within an electronic device.Which is why the zynthian likes them so much.

The zynthian simply controls the Linux audio subsystem, (Jack) and it then uses the MIDI standard provided by almost all Linux audio devices to control those engines. This is very helpful because a cleverly defined GUI (and it is one) can by easy selection of different pages present virtually any audio control in the same manner. The four Encoders provide 4 parameters per page, all of which respond. This is exactly what a performing interface requires. It provides as much control as 4 encoders can when behaving like 4 volume controls. It is highly responsive. Allowing for subtle and careful parameter control. Bending a synth filter for example. But it is important to recognize that the audio Engine involved may not be prepared for such fast change. Altering a time constant in a looper over a wide range will probably have irritating sonic sound effects, as such things occur and the Engine simply can't keep up.. That's down to the Engine. zynth just delivers the information you tell it to the parameter it has selected in the GUI.

But You might well want more than 4 parameters and some of the engines provide an incredible number. Well this is where the other element of the humble Encode comes into play. The press switch component.

By pressing down on the top of an encoder a completely separate switch can be operated without any alteration of the rotating component (hopefully). This used to select the page of parameter you are to use, which is demonstrated by a grey screen activated by a short push of the encoder. This is a basic Zynthian function and it is used to indicate selection in the zynthian world.