G120 with music module

Hi Guys,
Im trying to get a g120hdr module going with a gadgeteer music module…does this work?
If so how does it get wired up?
And how do i tell the software what pins to use?

From what I have seen you supply a gadgeteer port in the constructor…but on the g120 the user ports only have power and gnd connected if I understand correctly…so what pins do I need to connect?

Regards

Mike

@ michaelo - Hi Mike, yes it’s fairly easy to set up i just use the following driver - http://www.tinyclr.com/codeshare/entry/368

Then change:

 public Music(int socketNumber)
        {
            // This finds the Socket instance from the user-specified socket number.  
            // This will generate user-friendly error messages if the socket is invalid.
            // If there is more than one socket on this module, then instead of "null" for the last parameter, 
            // put text that identifies the socket to the user (e.g. "S" if there is a socket type S)
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);
 
            socket.EnsureTypeIsSupported(new char[] { 'S' }, this);
 
            // Set up our SPI 
            m_dataConfig = new SPI.Configuration(socket.CpuPins[5], false, 0, 0, false, true, 2000, socket.SPIModule, socket.CpuPins[3], false);
            m_cmdConfig = new SPI.Configuration(socket.CpuPins[6], false, 0, 0, false, true, 2000, socket.SPIModule, socket.CpuPins[3], false);
            m_dreq = new InputPort(socket.CpuPins[3], false, Port.ResistorMode.PullUp);
 
            m_SPI = new SPI(m_dataConfig);

to:

        public Music()
        {

            m_dataConfig = new SPI.Configuration(GHI.Premium.Hardware.G120.Pin.P0_1, false, 0, 0, false, true, 2000, SPI.SPI_module.SPI1, GHI.Premium.Hardware.G120.Pin.P0_11, false);
            m_cmdConfig = new SPI.Configuration(GHI.Premium.Hardware.G120.Pin.P0_16, false, 0, 0, false, true, 2000, SPI.SPI_module.SPI1, GHI.Premium.Hardware.G120.Pin.P0_11, false);
            m_dreq = new InputPort(GHI.Premium.Hardware.G120.Pin.P0_11, false, Port.ResistorMode.PullUp);


            m_SPI = new SPI(m_dataConfig);

And then wire up the side header pins for the socket you use 3,4,5,6,7,8 and 9 to P0.11,P0.22,P0.1,P0.16,P0.18,P0.17,P0.15

Hi Justin,
Thanks - this is exactly what I was looking for - all the info from others also filled gaps so appreciate everyones help :slight_smile:

@ michaelo - Your welcome, if you have any issues let me know - i have a HDR playing MP3’s and it works a treat.

Hi Justin,
For your mp3 did you use an sdcard module? If so how did you wire that one up?

Hi Michaelo, sorry for the slow reply - have been away from the PC…

Yes i have a project that reads from SD mps and plays the files with the music module and drives SPI LED’s

Attached is the schematics for the board. JP2 is the wiring for the SD and JP1 for the music module.

From this i created the attached board to clean up the wiring.

If you want i can send you a board to play with - just solder on headers to the G120HDR and sockets to the carrier…

Hope this helps.

Hi Justin,
I take it you also had to modify the sdcard driver as well - because the constructor takes only a socket?
Do you have some example code of the changes?

Hi Justin,
I have wired up my g120hdr as per your scematic but am still looking for how i can create an instance of the sdcard driver that doesnt require a socket in the constructor?
Any chance of seeing your code. Also where do I find the standard driver code (is that publicly available?)etc etc so I could have a crack at modifying it myself so that it doesnt need a socket?

Regards

Mike

Hi Mike send me an email to Justin at ingenuitymicro dot com and I’ll send you some code.

Hi Guys,
I seem to be going slowly backwards - have been on this for 3 weeks now and would be REALLY happy to have someone give me an answer at this point.

I have a g120hdr with a sdmodule connected to it. I also have music module…but i dont think this is related.
Initially I have had it reading from the sdcard and it was reading ok for a while then it threw an IO exception reading partway through the file (sometimes 3k into the file, sometimes 700k in…it fluctuates ).

I was getting various outcomes (lockups, io exceptions etc etc)

Now it just hangs when I get to the following line of code:

GHI.Premium.IO.PersistentStorage sdPS = new GHI.Premium.IO.PersistentStorage(“SD”);

This is not rocket science …so i am totally at a loss as to what is causing it.

I have tried the following to try and narrow it down:

  1. I have shortened all wires between the g120 and the sdcard.
  2. I have tried another micro sdcard module
  3. I have tried another sd carrd module (not micro)
  4. I have checked the wires many times
  5. I have had a colleague check the wires many times
  6. we have added a uf22 capacitor to the power supply
  7. Today I have upgraded the firmware to what i believe is the latest version (ghi.Premium.io shows version 4.2.7.0)
  8. I have tried different sdcards (the current microsd is apacer 2gb sd card, I have also tried another brand)
  9. I have verified I can read the entire file in a pc from the sdcard(s)

It just seems flakey - right now it locks every time when creating a persistantStorage instance. After it locks my only way to talk to the device is to reflash it …it hangs entirely, I have reflashed it many times already - so have eliminated that as an option.

After 3 weeks of pulling my hair out with this Im open for suggestions - Justin has done a lot to help but to date its still not working - his input has been appreciated.

Mike, cant you post a pickie of your No.8 wiring?

I would start with a new project, try something simple and if there is s problem then post the code here

@ Gus - been there, done that…

here is the code
create a new netmf console app 4.2 app

here is the code (e.g. I have added 2 lines …and it doesnt make it to the 2nd one - it blows up creating the persistantstorage instance)
also added references to 2 dll - GHI.Premium.IO and GHI.Premium.System (both 4.2.7.0)

using System;
using Microsoft.SPOT;

namespace MFConsoleApplication1
{
public class Program
{
public static void Main()
{
Debug.Print(
Resources.GetString(Resources.StringResources.String1));

        GHI.Premium.IO.PersistentStorage sdPS = new GHI.Premium.IO.PersistentStorage("SD");

        sdPS.MountFileSystem();

    }

}

}

Logic tells me it has to be wiring - i will try and take a photo but its almost midnight and the lighting isnt that good…

Sorry guys,

Just broke a wire trying to move the bits around to get a photo - I will have to solder it back on in the morning and then get a photo (need to go outside to another building to get the soldering iron etc… job for the morning (its almost midnight here))

@ michaelo - Go have a Speights…

OK - managed to get a photo (note the power pin is just sitting on the extender module…will solder in the morning). Basic setup is:

  • G120hdr
  • extender module with sdcard module connected that is then wired to g120hdr
    *ignore the grey extender wire that is wired direct to the board - that is for the music module (that was working if I can fix the sdcard issue)
  • we also run another extender (heavier wires) that runs a network module.
  • the red and white wires (with 2 switches) where added so i could reflash it a bit easier

Open for suggestions (apart from get better glasses and a smaller soldering iron :wink: )

Now where is that Speights … oh and justin you would know that #8 wire is perfect for everything - thats probably why its not working - maybe I need to grab some of that out of the shed instead of the soldering iron :slight_smile:

Header pins are your friend :wink:

yeap - there was a little more space on the extender pads…and I was soldering it at home (rather than at work) and the solder iron i was using had a tip big enough to do some plumbing soldering with :wink: - if no one can see anything obvious then I will get the smaller soldering iron and redo it with no extender lead.

Hi Guys,
Soldered the wire back on and then no difference. I then went and got another brand of micro sdcard and this time it changed the outcome (e.g. no error on constructor…previously I had 2 different cards give constructor errors). This card allows the song to play - however it sounds almost like there is static on the line …which is weird because when I had it going initially (when it was getting stream reading errors) - the quality was pretty much perfect…

Any suggestions?

NOTE Card I am using now is a sandisk ultra 2, 512mb… The reads the disk but the quality seems rubbish.