Welcome, Guest
Username: Password: Remember me

TOPIC: Debugging pedalSHIELD DUE (after a hiatus)

Debugging pedalSHIELD DUE (after a hiatus) 1 month 1 week ago #2109

I was clearing out my study (as I was running out of Covid-19 lock-down jobs) and came across a pedalSHIELD DUE that I had built about three years ago but never got around to testing out (various things intervened including redundancy - but that's another story). Anyway I thought I'd give it a whirl and see if it did anything.

My setup is as shown in the picture. Windows 10 laptop running Arduino IDE 1.8.13. Audio out from Laptop into pedalSHIELD DUE (so I can feed in some test tones) and audio out from pedalSHIELD DUE into a small guitar practice amp.


Tests that I've run so far:

1. Audio out from laptop straight through pedalSHIELD DUE (with foot-switch to bypass) - All OK (so my basic test set up is good)
2. Compiled and ran a test_all program
// The MIT License (MIT)
//
// Copyright (c) 2014 Alan Backlund
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
 
// Based on www.electrosmash.com/pedalshield previous work.
 
int in_ADC0, in_ADC1;  //variables for 2 ADCs values (ADC0, ADC1)
long avg;
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; 
const int FILTER = 2048;
 
void setup()
{
  Serial.begin(9600);
  Serial.println("PedalShield HW Test");
 
  //turn on the timer clock in the power management controller
  pmc_set_writeprotect(false);
  pmc_enable_periph_clk(ID_TC4);
 
  //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, 109); // sets <> 44.1 Khz interrupt rate
  TC_Start(TC1, 1);
 
  // enable timer interrupts on the timer
  TC1->TC_CHANNEL[1].TC_IER = TC_IER_CPCS;
  TC1->TC_CHANNEL[1].TC_IDR = ~TC_IER_CPCS;
 
  //Enable the interrupt in the nested vector interrupt controller 
  //TC4_IRQn where 4 is the timer number * timer channels (3) + the 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;         // Starts ADC conversion.
  ADC->ADC_CHER = 0x1CC0;  // Enable ADC channels 0, 1, 8, 9, 10. 
 
  // enable ADC interrupts on the timer
  ADC->ADC_IER = 0x00C0;
  ADC->ADC_IDR = ~0x00C0;
 
  //Enable the interrupt in the nested vector interrupt controller 
  NVIC_EnableIRQ(ADC_IRQn); 
 
  //DAC Configuration
  analogWrite(DAC0,0);  // Enables DAC0
  analogWrite(DAC1,0);  // Enables DAC0
 
  //pedalSHIELD pin configuration
  pinMode(LED, OUTPUT);  
  pinMode(FOOTSWITCH, INPUT);     
  pinMode(TOGGLE, INPUT);  
 
  Serial.println("Begin");
}
 
void loop()
{
  //Read the ADCs
  while((ADC->ADC_ISR & 0x1C00) != 0x1C00)
    ;  // wait for ADC 8, 9, 10 conversion complete.
  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 
 
  Serial.print("p1 ");
  Serial.print(POT0);
  Serial.print(", p2 ");
  Serial.print(POT1);
  Serial.print(", p3 ");
  Serial.print(POT2);
  Serial.print(", fs ");
  Serial.print(digitalRead(FOOTSWITCH));
  Serial.print(", s3 ");
  Serial.print(digitalRead(TOGGLE));
  Serial.print(", a0 ");
  Serial.print(in_ADC0);
  Serial.print(", a1 ");
  Serial.print(in_ADC1);
  Serial.print(", level ");
  Serial.println(avg / FILTER);
 
  if (digitalRead(TOGGLE))
    digitalWrite(LED, HIGH); 
  else
    digitalWrite(LED, LOW); 
 
  delay(250);
}
 
void TC4_Handler() //Interrupt at 44.1KHz rate (every 22.6us)
{ 
  TC_GetStatus(TC1, 1); //Clear status to fire again the interrupt.
 
  //Add volume feature with POT2
  out_DAC0=map(in_ADC0,0,4095,1,POT2);
  out_DAC1=map(in_ADC1,0,4095,1,POT2);
 
  //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
}
 
void ADC_Handler()
{
  int adcisr = ADC->ADC_ISR;
 
  //Read the ADCs
  if((adcisr & 0x0080) == 0x0080) // wait for ADC 0, 1 conversion complete.
    in_ADC0 = ADC->ADC_CDR[7];               // read data from ADC0
  if((adcisr & 0x0040) == 0x0040) // wait for ADC 0, 1 conversion complete.
    in_ADC1 = ADC->ADC_CDR[6];               // read data from ADC1  
 
  int v = abs(in_ADC0 - in_ADC1);
  avg = (avg - (avg / FILTER) + v);
}
 


This gave me an output like this on the serial monitor which to me says that
a. All POTS are working (although the centre values are not exactly on 2048)
b. S3 is working
c. FOOTSWITCH is working
d. There is something very odd going on at the input stage! a0 is dithering around mid-range and a1 is firmly stuck at max (4095). All of this was run with a 1KHz sinewave as an input.
PedalShield HW Test
Begin
 
p1 0, p2 0, p3 0, fs 0, s3 0, a0 2665, a1 4095, level 1429                      // POTS at MIN FS OFF S3 OFF
p1 0, p2 0, p3 0, fs 0, s3 0, a0 2661, a1 4095, level 1430
p1 0, p2 0, p3 0, fs 0, s3 0, a0 2663, a1 4095, level 1430
p1 0, p2 0, p3 0, fs 0, s3 0, a0 2657, a1 4095, level 1440
 
p1 0, p2 0, p3 0, fs 0, s3 1, a0 2669, a1 4095, level 1429                      // POTS at MIN FS OFF S3 ON
p1 0, p2 0, p3 0, fs 0, s3 1, a0 2663, a1 4095, level 1436
p1 0, p2 0, p3 0, fs 0, s3 1, a0 2655, a1 4095, level 1436
p1 0, p2 0, p3 0, fs 0, s3 1, a0 2667, a1 4095, level 1430
 
p1 0, p2 0, p3 0, fs 1, s3 1, a0 2665, a1 4095, level 1430                      // POTS at MIN FS ON S3 ON
p1 0, p2 0, p3 0, fs 1, s3 1, a0 2665, a1 4095, level 1430
p1 0, p2 0, p3 0, fs 1, s3 1, a0 2664, a1 4095, level 1431
p1 0, p2 0, p3 0, fs 1, s3 1, a0 2666, a1 4095, level 1430
 
 
p1 2045, p2 2031, p3 781, fs 1, s3 1, a0 3052, a1 4095, level 1045              // POTS at CENTRE FS ON S3 ON
p1 2043, p2 2033, p3 780, fs 1, s3 1, a0 3029, a1 4095, level 1064
p1 2044, p2 2033, p3 779, fs 1, s3 1, a0 3006, a1 4095, level 1089
p1 2045, p2 2032, p3 779, fs 1, s3 1, a0 2993, a1 4095, level 1099
 
p1 4095, p2 4095, p3 4095, fs 1, s3 1, a0 2668, a1 4095, level 1430             // POTS AT MAX  FS ON S3 ON
p1 4095, p2 4095, p3 4095, fs 1, s3 1, a0 2664, a1 4095, level 1434
p1 4095, p2 4095, p3 4095, fs 1, s3 1, a0 2664, a1 4095, level 1431
p1 4095, p2 4095, p3 4095, fs 1, s3 1, a0 2664, a1 4095, level 1429
 
p1 4095, p2 4095, p3 4095, fs 0, s3 1, a0 2666, a1 4095, level 1432             // POTS at MAX FS OFF S3 ON
p1 4095, p2 4095, p3 4095, fs 0, s3 1, a0 2676, a1 4095, level 1421
p1 4095, p2 4095, p3 4095, fs 0, s3 1, a0 2658, a1 4095, level 1433
p1 4095, p2 4095, p3 4095, fs 0, s3 1, a0 2671, a1 4095, level 1425


4. I compiled and ran the clean program which gave me nothing out unless the FOOTSWITCH was on the bypass position

5. I compiled and ran a sinewave program program which gave me a sinewave tone output. This means that the output stage is working okay.


So it's just something odd going on with the input stage - but where to start. I don't have a scope to hand but I may have to invest in a cheap one.

All ideas gratefully received :)
The administrator has disabled public write access.
Time to create page: 0.273 seconds
Powered by Kunena Forum
Joomla SEF URLs by Artio