Troubleshooting

Inquiries about using SKU:SEN0492

userHead SOJUNG.PARK 2023-05-17 20:13:32 1189 Views4 Replies

I recently purchased the SKU:SEN0492 sensor, and I have some questions about this.

I'm using a sensor and RS485 to usb module to test it before it's actually used.

I wrote Python code that fetches distance data once a second, and there is a problem when I execute it.

At first, I get the data well, but there is a problem that the value of the data is fixed from a certain point in time. When I move the laser, it is fixed to any value, so the value does not change.

Below is an example distance value.

200mm, 10mm, 399mm ...... 12mm, 15mm, 15mm, 15mm, 15mm, 15mm, 15mm ......

I don't know at what point or which of these problems arise. Is it a code problem? Or is it a hardware problem?

 

Can you tell me the cause of the problem? I attached my code together.

Please give me any details or explanations on these matters.

 

 

 

import serial

import time

 

ser = serial.Serial('/dev/ttyLaser', baudrate=115200, bytesize=serial.EIGHTBITS,

                    parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=1)

 

slave_address1 = 0x50

function_code1 = 0x03

register_address_high1 = 0x00

register_address_low1 = 0x34

read_length_high1 = 0x00

read_length_low1 = 0x01

crc_check_high1 = 0xC8

crc_check_low1 = 0x45

request_data1 = bytes([slave_address1, function_code1, register_address_high1, register_address_low1,

                      read_length_high1, read_length_low1, crc_check_high1, crc_check_low1])



response_length1 = 7 

response_data1 = None


 

def crc16(data):

        crc = 0xFFFF

        for b in data:

            crc ^= b

            for _ in range(8):

                if crc & 0x0001:

                    crc >>= 1

                    crc ^= 0xA001

                else:

                    crc >>= 1

        return crc.to_bytes(2, byteorder='little')


 

while True:

    ser.write(request_data1)

 

    data1 = ser.read(response_length1)

    if len(data1) == response_length1:

       

        crc_high1, crc_low1 = crc16(data1[:-2])

        if crc_high1 == data1[-2] and crc_low1 == data1[-1]:

            response_data1 = data1

           

            if response_data1:

                slave_address1, function_code1, data_length1, data_high1, data_low1, crc_high1, crc_low1 = response_data1

                data_value1 = (data_high1 << 8) + data_low1

 

                print(f"Response data1 (hex): {' '.join(f'{b:02X}' for b in response_data1)}")

                print(f"Slave address1: 0x{hex(slave_address1)[2:].zfill(2)}")

                print(f"Function code1: 0x{hex(function_code1)[2:].zfill(2)}")

                print(f"Data length1: 0x{hex(data_length1)[2:].zfill(2)}")

                print(f"Data value1: 0x{hex(data_value1)[2:].zfill(4)}")

                print(f"Data value1: {int(hex(data_value1), 16)}")

                print(f"CRC1: {' '.join(f'{b:02X}' for b in [crc_high1, crc_low1])}")

               

            else:

                print("Failed to receive sensor data.")

 

            time.sleep(1)

 

    else:

        print("Waiting for data...")

        continue

2023-11-26 12:15:54

Hi,

 

I have exactly the same behavior. Do you have a solution for this issue?

 

userHeadPic Daniel.Aeschlimann
2023-05-25 23:14:13

This laser range sensor detects objects in a range of 4400cm with a resolution of 2cm. With three measurement modes offered, it is well suited to a variety of detecting applications such as security gate retro bowl  detection.

userHeadPic Mike.Alley
Mike.Alley wrote:

It runs on 5V36V and has an industrial 485 chip that supports the Modbus-RTU protocol and works well with other <a href="https://retrobowlgo.com/">retro bowl</a> industrial 485 devices. 

2023-05-25 23:15:58
1 Replies
2023-05-17 22:35:59

The data will be unstable when measuring black objects. Have you changed the setting of the sensor? Could you pls upload the Hex data? For example: 50 03 02 07 0B 06 7F

 

userHeadPic jenna