Has anyone got SCP1000 working with .NET MF?

I posted previously that I couldn’t got my SCP1000 breakout board to work with FEZ Domino. People remarked that the SCP1000 might have been defective so I ordered another one. To my horror I can’t get this one to work either.

So far I haven’t found anyone who’s got it working with .NET MF. People have got it working with Arduino (in C), and I compared source code but I don’t see any obvuous differences.

Hi

Which interface are you using? SPI or I2C?

Thanks,
Errol

I’m using SPI. That’s the only option available for SparkFun’s breakout board I believe.

Let’s get started on this but you need to help the community to help you. Start by posting the code you have and the arduino code. Keep it simple please

Also, how is it connected? Any picture of your setup?

Essentially I initialize the SPI interface using:

static SPI.Configuration m_SPIConfig4PressureSensor = new SPI.Configuration((Cpu.Pin)FEZ_Pin.Digital.Di10, false, 100, 20, false, true, 500, SPI.SPI_module.SPI1);

Note: I got the setup and hold times from the SCP1000 datasheet.

And then I initialize the interface with:

        private static void InitPressureSensor()
        {
            Thread.Sleep(200);

            byte[] arrTxData = new byte[1];
            arrTxData[0] = 0x00;
            byte[] arrRxData = new byte[1];
            arrRxData[0] = 0xff;

            m_PressureSensor.WriteRead(arrTxData, arrRxData);

            WriteLineToFile("SCP1000 ASIC version: " + arrRxData[0].ToString());

            if (arrRxData[0] != 0x03)      // if we didn't get the expected version number
            {
                throw new InvalidOperationException("The pressure sensor could not be initialized");
            }
        }

I always get 0x00 back from the device.

I’ve got a picture of my setup as well.

more complete and simple info please http://www.tinyclr.com/forum/1/1904/

Thanks! I got it working!

I looked at the code from the example on how to write a question and I noticed I need two bytes for the input and output buffer.

Here’s the rewritten code:

        private static void InitPressureSensor()
        {
            Thread.Sleep(200);

            byte[] arrTxData = new byte[] { 0x00, 0xff };
            byte[] arrRxData = new byte[] { 0xff, 0xff };

            m_PressureSensor.WriteRead(arrTxData, arrRxData);

            WriteLineToFile("SCP1000 ASIC version: " + arrRxData[0].ToString());

            if (arrRxData[1] != 0x03)      // if we didn't get the expected version number
            {
                throw new InvalidOperationException("The pressure sensor could not be initialized");
            }
        }

I now get 0x03 back and no exception is therefore thrown. My problem stems from my assumption that I needed only 1 byte for send and one byte for receive. I assumed that the .NET MF would do the work of sending and receiving these for me.

Glad it worked for you and we look forward for your next question :slight_smile: