How to start programming pedalSHIELD

6 años 11 meses antes #850 por toastynoasty
This track with my band and arduino sinewave effect! Thank's!!

www.dropbox.com/s/8mwm8lps9soogfw/demokratos%20MBE.mov?dl=0

Por favor, Identificarse para unirse a la conversación.

6 años 11 meses antes #852 por Ray
Respuesta de Ray sobre el tema How to start programming pedalSHIELD
Thanks for contributing! I love the background video too, I have also posted your link into the sinewave generator topic:
www.electrosmash.com/forum/software-peda...enerator?lang=en#851

Por favor, Identificarse para unirse a la conversación.

4 años 9 meses antes - 4 años 9 meses antes #1863 por Matheus
Respuesta de Matheus sobre el tema How to start programming pedalSHIELD
Hello. In the line: while ((ADC -> ADC_ISR & 0x1CC0)! = 0x1CC0); // expects ADC conversion 0, 1, 8, 9, 10 to complete.
Add a conversion in ADC 6 and 7. How do I do this?

Por favor, Identificarse para unirse a la conversación.

4 años 9 meses antes - 4 años 9 meses antes #1864 por Ray
Respuesta de Ray sobre el tema How to start programming pedalSHIELD

Rendering Error in layout Message/Item: array_keys(): Argument #1 ($array) must be of type array, null given. Please enable debug mode for more information.

Por favor, Identificarse para unirse a la conversación.

4 años 9 meses antes - 4 años 9 meses antes #1866 por Matheus
Respuesta de Matheus sobre el tema How to start programming pedalSHIELD
Yes, thank you !
I had just done the part under "while," now it's starting to make sense.
void loop ()
{
  // Read the ADCs
  while ((ADC -> ADC_ISR & 0x1CC3)! = 0x1CC3); // expects the conversion of ADC 0, 1, 6, 7, 8, 9, 10 to 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
  POT3 = ADC -> ADC_CDR [0]; // read data from ADC7
  POT4 = ADC -> ADC_CDR [1]; // read data from ADC6
  }

Without wanting to bother, but already bothering kk, I would like to know: if the "if" function is used 4 times can they be checked at the same time?
And 2 of them can be executed at the same time?

I'm trying to make an alternative pedal for a college job and I'm using the pedalshield programming as a base (of course I'll cite it as a reference and with all the credits). I intend to make the pedal with 4 effects. 2 of them can be used simultaneously and can be combined in parallel or in series. And for this I feel that here I will find help to make doubts and to progress with this :)
If I can and will work, as expected, I promise to post here on the site with all the details of execution for whoever wants to mount it.

Por favor, Identificarse para unirse a la conversación.

4 años 9 meses antes #1870 por Ray
Respuesta de Ray sobre el tema How to start programming pedalSHIELD

if the "if" function is used 4 times can they be checked at the same time?

Which "if" are you referring to? I am not sure about that. Could you show a code with that "if"?

And 2 of them can be executed at the same time?

If I understood well, yes, you can read the analog input and then treat the signal differently and add them together at the end. Nobody tried yet, but should be ok.
El siguiente usuario dijo gracias: Matheus

Por favor, Identificarse para unirse a la conversación.

4 años 9 meses antes #1872 por Matheus
Respuesta de Matheus sobre el tema How to start programming pedalSHIELD
Below is what I am referring to:


void loop ()
{
  // Read the ADCs
  while ((ADC -> ADC_ISR & 0x1CC3)! = 0x1CC3); // expects the conversion of ADC 0, 1, 6, 7, 8, 9, 10 to 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
  POT3 = ADC -> ADC_CDR [0]; // read data from ADC7
  POT4 = ADC -> ADC_CDR [1]; // read data from ADC6
  }
 
void TC4_Handler ()
{{
  // We need to get the status to clear it and allow the interrupt to fire again
  TC_GetStatus (TC1, 1);
  
  if (effect_1 == HIGH) // EFFECT 1: Symmetric distortion
  {
 // digitalWrite (LED, LOW);
    upper_threshold = map (POT0, 0, 4095, 4095,! POT0);
    lower_threshold = map (POT0, 0, 4095, 0000, POT0);
    
  // upper_threshold0 =! upper_threshold;
  // lower_threshold0 =! lower_threshold;
 
  if (in_ADC0> = upper_threshold) in_ADC0 = upper_threshold;
  else if (in_ADC0 <lower_threshold) in_ADC0 = lower_threshold;
  // if (in_ADC1> = upper_threshold) in_ADC1 = upper_threshold;
  // else if (in_ADC1 <lower_threshold) in_ADC1 = lower_threshold;
  
  // adjust the volume with POT2 with constant intensity
  out_DAC0 = map (in_ADC0, lower_threshold, upper_threshold, 1, POT4);
 // out_DAC1 = map (in_ADC1, lower_threshold, upper_threshold, 1, POT2);
  
  // Record the DACs
  dacc_set_channel_selection (DACC_INTERFACE, 0) // selects DAC channel 0
  dacc_write_conversion_data (DACC_INTERFACE, out_DAC0) // write to DAC 0
  // dacc_set_channel_selection (DACC_INTERFACE, 1) // select DAC channel 1
  // dacc_write_conversion_data (DACC_INTERFACE, out_DAC1); // writes in DAC 1
  }
  
  if (effect_2 == HIGH) // EFFECT 2: Clean.
  {
    // Add volume feature with POT4
    out_DAC0 = map (in_ADC0,0,4095,1, POT4);
    // out_DAC1 = map (in_ADC1,0,4095,1, POT4);
    
    // Write the DACs
    dacc_set_channel_selection (DACC_INTERFACE, 0); // select DAC channel 0
    dacc_write_conversion_data (DACC_INTERFACE, out_DAC0); // writes in DAC 0
    // dacc_set_channel_selection (DACC_INTERFACE, 1); // select DAC channel 1
    // dacc_write_conversion_data (DACC_INTERFACE, out_DAC1); // writes in DAC 1
    }
    
    if (effect_3 == HIGH) // EFFECT 3: Delay.
  {
    // digitalWrite (LED, LOW);
    
  // Store current readings
  // sDelayBuffer0 [DelayCounter] = in_ADC0;
  sDelayBuffer1 [DelayCounter] = in_ADC1;
  
  // Set the delay depth based on the position of the pot1. $$$$
  Delay_Depth = map (POT2 >> 2.0,1023,1, MAX_DELAY);
  
  // Increse / reset delay counter.
  DelayCounter;
  if (DelayCounter> = Delay_Depth) DelayCounter = 0;
  // out_DAC0 = ((sDelayBuffer0 [DelayCounter]));
  out_DAC1 = ((sDelayBuffer1 [DelayCounter]));
  
  // Add volume feature
  // out_DAC0 = map (out_DAC0,0,4095,1, POT3);
  out_DAC1 = map (out_DAC1,0,4095,1, POT3);
  
  // Write the DACs
  // dacc_set_channel_selection (DACC_INTERFACE, 0); // select DAC channel 0
  // dacc_write_conversion_data (DACC_INTERFACE, out_DAC0); // writes in the DAC
  dacc_set_channel_selection (DACC_INTERFACE, 1); // select DAC channel 1
  dacc_write_conversion_data (DACC_INTERFACE, out_DAC1); // writes in DAC 0
  
  // Clear status allowing the interrupt to be triggered again.
  TC_GetStatus (TC1, 1);
  }}
  
  // void switch_handler ()
  
  // delayMicroseconds (100000); // debouncing protection
  // if (toggle_value! = digitalRead (TOGGLE)) effect;
  // delayMicroseconds (100000); // debouncing protection
    // toggle_value = digitalRead (TOGGLE);
    // if (effect == 1) effect = 0;
    // Delay_Depth = 300; // resets the variable.
    
    if (effect_4 == HIGH) // EFFECT 4: Tremolo.
    {
      // Store current readings in ECHO mode
      DelayBuffer_A [DelayCounter_A] = (in_ADC0 (DelayBuffer_A [DelayCounter_A])) >> 1;
      DelayBuffer_B [DelayCounter_B] = (in_ADC1 (DelayBuffer_B [DelayCounter_B])) >> 1;
      
      // Set the delay depth based on position POT0 and POT1.
      Delay_Depth_A = map (POT2 >> 3,0,512,1, MAX_DELAY_A);
      Delay_Depth_B = map (POT2 >> 3,0,512,1, MAX_DELAY_B);
      
      // Increse / reset delay counter.
      DelayCounter_A;
      DelayCounter_B;
      if (DelayCounter_A> = Delay_Depth_A) DelayCounter_A = 0;
      if (DelayCounter_B> = Delay_Depth_B) DelayCounter_B = 0;
      
      // Calculate the output as the sum of DelayBuffer_A DelayBuffer_B
      // out_DAC0 = (DelayBuffer_A [DelayCounter_A]);
      out_DAC1 = (DelayBuffer_B [DelayCounter_B]);
      
      // Add volume feature based on pot3 position.
      // out_DAC0 = map (out_DAC0,0,4095,1, POT3);
      out_DAC1 = map (out_DAC1,0,4095,1, POT3);
      
      // Write the DACs
      // dacc_set_channel_selection (DACC_INTERFACE, 0); //select DAC channel 0
       // dacc_write_conversion_data (DACC_INTERFACE, out_DAC0); // writes in DAC 0
       dacc_set_channel_selection (DACC_INTERFACE, 1); // select DAC channel 1
       dacc_write_conversion_data (DACC_INTERFACE, out_DAC1); // writes in DAC 1
       }}


2 of these effects will have to work simultaneously. And I'd like to know if it's possible 2 "if" to run at the same time.

Por favor, Identificarse para unirse a la conversación.

4 años 9 meses antes #1878 por Ray
Respuesta de Ray sobre el tema How to start programming pedalSHIELD
Yes, if you run the codes in parallel they should work, but you just need to make sure that the variables are not overwritten by the 2 processes at the same time.
El siguiente usuario dijo gracias: Matheus

Por favor, Identificarse para unirse a la conversación.

4 años 9 meses antes #1879 por Matheus
Respuesta de Matheus sobre el tema How to start programming pedalSHIELD
I also want help from you with this error that appears when I check:

C: \ Users \ mathe \ AppData \ Local \ Arduino15 \ packages \ arduino \ hardware \ sam \ 1.6.12 \ colors \ arduino \ syscalls_sam3.c: In the '_exit' function:

C: \ Users \ mathe \ AppData \ Local \ Arduino15 \ packages \ arduino \ hardware \ sam \ 1.6.12 \ colors \ arduino \ syscalls_sam3.c: 133: 24: warning: unused parameter 'status' [-Wunused-parameter ]

extern void _exit (int status)

^



No error appears in the code, so I do not know what it can be. Can you help me with this?






This is the full code I am using:

   int in_ADC0, in_ADC1; // variables for 2 values ​​of ADCs (ADC0, ADC1)
   int POT0, POT1, POT2, POT3, POT4, out_DAC0, out_DAC1; // variables for 5 pots (ADC6, ADC7, ADC8, ADC9, ADC10)
   // int LED = 3;
   // int FOOTSWITCH = 7;
   // int TOGGLE = 2;
   int sample, accumulator, count, LFO;

   int effect_1 = 2;
   int effect_2 = 3;
   int effect_3 = 4;
   int effect_4 = 5;
   
  // int toggle_value = 0;
  // int effect = 0;
   
   int upper_threshold, lower_threshold;
   
   #define MAX_DELAY 20000
   uint16_t sDelayBuffer0 [MAX_DELAY];
   uint16_t sDelayBuffer1 [MAX_DELAY];
   unsigned int DelayCounter = 0;
   unsigned int Delay_Depth = MAX_DELAY;
   
   // # define MAX_DELAY 500
   // # define MIN_DELAY 200
   unsigned int count_up = 1;
   int p;
   int switch_handler = 0;

  #define MAX_DELAY_A 10000
  #define MAX_DELAY_B 10000
  uint16_t DelayBuffer_A [MAX_DELAY_A];
  uint16_t DelayBuffer_B [MAX_DELAY_B];
  unsigned int DelayCounter_A = 0;
  unsigned int DelayCounter_B = 0;
  unsigned int Delay_Depth_A, Delay_Depth_B;
 
void setup ()
{
  // * turns the timer on the power management control * /
  pmc_set_writeprotect (false);
  pmc_enable_periph_clk (TC_ID4);
 
  // we want wavesel 01 with RC
  TC_Configure (TC1,1, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK2);
  TC_SetRC (TC1, 1, 238); // define <> interruption rate of 44.1 KHz
  TC_Start (TC1, 1);

   
  // activates the timer interrupts on the timer
  TC1 -> TC_CHANNEL [1]. TC_IER = TC_IER_CPCS;
  TC1 -> TC_CHANNEL [1]. TC_IDR = ~ TC_IER_CPCS;
 
  // * Enables interrupt on null vector interrupt handler * /
  // * TC4_IRQn where 4 is the timer number * timer channels (3) + channel number
  // (= (1 * 3) +1) for timer1 channel1 * /
  NVIC_EnableIRQ (TC4_IRQn);
  
  // ADC Configuration
  ADC -> ADC_MR | = 0x80; // DAC in free running mode.
  ADC -> ADC_CR = 2; // Initiates ADC conversion.
  ADC -> ADC_CHER = 0x1CC3; // Activate ADC channels 0 and 1.
  
  
  // DAC Configuration
  analogWrite (DAC0, 0); // Enable DAC0
  analogWrite (DAC1, 0); // Enable DAC0
  
  
 // set pin2 as an input and enable the internal pull-up resistor
 // pinMode (LED, OUTPUT);
 // pinMode (TOGGLE, INPUT_PULLUP);
 // attachInterrupt (TOGGLE, switch_handler, CHANGE);
 // pinMode (FOOTSWITCH, INPUT);
  }
 
void loop ()
{
  // Read the ADCs
  while ((ADC -> ADC_ISR & 0x1CC3)! = 0x1CC3); // expects the conversion of ADC 0, 1, 6, 7, 8, 9, 10 to 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
  POT3 = ADC -> ADC_CDR [0]; // read data from ADC7
  POT4 = ADC -> ADC_CDR [1]; // read data from ADC6
  }
 
void TC4_Handler ()
{
  // We need to get the status to clear it and allow the interrupt to fire again
  TC_GetStatus (TC1, 1);
  
  if (effect_1 == HIGH) // EFFECT 1: Symmetric distortion
  {
   // digitalWrite (LED, LOW);
    upper_threshold = map (POT0, 0, 4095, 4095,! POT0);
    lower_threshold = map (POT0, 0, 4095, 0000, POT0);
    
  // upper_threshold0 =! upper_threshold;
  // lower_threshold0 =! lower_threshold;
 
  if (in_ADC0> = upper_threshold) in_ADC0 = upper_threshold;
  else if (in_ADC0 <lower_threshold) in_ADC0 = lower_threshold;
  // if (in_ADC1> = upper_threshold) in_ADC1 = upper_threshold;
  // else if (in_ADC1 <lower_threshold) in_ADC1 = lower_threshold;
  
  // adjust the volume with POT4 with constant intensity
  out_DAC0 = map (in_ADC0, lower_threshold, upper_threshold, 1, POT4);
  // out_DAC1 = map (in_ADC1, lower_threshold, upper_threshold, 1, POT4);
  
  // Record the DACs
  dacc_set_channel_selection (DACC_INTERFACE, 0) // selects DAC channel 0
  dacc_write_conversion_data (DACC_INTERFACE, out_DAC0) // write to DAC 0
  // dacc_set_channel_selection (DACC_INTERFACE, 1) // select DAC channel 1
  // dacc_write_conversion_data (DACC_INTERFACE, out_DAC1); // writes in DAC 1
  }
  
  if (effect_2 == HIGH) // EFFECT 2: Clean.
  {
    // Addvolume feature with POT4
    out_DAC0 = map (in_ADC0,0,4095,1, POT4);
    // out_DAC1 = map (in_ADC1,0,4095,1, POT4);
    
    // Write the DACs
    dacc_set_channel_selection (DACC_INTERFACE, 0); // select DAC channel 0
    dacc_write_conversion_data (DACC_INTERFACE, out_DAC0); // writes in DAC 0
    // dacc_set_channel_selection (DACC_INTERFACE, 1); // select DAC channel 1
    // dacc_write_conversion_data (DACC_INTERFACE, out_DAC1); // writes in DAC 1
    }
    
    if (effect_3 == HIGH) // EFFECT 3: Delay.
  {
    // digitalWrite (LED, LOW);
    
  // Store current readings
  // sDelayBuffer0 [DelayCounter] = in_ADC0;
  sDelayBuffer1 [DelayCounter] = in_ADC1;
  
  // Set the delay depth based on the position of pot2.
  Delay_Depth = map (POT2 >> 2.0,1023,1, MAX_DELAY);
  
  // Increse / reset delay counter.
  DelayCounter ++;
  if (DelayCounter> = Delay_Depth) DelayCounter = 0;
  // out_DAC0 = ((sDelayBuffer0 [DelayCounter]));
  out_DAC1 = ((sDelayBuffer1 [DelayCounter]));
  
  // Add volume feature
  // out_DAC0 = map (out_DAC0,0,4095,1, POT3);
  out_DAC1 = map (out_DAC1,0,4095,1, POT3);
  
  // Write the DACs
  // dacc_set_channel_selection (DACC_INTERFACE, 0); // select DAC channel 0
  // dacc_write_conversion_data (DACC_INTERFACE, out_DAC0); // writes in the DAC
  dacc_set_channel_selection (DACC_INTERFACE, 1); // select DAC channel 1
  dacc_write_conversion_data (DACC_INTERFACE, out_DAC1); // writes in DAC 0
  
  // Clear status allowing the interrupt to be triggered again.
  TC_GetStatus (TC1, 1);
  }
  
  // void switch_handler ()
  
  // delayMicroseconds (100000); // debouncing protection
  // if (toggle_value! = digitalRead (TOGGLE)) ++ effect;
  // delayMicroseconds (100000); // debouncing protection
    // toggle_value = digitalRead (TOGGLE);
    // if (effect == 1) effect = 0;
    // Delay_Depth = 300; // resets the variable.
    
    if (effect_4 == HIGH) // EFFECT 4: Tremolo.
    {
      // Store current readings in ECHO mode
      DelayBuffer_A [DelayCounter_A] = (in_ADC0 + (DelayBuffer_A [DelayCounter_A])) >> 1;
      DelayBuffer_B [DelayCounter_B] = (in_ADC1 + (DelayBuffer_B [DelayCounter_B])) >> 1;
      
      // Set the delay depth based on position POT2 and POT2.
      Delay_Depth_A = map (POT2 >> 3,0,512,1, MAX_DELAY_A);
      Delay_Depth_B = map (POT2 >> 3,0,512,1, MAX_DELAY_B);
      
      // Increse / reset delay counter.
      DelayCounter_A ++;
      DelayCounter_B ++;
      if (DelayCounter_A> = Delay_Depth_A) DelayCounter_A = 0;
      if (DelayCounter_B> = Delay_Depth_B) DelayCounter_B = 0;
      
      // Calculate the output as the sum of DelayBuffer_A + DelayBuffer_B
      // out_DAC0 = (DelayBuffer_A [DelayCounter_A]);
      out_DAC1 = (DelayBuffer_B [DelayCounter_B]);
      
      // Add volume feature based on pot3 position.
      // out_DAC0 = map (out_DAC0,0,4095,1, POT3);
      out_DAC1 = map (out_DAC1,0,4095,1, POT3);
      
      // Write the DACs
      // dacc_set_channel_selection (DACC_INTERFACE, 0); // select DAC channel 0
      // dacc_write_conversion_data (DACC_INTERFACE, out_DAC0); // writes in DAC 0
      dacc_set_channel_selection (DACC_INTERFACE, 1); // select DAC channel 1
      dacc_write_conversion_data (DACC_INTERFACE, out_DAC1); // writes in DAC 1
      }}

Por favor, Identificarse para unirse a la conversación.

4 años 9 meses antes #1883 por Ray
Respuesta de Ray sobre el tema How to start programming pedalSHIELD

Rendering Error in layout Message/Item: array_keys(): Argument #1 ($array) must be of type array, null given. Please enable debug mode for more information.

Por favor, Identificarse para unirse a la conversación.

Tiempo de carga de la página: 0.093 segundos