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 ?
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 ?
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.
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 ?
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.
While reading from SD card the two CSs are active:
Most likely it is the reason the smoothie crashes. The timing diagrams of SPI after crash looks like this:
What's your thoughts on this ?
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.