Page 1 of 1

Help deciphering the tsdz2 torque sensor circuit

Posted: Dec 31 2022 1:33pm
by beemac
I posted this here rather than in the general tsdz2 threads as they are behemoths - and the question is about general electronics than the tsdz2 really...

I'm trying to work out the circuit that is used to read the torque sensor - so I can replicate it and interface to an nrf52840 (or any other microcontroller).

I've traced a pcb I depotted - and I believe the circuit is as the image shows. But I'm not really sure what the components KF or G1 are - I *think* the component marked KF is a diode - something like this https://www.s-manuals.com/pdf/datasheet ... r6_nxp.pdf and the G1 is a transistor - something like this https://assets.nexperia.com/documents/d ... BT5551.pdf but they are just ill-informed guesses based on googling and my basic electronic knowledge.

Image shows the red connection to the torque sensor - from what I can tell black is just connected to ground.

Unfortunately the pcb i'm tracing has a broken power stage - so I can't power it up to see where any voltages are input to the circuit. My guess is there's at least a 5v connection missing somewhere.

The circuit connects back to an ADC pin on the STM8 controller - and that maps to PD3 which is the right pin - so it's def the torque sensor circuit.

Can anyone shed any light on what the circuit is doing and clarify any of the components by any chance? :thumb:

I've added a pic of the pcb - ignore the blue/green rings. KF/G1 packages are SOT23 I believe. Or are they - i've just noticed KF is fatter - but I can't find my calipers to confirm the sizes.

Q4 = KF
Q3/Q2 = G1

Re: Help deciphering the tsdz2 torque sensor circuit

Posted: Jan 01 2023 1:09am
by amberwolf
beemac wrote:
Dec 31 2022 1:33pm

I've traced a pcb I depotted - and I believe the circuit is as the image shows. But I'm not really sure what the components KF or G1 are - I *think* the component marked KF is a diode - something like this https://www.s-manuals.com/pdf/datasheet ... r6_nxp.pdf and the G1 is a transistor - something like this https://assets.nexperia.com/documents/d ... BT5551.pdf but they are just ill-informed guesses based on googling and my basic electronic knowledge.
They would probably both have to be transistors (or other control / amplifier / buffer devices) of some type to do what the traced circuit shows.

The basic thing the circuit must do is re-scale the torque sensor voltage up (or down) to the range the ADC input can take, full scale, to give the best resolution possible of the signal.

How exactly it does that I haven't enough info to determine, but my best guess at first glance is the input device KF is used to match impedance from the torque sensor (which IIRC is a large coil?) to the op-amp input so the op-amp can then buffer the signal and amplify it. The first G1 is then used to control the feedback on the op-amp, and the next G1 is used to buffer the op-amp signal to the ADC pin. The RC circuit is probably used to dampen the oscillations in the sensor output to make it easier for the ADC to read the signal, or it's filtering out a specific range of frequencies the torque sensor generates that aren't useful for sensing pedalling torque.

I don't know how the torque sensor works, but if it is a large coil, it is likely using a signal generated by the MCU to create a field in it that interferes with something else in the sensor (magnets, other coils, etc), and so the signal in this circuit is then not a DC voltage, but a switching signal that either changes frequency or amplitude (of voltage, or more likely current with a coil) or both in response.

I'd guess the OSFW TSDZ2 project(s) either here on ES in various threads, or on Github/etc have details on how the sensor works so that the programmers could create code to operate it and read it, so that should also help you with this circuit.

Re: Help deciphering the tsdz2 torque sensor circuit

Posted: Jan 01 2023 2:36am
by endlessolli
I have no info on the circuit on the Controller-side, but the basic functional principle of this torque sensor is that the torque is measured via a CURRENT variation, originating from a Hall-sensor. That is why you only need 2 wires to connect the sensor.
So your circuit must generate a ~kHz Signal and measure the current of that signal.
Some more details are here (unfortunately only in german):
https://www.pedelecforum.de/forum/index ... dz2.45029/
Hope this helps to understand the circuit on the Controller-side

Re: Help deciphering the tsdz2 torque sensor circuit

Posted: Jan 02 2023 9:39am
by beemac
amberwolf wrote:
Jan 01 2023 1:09am

How exactly it does that I haven't enough info to determine, but my best guess at first glance is the input device KF is used to match impedance from the torque sensor (which IIRC is a large coil?) to the op-amp input so the op-amp can then buffer the signal and amplify it. The first G1 is then used to control the feedback on the op-amp, and the next G1 is used to buffer the op-amp signal to the ADC pin. The RC circuit is probably used to dampen the oscillations in the sensor output to make it easier for the ADC to read the signal, or it's filtering out a specific range of frequencies the torque sensor generates that aren't useful for sensing pedalling torque.

I don't know how the torque sensor works, but if it is a large coil, it is likely using a signal generated by the MCU to create a field in it that interferes with something else in the sensor (magnets, other coils, etc), and so the signal in this circuit is then not a DC voltage, but a switching signal that either changes frequency or amplitude (of voltage, or more likely current with a coil) or both in response.

I'd guess the OSFW TSDZ2 project(s) either here on ES in various threads, or on Github/etc have details on how the sensor works so that the programmers could create code to operate it and read it, so that should also help you with this circuit.
Sorry for the delay in replying - bad hangover from nye - couldn't look at a screen yesterday :mrgreen:

Thanks very much, yes I believe the sensor is a coil, code-wise it's just reading an adc value, there's nothing the code does to send any activation/excitation pulse. Casainho took oscilloscope traces of the signal here https://opensourceebikefirmware.bitbuck ... oller.html

"The torque sensor signal is measured on ADC channel 3. There is a specific circuit to excite the primary coil of the torque sensor and it needs a pulse signal that is generated on PD3 and has a period of 20us and a 2us Ton:"

I'll do some more tracing and see if I can find any missing parts of the circuit to map out - I'm sure there must be a connection to power somewhere - but so far I can't find it...
endlessolli wrote:
Jan 01 2023 2:36am
I have no info on the circuit on the Controller-side, but the basic functional principle of this torque sensor is that the torque is measured via a CURRENT variation, originating from a Hall-sensor. That is why you only need 2 wires to connect the sensor.
So your circuit must generate a ~kHz Signal and measure the current of that signal.
Some more details are here (unfortunately only in german):
https://www.pedelecforum.de/forum/index ... dz2.45029/
Hope this helps to understand the circuit on the Controller-side
Great thanks very much - yes I've read somewhere else that it's a current measurement but I can't find that reference right now - I'll have a read of that link with a bit of help from google translate.

Re: Help deciphering the tsdz2 torque sensor circuit

Posted: Jan 02 2023 9:53am
by beemac
beemac wrote:
Jan 02 2023 9:39am
there's nothing the code does to send any activation/excitation pulse.
Oh maybe there is - i forgot to check the code that initialises the ADC pin - will look into how the adc pins work on the stm8
Screenshot 2023-01-02 144903.png
Screenshot 2023-01-02 144903.png (20.82 KiB) Viewed 889 times

Re: Help deciphering the tsdz2 torque sensor circuit

Posted: Jan 02 2023 10:51am
by beemac
beemac wrote:
Jan 02 2023 9:53am
there's nothing the code does to send any activation/excitation pulse.
Oh yes there is...

Re: Help deciphering the tsdz2 torque sensor circuit

Posted: Jan 02 2023 11:00am
by beemac
And Timer2 is on the same pin as PD3. Ok great think I'm getting there... I'll do some tests using the existing circuit hooked up to a nrf52 - then if that works I'll need to confirm the unknown components and build a replica circuit.

Re: Help deciphering the tsdz2 torque sensor circuit

Posted: Jan 02 2023 1:39pm
by amberwolf
beemac wrote:
Jan 02 2023 9:39am
Thanks very much, yes I believe the sensor is a coil, code-wise it's just reading an adc value, there's nothing the code does to send any activation/excitation pulse. Casainho took oscilloscope traces of the signal here https://opensourceebikefirmware.bitbuck ... oller.html

"The torque sensor signal is measured on ADC channel 3. There is a specific circuit to excite the primary coil of the torque sensor and it needs a pulse signal that is generated on PD3 and has a period of 20us and a 2us Ton:"

FWIW, that quoted statement actually says there *is* an activation / excitation pulse, and what that pulse must be. It doesnt' say if code is used to generate the pulse timing/etc, but that would be a simple way to do it that would save some power vs having a completely independent circuit that simply always generates it, if there are any times or modes where the signal would not be generated but the system would still be on. If the signal is required the entire time, and the signal never needs to vary, then a dedicated hardware circuit to generate it always is simpler.
I'll do some more tracing and see if I can find any missing parts of the circuit to map out - I'm sure there must be a connection to power somewhere - but so far I can't find it...
I would expect the complete circuit diagram would already exist in the OSFW stuff, because to write software from scratch for something you need to know how the hardware works and is wired. ;)

Re: Help deciphering the tsdz2 torque sensor circuit

Posted: Jan 02 2023 1:54pm
by beemac
amberwolf wrote:
Jan 02 2023 1:39pm
I would expect the complete circuit diagram would already exist in the OSFW stuff, because to write software from scratch for something you need to know how the hardware works and is wired. ;)
Cheers - I think/hope I've got the handle on how it works now - the pin is both a timer and ADC - the timer is setup to send the required pulse, then the ADC is used to read the value from the circuit which amplifies the current sensed.

It's not documented in the osfw stuff from a circuit pov - i've chatted to casainho on the other thread, he just used an oscilloscope to measure what was happening and read the value from the adc pin it's connected to - so didn't need to understand the circuit completely, where as I do since I want to replicate it on a new hardware board hence the quest for new information :)