Combi Sensor
Sensor Functions and Robotics Applications
3-Axis Accelerometer – ax, ay, az
Measures linear acceleration along the X, Y, and Z axes (m/s² or g). Typical uses in robotics:
- Detecting tilt or inclination
- Monitoring vibrations from motors or gearboxes
- Recognizing impacts or collisions
- Rough estimation of movement direction
3-Axis Gyroscope – rx, ry, rz
Measures angular velocity (°/s or rad/s). Typical uses in robotics:
- Measuring rotational speed of a robot or joint
- Stabilizing mobile robots
- Enabling smooth and controlled turns
3-Axis Magnetometer – mx, my, mz
Measures magnetic field strength (µT). Typical uses in robotics:
- Determining the robot’s heading relative to Earth’s magnetic field (e.g., "facing north")
- Correcting gyroscope drift during long movements
Combined as a 9-DoF IMU (Inertial Measurement Unit)
All nine values together: ax, ay, az, rx, ry, rz, mx, my, mz can be combined to compute:
- Orientation in 3D (roll, pitch, yaw)
- Stable navigation and balancing
- Components of localization / SLAM (Simultaneous Localization and Mapping)
Programming Blocks
Note: The “compensation” parameters are not used with the 6-pin combi sensor; it applies only to the 10-pin combi sensor. The sensor included in the set has a 6-pin connector.
| Block | Function |
|---|---|
![]() |
Initializes the accelerometer component, allowing the user to set the measurement range in g, the bandwidth in Hz, and toggle compensation. |
![]() |
Outputs the current linear acceleration reading along a selected axis. |
![]() |
Checks whether the current acceleration on a specified axis matches a defined mathematical condition. |
![]() |
Initializes the magnetometer component, allowing the user to set the data update rate in Hz |
![]() |
Outputs the current magnetic field strength reading along a selected axis. |
![]() |
Checks whether the current magnetic flux on a specified axis matches a defined condition |
![]() |
Initializes the gyrometer component, allowing the user to set the rotational measurement range in °/s, the bandwidth in Hz, and toggle compensation. |
![]() |
Outputs the current angular rotation speed along a selected axis. |
![]() |
Checks whether the current rotational speed on a specified axis matches a defined condition. |
Sample Code 1
Connection: Connect the Combi Sensor to the EXT1 port of the TXT 4.0 Controller.
Result: This program acts as a smart steering system that helps a robot drive straight. It runs continuously in a "repeat forever" loop, working to keep the robot on course indefinitely as long as it operates safely. To determine if the robot has drifted off its straight path, the program continuously calculates the current yaw angle (angle_rz) in degrees. It gets this angle by reading the rotation speed in the z-direction (rz) from the gyroscope and multiplying it by the exact time that has passed since the last check (ts_diff), adding this incremental change to the running total.
CurrentAngle = PreviousAngle + (RotationSpeed /TimePassed)
When it detects a drift away from its zero-degree target, the program calculates this directional drift (error) and automatically adjusts the individual motor speeds (m1 and m2). It calculates this adjustment by applying a proportional multiplier (Kp) to the error, and then adds or subtracts that Kp value from the baseline maximum speed (speed_max) to slow one wheel down and speed the other up. This differential speed effectively steers the robot back on track. At the end of every cycle, the program pauses for a brief 10 milliseconds and updates the initial timer (ts0) so the elapsed time (ts_diff) calculated in the next round is perfectly accurate.
Finally, it includes a strict safety switch: if the robot spins too far out of control and the absolute angle (absolute angle_rz) passes a 60-degree limit (thresh_angle), the program instantly breaks out of the endless loop and shuts off both motors to stop the machine completely.
To learn more about this type of controllers, you can refer to the Magic of Controllers course.
Sample Code 2
Connection: Connect the Combi Sensor to the EXT1 port of the TXT 4.0 Controller.
Result: This program acts as a smart guide that tells a robot how to make a perfect turn. It runs continuously in a "repeat forever" loop, watching the robot spin until it reaches the right spot. To figure out how far the robot has turned, the program constantly calculates the current turning angle (angle_rz). It gets this angle by reading the spinning speed (rz) from the sensor and multiplying it by the exact time that just passed (ts_diff), adding this tiny movement to the total angle.
Before starting the loop, the program sets a top speed (speed_max) and turns on the motors in opposite directions so the robot starts spinning in place. As the robot spins, the program prints out the numbers to track its progress. At the end of every round, it updates the timer (ts_diff) so the math for the next check is completely accurate.
Finally, it includes a strict stopping rule: if the robot spins far enough to hit its 85-degree goal (angle_target), the program instantly breaks out of the loop and shuts off both motors to stop the machine completely.








