Page:12

## Distortion Pedal (Symmetric and Assymetric) 6 years 10 months ago #351

 Stormmaker OFFLINE New Member Posts: 1 Thank you received: 1 Karma: 2 Hi,everyone! Recently I find a function called constrain() in the Arduino official website. https://www.arduino.cc/en/Reference/Constrain Maybe we could use it like this: in_ADC0 = constrain(in_ADC0, lower_threshold, upper_threshold); The code maybe more concise in this way. The administrator has disabled public write access. The following user(s) said Thank You: Ray

## Distortion Pedal (Symmetric and Assymetric) 4 years 4 months ago #1298

 tram8001 OFFLINE New Member Posts: 3 Karma: 0 I am new to Arduino and pedalshield and am trying my best to understand code like this. I copied this into my program and got an error. Can sombody explain to me why this is? // 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   pinMode(LED, OUTPUT); pinMode(FOOTSWITCH, INPUT_PULLUP); }   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

## Distortion Pedal (Symmetric and Assymetric) 4 years 4 months ago #1301

 Ray OFFLINE Moderator Posts: 702 Thank you received: 152 Karma: 44 These operations are related to generating the output signal, it is usually the last stage in a guitar pedal effect. So once the input signal has been modified (clipped in this case) it needs to be generated again, so the DACs will produce the new output signal. 2 DACs are used (named DAC0 and DAC1) for this operation (one will be enough, but 2 gives you more resolution). Every time that we want to use the DAC we need to: Select the DAC (because there is 2 of them, and we need to make sure that we are addressing the right DAC) Write the desired values on that DAC (the newly generated signal value) That operations that you highlighted do exactly these 2 things: dacc_set_channel_selection(DACC_INTERFACE, 0); //select DAC channel 0With that line we select the DAC0 tpo be used dacc_write_conversion_data(DACC_INTERFACE, out_DAC0); //write on DAC`With that line we write the value "out_DAC0" into the DAC0 After that, if we want to use the DAC1 we need to repeat the operation but selecting the DAC1 and writing the desired value for DAC1. In a nutshell, writing into the DACs is not as easy as just giving them a value, we have to select the one we want to use and then write the value. Last Edit: 4 years 4 months ago by Ray. The administrator has disabled public write access.
 Page:12
Time to create page: 0.171 seconds
Joomla SEF URLs by Artio