When sd card is inserted spi bus is disrupted??

Long story short I am running an due based board for a 3d printer(Ultratronics PRO). I am running repetier firmware dev version. I have 7 devices on the spi bus. 4 max31855 thermocouples, 1 SD card, 1 ST7920 Full graphic Smart controller, and an Ethernet IC. Ehternet is not used in firmware but could be a potential source of this problem even though the cs pin is always high

The problem the spi buss works okay when the sd card is removed except for 2 horizontal lines across the display. So lcd and the 4 thermocouples read correctly. But! when the sd card is inserted the thermocouples read all ones. Changing the spi settings like speed, mode, and polarity do not affect this error state of the thermocouples. However I can read and write files to the sd card without any issues. and the lcd display still responds to button presses and acts like it should except for the 2 lines. If the sd card is removed the thermocuples start reading correctly.

I have tried to read the sck and MISO pins on my Oscope but it is only good to 20 MHz and the due is at 84 MHz. I can see the the occasional string of 1's go across the screen but nothing else it appears to be too fast for the scope.

Any ideas for troubleshooting I'm kind of blind without the scope.

If you would like to look at the code

I have a vague understanding of SPI, like sw and Hw, and the modes but I am having a heck of a time trying to figure out which section to kick I can't tell if the thermocouple code is the cause or if the sd card code is the cause. Any help would be greatly appreciated. Thank you for your time and help.

MAX31855(1).pdf (562 KB)

datasheet_ultratronics10_05.pdf (221 KB)

graphicallcd_10.pdf (271 KB)

I can't find your code on that link. If it is too big to post, then attach it to your next post.

I don't understand what you mean by "inserting the SD card". Are you starting the Due with the SD card inserted? Or are you removing it and inserting it while running?

Always disable all SPI devices before starting any of them. With the Due, that can be tricky. Do not set D4 or D10 as OUTPUT. Use digitalWrite to set them as HIGH only. That uses the weak pullup resistors to disable the w5100 and the SD card.

I've never used an SD card in a project but I gather some of them don't release the bus even when they are not selected. Dunno if that's the case or not but if so them it wouldn't help.

Why not slow it all down so you can use your scope?

MDM3D:
Long story short I am running an due based board for a 3d printer(Ultratronics PRO). I am running repetier firmware dev version. I have 6 devices on the spi bus. 4 max31855 thermocouples, 1 SD card, 1 ST7920 Full graphic Smart controller, and an Ethernet IC. Ehternet is not used in firmware but could be a potential source of this problem even though the cs pin is always high

The problem the spi buss works okay when the sd card is removed except for 2 horizontal lines across the display. So lcd and the 4 thermocouples read correctly. But! when the sd card is inserted the thermocouples read all ones. Changing the spi settings like speed, mode, and polarity do not affect this error state of the thermocouples. However I can read and write files to the sd card without any issues. and the lcd display still responds to button presses and acts like it should except for the 2 lines. If the sd card is removed the thermocuples start reading correctly.

I have tried to read the sck and MISO pins on my Oscope but it is only good to 20 MHz and the due is at 84 MHz. I can see the the occasional string of 1's go across the screen but nothing else it appears to be too fast for the scope.

https://www.youtube.com/watch?v=tIwnwA3W8n4

Any ideas for troubleshooting I'm kind of blind without the scope.

If you would like to look at the code

Dropbox - Repetier-Firmware - Simplify your life

I have a vague understanding of SPI, like sw and Hw, and the modes but I am having a heck of a time trying to figure out which section to kick I can't tell if the thermocouple code is the cause or if the sd card code is the cause. Any help would be greatly appreciated. Thank you for your time and help.

I watched you YouTube video, your SCK signal is very bad, bouncy, is that an artifact? or is it the actual signal.

What does your circuit look like?

To me, you have way too much inductance on that line.

How long is your SCK signal path?

How fast are you setting your SPI clock speed?

If your 'scope output can be believed, I have no idea how any of your SPI device are actually functioning.

The SPI clock signal (SCK) should be a clear square wave. With all of that ringing, each of the ring oscillation could be interpreted as a clock pulse by the devices (SDcard, MAX31855's). You need to clean up that clock before you go any further.

Here is a good discussion on SPI bus termination.

What is the topology of the of your SPI network?

Hopefully it is a bus, not a Star.

Are you using long cables to your MAX31855 sensors? High Speed SPI is limited to inches (<10).

I am just guessing, but I believe from your 'scope video, you have the MAX31855 wired with LONG cables(20+ inches total length).

Chuck.

The Ethernet IC, MAX31855's and SD card are all on the ultratronics Board via surface mount the lcd is connected by some fairly long ribon cables(about 18 inches)
I think the scope is so noisy because of the long extension cord I had the Oscope on and the smps I was using to power the steppers.
I'll dig up the ground leads for the probes and run the board off of usb and see if I can get a cleaner signal.
The dropbox link has all of the source code and board schematics. You will need designspark to open of the ultratronics source files(sch and Brd) it's free. And the whole folder is about 40Mb so too big to attach.

SurferTim:
I can't find your code on that link. If it is too big to post, then attach it to your next post.

I don't understand what you mean by "inserting the SD card". Are you starting the Due with the SD card inserted? Or are you removing it and inserting it while running?

Always disable all SPI devices before starting any of them. With the Due, that can be tricky. Do not set D4 or D10 as OUTPUT. Use digitalWrite to set them as HIGH only. That uses the weak pullup resistors to disable the w5100 and the SD card.

Both scenarios produce the same error. pin in use are

D74 for MISO
D75 for MOSI
D76 for SCK
D59 for CS SD
D61 for Ethernet(not used in firmware yet)
D62 for CS LCD
D65 for CS TC0(thermocouple 0)
D52 for CS TC1
D51 for CS TC2
D50 for CS TC3

I don't have much control over the pins because it is all smd traces on the pcb

What does this mean?

I don't have much control over the pins because it is all smd traces on the pcb

Are you using a custom designed board?

So those are the analog pins you are using for the SD and w5100? If so, that will be interesting when you get to the ethernet library.

Are you setting the SD CS pin HIGH? You may need to set it as an OUTPUT also. How are you planning on determining if you need to run SD.begin(59)?

SurferTim:
What does this mean?Are you using a custom designed board?

So those are the analog pins you are using for the SD and w5100? If so, that will be interesting when you get to the ethernet library.

Are you setting the SD CS pin HIGH? You may need to set it as an OUTPUT also. How are you planning on determining if you need to run SD.begin(59)?

Yes it is called the Ultratronics Pro source files are in the dropbox link.

Yes analog pins but as far as I can tell the HAL layer and fastio.h allow them to be used as digital pins.

Yes I can see the CS SD pin toggle states.

I just went through the math for the hw spi rate fastest sck signal should be just under 21 Mhz I powered the board from usb and got much cleaner traces on the scope waiting for the video to upload to youtube then will post a new link.

SurferTim:
I can't find your code on that link. If it is too big to post, then attach it to your next post.

I don't understand what you mean by "inserting the SD card". Are you starting the Due with the SD card inserted? Or are you removing it and inserting it while running?

Always disable all SPI devices before starting any of them. With the Due, that can be tricky. Do not set D4 or D10 as OUTPUT. Use digitalWrite to set them as HIGH only. That uses the weak pullup resistors to disable the w5100 and the SD card.

Unfortunately I cannot use the standard cs pins on the due because of the circuit layout.

Dumb ? what is the w5100? an ic? part of the processor?

The w5100 is an Ethernet controller chip.