AN-057: How to Make a Thermostat With the TMC2300
Introduction
As an example for a great IOT-Application, this appnote uses a DIY smart thermostat. However, batterypowered bipolar stepper motors can be used for a range of other useful gadgets: From automated window blinds - to door locks and kitchen appliances or even your own small robot. The example settings and hints from this application note can easily be used for any of these.
The Power Source
The power source is a central item of portable equipment – it’s not only a relevant part for the electrical capabilities, but also for cost, size and weight. Further, for mass products, sustainability, runtime and service/charging interval, overall lifetime, safety and recycling options are important. After all, several of these aspects determine user experience. Power sources to be considered are rechargeable batteries (Li-Ion/LiPo, NiMH cells) or Alkaline batteries. Also, combinations of rechargeable batteries and harvesting sources like solar energy for equipment used in bright environments, Peltier-elements, or combinations with supercapacitors could be considered.
For more details have a look into this Whitepaper on our web page: "How to Operate a Stepper or DC Motor from a Low Voltage Power Supply" by Bernhard Dwersteg, which sheds some light on the following topics:
- Optimization targets: How to keep power consumption to a minimum.
- Battery characteristics: Efficient use of the battery voltage.
- Improving the power source: Add an ultracapacitor
- Improving the power source: Add a step-up converter
Motor Choice
Applications benefiting the most from stepper motors are positioning applications or those demanding relative motion, applications requiring stable position holding over longer periods, those with brief motion, those requiring movement with precise velocity, or applications requiring high torque at a low speed. Generally, two types of stepper motors are available: inexpensive permanent magnet stepper motors, and more expensive hybrid stepper motors.
As battery-powered applications normally require a compact solution, standard hybrid steppers like the NEMA 17 types are too large. Even if NEMA 17 offers the best value-for-money due to high volume usage, e.g. in 3D printers. Smaller hybrid stepper motors like NEMA 11 and NEMA 8 or even smaller come at an increased price. As such, inexpensive permanent magnet stepper motors are often preferred for mobile solutions and widely available in different sizes with manufacturer-specific mounting schemes. Standard types often come with a motor coil wound for 5V or for 12V. Both voltages are neither intended nor good for battery operation. Instead, they are intended for mains operated constant voltage driving scheme with quite limited motor velocity as there is no headroom for back-EMF, which builds up at increased velocity. A 5V or 12V coil requires a large number of windings of a thin wire in the motor. To adapt a motor to lower voltage operation, fewer windings of a thicker wire are required. This is easy to do and all motor manufacturers offer to adapt the winding. But which winding is optimum for a battery-powered application?
For the thermostat application a stepper motor with 1.5Ω coil current was chosen. On the reason behind this there is a chapter in the whitepaper "How to Operate a Stepper or DC Motor from a Low Voltage Power Supply." A short comparison to a 5.2Ω version is shown in table 1.
Measured Item | Standard Coil | Modified Coil | Unit |
Rcoil | 5.2 | 1.5 | Ω |
Icoil | 400 | 760 | mA |
Pcoil = 2 · R · I2 | 1.66 | 1.62 | w |
Required Supply (motion) | 5.0 | 3.2 | V |
Current Draw | 487 | 850 | mA |
Power | 2.24 | 2.76 | W |
Difference | -- | 8+23 | % |
Despite that the power dissipation of the low voltage motor is slightly higher than that of the standard motor, its benefit is that we can work with a single Li-Ion cell as power source, or, respectively, we save the additional expense for a higher voltage supply or step-up converter.
To support companies during their application development, Trinamic added GOOT motors with modified coils to their portfolio. These permanent magnet stepper motors are optimized for microstepping at low voltage. With fewer windings of a thicker wire, for which the reason is described above, they deliver excellent performance for battery-powered devices.
The Application
Nearly all European households have a heater to keep you warm when the weather is cold. Most of these have a thermostat either directly at the radiator itself, or centralized in the building or flat. The thermostats are used to control the heat of the room in an energy efficient way. However, most of them still require manual control to adapt to changing outside temperatures during the days, nights or seasons. This is why smart thermostats are becoming increasingly popular, to connect them to higher control loops and sensors or to make the manual control easier. For example by extending the control to your smartphone to make it mobile. The smart thermostats can be bought from multiple manufacturers, but for this example we used a 3D printed version with a linear actuator to control the valve.
Setup
The following items were used for the first setup of this application.
- 3D-printed Thermostat with locking ring.
- Linear actuator with Stepper-Motor (1.5Ω coil resistance)
- TMC2300-EVAL-KIT
- TMCL-IDE (3.0.25.16)
- Landungsbrücke Firmware V3.08
- Power Supply (3V3/1A)
- Mini-USB-Cable
- Scope with current clamps
Getting Started
Before any initial connections are made, connect the Landungsbrücke to your PC with the USB-cable and check the board’s firmware. The TMCL-IDE shows you if the latest version is installed. Here the firmware version V3.08 was used, which you can also upload to the board via the TMCL-IDE firmware update tool.
Now connect the TMC2300 Evalboard to the actuator and power supply and follow these steps in the TMCL-IDE.
First select the phase current that your motor is capable of. Here 680mA were chosen for running the motor and 40mA as hold current as shown in figure 3. The current is about proportional to the motor torque and can be evaluated for your application or load scenario. The hold current can be low in this application as a gearing provides enough detent torque. This will also save battery power.
After making the correct current settings, the driver stage can be enabled by clicking on the power-symbol inside the standbytool:
You are now able to run the motor using the velocity mode or position mode tools.
Homing of the valve
As the setup has no means to determine the current state of the valve or the actuator, a homing procedure needs to be implemented. This is where StallGuard4 comes into play.
To understand how StallGuard4 works, it must first be understood how the TMC2300 Evaluation setup is built up. Some functions are implemented inside the Landungsbrücke µC-Board that need to be taken over to your own µC, when moving away from the design with the evaluation boards.
StallGuard4
StallGuard4 is the first sensorless load detection technology that can be used together with the silent StealthChop2 mode. It measures the back-EMF of the motor to determine the actual load situation, which allows your setup to determine the endstops of the valve.
As shown in figure 5, the TMC2300 uses its DIAG pin to show a stalldetection. The Landungsbrücke then interrupts the stepgeneration immediately to stop the motor.
With the TMCL-IDE’s Coolstep&StallGuard-Tool, the stalldetection can be configured. A stall is indicated when the motor is running and the StallGuard value goes below 2x the threshold.
Inside the velocity mode tool, we set the acceleration and velocity of the motor to our desired setpoint. The velocity needs to be high enough to generate a good StallGuard signal from the back-EMF. In our example a velocity of 100kpps was chosen, so the valve can be closed/opened in just a few seconds. When running the motor, we can observe the StallGuard value to figure out the rest of the parameters.
The velocity threshold needs to be set, in order to activate the StallGuard feature. For our first valve was set to 90kpps, as shown in figure 6. A StallGuard threshold of 50 enabled a quick detection of the endstop, without losing any position information. The graph shows several opening/closing procedures of the valve. Where the StallGuard value goes below 2x50, the motor is stopped. Note that due to the sampling frequency of the TMCL-IDE, this is not always possible to determine in the graph.
In figure 7 we see a different type of valve, where the same parameter settings could be used. The linear path of the valve is smaller, which can be observed on the timescale as well as through the position counter. With the StallGuard value it would also be possible to determine the actual stroke length of the valve in software, since the actuator shows some resonances before the load is applied.
StealthChop2
The StealthChop2 chopper scheme implemented inside the TMC2300, enables absolute silent stepper motor control. In figure 8 you see how the sinusoidal phase currents should look like. Here the standard settings were used.
While a current controlled chopper will always try to yield a sine-shaped current wave, the StealthChop driver applies a sine wave shaped voltage to the motor. However, especially with inexpensive motors, the resulting current wave will not be exactly sine-shaped. This results from the shape of the motor’s back-EMF. In many cases, this mal-formed current shape even positively influences the motor’s quiet operation!
Outlook
Soon the TMC2300-THERMO-BOB is launched. This enables a great way of integrating your device together with an IOT Board like the AVR-IOT.
https://www.trinamic.com/support/eval-kits/details/tmc2300-thermo-bob/