Skip to main content

A library for communication with laser model produced by Micro photons(Shanghai)Technology Co., Ltd.

Project description

About

This lib is created for scanning laser module GC-76000C produced by Micro photons(Shanghai)Technology Co., Ltd. The tech documentation of it provided by the corporation is my reference.

It can send control parameters (such as starting frequency) to the module, and request informations from it.

Usage

Function definitions

Here is the usage of all functions in the LaserSerial class, including their parameters and return values:

  1. __init__:

    • Parameters:
      • port: String, specifies the serial port name, default is 'COM6'.
      • baudrate: Integer, specifies the baud rate, default is 9600.
      • bytesize: Specifies the byte size, default is serial.EIGHTBITS.
      • parity: Specifies the parity bit, default is serial.PARITY_NONE.
      • stopbits: Specifies the stop bits, default is serial.STOPBITS_ONE.
      • xonxoff: Boolean, specifies whether to enable software flow control, default is False.
      • rtscts: Boolean, specifies whether to enable hardware flow control, default is False.
      • dsrdtr: Boolean, specifies whether to enable DSR/DTR flow control, default is False.
      • timeout: Integer or float, specifies the timeout in seconds, default is 2 seconds.
    • Return Value: None.
  2. calcBIP4:

    • Parameters:
      • data: Byte sequence, the data for which the BIP4 checksum needs to be calculated.
    • Return Value:
      • The BIP4 checksum.
  3. convertCommand:

    • Parameters:
      • data: Byte sequence, the command data that needs to be converted.
    • Return Value:
      • The converted command, including the BIP4 checksum.
  4. sendCommand:

    • Parameters:
      • data: Byte sequence, the command data that needs to be sent.
    • Return Value: None.
  5. checkResponse:

    • Parameters: None.
    • Return Value:
      • Boolean, True if the response's BIP4 checksum is correct, otherwise False.

Actually, the above functions are basically not directly called in use, the following functions are more convenient for direct use

  1. send_starting_frequency:

    • Parameters:
      • starting_frequency: Integer, specifies the starting frequency. Can choose between 196250 and 191150 (Their physical unit are GHz).
    • Return Value:
      • Boolean, indicates whether the command was executed successfully, (True means your are successful).
  2. send_scan_step:

    • Parameters:
      • scan_step: Integer, specifies the scan step value. Can be set to 1 or 2 (Their physical unit are GHz).
    • Return Value:
      • Boolean, indicates whether the command was executed successfully.
  3. send_stop_frequency:

    • Parameters:
      • stop_frequency: Integer, specifies the stop frequency. Can choose between 196250 and 191150 (Their physical unit are GHz).
    • Return Value:
      • Boolean, indicates whether the command was executed successfully.
  4. send_scan_speed:

    • Parameters:
      • scan_speed: Integer, specifies the scan speed. Can be set to 1, 2, 3, or 4.
    • Return Value:
      • Boolean, indicates whether the command was executed successfully.
  5. send_scan_control_command:

    • Parameters:
      • command: Byte, specifies the scan control command. Can be set to 0x01, 0x02, 0x00, for single scan, continuous scan, and stop scan respectively.(In fact, python is so "smart" that you can use Integer 1, 2 or 0 instead of 0x01, 0x02, 0x00.)
    • Return Value:
      • Boolean, indicates whether the command was executed successfully.
  6. read_serial_number:

    • Parameters: None.
    • Return Value:
      • Integer, the device's serial number.
  7. read_firmware_version:

    • Parameters: None.
    • Return Value:
      • Integer, the device's firmware version number.

Example

You can initialize your laser module as follows:

import serial
from laserlib import LaserSerial

laser = LaserSerial(port='COM6', baudrate=9600)
# Default setting is 
#     port='COM6', baudrate=9600, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, xonxoff=False, rtscts=False, dsrdtr=False, timeout=2

Then you can use the functions like this:

laser.send_starting_frequency(196250) #In fact, you can use the return value of this function, to ensure your command have been executed correctly. 
time.sleep(0.1) #It needs a delay time, but I dont know why...
laser.send_scan_step(1)
time.sleep(0.1)
laser.send_stop_frequency(191150)
time.sleep(0.1)
laser.send_scan_control_command(1)
time.sleep(0.1)
#You should set your laser module in above sequence.
laser.send_scan_speed(1)
time.sleep(0.1)
print(laser.read_serial_number())
time.sleep(0.1)
print(laser.read_firmware_version())
laser.closeSerial()

License

This project is licensed under the MIT License - see the LICENSE file for details

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

laserlib-0.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

laserlib-0.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file laserlib-0.1.tar.gz.

File metadata

  • Download URL: laserlib-0.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for laserlib-0.1.tar.gz
Algorithm Hash digest
SHA256 dd4be4cb7ff849171f8debf124e1233da83db7dc694607b2d71ba9f7c018d031
MD5 1ce435a478164a17ac69d6260b7c8c89
BLAKE2b-256 a7ee0fdadccd4cd5974fd43884156b6f548d73ea1d0ffef43c1a16e4f708724a

See more details on using hashes here.

File details

Details for the file laserlib-0.1-py3-none-any.whl.

File metadata

  • Download URL: laserlib-0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for laserlib-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 52d2ce4baacc7c462776093cc0d7631d026700c8dc1feaa84c3e82cdf94129d1
MD5 e7c709c15190447eda4ff82701ba7a8e
BLAKE2b-256 4030fbdbc6ae974645d1a48c3074eaee6a8c7e0f0d2c9ab9ff6c033d6bcf7d0b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page