Basic Information:
Printer Model: hackjob garbage DIY
MCU / Printerboard: 2X SKR Pico + 1X Arduino Nano
Host / SBC: RPI4B
klippy.log: N/A? (general question)
Describe your issue:
I want to make a toolhead board with Arduino Nano and I want it to have 4X MAX6675 thermocouple ICs on it. I have gotten this to work by defining software SPI pins multiple times and while that doesn’t throw any errors, it doesn’t feel right, and the readings are jumping around like there is some cross-talk between the sensors or something. If that’s not clear, this is what I mean:
[mcu] # Main MCU, SKR Pico
serial: /dev/serial/by-id/usb-Klipper_rp2040_45503571278E2E78-if00
[mcu pico_A] # 2nd MCU, SKR Pico
serial: /dev/serial/by-id/usb-Klipper_rp2040_45503571279302A8-if00
[mcu nano] # 3rd MCU (toolhead), Arduino Nano
serial: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
[temperature_sensor TypeK_1]
sensor_type:MAX6675
sensor_pin: nano:PD7 # arduino Nano Pin D7. On MAX6675 board, purple wire to Pin CS
spi_speed: 100000
spi_software_sclk_pin:nano:PB5 # arduino Nano Pin D13. On MAX6675 board, gray wire to Pin SCK
spi_software_mosi_pin:nano:PB3 # arduino Nano Pin D11. On MAX6675 board, no connection
spi_software_miso_pin:nano:PB4 # arduino Nano Pin D12. On MAX6675 board, blue wire to Pin SO
[temperature_sensor TypeK_2]
sensor_type:MAX6675
sensor_pin: nano:PB0 # arduino Nano Pin D8. On MAX6675 board, purple wire to Pin CS
spi_speed: 100000
spi_software_sclk_pin:nano:PB5 # arduino Nano Pin D13. On MAX6675 board, gray wire to Pin SCK
spi_software_mosi_pin:nano:PB3 # arduino Nano Pin D11. On MAX6675 board, no connection
spi_software_miso_pin:nano:PB4 # arduino Nano Pin D12. On MAX6675 board, blue wire to Pin SO
[temperature_sensor TypeK_3]
sensor_type:MAX6675
sensor_pin: nano:PB1 # arduino Nano Pin D9. On MAX6675 board, purple wire to Pin CS
spi_speed: 100000
spi_software_sclk_pin:nano:PB5 # arduino Nano Pin D13. On MAX6675 board, gray wire to Pin SCK
spi_software_mosi_pin:nano:PB3 # arduino Nano Pin D11. On MAX6675 board, no connection
spi_software_miso_pin:nano:PB4 # arduino Nano Pin D12. On MAX6675 board, blue wire to Pin SO
[temperature_sensor TypeK_4]
sensor_type:MAX6675
sensor_pin: nano:PB2 # arduino Nano Pin D10. On MAX6675 board, purple wire to Pin CS
spi_speed: 100000
spi_software_sclk_pin:nano:PB5 # arduino Nano Pin D13. On MAX6675 board, gray wire to Pin SCK
spi_software_mosi_pin:nano:PB3 # arduino Nano Pin D11. On MAX6675 board, no connection
spi_software_miso_pin:nano:PB4 # arduino Nano Pin D12. On MAX6675 board, blue wire to Pin SO
The above works (sorta? I think?), but is wonky; I think sometimes K1 is reported as K2 or K3, K2 is reported as K3 or K4, and so on, or some other random comms timing thing is happening.
I think the right way to do this is to define spi_bus, and cs_pin (or sensor_pin) but I can’t figure out how to specify the spi_bus of a specific board, and exactly that spi_bus is named. From looking at examples all across the internet I have gleaned that the spi_bus name for a pi Pico will be “spi0a” and for arduino nano it will be just “spi” but where is that written? I have not found this info in any docs.
So from what I understand and what I expect, in my current situation using arduino nano I would do it like this:
[temperature_sensor TypeK_1]
sensor_type:MAX6675
spi_bus: nano:spi
sensor_pin: nano:PD7 # arduino Nano Pin D7. On MAX6675 board, purple wire to Pin CS
[temperature_sensor TypeK_2]
sensor_type:MAX6675
spi_bus: nano:spi
sensor_pin: nano:PB0 # arduino Nano Pin D8. On MAX6675 board, purple wire to Pin CS
[temperature_sensor TypeK_3]
sensor_type:MAX6675
spi_bus: nano:spi
sensor_pin: nano:PB1 # arduino Nano Pin D9. On MAX6675 board, purple wire to Pin CS
[temperature_sensor TypeK_4]
sensor_type:MAX6675
spi_bus: nano:spi
sensor_pin: nano:PB2 # arduino Nano Pin D10. On MAX6675 board, purple wire to Pin CS
But when I try that, I get this error:
Unknown spi_bus ‘nano:spi’
I have found examples on the internet where an arduino is used as toolhead board and ADXL345 is connected. In those examples they usually use the software SPI but once or twice I saw where they used spi_bus and cs_pin like this:
# Arduino Uno 328p
[adxl345]
cs_pin: 2nd:pb2
spi_bus: spi
axes_map: x,y,z
So for cs_pin they specified the 2nd MCU (cs_pin: **2nd:**pb2) but for the SPI bus they didn’t (spi_bus: spi)? That doesn’t make a whole lot of sense to me but I tried it anyway:
[temperature_sensor TypeK_1]
sensor_type:MAX6675
spi_bus: spi
sensor_pin: nano:PD7 # arduino Nano Pin D7. On MAX6675 board, purple wire to Pin CS
[temperature_sensor TypeK_2]
sensor_type:MAX6675
spi_bus: spi
sensor_pin: nano:PB0 # arduino Nano Pin D8. On MAX6675 board, purple wire to Pin CS
[temperature_sensor TypeK_3]
sensor_type:MAX6675
spi_bus: spi
sensor_pin: nano:PB1 # arduino Nano Pin D9. On MAX6675 board, purple wire to Pin CS
[temperature_sensor TypeK_4]
sensor_type:MAX6675
spi_bus: spi
sensor_pin: nano:PB2 # arduino Nano Pin D10. On MAX6675 board, purple wire to Pin CS
That didn’t work, I got:
MCU ‘nano’ shutdown: Thermocouple reader fault
So it seems to know I refer to THE nano MCU even though I didn’t specify it? how? Just because I used “spi” instead of “spi0a” or some other board-specific name? What if I had two nanos? How would it know which one I was referring to? And why did I get the error?
I noticed that if comment out 3 of the thermocouple and just do 1, I don’t get the error. But I also don’t get a temperature reading. it just says 0.0C. What am I doing wrong?