Change a pin in the WaveHC library
Moderators: adafruit_support_bill, adafruit

Re: Change a pin in the WaveHC library

by adafruit_support_bill on Wed Jan 30, 2013 5:38 pm

Good point xl97. I'm not familiar with the rotoshield or its library, but depending on which timer(s) it uses for PWM , you may have a timer conflict there.
User avatar
adafruit_support_bill
 
Posts: 30829
Joined: Sat Feb 07, 2009 10:11 am

Re: Change a pin in the WaveHC library

by Vincent14 on Thu Jan 31, 2013 4:47 am

The Rotoshied uses the Snootor Library (I use only DC motors), the constructor also says me that there is a possible timer conflict. I don't really know how to solve it, is it possible ?
Vincent14
 
Posts: 17
Joined: Sun Jan 20, 2013 2:49 pm

Re: Change a pin in the WaveHC library

by adafruit_support_bill on Thu Jan 31, 2013 8:32 am

The timers are associated with specific PWM pins. You might be able to get it to work using different motor channels on the rotoshield.

http://playground.arduino.cc/Main/TimerPWMCheatsheet
User avatar
adafruit_support_bill
 
Posts: 30829
Joined: Sat Feb 07, 2009 10:11 am

Re: Change a pin in the WaveHC library

by Vincent14 on Thu Jan 31, 2013 1:22 pm

Refering to my post about the map of my pins :
- the Rotoshield uses "the timer 0" (both D5 & D6 not removables, used by it),
- the WaveShield is alone on timer 1 (D9 free, D10 used by it),
- the Waveshield uses timer 2 (D3 is a not removable port that I don't use on the Rotoshield, D11 used by it).

1) So, if I use only motors 3 and 4 (pins D5 & D6), what is the other change I have to do ? Do two timers could be at the same frequency ?

2) Is my modification correct, when I've moved Waveshield' pins from D3 to D7 (from a pin on timer 2 to a pin without timer) and from D5 to D8 (again without timer on D8) ?
Vincent14
 
Posts: 17
Joined: Sun Jan 20, 2013 2:49 pm

Re: Change a pin in the WaveHC library

by adafruit_support_bill on Fri Feb 01, 2013 6:48 am

1) I am not familiar with the rotoshield or its library. But it is likely that they are using the timer on those pins for PWM.
2) The waveshield does not need PWM for the DAC. You can relocate those pins.
User avatar
adafruit_support_bill
 
Posts: 30829
Joined: Sat Feb 07, 2009 10:11 am

Re: Change a pin in the WaveHC library

by Vincent14 on Fri Feb 01, 2013 1:02 pm

If I comment all parts of code about Rotoshield, and if I try to move the Waveshield pin D3 to a free pin (in WavePinDefs.h), the sound doesn't play anymore. Do you know why ?

I've succeed to play a sound continually with the motor wired on D6 (not used by Waveshield) activated but not with the motor wired on D5 activated, even if I move this pin of the Waveshield to a free pin.
Vincent14
 
Posts: 17
Joined: Sun Jan 20, 2013 2:49 pm

Re: Change a pin in the WaveHC library

by adafruit_support_bill on Fri Feb 01, 2013 1:14 pm

if I try to move the Waveshield pin D3 to a free pin (in WavePinDefs.h)

Are you moving the corresponding jumper wires too?
User avatar
adafruit_support_bill
 
Posts: 30829
Joined: Sat Feb 07, 2009 10:11 am

Re: Change a pin in the WaveHC library

by xl97 on Fri Feb 01, 2013 1:29 pm

Im a bit lost on all this stuff your trying to do.. but:

1.) Dont change the PINS used for the Micro SD socket on the Waveshield.. (except for the CS pin = D10).. the other pins are the SPI bus.

2.) Id you want to change the CS pin of the microSD card on the Waveshield.. do so in the sketch. (may or may not need to still turn D10/SS pin to output..even if NOT using that pin as the CS pin for the SD card)


3.) As far as the DAC is concerned, you can change ANY/ALL pins it uses. Only done through the WavePinDefs.h file.

I have a 'custom' hybrid Arduino/Waveshield... and it uses: // use arduino pins A3(D17), D4, D7, D8 for DAC


default WavePinDefs.h file has set as:

// use arduino pins 2, 3, 4, 5 for DAC

So it should work just fine, unless Im missing something else?.

I think gettingyour waveshield to work on the updated pins you want first is a good idea...

then try to work in your other library/code.
xl97
 
Posts: 144
Joined: Mon Jul 27, 2009 12:51 pm

Re: Change a pin in the WaveHC library

by Vincent14 on Fri Feb 01, 2013 2:58 pm

@adafruit_support : No, my jumpers (four wires ?) are soldered to my Waveshield I can't move them easily :? Lionel (constructor of the Rotoshield) said it's possible to move this pins only by editing the library, is it true ?

@xl97 : 1) & 2) It's O.K, my other shield only use D3, D5 and D11 in common, but i don't use part of it where using D11. I have to use D3 or D5 on my other shield, that's why I try to move them in the WaveShield library.

3) What is "DAC" ? I've tried to move pin 3 (the comment and 3 lines following) on an other free pin but after upload, my shield could not make a sound.

If I want to set an analog pin, do I have something like that ?
Code: Select all | TOGGLE FULL SIZE
// pin analog 16 is DAC serial clock
/** Data direction register for DAC clock. */
#define MCP_DAC_SCK_DDR  PIN16_DDRREG
/** Port register for DAC clock. */
#define MCP_DAC_SCK_PORT PIN16_PORTREG
/** Port bit number for DAC clock. */
#define MCP_DAC_SCK_BIT  PIN16_BITNUM


The pins of the other library are not removables at all (it's the wiring of the motors).


Thank both of you for your support :| Say me if I'm not clear, It's not easy to explain in another language for me.
Vincent14
 
Posts: 17
Joined: Sun Jan 20, 2013 2:49 pm

Re: Change a pin in the WaveHC library

by adafruit_support_bill on Fri Feb 01, 2013 3:53 pm

The DAC is the "digital to analog converter" You have a jumper on your wave shield that goes to pin 3. If you change the pin assignment in the library, you must also change the jumper to the same pin.
User avatar
adafruit_support_bill
 
Posts: 30829
Joined: Sat Feb 07, 2009 10:11 am

Re: Change a pin in the WaveHC library

by xl97 on Fri Feb 01, 2013 4:14 pm

Vincent14 wrote:@adafruit_support : No, my jumpers (four wires ?) are soldered to my Waveshield I can't move them easily :? Lionel (constructor of the Rotoshield) said it's possible to move this pins only by editing the library, is it true ?

@xl97 : 1) & 2) It's O.K, my other shield only use D3, D5 and D11 in common, but i don't use part of it where using D11. I have to use D3 or D5 on my other shield, that's why I try to move them in the WaveShield library.

3) What is "DAC" ? I've tried to move pin 3 (the comment and 3 lines following) on an other free pin but after upload, my shield could not make a sound.

If I want to set an analog pin, do I have something like that ?
Code: Select all | TOGGLE FULL SIZE
// pin analog 16 is DAC serial clock
/** Data direction register for DAC clock. */
#define MCP_DAC_SCK_DDR  PIN16_DDRREG
/** Port register for DAC clock. */
#define MCP_DAC_SCK_PORT PIN16_PORTREG
/** Port bit number for DAC clock. */
#define MCP_DAC_SCK_BIT  PIN16_BITNUM


The pins of the other library are not removables at all (it's the wiring of the motors).


Thank both of you for your support :| Say me if I'm not clear, It's not easy to explain in another language for me.


Im still a bit fuzzy.. (but Im a noob myself.. so its to be expected!) LOL..

maybe this will help:

here is what/how I edited my WavePinDefs.h file:


NEW:
Code: Select all | TOGGLE FULL SIZE
// use arduino pins A3(D17), D4, D7, D8 for DAC

// pin A3/D17 is DAC chip select

/** Data direction register for DAC chip select. */
#define MCP_DAC_CS_DDR  PIN17_DDRREG
/** Port register for DAC chip select. */
#define MCP_DAC_CS_PORT PIN17_PORTREG
/** Port bit number for DAC chip select. */
#define MCP_DAC_CS_BIT  PIN17_BITNUM

// pin D4 is DAC serial clock
/** Data direction register for DAC clock. */
#define MCP_DAC_SCK_DDR  PIN4_DDRREG
/** Port register for DAC clock. */
#define MCP_DAC_SCK_PORT PIN4_PORTREG
/** Port bit number for DAC clock. */
#define MCP_DAC_SCK_BIT  PIN4_BITNUM

// pin D7 is DAC serial data in
/** Data direction register for DAC serial in. */
#define MCP_DAC_SDI_DDR  PIN7_DDRREG
/** Port register for DAC clock. */
#define MCP_DAC_SDI_PORT PIN7_PORTREG
/** Port bit number for DAC clock. */
#define MCP_DAC_SDI_BIT  PIN7_BITNUM


// pin D8 is LDAC if used
#if USE_MCP_DAC_LDAC
/** Data direction register for Latch DAC Input. */
#define MCP_DAC_LDAC_DDR  PIN8_DDRREG
/** Port register for Latch DAC Input. */
#define MCP_DAC_LDAC_PORT PIN8_PORTREG
/** Port bit number for Latch DAC Input. */
#define MCP_DAC_LDAC_BIT  PIN8_BITNUM
#endif // USE_MCP_DAC_LDAC



original:
Code: Select all | TOGGLE FULL SIZE
// use arduino pins 2, 3, 4, 5 for DAC

// pin 2 is DAC chip select

/** Data direction register for DAC chip select. */
#define MCP_DAC_CS_DDR  PIN2_DDRREG
/** Port register for DAC chip select. */
#define MCP_DAC_CS_PORT PIN2_PORTREG
/** Port bit number for DAC chip select. */
#define MCP_DAC_CS_BIT  PIN2_BITNUM

// pin 3 is DAC serial clock
/** Data direction register for DAC clock. */
#define MCP_DAC_SCK_DDR  PIN3_DDRREG
/** Port register for DAC clock. */
#define MCP_DAC_SCK_PORT PIN3_PORTREG
/** Port bit number for DAC clock. */
#define MCP_DAC_SCK_BIT  PIN3_BITNUM

// pin 4 is DAC serial data in

/** Data direction register for DAC serial in. */
#define MCP_DAC_SDI_DDR  PIN4_DDRREG
/** Port register for DAC clock. */
#define MCP_DAC_SDI_PORT PIN4_PORTREG
/** Port bit number for DAC clock. */
#define MCP_DAC_SDI_BIT  PIN4_BITNUM

// pin 5 is LDAC if used
#if USE_MCP_DAC_LDAC
/** Data direction register for Latch DAC Input. */
#define MCP_DAC_LDAC_DDR  PIN5_DDRREG
/** Port register for Latch DAC Input. */
#define MCP_DAC_LDAC_PORT PIN5_PORTREG
/** Port bit number for Latch DAC Input. */
#define MCP_DAC_LDAC_BIT  PIN5_BITNUM
#endif // USE_MCP_DAC_LDAC





what is a DAC? DAC = Digital to Anolog Converter... helps in creating/converting your Audio output.....

THESE are the pins you can change for the WaveShield.. for the DAC... you must also physically ire it up to match the code here.


The ONLY pin on the SD card you can change is the CS (chip select) pin... and again..you must physically match the wiring to whatever you set the code to..


Lets start simple question:

what pin(s) do you want your other motor library to work with? Or does it work with/use by default?
xl97
 
Posts: 144
Joined: Mon Jul 27, 2009 12:51 pm

Re: Change a pin in the WaveHC library

by Vincent14 on Fri Feb 01, 2013 6:13 pm

I thank you because now I think I understand the problem, you've restored my hope to end my project.

To answer you, I need D3 or D5 free for my other shield.

Here is my Waveshield :

Image

1) Is it what you named "jumpers" ?

Image

2) Can you confirm I have to unsolder the link between "LAT" and D5 holes, and wire a new connexion between "LAT" and D7 ?

3) Any solution by using the free hole "SW" on the Waveshield and replace "LAT" by "SW" in the library, to avoid having to take the risk of desoldering ?
Vincent14
 
Posts: 17
Joined: Sun Jan 20, 2013 2:49 pm

Re: Change a pin in the WaveHC library

by xl97 on Fri Feb 01, 2013 6:41 pm

I dont understand when you talk LAT & SW..etc..

post simple PIN NUMBERS!!

Current/Default Pin Set-up:

WaveShield SD Pin Out: 10, 11, 12, 13 pins...

* you can ONLY change pin D10 here.. and ONLY do that if your other shield requires the usage of D10


WaveShield DAC Pin Out: 2, 3, 4, 5 pins....

* ANY OR ALL OF THESE "CAN" BE CHANGED!..
* If you change these pins in the WavePinDefs.h file.. you MUST ALSO UPDATE THE WIRES/JUMPERS to match!!!!


NEW ROTO SHIELD PIN OUT: (no clue)


NOW.. if you wanted to say OPEN UP D3 or D5 fromthe WaveShield so your OTHER Shield can use it..

you must FIRST edit the WavePinDefs.h file..

find this section:
Code: Select all | TOGGLE FULL SIZE
// use arduino pins 2, 3, 4, 5 for DAC

// pin 2 is DAC chip select

/** Data direction register for DAC chip select. */
#define MCP_DAC_CS_DDR  PIN2_DDRREG
/** Port register for DAC chip select. */
#define MCP_DAC_CS_PORT PIN2_PORTREG
/** Port bit number for DAC chip select. */
#define MCP_DAC_CS_BIT  PIN2_BITNUM

// pin 3 is DAC serial clock
/** Data direction register for DAC clock. */
#define MCP_DAC_SCK_DDR  PIN3_DDRREG
/** Port register for DAC clock. */
#define MCP_DAC_SCK_PORT PIN3_PORTREG
/** Port bit number for DAC clock. */
#define MCP_DAC_SCK_BIT  PIN3_BITNUM

// pin 4 is DAC serial data in

/** Data direction register for DAC serial in. */
#define MCP_DAC_SDI_DDR  PIN4_DDRREG
/** Port register for DAC clock. */
#define MCP_DAC_SDI_PORT PIN4_PORTREG
/** Port bit number for DAC clock. */
#define MCP_DAC_SDI_BIT  PIN4_BITNUM

// pin 5 is LDAC if used
#if USE_MCP_DAC_LDAC
/** Data direction register for Latch DAC Input. */
#define MCP_DAC_LDAC_DDR  PIN5_DDRREG
/** Port register for Latch DAC Input. */
#define MCP_DAC_LDAC_PORT PIN5_PORTREG
/** Port bit number for Latch DAC Input. */
#define MCP_DAC_LDAC_BIT  PIN5_BITNUM
#endif // USE_MCP_DAC_LDAC




If you want to FREE UP pin D3... then you edit this:
Code: Select all | TOGGLE FULL SIZE
// pin 3 is DAC serial clock
/** Data direction register for DAC clock. */
#define MCP_DAC_SCK_DDR  PIN3_DDRREG
/** Port register for DAC clock. */
#define MCP_DAC_SCK_PORT PIN3_PORTREG
/** Port bit number for DAC clock. */
#define MCP_DAC_SCK_BIT  PIN3_BITNUM



to this: (assuming you want to use say pin 7 instead of pin 3)

Code: Select all | TOGGLE FULL SIZE
// pin 7 is DAC serial clock
/** Data direction register for DAC clock. */
#define MCP_DAC_SCK_DDR  PIN7_DDRREG
/** Port register for DAC clock. */
#define MCP_DAC_SCK_PORT PIN7_PORTREG
/** Port bit number for DAC clock. */
#define MCP_DAC_SCK_BIT  PIN7_BITNUM



you MUST then go to where you have/had the original wire/jumper connected from the Waveshield to D3 on the Arduino.. and MOVE that to go to pin D7 on the Arduino..



Yes, 'jumpers' = wires....


if you want to remove/use pin D5 instead of pin D3.. its the same steps.. except a different pin.


its really simple.. you must be over thinking it..


remove the wire/jumper from pin D3 or D5 (whatever you choose).. and move it to D7

make sure BOTH the code and the wires match.




as mentioned before.. Im using: pins A3(D17), D4, D7, D8 for the Waveshield DAC
xl97
 
Posts: 144
Joined: Mon Jul 27, 2009 12:51 pm

Re: Change a pin in the WaveHC library

by Vincent14 on Sat Feb 02, 2013 9:17 am

Look at this picture, on the right :

Image

LAT is the name of the hole where D5 is connected on the Waveshield. (see this topic about building)

Ok so I moved LAT-to-D5 to LAT-to-D8, make the library modification and ...

IT WORKS FINE ! Thanks very, VERY much guys ! :D Thanks for your amazing support !

Edit. Here is the result :

Image

Image

My soldering iron was not small enough, I hacked :oops:
Vincent14
 
Posts: 17
Joined: Sun Jan 20, 2013 2:49 pm

Re: Change a pin in the WaveHC library

by xl97 on Sat Feb 02, 2013 9:56 am

glad it all worked for you!!!..

:)
xl97
 
Posts: 144
Joined: Mon Jul 27, 2009 12:51 pm