Main Site Documentation

Spider, Spi socket and MCP4131


#1

Hi all. I got a strange problem again with the mcp4131 module.
At first I plugged the mcp4131 using the extender module into socket 9 (s type) and invoked the constructor:


SPI.Configuration MCP4131_Config = new SPI.Configuration((Cpu.Pin)GHI.Hardware.EMX.Pin.IO46, false, 0, 0, false, true, 800, SPI.SPI_module.SPI1);

SPI MCP4131_SPI = new SPI(MCP4131_Config);

And everything worked fine. I wanted to use socket 6 (S type as well) for the same module I plugged the extender to socket 6 and changed the code to:


SPI.Configuration MCP4131_Config = new SPI.Configuration((Cpu.Pin)GHI.Hardware.EMX.Pin.IO18, false, 0, 0, false, true, 800, SPI.SPI_module.SPI2); //IO18 is Pin number 3 at socket 6 according to schematics

SPI MCP4131_SPI = new SPI(MCP4131_Config);

But this time It won’t work. Any suggestion ? Is it possible to control 2 spi modules ?
Thanks in advance.


#2

How exactly it doesn’t work?


#3

@ Architect - Hi, thanks for replying.
The output is as follow:
i=128
Wiper REG: 0
Status REG: 0
TCON: 0
i=127
Wiper REG: 0
Status REG: 0
TCON: 0

and the resistance shows 157 ohm steady.


#4

Is it the same mcp4131 that worked on the other socket?


#5

@ Architect - Yeah, If I return the extender to socket 9 and invoke the first constructor, It works again.


#6

Ok you need to have one SPI instance and switch SPI.Configuration for each IC when you need to access it.


#7

@ Architect - I think i’m doing it already:



if (socketNumber == 9)
{
             MCP4131_Config = new SPI.Configuration((Cpu.Pin)GHI.Hardware.EMX.Pin.IO46, false, 0, 0, false, true, 800, SPI.SPI_module.SPI1);
 }
if (socketNumber == 6)
{
             MCP4131_Config = new SPI.Configuration((Cpu.Pin)GHI.Hardware.EMX.Pin.IO18, false, 0, 0, false, true, 800, SPI.SPI_module.SPI2);
}

MCP4131_SPI = new SPI(MCP4131_Config);

Is that what you mean?


#8

more like

Config1 = new …
Config2 = new …

MCP_SPI = new SPI(Config1)

at this point SPI is connected to the first sensor.

When you need to talk to the second one you need to switch configuration:

MCP_SPI.Config = Config2

That is if you want to use both in your application. If you are using only one then your code should work.


#9

@ Architect - Let’s go back to basic. I don’t wish to use socket 9.

Constructor at mcp4131.cs ->

 

      public MCP4131(Cpu.Pin cs_pin, SPI.SPI_module mod)
        {
            MCP4131_Config = new SPI.Configuration(cs_pin, false, 0, 0, false, true, 800, mod);
            MCP4131_SPI = new SPI(MCP4131_Config);
        }

Invoked with:


MCP4131 myMCP4131 = new MCP4131((Cpu.Pin)GHI.Hardware.EMX.Pin.IO18, SPI.SPI_module.SPI2);

And again, Plugged it to socket 6 (Lets forget about socket 9 right now), but the resistance stuck on low and won’t change, but you know, at the beginning, (before deploying the code) the resistance shows ~5k but afterwards it drops to 150 ohm steady, what’s your opinion? (the same code works fine with socket 9 using IO46 and spi1)


#10

Maybe the socket is corrupted ? Is there any way the check that?


#11

Do a visual examination first. Then try a logic analyzer to see that SPI lines are live.

You can also use a LED to check that each pin on that socket works as digital output.


#12

@ Architect - Great idea! I connected led7r, every one of the leds except D5 turned on,
I guess the socket is corrupt. What’s next?
(Any idea how to fix this…)


#13

Check if there is a short.


#14

@ Architect - I’m not sure where to check, nothing is connected to the mainboard. I’ll open a new topic, thanks for all your help.


#15

It is possible that you have damaged the pin when you had your IC laying on the conductive material.

If you have another Spider around I would check that first.