Wave Shield and Arduino Mega: how-to

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
benres
 
Posts: 1
Joined: Thu Oct 22, 2009 2:42 pm

Re: Wave Shield and Arduino Mega: how-to

Post by benres »

I just followed the same procedure to get the GPS Shield working with the Arduino Mega / ATMega1280

First, you don't have to chop off shield pins if you make pins 10 - 13 inputs by adding the following code at the top of the "void setup()" routine:

pinMode(10, INPUT);
pinMode(11, INPUT);
pinMode(12, INPUT);
pinMode(13, INPUT);

Here's some other notes on getting the GPS Shield happy with the Mega:

*** There's no CS pad, so connect pin 10 of the GPS Shield to pin 53 of the Arduino Mega.

*** When you copy the file "sd_raw_config.h", change:

#define SD_RAW_WRITE_SUPPORT 0
to
#define SD_RAW_WRITE_SUPPORT 1

You'll get a weird compile error if you don't.

*** You don't need the file "dac.h".

----------------------

*** When using the file "GPStest_RMC.pde", I had to make the following to changes to get uncorrupted serial data:

- Replace all three instances of "NewSoftSerial" with "SoftwareSerial". For some reason, NewSoftSerial simply didn't work with the Mega.

- Comment out the line "Serial.print("\n\rread: ");" at the start of the loop() routine. While the Arduino busy is outputting this text, it's missing incoming bytes and some characters show up as garbage. It should be possible to use a UART on the Mega but I'm not there yet.

User avatar
abritinthebay
 
Posts: 32
Joined: Wed Dec 02, 2009 5:00 pm

Re: Wave Shield and Arduino Mega: how-to

Post by abritinthebay »

nandadoes wrote: Does it take all PWM pins?
I too would like to know that.

If I understand it correctly though - it allows you to access the pins (that aren't being used - 13, 12, & 11 have to be whereas 2, 3, 4, 5, & 10 are software configurable) with the contacts next to the soldered headers.

Am I correct? (I've not worked with shields before, this is my first, so this would be good to know).

If so, I suppose you could buy some pin sockets like the ones used in the Arduino itself and solder them into the sections that aren't used. (right?)

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Wave Shield and Arduino Mega: how-to

Post by adafruit »

it doesnt use the PWM pins but it does use some timers! the mega has more timers but we are not sure which ones go to which PWM pins :(

User avatar
abritinthebay
 
Posts: 32
Joined: Wed Dec 02, 2009 5:00 pm

Re: Wave Shield and Arduino Mega: how-to

Post by abritinthebay »

Well all the pins listed are PWM pins, so it does "use" them in that regard.

However, given what you just said, does that mean that the optional pins have to be mapped to PWM supporting pins (as they are by default), or would any digital IO pin do?

If any would do that would mean a major gain in the number of free PWM capable pins with the Wave Sheild....

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Wave Shield and Arduino Mega: how-to

Post by adafruit »

only the SPI (SD card) pins are important. the others can be remapped

User avatar
abritinthebay
 
Posts: 32
Joined: Wed Dec 02, 2009 5:00 pm

Re: Wave Shield and Arduino Mega: how-to

Post by abritinthebay »

Fantastic - and as those are already being remapped on the Mega (per the OP) to standard Digital IO pins... that makes life nice and easy :)

User avatar
abritinthebay
 
Posts: 32
Joined: Wed Dec 02, 2009 5:00 pm

Re: Wave Shield and Arduino Mega: how-to

Post by abritinthebay »

Hmmm... odd issue here.

I got the Wave Shield working, and made sure to add/change the correct code. However... now I'm getting a SD I/O Error with a card that *worked* before with it.

(long story short - I forgot I had the damn thing turned off, it was playing fine but muted, so I started to de-solder the pins - I'm using 46,47,48,& 49 as DAC pins - but then realized what I did, soldered the two things back in, and now I get an IO error after reconnecting all the wires).

Only thing that changed is that I uses sudo rm to remove the .Trashes and such files (I'm on a mac, card is FAT32).

My Macbook reads the card fine over the usb reader, but I still get IO Error (0, 1). (which means it can't read the card)...

Now I've double checked that the wires are in the right pins, and the wires have full conductivity... so what else could be going wrong here?

User avatar
abritinthebay
 
Posts: 32
Joined: Wed Dec 02, 2009 5:00 pm

Re: Wave Shield and Arduino Mega: how-to

Post by abritinthebay »

Scratch that.

Not sure what magic I did, but re-inserting the SD into the macbook and removing it fixed the issue (but now it has all the hidden files on it again, annoying)..

New problem - no sound. No errors, but no sound.

I remapped the DAC pins to 46-49 as follows in dac.h:

Code: Select all

#define DAC_CS_PORT PORTL
#define DAC_CS_DDR DDRL
#define DAC_CS PINL0 //49

#define DAC_CLK_PORT PORTL
#define DAC_CLK_DDR DDRL
#define DAC_CLK PINL1 //48

#define DAC_DI_PORT PORTL
#define DAC_DI_DDR DDRL
#define DAC_DI PINL2  //47

#define DAC_LATCH_PORT PORTL
#define DAC_LATCH_DDR DDRL
#define DAC_LATCH PINL3  //46
From what I can tell this should be perfectly fine (though correct me if you see anything wrong).

What would cause no sound with no errors?

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Wave Shield and Arduino Mega: how-to

Post by adafruit »

should be fine. just make sure you've got 'em hooked up right :D

User avatar
fat16lib
 
Posts: 595
Joined: Wed Dec 24, 2008 1:54 pm

Re: Wave Shield and Arduino Mega: how-to

Post by fat16lib »

Did you change this in setup()?

Code: Select all

  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);

User avatar
abritinthebay
 
Posts: 32
Joined: Wed Dec 02, 2009 5:00 pm

Re: Wave Shield and Arduino Mega: how-to

Post by abritinthebay »

fat16lib wrote:Did you change this in setup()?
.... no.

Sonofa... that's what I get for doing electronics projects at 2am in the grip on insomnia!
Works fine now!

Not sure why that step isn't done in the library (not sour grapes, just curious), wouldn't that make more sense? As the pins themselves have to be defined there anyhow (just in a more literal way)... or at least via constants defined in the same DAC.h file.

I'd be happy to submit a patch that added it, but it is a trivial modification (and keeps all that sort of data in the same header files).

User avatar
fat16lib
 
Posts: 595
Joined: Wed Dec 24, 2008 1:54 pm

Re: Wave Shield and Arduino Mega: how-to

Post by fat16lib »

This is one of many thing that need to be fixed. The DAC code was written before there was a Mega then a user started this thread with a hack. In fact ladyada did he DAC stuff before there was a 328 Arduino.

I started a major rewrite but got interrupted by a more tasty project.

User avatar
abritinthebay
 
Posts: 32
Joined: Wed Dec 02, 2009 5:00 pm

Re: Wave Shield and Arduino Mega: how-to

Post by abritinthebay »

Ah, yeah - I know how that goes.

I know the project is on google code, but it doesn't look like you have the individual code files set up there in its version control system (svn I think). Have you considered doing this? It would be easy for people to help, and I'd love to help optimize the lib in any way I can.

User avatar
fat16lib
 
Posts: 595
Joined: Wed Dec 24, 2008 1:54 pm

Re: Wave Shield and Arduino Mega: how-to

Post by fat16lib »

I don't plan to open WaveHC to that kind of development. It is part of a set of projects that I want to keep synchronized. I just use google as a place for people to download code.

The SD I/O stuff in WaveHC uses parts of other libraries I wrote. The new DAC stuff can mostly be lifted from WaveRP, a record/play library that I wrote for the Wave Shield.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Wave Shield and Arduino Mega: how-to

Post by adafruit »

well...at least its good now :) OneOfTheThingsWereWorkingOn is making the pins not-hardcoded - paul s. made some AWESOME macros that allow compiler optimizations that use 'arduino naming' and convert to single-instruction codes. so that would solve a lot of problems.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”