Skip to main content

Digital In

Hardware

The AutomatePro comes with 10x digital inputs for checking the binary state of external systems. It is designed to work with a wide range of different sensors and switches.

Connector Pinout

Digital Input Specifications


ParameterValue
High Voltage State5-24V
Low Voltage State<2V
Input Impedance2kΩ
Sample Rate10Hz
Number of Inputs10

SVG Image created as Graphical Drawings-DIN_x.svg date 2025/02/06 13:37:17 Image generated by Eeschema-SVGGND2kΩOnboardAutomateProDI_xx2kΩ


ROS API

Publishers

TopicTypeDescription
/io/dinautomatepro_interfaces/msg/DigitalInContains the states of the digital in.
Only published on state change or when requested.
AutomatePro supports 10 digital input pins. Each input pin is referred to as din_XX, where XX is the pin number, ranging from 01 to 10.

Input Pins: din_01-din_10
DataType: bool
Response Rate: 200 ms

Services

ServiceTypeDescription
/io/din/requestautomatepro_interfaces/srv/ReqDigitalInRequest to send the current state of the digital inputs. When requested, current states will be published to /io/din.
tip

It is recommended to request the states of the digital inputs by calling the service, immediately after subscribing to /io/din to ensure you have the most up-to-date information.

Example

Example code snippet prints the states of the digital inputs by subscribing to the /io/din topic.

import rclpy
from rclpy.node import Node
from automatepro_interfaces.msg import DigitalIn
from automatepro_interfaces.srv import ReqDigitalIn


class DigitalInSubscriber(Node):

def __init__(self):
super().__init__('digital_in_subscriber')
self.subscription = self.create_subscription(
DigitalIn,
'/io/din',
self.listener_callback,
10)
self.client = self.create_client(ReqDigitalIn, '/io/din/request')
self.request_state() # Request the current state of the digital inputs

def listener_callback(self, msg):
self.get_logger().info('Received DigitalIn message: %s' % [
msg.din_01, msg.din_02, msg.din_03, msg.din_04, msg.din_05,
msg.din_06, msg.din_07, msg.din_08, msg.din_09, msg.din_10])

def request_state(self):
while not self.client.wait_for_service(timeout_sec=1.0):
self.get_logger().info('service not available, waiting again...')
request = Trigger.Request()
self.future = self.client.call_async(request)
self.future.add_done_callback(self.service_callback)

def service_callback(self, future):
try:
response = future.result()
self.get_logger().info('Service response: %s' %
('Success' if response.success else 'Failure'))
except Exception as e:
self.get_logger().info('Service call failed %r' % (e,))

def main(args=None):
rclpy.init(args=args)
node = DigitalInSubscriber()
rclpy.spin(node)
node.destroy_node()
rclpy.shutdown()

if __name__ == '__main__':
main()

Run the node using the following command:

ros2 run automatepro_python_tutorials digital_in_node