Example Code for Arduino-I/O Output
Discover how to configure Arduino I/O Output in single and double threshold modes. Learn about TX/RX complementary levels and their interaction with UART mode. Understand how to switch modes for optimal device performance. Perfect for developers looking to enhance their projects with effective I/O management.
I/O Output
In I/O output mode, it can only be used in single module. The module cannot output ranging value. TX/CAN_L and RX/CAN_H output complementary levels. The levels of the two signal lines are opposite. The high level is 3.3V and the low level is 0V. In addition, it should be noted that the output current is small, and it should be noted whether it can drive other devices when driving other devices. If it cannot be driven directly, it can be driven through relays and other methods.
When the module is in UART mode (note that the host computer software cannot recognize the module in I/O mode), connect the TOFSense series products to the host computer software through the USB to TTL module (refer to the data manual for the line sequence and power supply voltage). After successful recognition, click
to enter the settings page, configure the parameters and click the write parameters button to save the parameters. Note: After switching to I/O mode, if you need to change Band_Start, Bandwidth and other parameters, you can refer to the method in the FAQ section to switch back to UART mode for configuration.
Please remember your baud rate (Baudeate) before modifying the configuration, so as to switch back to UART mode later.
Single Threshold
The interface type is set to IO, Band Start is set to 1000, Band Width is set to 0, IO single threshold configuration is as shown in the figure, after writing the parameter, the module restarts and no longer outputs ranging value but outputs high and low level.
According to the above settings, the threshold value=Band Start=1000(mm), in this mode, when the ranging value<1m, RX is high level, TX is low level, when the ranging value>1m, RX is low level, TX is high level.
Example: When the ranging value is 0.3 meters, RX is high level, TX is low level, when the ranging value increases to 1.2 meters, RX is high level, TX is low level.
Double Threshold
The interface type is set to IO, the hysteresis start point Band Start is set to 1000, the hysteresis width Band Width is set to 500, and the IO double threshold configuration is as shown in the figure. After writing the parameters, the module restarts and no longer outputs ranging values but outputs high and low levels.
According to the above settings, the distance value is converted into high and low level output through hysteresis comparison. When the distance changes from small to large and exceeds the high threshold, or from large to small and is lower than the low threshold, the I/O port level is reversed.
For example, based on the above settings, the low threshold is 1 meter, and the high threshold is 1.5 meters. (Low threshold=Hysteresis start point Band Start, High threshold=Hysteresis start point Band Start + Hysteresis width Band Width)
When the ranging value is 0.3 meters, RX is high level, TX is low level,
When the ranging value increases to 1.2 meters, RX is high level, TX is low level,
When the ranging value continues to increase beyond 1.5 meters, the level is reversed, RX is low level, TX is high level.
When the ranging value drops from more than 1.5 meters to 1.2 meters, RX is low level, TX is high level,
When the ranging value continues to drop below 1 meter, the level is reversed, RX is high level, TX is low level.
Hysteresis comparison schematic diagram is as shown in the figure

Was this article helpful?
