tommag / Estee_TMC5130

Trinamic TMC5130 Arduino Library
MIT License
3 stars 2 forks source link

understanding bus switch strategy with NAI left open. #3

Closed imBunyip closed 1 year ago

imBunyip commented 1 year ago

hey i recently built a remix of your faradet system for nema 11 size steppers, thanks for sharing the schematic it helped loads.

after spending days on the arduino mega avr and nothing working i moved to teensy and i got the library working reading the correct address.

so far i can only get the first chained driver working,and im a little confused by some of the comments inside the uart_chained_drivers.ino.

line 20 you say "This code uses the bus switch strategy with NAI left open."

line 92 you say " Use Serial1 (hardware UART on Feather M0) ; address 1 (NAI input has a pull up resistor)"

does only the first driver in this solution need nai pulled up? and therefore the analog switch and eeprom do the rest of the address switching?

if nai is not pulled up my analog switch does not switch. im guessing this isnt the same for the next drivers in the chain?

setup, tmc5160 from mellow fly with encoder pins and diag0 and diag1 available for use. teensy 3.6 > rs458 module. 9 volt power from PD for motors, 3.3v supply to encoders and swicth and eeprom and driver itself. im using this code but have adapted it for use with your tmc5160 library.

tommag commented 1 year ago

Well... You mention TMC5160 but are posting this in the TMC5130 Lib... Hard to give you any advice without a clear schematic of what you're doing :) TMC5130 has an internal pull up resistor (datasheet p. 10). TMC5160 hasn't.

If you use a bus switch, having a pull up resistor or not on the NAI input doesn't matter actually. This is the adressing sequence :

  1. communicate with the first motor driver in the chain (address 0 or 1 depending on the state of NAI - on TMC5130 there is a pull up resistor so I left the pin open and communicated on address 1).
  2. change the address by software (setSlaveAddress) to 254 for example
  3. Set the NAO output to 0 (writeRegister(TMC5130_Reg::IO_INPUT_OUTPUT, 0)) -> this enables the bus switch and connect the next motor driver in the chain, which will answer on address 0 or 1 depending on the state of its own NAI pin.
  4. Repeat with the following driver.

Hope this helps. As stated in the code, all of this is explained in the TMC5130 datasheet section 5.4.