tuff's Content - Netduino Forums
   
Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

tuff's Content

There have been 8 items by tuff (Search limited from 29-March 23)


By content type

See this member's

Sort by                Order  

#53256 VS1053 breakout board

Posted by tuff on 18 October 2013 - 05:05 PM in Netduino Plus 2 (and Netduino Plus 1)

I tried without any Debug, I you were right, the speed rise up. But it's still to low compare to a normal play.

I use both of your sdcard class and vs1053 class, so I suppose I have the same than you...




#53240 VS1053 breakout board

Posted by tuff on 17 October 2013 - 02:23 PM in Netduino Plus 2 (and Netduino Plus 1)

I send order to my netduino card over network by my windows phone with an app I made. This app send to the netduino the song's name to play, On the netduino there is a socket server witch process the phone request and then send byte data to the vs1053.

With hanzibal's code, on the first song, i get this output :

RATE=8000 Hz (mono)

The music speed is really slow. And when I send a second order with another song :

RATE=44100 Hz (stereo)

But nothing is play...

 

I think i should have RATE=44100 Hz (stereo) at the first song to ear a clean sound, isn't it ?




#53207 VS1053 breakout board

Posted by tuff on 15 October 2013 - 02:25 PM in Netduino Plus 2 (and Netduino Plus 1)

Ok so the error that I got come from a bad SPI configuration in my code. But I have an other problem now.

I can play a file on my sd card but the play rate is really too low,  it's like a "slow-motion" but for a song (RATE = 8000 Hz display in the visual output)

 

How can I speed it up ? (I'm sorry I don't understand perfectly your playstream function hanzibal ^^")




#53186 VS1053 breakout board

Posted by tuff on 14 October 2013 - 09:58 AM in Netduino Plus 2 (and Netduino Plus 1)

After some research, I found this in the vs1053 doc :

 

7.3 Data Request Pin DREQ

The DREQ pin/signal is used to signal if VS1053b’s 2048-byte FIFO is capable of receiving data. If
DREQ is high, VS1053b can take at least 32 bytes of SDI data or one SCI command. DREQ is turned
low when the stream buffer is too full and for the duration of a SCI command.

 

I also found code example witch wait for the dreq pin goes to true :

private void CommandWrite(byte register, ushort data)        {            while (_dreq.Read() == false)            {                Debug.Print("- CommandWrite / _dreq : " + _dreq.Read().ToString());            }            _spi.Config = CmdConfig;            cmdBuffer[0] = CMD_WRITE;            cmdBuffer[1] = register;            cmdBuffer[2] = (byte)(data >> 8);            cmdBuffer[3] = (byte)data;            _spi.Write(cmdBuffer);        }

The result out put I get is : 

- CommandWrite / _dreq : FALSSE

 

And that's all, the code is block in the while loop...

 

The board is supposed to change the state of the dreq pin by herself, right ?




#53174 VS1053 breakout board

Posted by tuff on 13 October 2013 - 12:17 PM in Netduino Plus 2 (and Netduino Plus 1)

I finally end up with this resources : 

the second one is a c# implementation of the third resources. So i tried to use it but I don't succeed to read any data from the board...

This is my code :

using System;using System.IO;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware.Netduino;using System.Threading;using System.Diagnostics;using Microsoft.SPOT;namespace NetduinoApplication2{    public class VS1053    {        // GPIO ports:        private OutputPort _reset;        private InterruptPort _dreq;         private Cpu.Pin PinBsync = Pins.GPIO_PIN_D2;        private Cpu.Pin PinDreq = Pins.GPIO_PIN_D3;        private Cpu.Pin PinReset = Pins.GPIO_PIN_D6;  // NOTE: This doesn't map to an actual pin        private Cpu.Pin PinCs = Pins.GPIO_PIN_D9;         // Define SPI Configuration for VS1053 MP3 decoder:        private SPI.Configuration DataConfig;        private SPI.Configuration CmdConfig;        private SPI _spi;         // Registers:        private byte RegisterSciMode = 0x00;        private byte RegisterSciVol = 0x0B;        private byte RegisterSciClockf = 0x03;         public static readonly int BufferSize = 96;        private ushort SciMode = 0x880;  // SM_SDINEW (default) + SM_EARSPEAKER_HI         private bool _isInitialized;        private readonly byte[] ReadBuffer = new byte[BufferSize];        private readonly byte[] CmdBuffer = new byte[4];         private readonly AutoResetEvent AutoResetEvent = new AutoResetEvent(false);         public void Initialize() {            DataConfig = new SPI.Configuration(PinBsync, false, 0, 0, false, true, 3000, SPI.SPI_module.SPI1);            CmdConfig = new SPI.Configuration(PinCs, false, 0, 0, false, true, 3000, SPI.SPI_module.SPI1);                        Debug.Print("--- _isInitialized : " + _isInitialized.ToString());            if (_isInitialized)            {                Debug.Print("Shutdown !");                Shutdown();            }            _spi = new SPI(CmdConfig);            _reset = new OutputPort(PinReset, true);            _dreq = new InterruptPort(PinDreq, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);            _dreq.OnInterrupt += _dreq_OnInterrupt;             _isInitialized = true;             Reset();            var test = SciMode | (1 << 2);            var test2 = (ushort)test;            Debug.Print("--- set : " + test2.ToString("x") + " : " + test2.GetType());            CommandWrite(RegisterSciMode, test2);            var result = CommandRead(RegisterSciMode);            Debug.Print("--- read :");            foreach (byte b in result)            {                Debug.Print(b.ToString("x"));            }            //CommandWrite(RegisterSciClockf, 7 << 13);            //CommandWrite(RegisterSciVol, 0x2424);             //_spi.Config = DataConfig;        }         private void _dreq_OnInterrupt(uint port, uint state, DateTime time) {            if (state == 0)            {                AutoResetEvent.Set();            }            else            {                AutoResetEvent.WaitOne();            }            _dreq.ClearInterrupt();        }         private void Reset() {            Debug.Print("--- Start reset ---");            _reset.Write(false);            Thread.Sleep(1);            _reset.Write(true);            Thread.Sleep(1);            Debug.Print("--- Finish reset ---");        }         private void CommandWrite(byte address, ushort data) {            CmdBuffer[0] = 0x02;            CmdBuffer[1] = address;            CmdBuffer[2] = (byte)(data >> 8);            CmdBuffer[3] = (byte)data;             _spi.Write(CmdBuffer);        }         private byte[] CommandRead(byte address) {                        var buffer = new byte[4];                        CmdBuffer[0] = 0x03;            CmdBuffer[1] = address;            CmdBuffer[2] = 0;            CmdBuffer[3] = 0;            _spi.WriteRead(CmdBuffer, buffer, 0);             //ushort command = CmdBuffer[0];            //command <<= 8;            //command += CmdBuffer[1];            return buffer;        }        public void SetVolumePercent(int volume)        {            if (volume < 0 || volume > 100)                throw new ArgumentOutOfRangeException("volume");             SetVolumePercent(volume, volume);        }         public void SetVolumePercent(int leftChannel, int rightChannel) {            if (leftChannel < 0 || leftChannel > 100)                throw new ArgumentOutOfRangeException("leftChannel");            if (rightChannel < 0 || rightChannel > 100)                throw new ArgumentOutOfRangeException("rightChannel");             // TODO: Invert decibel value, divide by percent, call SetVolume(ushort leftChannel, ushort rightChannel)        }         public void SetVolume(ushort bothChannels) {            CommandWrite(RegisterSciVol, bothChannels);  // TODO: This doesn't work outside the Initialize() method        }         public void SetVolume(ushort leftChannel, ushort rightChannel)        {            SetVolume((ushort) (leftChannel*256 + rightChannel)); // TODO: Verify no loss of fidelity        }         public void SendData(FileStream fileStream)        {            var size = fileStream.Length - fileStream.Length % BufferSize;            for (var i = 0; i < size; i += BufferSize) {                fileStream.Read(ReadBuffer, 0, BufferSize);                 _spi.Write(ReadBuffer);            }        }         private void Shutdown() {            if (!_isInitialized) return;             Reset();             _spi.Dispose();            _reset.Dispose();            _dreq.Dispose();             _isInitialized = false;        }    }} 
using System;using System.Net;using System.Net.Sockets;using System.Threading;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.Netduino;namespace NetduinoApplication2{    public class Program    {        public static void Main()        {            VS1053 vs = new VS1053();            vs.Initialize();            //vs.SetVolume(0xFEFE);        }    }} 

And this is this output I got :

--- _isInitialized : False--- Start reset ------ Finish reset ------ set : 884 : System.UInt16--- read :00000000The thread '<No Name>' (0x1) has exited with code 0 (0x0).Done. 

I think I'm supposed to receive the exact same byte array that I send with CommandWrite, but I just receive 0...

Any Idea ?




#53155 VS1053 breakout board

Posted by tuff on 12 October 2013 - 10:22 AM in Netduino Plus 2 (and Netduino Plus 1)

My idea is pretty much the same than this topics but I don't use sd card for now. Anyway, it doesn't really help me, hanzibal describe his project but didn't say "how" he did it, and the only code spinnet I found are for an other component...

I continue to search ;) 




#53153 VS1053 breakout board

Posted by tuff on 12 October 2013 - 09:12 AM in Netduino Plus 2 (and Netduino Plus 1)

Ok, thank you for the quick answer I will look at this :)



#53140 VS1053 breakout board

Posted by tuff on 11 October 2013 - 05:20 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi,

 

I'm working on a netduino plus 2 and vs1053 for a school project. The main idea of the project is to  stream mp3 audio from web. 

I succeed to request audio, but I'm completly block with the vs1053, I'm new with SPI and all stuff like this. 

For now, I read this datasheet : https://www.sparkfun.../SMD/vs1053.pdf

but i'm not sure of what I'm supposed to do with it. 

Any help will be appreciate.

 

Thanks.

P.S : I steel have a complete week to finish my project.





home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.