Welcome, Guest
Username: Password: Remember me

TOPIC: pedalSHIELD on Arduino MEGA

pedalSHIELD on Arduino MEGA 3 years 1 week ago #605

  • jimt
  • jimt's Avatar
  • OFFLINE
  • New Member
  • Posts: 13
  • Thank you received: 1
  • Karma: 1
Hi! well.. I'm exited by this project... but, i only have an Arduino MEGA, and the money... well, i cant buy an Arduino DUE or UNO right now... is there a chance of modify the DUE PBC and adapt it to MEGA?

I'm sorry for my english, but I'm from Argentina.
The administrator has disabled public write access.

pedalSHIELD on Arduino MEGA 3 years 11 hours ago #609

  • Ray
  • Ray's Avatar
  • OFFLINE
  • Moderator
  • Posts: 692
  • Thank you received: 146
  • Karma: 41
Hi, I never tried to use pedalSHIELD UNO with a MEGA board, but in theory it should be possible you just need and ADC and PWM outputs, maybe making some mods... but it should be possible.
I have bought right now a MEGA on ebay and I will try to make it happen.
The administrator has disabled public write access.

pedalSHIELD on Arduino MEGA 2 years 10 months ago #674

  • Ray
  • Ray's Avatar
  • OFFLINE
  • Moderator
  • Posts: 692
  • Thank you received: 146
  • Karma: 41
I post here my updates in this topic.
I reckon that porting the pedalSHIELD UNO to the MEGA board is a fantastic idea, so I got an Arduino MEGA 2560 online and these is my progress so far:
  • Compiling is straight forward, the UNO codes compile perfectly for the MEGA 2560 board, good here. :)
  • Uploading the codes and plugging the guitar and the amp does not produce any sound, bad here :(
  • Loading the metronome code (www.electrosmash.com/forum/pedalshield-u...23-metronome?lang=en) you can see that the LED blinks, and the pushbuttons are read (the blinking rate changes), the footswitch is also read fine, so all looks fine (or at least the LED, footswitch, and pushbuttons)
  • I have modified a distortion code, so when the distortion occurs the LED blinks (see the code below), so the ADC is read fine, otherwise the Arduino board will not be able to see when the signal clips or not

I cant see any PWM signal going out of the board, Ive used my oscilloscope to check all the board pins and there is no PWM signal anywhere.
So I belive that there is some problem with the PWM signal configuration, probably the UNO and the MEGA board are configured differently, I will try to find in the arduino forums how the PWM is configured in the MEGA and compare it with the configuration that we are using in the UNO.
Its not difficult but my time for this is very reduced...

In a nutshell: seems that all works but the PWM.


This is the mod distortion code that blinks the LED when the distortion is produced:
// CC-by-www.Electrosmash.com
// Based on OpenMusicLabs previous works.
// pedalshield_uno_distortion.ino reads the ADC signal and clip it to a threshold value
// pressing the pushbutton_1 or 2 turns the distortion harder or softer.
 
 
//defining harware resources.
#define LED 13
#define FOOTSWITCH 12
#define TOGGLE 2
#define PUSHBUTTON_1 A5
#define PUSHBUTTON_2 A4

//defining the output PWM parameters
#define PWM_FREQ 0x00FF // pwm frequency - 31.3KHz
#define PWM_MODE 0 // Fast (1) or Phase Correct (0)
#define PWM_QTY 2 // 2 PWMs in parallel

//other variables
int input, distortion_threshold=6000; //initial value adjusted by try and error.
int counter=0;
unsigned int ADC_low, ADC_high;
 
void setup() {
 
  //setup IO
  pinMode(FOOTSWITCH, INPUT_PULLUP);
  pinMode(TOGGLE, INPUT_PULLUP);
  pinMode(PUSHBUTTON_1, INPUT_PULLUP);
  pinMode(PUSHBUTTON_2, INPUT_PULLUP);
  pinMode(LED, OUTPUT);
 
  // setup ADC
  ADMUX = 0x60; // left adjust, adc0, internal vcc
  ADCSRA = 0xe5; // turn on adc, ck/32, auto trigger
  ADCSRB = 0x07; // t1 capture for trigger
  DIDR0 = 0x01; // turn off digital inputs for adc0
 
  // setup PWM
  TCCR1A = (((PWM_QTY - 1) << 5) | 0x80 | (PWM_MODE << 1)); //
  TCCR1B = ((PWM_MODE << 3) | 0x11); // ck/1
  TIMSK1 = 0x20; // interrupt on capture interrupt
  ICR1H = (PWM_FREQ >> 8);
  ICR1L = (PWM_FREQ & 0xff);
  DDRB |= ((PWM_QTY << 1) | 0x02); // turn on outputs
  sei(); // turn on interrupts - not really necessary with arduino
  }
 
void loop() 
{
    //Turn on the LED if the effect is ON.
  if (digitalRead(FOOTSWITCH)) digitalWrite(LED, LOW); 
     else  digitalWrite(LED, HIGH);
  //nothing here, all happens in the Timer 1 interruption.
}
 
ISR(TIMER1_CAPT_vect) 
{
  // get ADC data
  ADC_low = ADCL; // you need to fetch the low byte first
  ADC_high = ADCH;
  //construct the input sumple summing the ADC low and high byte.
  input = ((ADC_high << 8) | ADC_low) + 0x8000; // make a signed 16b value
 
counter++; //to save resources, the pushbuttons are checked every 1000 times.
if(counter==1000)
{ 
counter=0;
if (!digitalRead(PUSHBUTTON_2)) {
  if (distortion_threshold<32768)distortion_threshold=distortion_threshold+25; //increase the vol
    digitalWrite(LED, LOW); //blinks the led
    }
 
    if (!digitalRead(PUSHBUTTON_1)) {
  if (distortion_threshold>0)distortion_threshold=distortion_threshold-25; //decrease vol
  digitalWrite(LED, LOW); //blinks the led
    }
}
 
  //the input signal is 16bits (values from -32768 to +32768
  //the valueif(input>distortion_threshold) input=distortion_threshold; is clipped to the distortion_threshold value
    if(input>distortion_threshold) 
    {input=distortion_threshold;
digitalWrite(LED, HIGH); //blinks the led
    }
 
  //write the PWM signal
  OCR1AL = ((input + 0x8000) >> 8); // convert to unsigned, send out high byte
  OCR1BL = input; // send out low byte
}
The administrator has disabled public write access.

pedalSHIELD on Arduino MEGA 1 year 9 months ago #1203

  • alessiow
  • alessiow's Avatar
  • OFFLINE
  • Junior Member
  • Posts: 23
  • Thank you received: 10
  • Karma: 3
hey Jr/Ray
I've been reading into this issue for a few days now. there are major pin differences between the uno and mega.. this is what i have found so far:
As you look at the uno with the power plug in the top left corner, the uno pedalshield pins for power and the A0 and A4-5 pins will all transfer over to the mega2560 with no issue. Now on the right side of the board, there are big changes with the pin configuration between the uno and mega.
Basically the PWM pins 9 and 10 are no longer oc1a and oc1b..they are flopped on the mega and now oc2b and oc2a..
finally the dig_2 pin is no longer the INT0 pin. That is now INT4 on the mega. INT0 is down on pin 21 on the mega.
So for a direct plug and play, the UNO pedalshield wont transfer...I found the same thing happened that you did when doing so. I'm thinking about trying to see if I can run jumpers to the original pin calls on the pedalshield to the mega, just to see if the original sketches can be used on the mega...If this cant be done then the coding will have to be re-written to use timer2 possibly. Some sections of the mega datasheets, i just cant seem to wrap my brain around...
I think it would be easier to just write new code to use the same pinout as the uno pedalshields on the mega2560, as I'm sure you wouldn't care to have to make all new pcb just to incorporate the mega 2560 into the lineup.
Slowly day by day I understand more about whats going on and what the datasheets are saying, and comparing how the original uno sketches are written and how to convert.. If i'm right then we need to use timer2 to run uno pedalshield on the mega. Unless there is a way to do pin/port manipulation to get the mega to believe its using a certain pin to play nice with the pedalshield.
Last Edit: 1 year 9 months ago by alessiow.
The administrator has disabled public write access.

pedalSHIELD on Arduino MEGA 1 year 7 months ago #1334

  • jimt
  • jimt's Avatar
  • OFFLINE
  • New Member
  • Posts: 13
  • Thank you received: 1
  • Karma: 1
there must be a problem, i have register with this name but i am not he, neither from Argentina, is this account deleted?
The administrator has disabled public write access.

pedalSHIELD on Arduino MEGA 1 year 7 months ago #1338

  • Ray
  • Ray's Avatar
  • OFFLINE
  • Moderator
  • Posts: 692
  • Thank you received: 146
  • Karma: 41
Hi jimt, that was a very old message 1.5 years back, maybe the old jimt deleted his account and now you inherit his name.
I hope that everything is all right, I can try to dive into the database and move/delete things but that is my last resort!
.. or maybe you just have an evil twin brother in Argentine, you never know.
The administrator has disabled public write access.

pedalSHIELD on Arduino MEGA 8 months 2 weeks ago #1683

  • BaseMell
  • BaseMell's Avatar
  • OFFLINE
  • New Member
  • Posts: 1
  • Karma: 0
Hi...Microcontroller control and the integration of digital and analog has moved pedals in fascinating directions of late. Just poke through the catalog of what Chase Bliss, Walrus Audio, Earthquaker, and Sub-Decay (among others) are doing these days. Then you have stuff like what electricdruid and Molten Voltage are doing, which is developing and producing what are effectively drop-in MCU chips (PICs and ATMELs, for the most part) that handle a bunch of duties and provide tap-tempo.
The administrator has disabled public write access.

pedalSHIELD on Arduino MEGA 8 months 2 weeks ago #1684

  • Ray
  • Ray's Avatar
  • OFFLINE
  • Moderator
  • Posts: 692
  • Thank you received: 146
  • Karma: 41
Hi...Microcontroller control and the integration of digital and analog has moved pedals in fascinating directions of late. Just poke through the catalog of what Chase Bliss, Walrus Audio, Earthquaker, and Sub-Decay (among others) are doing these days. Then you have stuff like what electricdruid and Molten Voltage are doing, which is developing and producing what are effectively drop-in MCU chips (PICs and ATMELs, for the most part) that handle a bunch of duties and provide tap-tempo.
We are just trying to add our little push to the guitar pedal community creating open-source projects where people can learn and play with digital guitar pedals. There are plenty of talented people out there... check Dr. Scientist from Canada :)
The administrator has disabled public write access.
Time to create page: 0.193 seconds
Powered by Kunena Forum
Joomla SEF URLs by Artio