Thermocouple via SPI

My smoothie crashes when i plug in usb to PC. Problem occurred when i started communicating with thermocouples via SPI. Could it be that USB and SD card have sommething to do with it ? Does smoothie prevent using SPI for thermocouples while being connected to PC or SD Card ?

Imported from wikidot

That sounds like a short or a wiring problem.
How do you connect the SPI thermocouple board, what type is it, what else do you have connected to the board ?

Cheers.

Apart the thermocouples, SD card and USB i have connected LCD screen and stepper motors. Thermocouple board is self made, based on MAX31855 SPI connection is described in the link below.

20150827_151244.jpg

The reprapdiscount LCD does not implement SPI properly and won’t let you share a SPI port, unfortunately.

I use different LCD screen, it’s ST7565. Here’s the link for LCD Panel : hbot3d[DOT]com/sklep-2/elektronika-en/panel-sb-2-0/?lang=en Do you have any ideas how to overcome this SPI problem ?

Can you try one SPI thermocouple alone, without the panel ?

Without the panel with one thermocouple it works about 50% of the time, with both of them never. Could it be software related problem ?

SPI thermocouple support has been in for a while, and is known to work on many machines. Are you sure there isn’t a wiring or design issue ?

It looks like there is something wrong with CS as proof i send timing diagrams from logic analyzer. First thermocouple CS is connected to pin 1.21 and the second one to the pin 1.24. Reading from one thermocouple is shown on picture below.

1thermocouple.png

While reading from SD card the two CSs are active:

2thermocouple_SD_ERR2.png

Most likely it is the reason the smoothie crashes. The timing diagrams of SPI after crash looks like this:

2thermocouple_ERR.png

What’s your thoughts on this ?

Possibly a bug. Would you mind making an issue on the Smoothieware github ?

1.24 is led4 so you have one pin being used for two different things.

In my case Leds are not used. I created an issue on the Smoothieware github.

You cannot use the SDCARD SPI port for this, you need to use the SPI port you are also using for the LCD.

Using LCD SPI for thermocouples makes LCD unresponsive about 20% of the time.

It will work fine if you wire it correctly, the circuit you show above is totally unnecessary and you can wire it direct without any of those components.
You should not use the LED pins either even with leds disabled, so use a different pin for the CS.

There will be collisions as the thermocouples are being polled every 20ms, and the LCD is being updated 20 times a second so yea there maybe some pauses. you may want to slow down the LCD refresh rate and maybe even the thermocouple poll rate.

FWIW having two thermocouples was never tested or intended to work, so if it works at all it is pretty good.

I now have two boards I can test with so I’ll see if I can get it to work.

Ok so looking at the code more closely I see the thermocouple is being read during an interrupt cycle. this would be fine if it was the only thing using the SPI channel. However as you are sharing with the LCD ti will cause severe problems. This would also be tru of the SPI channel for SDCARD.

Basically the way it is currently written the thermocouple cannot share any SPI channel, so for now you have to choose between thermocouples or LCD.

I will look into fixing this as reading SPI in an interrupt is not a good model anyway. The person who wrote that probably did not understand this.

I do not know when I can fix this, but I’ll let you know. I am reopening the Issue, as even though you still cannot share with the SDCARD the way you are doing it, the reading SPI during SPI is bad.

Once I fix this you should be able to share the sdcard SPI if you wanted to as long as you do not use a led pin for the CS. However that would still not be recommended.

Thank you for your time and help. As a temporary solution i will try to redefine SPI communication for different pins.