Page:12

## Distortion Pedal (Symmetric and Assymetric) 8 years 2 weeks ago #11

• JR
• Senior Member
• Posts: 77
• Karma: 6
There are several ways to create signal distortion. One of the easier is to define a threshold and clip the signals above (and below) this threshold.

The guitar signal is acquired by the ADC using 12 bits (numbers from 0 to 4095) so, when there is no input the measurement is in the middle point, around 4095/2=2047. When playing the guitar this measure fluctuates up and down this 2047 middle value.
Knowing this, the upper threshold is defined as the middle point plus the POT0 value divided by 2(numbers from 0 to 2047) so the resulting upper threshold goes from 2047 to 4095. The lower threshold is defined in the same way symmetrically.
1. Potentiometer 0: Sets the distortion level.
2. Potentiometer 1: Not used.
3. Potentiometer 2: Adjust the effect volume.

distortion.ino:
// Licensed under a Creative Commons Attribution 3.0 Unported License.
// Based on rcarduino.blogspot.com previous work.
// www.electrosmash.com/pedalshield

const int LED = 3;
const int FOOTSWITCH = 7;
const int TOGGLE = 2;
int upper_threshold, lower_threshold;

void setup()
{

//DAC Configuration
analogWrite(DAC0,0);  // Enables DAC0
analogWrite(DAC1,0);  // Enables DAC1
}

void loop()
{

upper_threshold=map(POT0,0,4095,4095,2047);
lower_threshold=map(POT0,0,4095,0000,2047);

//Write the DACs
dacc_set_channel_selection(DACC_INTERFACE, 0);          //select DAC channel 0
dacc_write_conversion_data(DACC_INTERFACE, out_DAC0);//write on DAC
dacc_set_channel_selection(DACC_INTERFACE, 1);          //select DAC channel 1
dacc_write_conversion_data(DACC_INTERFACE, out_DAC1);//write on DAC
}

You can listen how the Distortion effect sounds in SoundCloud.

#### File Attachment:

File Name: distortion.rar
File Size: 1 KB

## Basic Distortion Pedal (Symmetric and Assymetric) 8 years 2 weeks ago #12

• JR
• Senior Member
• Posts: 77
• Karma: 6
Asymmetric distortion is considered to have a tubelike sound. This code is based on the previous distortion.ino and it has a more dynamic distortion.
The asymmetric distortion is created by using the POT0 to set the upper threshold and POT1 the lower threshold. The rest of the code is similar to distortion.ino:
1. Potentiometer 0: Sets the positive signal distortion level.
2. Potentiometer 1: Sets the negative signal distortion level.
3. Potentiometer 2: Adjust the effect volume.

distortion_asymmetric.ino:
// Licensed under a Creative Commons Attribution 3.0 Unported License.
// Based on rcarduino.blogspot.com previous work.
// www.electrosmash.com/pedalshield

const int LED = 3;
const int FOOTSWITCH = 7;
const int TOGGLE = 2;
int upper_threshold, lower_threshold;

void setup()
{

//DAC Configuration
analogWrite(DAC0,0);  // Enables DAC0
analogWrite(DAC1,0);  // Enables DAC1
}

void loop()
{

upper_threshold=map(POT0,0,4095,4095,2047);
lower_threshold=map(POT1,0,4095,0000,2047);

//Write the DACs
dacc_set_channel_selection(DACC_INTERFACE, 0);       //select DAC channel 0
dacc_write_conversion_data(DACC_INTERFACE, out_DAC0);//write on DAC
dacc_set_channel_selection(DACC_INTERFACE, 1);       //select DAC channel 1
dacc_write_conversion_data(DACC_INTERFACE, out_DAC1);//write on DAC
}

#### File Attachment:

File Name: distortion_assymetric.rar
File Size: 1 KB

## Distortion Pedal (Symmetric and Assymetric) 7 years 3 months ago #154

 aipimrs OFFLINE New Member Posts: 1 Karma: 0 Hi JR, This project is incredible, I'm trying to found all components in Brazil to assembly one pedal for me. I had a quick look on the code you write as a start for many kinds of effects but neither of them use the knobs to adjust the tone. Is this possible? Could you show some example? Thanks, Alexandre. Last Edit: 7 years 3 months ago by aipimrs. The administrator has disabled public write access.

## Distortion Pedal (Symmetric and Assymetric) 7 years 2 months ago #156

 JR OFFLINE Senior Member Posts: 77 Thank you received: 31 Karma: 6 Yes you're right, so far I did not use any programmable potentiometer as a tone knob. A simple way to do it, could be to implement a low pass filter by accumulating some samples and averaging. There is a smoothing filter for arduino that can inspire you: arduino.cc/en/Tutorial/Smoothing My idea of a simple circuit is something like: output[i] = (input[i] + input [i-1] + input [i-2] + input [i-3])/4Then you can average only 2, or 4 (like the example), or 8, or 16 input signals to make the filter more abrupt. I average in powers of 2 because it is easier for the ARM to make them. I should get some time to code a proper example.... keep it simple The administrator has disabled public write access.

## Distortion Pedal (Symmetric and Assymetric) 6 years 9 months ago #234

 Vince OFFLINE New Member Posts: 12 Thank you received: 7 Karma: 5 My dream with this shield is to build a bit crusher (adjustable on one potentiometer) and a rate reducer (adjustable on the second potentiometer). Is there anyone already succeed in this kind of project ? The administrator has disabled public write access. The following user(s) said Thank You: dwhacks

## Distortion Pedal (Symmetric and Assymetric) 6 years 9 months ago #253

 dwhacks OFFLINE New Member Posts: 4 Thank you received: 1 Karma: 0 I am interested in the same this as Vince. This pedal would be a great inspiration: www.hexeguitar.com/pedals/bc3 Have the bit pot also add distortion! The administrator has disabled public write access.

## Distortion Pedal (Symmetric and Assymetric) 6 years 7 months ago #263

 CCC123 OFFLINE New Member Posts: 1 Karma: 0 I think this is a great product. I recently got one of my own but when I tried using the given programs, I have been getting a "p01_clean:14: error: base operand of '->' is not a pointer" error in the debugging window. I am using the arduino software and have tried both v1.6.3 and v1.5.6-r2. Could someone tell me what is wrong? i am somewhat new to programing, but not the hardware. The administrator has disabled public write access.

## Distortion Pedal (Symmetric and Assymetric) 6 years 7 months ago #265

 Ray OFFLINE Moderator Posts: 702 Thank you received: 152 Karma: 44 Check this out, it will solve your problems! The administrator has disabled public write access. The following user(s) said Thank You: CCC123

## Distortion Pedal (Symmetric and Assymetric) 6 years 5 months ago #313

 gutmet OFFLINE New Member Posts: 1 Thank you received: 1 Karma: 1 Hi, if I understand the implementation of the distortion pedal correctly, you are basically clipping the amplitudes to thresholds - if I'm not mistaken, this effectively lowers your loudness, so instead of adjusting the volume by mapping from [0,4095] to [1,POT2] you could map from [lower_threshold,upper_threshold], i.e. instead of out_DAC0=map(in_ADC0,0,4095,1,POT2); out_DAC1=map(in_ADC1,0,4095,1,POT2); you could do out_DAC0=map(in_ADC0,lower_threshold,upper_threshold,1,POT2); out_DAC1=map(in_ADC1,lower_threshold,upper_threshold,1,POT2); to pretty much keep the loudness - or does this have other negative effects that I have not noticed yet? ... just a suggestion Awesome shield, btw The administrator has disabled public write access. The following user(s) said Thank You: Ray

## Distortion Pedal (Symmetric and Assymetric) 6 years 5 months ago #314

 Ray OFFLINE Moderator Posts: 702 Thank you received: 152 Karma: 44 Hi gumet, I have been checking your idea and makes perfect sense, the signal would be never smaller than lower_threshold of bigger than upper_threshold,so adjusting the level like you suggest would keep the same loudness. So I have updated below the code with your idea (and giving you the credit in the first line) but we would keep distortion_asymmetric.ino as it is because it is easier for non experienced users to be understood. distortion_asymmetric_constant_loudness.ino`// Code updated by GUMET introducing constant loudness to distortion_asymmetric.ino // Licensed under a Creative Commons Attribution 3.0 Unported License. // Based on rcarduino.blogspot.com previous work. // www.electrosmash.com/pedalshield   int in_ADC0, in_ADC1; //variables for 2 ADCs values (ADC0, ADC1) int POT0, POT1, POT2, out_DAC0, out_DAC1; //variables for 3 pots (ADC8, ADC9, ADC10) const int LED = 3; const int FOOTSWITCH = 7; const int TOGGLE = 2; int upper_threshold, lower_threshold;   void setup() { //ADC Configuration ADC->ADC_MR |= 0x80; // DAC in free running mode. ADC->ADC_CR=2; // Starts ADC conversion. ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0,1,8,9 and 10   //DAC Configuration analogWrite(DAC0,0); // Enables DAC0 analogWrite(DAC1,0); // Enables DAC1 }   void loop() { //Read the ADCs while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0, 1, 8, 9, 10 conversion complete. in_ADC0=ADC->ADC_CDR[7]; // read data from ADC0 in_ADC1=ADC->ADC_CDR[6]; // read data from ADC1 POT0=ADC->ADC_CDR[10]; // read data from ADC8 POT1=ADC->ADC_CDR[11]; // read data from ADC9 POT2=ADC->ADC_CDR[12]; // read data from ADC10   upper_threshold=map(POT0,0,4095,4095,2047); lower_threshold=map(POT1,0,4095,0000,2047);   if(in_ADC0>=upper_threshold) in_ADC0=upper_threshold; else if(in_ADC0=upper_threshold) in_ADC1=upper_threshold; else if(in_ADC1
 Page:12
Time to create page: 0.513 seconds
Joomla SEF URLs by Artio