Internal sense resitor TMC2226

I built a print with hardware exactly as shown in figure 3.2 (page 12) of the datasheet TMC2226 with MS1=MS2=LOW , ENN=STEP=DIR= HIGH and SPREAD and
STDBY are left open. Vref to 5VOUT: 6K8 ohm. VS not connected yet to avoid overcurrent.

On the UART pin I sent according to instructions on pages 20 ,15 and 53 of the datasheet TMC2226:
||UCHAR instructions[8];|
||instructions[0] = B10100000; //synchronisation|
||instructions[1] = B00000000; //slave adres
||instructions[2] = B00000001; //register adres 00(GCONF)
||instructions[3] = 0;|
||instructions[4] = 0;|
||instructions[5] = 0;|
||instructions[6] = B01000000; //lowest databyte; intern resistor|
||swuart_calcCRC (instructions,(byte)8); //(checksum calculation function copied from datasheet) generates instructions[7]

It was sent to the TMC pin UARTwith|
for (i=0; i<8; i++) {
instructionline = instructions[i];
digitalWrite (UART_TCM2226, 0); //start byte
delayMicroseconds (5);
for (j=0; j<8; j++) {
digitalWrite (UART_TCM2226, (instructionline& 0x80)? 1 : 0);
instructionline = instructionline << 1;
delayMicroseconds (5);
}
digitalWrite (UART_TCM2226, 1); //eind byte
delayMicroseconds (5);
}
A logic analyser, showed that the message is sent exactly as intended, but unfortunately a copy of it cannot be copied here.

I expect a drop of the voltage on pin 21 (VREF) to a constant value of about .3V after a succesfull instruction.
This however keeps drifting between about 1 and 3 Volts.
Question now is: What might have gone wrong or do I have a wrong expectation?

)

You have to connect Vs to power for the driver to generate 5v internally for its own control voltage for the FETs. It doesn’t use the same voltage source from VCC_IO.
Be sure to have the ENN pin pulled high when you power it up. This will disable the drivers on board so they won’t go into over current.
According to the datasheet on page 12:
ā€œAttention:
Start with ENN=high!
Set GCONF.1 or OTP0.6
prior to enabling the driver!ā€

This code sets the 7th bit in GCONF high, which isn’t the right bit.
You need to set the 2nd bit (bit 1) in GONCF which is internal_Rsense
Instead, use B00000010

Try those two suggestions and let us know what it does.

Thank you for your fast answer.
It was confusing for me. Page 15 says: The 32 bit data words are transmitted with the highest byte first. But about sequence of the bits in the byte I find an example:
. Example: Address 0x10 is changed
to 0x90 for a write access. and the applicable 1 is on bit23 of the write acces diagram above that.
The word ā€œorā€ in ā€œSet GCONF.1 or OTP0.6ā€ also confused me, but I now understand that OPTO.6 is exactly the bit in the lowest data byte and ƶr"should be read as ā€œandā€.
A firts test of just changing 01000000 to 00000010 appears not enough.
I’m sorry to have an other obligation now and I’ll proceed and let you know the further result tomorrow

Did you connect Vs, as well as all of the other power / ground connections? Its 100% vital that you supply everything with power or else it will not work.

I did put 24V on the VS. The TMC2226 raised in temperature for may be a minute, but cooled down again after that I repeted the pulse train on the UART pin.
After that mesured voltages were: VS 24.8V ; VCCIO 5.18V ; VOUT 5.03V ; VREF 4.92V.
If these are normal values, my problem is solved, but I distrust this. What value should I expect? Page 54 of the spec writes: ā€œVREF input resistance is about 0.45kOhmā€. So I expected about .3V

How are you measuring your voltages?
The voltage from 5VOUT to GND should be about 5v, which it is.
If using a 6.8k resistor, the voltage across that resistor (Positive volt meter probe on 5VOUT, negative probe on VREF) you should get roughly 4.7v, which your measured 4.92 is fairly close.
The internal resistance of VREF should have the 0.3v drop, but that may not be feasible to simple measure with your multimeter. You could try measuring from VREF to GND and see what the voltage is, but it may not work that way.
If you don’t mind, could you post all of your code? Sometimes there are more registers to configure before the TMC drivers will work. I’m using some TMC2660’s and they are very picky about configurations.
Also, double check your connections:
Page 55 says: ā€œBe sure to directly attach BRA and BRB pins to GND in this mode near the IC package.ā€

All measures are done with with a simple not calibrated multimeter, the negative probe on ground. Internal resistance of this instrument is not specified, but I expect several 100kOhm.
Length of trace from BRA and BRB to the PTHhole connecting the groundplate on the downside of doublesided print is about 1.5 mm.
The code I used is applicated on an arduinouno processor; I did not translate all of my comments (in Dutch) I’m sorry that it might be a little boring.

#define MS1 A3 //PC3 pin 26
#define MS2 A4 //PC4 pin 27
#define UART_TCM2226 A5 //PC5 pin 28
#define ENABLe 8 //PB0 pin14
#define STAP 9 //PB1 pin15
#define ROOD 6 //PD6 pin12
#define GROEN 5 //PD5 pin11
#define RICHTING 10 //PB2 pin16
#define UCHAR byte
#define AAN digitalWrite(ENABLe,LOW);
#define UIT digitalWrite(ENABLe,HIGH);
#define PRINT(b) {Serial.print(b); Serial.flush();}
#define ROODAAN digitalWrite(ROOD,HIGH);
#define ROODUIT digitalWrite(ROOD,LOW);

/************************************************************************************/
void setup() {
Serial.begin(9600);
pinMode(MS1, OUTPUT);
pinMode(MS2, OUTPUT);
pinMode(UART_TCM2226, OUTPUT);
pinMode(ENABLe, OUTPUT);
pinMode(STAP, OUTPUT);
pinMode(RICHTING, OUTPUT);
pinMode(ROOD, OUTPUT);
digitalWrite (MS1, 0);
digitalWrite (MS2, 0);
digitalWrite (ENABLe, 1);
digitalWrite (STAP, 1);
digitalWrite (RICHTING, 1);
digitalWrite (UART_TCM2226, 1);
instrueren();
ROODAAN
}

/************************************************************************************/
void instrueren(){ /DATASHEET pag 20 en 15 en 53/
UCHAR instructies[8];
instructies[0] = B10100000; //synchronisatie
instructies[1] = B00000000; //slave adres (MS1=0; MS2 =0 )
instructies[2] = B00000001; //register adres 0x00(GCONF); interne weerstanden;send
instructies[3] = 0;
instructies[4] = 0;
instructies[5] = 0;
instructies[6] = B00000010; //lowest databytes; interne weerstanden
swuart_calcCRC (instructies,(byte)8); //checksum berekenen

int i, j;
byte instructieregel;

for (i=0; i<8; i++) {  //ter controle
	PRINT(i);
	PRINT(" ");
	instructieregel = instructies[i];
	PRINT(" 0 ");
	for (j=0; j<8; j++) {
		Serial.print  ((instructieregel & 0x80)?  "1" : "0");
		Serial.flush();
		instructieregel = instructieregel << 1;
	}
	PRINT(" 1\n");
}

for (i=0; i<8; i++) {  //instructie doorgeven
	instructieregel = instructies[i];
	digitalWrite (UART_TCM2226, 0); //start van een byte
	delayMicroseconds (5);
	for (j=0; j<8; j++) { 
		digitalWrite (UART_TCM2226, (instructieregel & 0x80)?  1 : 0);
		instructieregel = instructieregel << 1;
		delayMicroseconds (5);
	}
	digitalWrite (UART_TCM2226, 1); //einde van een byte
	delayMicroseconds (5);
}	

}

/***********************************************************************************/
/

De volgende functie is lettelijk overgenomen uit pagina 17 van TMC2226 DATASHEET(Rev. 1.06/ 2020-MAY-18)
/
void swuart_calcCRC (UCHAR
datagram, UCHAR datagramLength){
int i, j;
UCHAR * crc = datagram + (datagramLength-1); //
UCHAR currentByte;

*crc = 0;
for (i=0; i<(datagramLength-1); i++) {
	currentByte = datagram[i];
	for (j=0; j<8; j++){
		if ((*crc >> 7) ^ (currentByte&0x01))
			*crc = (*crc <<1) ^ 0x07;
		else
			*crc = (*crc << 1) ;
		currentByte = currentByte >> 1;
	}
}

}

/************************************************************************************/
void loop() {
char txt;
if (Serial.available()) { //willekeurige input als de seriele monitor is aangesloten
txt = Serial.read();
while (Serial.available());
if (txt == ā€˜x’){
PRINT(ā€œend\nā€);
ROODUIT
exit(1);
}
}
}

Have you tried to run a motor yet with the TMC2226? I would be interested to know what is or isn’t working at this point.

I only have done the first file that is a sort of start up.
My second next step testfile is to check the speeds and accelerations that relaeble can be received and the third file is a really large one for the intended application. That second and third one did function already with a TMC2226, but that one was mounted on a chinese carrier with extern sense resistors and my goal now was to minimise the board size. May be I should redesign it with extern sense resistors.
I did not try the second file yet becouse I wanted te debug step after step and I stay affraid that I blow up things when I have a VREF of several volts without extern sense resistors. Size of my second file is more then 3 times the size of the first one en commented in Dutch.
The situation now is that either I misunderstand the wished VREF value (not likely as I understand from your comment) or The pulsetrain is wrong (not likely becouse I followed your correction) or a miswiring on the board (not likely becouse it was at least triple cheked and disigned witk help of kicad) or the 2226 is blown up (not likely, but it might have happend after connecting the 24Volts when the temperature rose for a very short time but why?)
What I am going to do is preparing a second identical printboard and I ask you: Are you very sure that the composition of the pulsetrain is right?
If you are interested in my second phase testfile (ino extension for an arduino prosessor and comments in dutch), let me know

I’ll go through the datasheet later when I have a chance and see if I can figure out exactly what needs to be sent to the TMC2226 to initialize it. I’m pretty sure that the code is correct, but I do not know if the TMC2226 needs any more information before it will start to work.

I reconsidered things. The attention mark on page 12 was not yet applicable becouse the point to enable ENN=low was not yet reached. Besides that, the register should be set in a WRITE registeraddres depending MS1 and MS2 (0,1,2 or 3) and can be READ in register addres number 0x05. (OTP 0.6 on page 24). Again a confusing indistinct. The fact that imidiately after setting voltage on VS the reading of an infrared thermometer showed 60 degrees celcius (within few minutes back to normal) makes the reflow soldering prosess suspect. Microscopic inspection however showed as far as visable from any side no short of the heat sink solder to any of the other pads. By the way, outputs were not yet connected to a motor, only 30V varistors.
If the second print that I’m going to prepare shows the same mistery, I will make a new design with extern resistors, hoping for a working default solution.
Thank you for your help so far, I will let you know about the result on the second board to morrow.

That has been the biggest problem for me with the TMC429 and TMC2660 that I’m using. The datasheets are pretty bad.

Yes. You should set ENN=HIGH before applying voltage to the driver. Upon startup, while ENN=HIGH, the power stage with the transistors should be disabled, and the driver should not get hot. If it got hot before you set ENN=LOW, then something else is wrong.

Always use a motor. Stepper motors are inductors and the TMC2226 senses the current/voltage flows through the coils to adjust driving power. Varistors are not the same and could potentially be causing trouble. The current/voltage flows through them differently. They may be ok, but I would not use them, I would use a motor.

In my interpretation, as long as ENN==high, no current at all should flow. The varistors are for protection; if a motor is manually rotated a current will flow (page 14 figure 3.4)
If I put 6V on VS on the first print this results in: 5OUT=4.95V; VREF=4.84V. In my second (identical) print 5OUT=5.00V; VREF=4.98V. So the voltage drops over the 6K8 resistor are identical. So far without motor. With motor te figures read are 4.94 and 4.83 (first print) and again 5.00 and 4.98 Not really a convinsing difference. Changing VS to 7.5V neither makes any difference.
Obviously the used pulsetrain does not work. I admire your patience in answering my problem.
If a would make a new design, what value of extern resistors would you advice?
There is a theoretical possibility that the 0.11V voltage drop over 6K8 0hm (corresponing with 0.016mA) is exactly what it should be. This however is very odd. End page 53 mentions a factor 3000, corresponding to 0.048A. However this shoud be 1.35A rms according to the table
When (for a test I enlargebthe 6K8 wit an extra 10K in series to 16K8 this doen not change te measured voltages, not even .01 Volt. With the multimeter probes direct on the resistor it is even worse, rater than 0.11V I now get 0.07 Volt

If you want to use the same schematic that uses only the reference resistor, you should follow the chart on page 55 in the datasheet to select the current levels for the motor you will use.

I interpret the circuit this way:
Rref = 6.8kohm, Vref internal resistance is 0.45kohm. That give a total resistance of 7.25kohm, which at 5 volts would be 0.69mA. That give a voltage drop of 4.69 volts across the 6.8kohm resistor and 0.31 volts internally for Vref.
The 0.69mA current multiplied by the 3000 factor gives 2.07 Amps, and the datasheet says the peak rating is 1.92 Amps with 6.8kohms, which is close enough considering tolerances.

Have you used varistors in this way before? The TMC2226 has short-circuit protection on the power driver stages, and if it detects a short circuit, it will automatically cut off. Depending on you varistors, they may appear as shorts to the chip under the right conditions. I would recommend not using them and hook a motor directly up to the chip. There shouldn’t be any need for external circuit protection on the motor contacts. That is all built into the chip already.

Do you have a schematic that you are using, not the one in the datasheet?

This is exactly what I expected, after downloding the train of bits: A volage between ground and Vref of circa 0.3V. Becouse that did not happen I started the problem questions.

No, but as log as voltage stays <30V they behave as (almost) infinit ohm. Though not nesessary in this stage, it’s easier to mount them in the reflow phase then later on. In the final application there is a possibility that the mechanical load is moved rather fast by hand. I used only 2 varistors, paralleel to the motorcoils.

Yes, of course, it is printed on a A3 size paper sheet and almost identical to a one that I used years ago with a A3982, wich worked perfectly. I don’t see a way to incprporate a copy in this mail.

In the mean time I incorporate miy first tage testfile in the second one and took the risk to put 24 V on the VS pin. On both Identical prints i tried a pulse train of 100 steps. It resulted only every now and then in a little vibration and every now and then in maybe 10 steps in one direction

Can you take a photo of it and upload it?

Is there any reason to stick with only the single resistor and use the setup you have chosen instead of using the external sense resistors? You said you wanted to make the board small, but using the two external sense resistors doesn’t take up much space at all.
I’ve had no experience with the setup you are using, I’ve only used the normal sense resistors. Unless I could see all of your schematics/code/ect… it is a bit difficult to really track down the exact problem. It does sound like it could be many different things at this point, unfortunately.


Hardly a special reason. I chose one of the options that at first sight seamed easiest. I know better now. Redesigning is not even that difficult, but I then have to let manufacture a new print, new components etc. If the solution is found, that would be a great gain in efford from the point where I am now. Besides that, will A redesign show no problems?

I hope picture is readebal, I cant check that

The picture is hard to read, but I was able to figure out most of the connections.

Between your 5VOUT and VREF pins, you have the 6.8kohm resistor with what looks like a variable resistor. What do you have that set at?

Everything looks good for your schematic. Unless you have a defective chip, I believe it is an issue with your code.

Keep in mind when testing the motor, assuming you are using a standard 200 steps/revolution motor, that with an 8 microstep divider (from MS1 and MS2 set to LOW), you will need 1600 step pulses to complete one full revolution. I would put the test code to do an infinite loop of only step pulses.

Your UART baud is 9600. The datasheet says that 9000 is the minimum if running at 20Mhz. I would recommend making the baud higher. The TMC2226 should be able to support up to 1Mhz.

Lastly, In your code you posted above, you have ā€œdigitalWrite (ENABLe, 1);ā€ in your setup. This is good, but after sending the UART code to the TMC2226, I don’t see any code that sets ENABLe to LOW. The ENN pin has to be set to LOW after the UART code to enable it. I’m sure you have plenty of other code, I just happened to notice that in the code you posted.

For now the variable resistor is set at zero ohms. The intention of is was to find out in the final application if I really need the highest possible corrent

Might be as its temperatue rose to about 60 degrees C for a short time but I see no mechanism at all about what te course might be of that.

Serial.begin(9600) is not the UART boutrate, but the rate my processor communicates wiih my display.
The Bout rate to the UART is 5usec for each bit (plus a few usec for overhead), making about 100kHz

In the codes I sent was no pulse on pin 20 (STEP) either. In a much larger file I had not forgotten to do so. The testtrain of pulses for movement of 200 steps is;


I tried 2000 steps to ten or twenty times.All exept one resulting in nothing more than a little vibration, but one time, may be the eihts test, the motor did its work and rotated about a full revolution.
I feel a little flabbergasted, there a no loose contacts as far as i can test. It must be a programming error somewhere.
On page 13 point 3.4 of the datasheet is written that there are 4 configuration pins, it describes only tree ones. One of them states: When using the UART interface, the configuration pin should be disabled via GCONF.pdn_disable = 1. Nowhere in the whole datsheet however the word GCONF.pdn can be found.

Page 22. GCONF.pdn_disable is bit #6

The TMC2226 is designed to be able to run standalone without UART interface. The UART setup is optional for more advanced settings, including the single external resistor for VREF. If it were my design, I would forget about the design you are using and use the two external reference resistors instead. Not only will the driver be able to run without any initialization, but it also (according to the datasheet) runs better with the two external resistors. The only advantage of your current design would be a slightly smaller circuit board, but even with the two external reference resistors, the board will still be a small size.

That is simply my opinion. It seems like the difficulty is not worth the end result which will honestly be a worse performing driver only to save a few millimeters of space.