PosConCM

class compas_fab.sensors.baumer.PosConCM(serial, address)[source]

Bases: compas_fab.sensors.base.SerialSensor

Provides an interface for the Baumer PosConCM round objects measurement sensor.

The sensor has different interfaces to retrieve its data. This class provides access to the serial interface (RS-485). This class is a context manager type, so it’s best used in combination with the with statement to ensure resource deallocation. The protocol of the sensor when operated via RS-485 indicates that access to it must be locked programmatically before starting operations and unlocked on completion. This is handled automatically if you use this class on a with statement, otherwise, the methods begin() and end() must be invoked by hand.

Attributes
  • serial (serial.Serial) – Instance of the serial port used to communicate with the sensor.

  • address (int) – PosConCM sensors have an address assigned, which defaults to 1. There’s also a broadcast address (PosConCM.BROADCAST_ADDRESS) that can be used to query the address of the sensor connected to the RS-485 bus. Only one sensor can be in the bus when using the broadcast address to query for sensor’s address.

Examples

>>> from serial import Serial                                                   
>>> with Serial('COM5', 57600, parity=PARITY_EVEN, timeout=1) as serial:                            
>>>     with PosConCM(serial, PosConCM.BROADCAST_ADDRESS) as broadcast_query:   
...         addr = broadcast_query.get_address()                                
...                                                                             
...     with PosConCM(serial, addr) as sensor:                                  
...         sensor.set_measurement_type('X-Center')                             
...         sensor.set_precision(2)                                             
...         data = sensor.get_measurement()                                     

Methods

__init__(serial, address)

Initialize self.

activate_flex_mount()

Activates the FLEX Mount feature of the sensor to allow positioning it on an angled installation.

adjust_to_dark_object(is_dark_object)

Adjusts the sensor to detect darker or lighter surfaces.

begin()

Locks the sensor to start RS-485 communication.

calculate_checksum(command)

Checks that message is complete.

deactivate_flex_mount()

Deactivates the FLEX Mount feature.

end()

Unlocks the sensor from RS-485 communication.

format_command(address, command[, data])

Formats the command.

get_address()

Gets the address of the RS-485 sensors currently connected to the bus.

get_measurement()

Retrieves the current measurement of the sensor according to the current settings.

get_payload(result)

Gets payload.

reset()

Resets the sensor to factory settings.

send_command(address, command[, data])

Sends a command to the sensor’s address specified.

set_flex_mount(angle, distance)

Sets the FLEX Mount feature to a specific angle and distance.

set_measurement_type(measurement_type)

Defines the measurement type to use.

set_precision(precision)

Defines the precision the sensor will use to determine edges:

teach_flex_mount(reference_thickness)

Sets the FLEX Mount feature to a specific angle and distance.

Attributes

BROADCAST_ADDRESS

ERROR_CODES

FRAME_HEAD

FRAME_TAIL

MEASUREMENT_TYPES

QUALITY