Author Topic: Trying to get rangefinder sensor working  (Read 229 times)

0 Members and 1 Guest are viewing this topic.

Offline DogmaTopic starter

  • Newbie
  • Posts: 1
  • Country: nz
Trying to get rangefinder sensor working
« on: July 11, 2024, 01:12:16 am »
Hi everyone,

For a university project I've just bought this rangefinder module:

https://www.aliexpress.com/item/1005005384252531.html?spm=a2g0o.store_pc_home.0.0.4cdc487fmbcKfl&pdp_npi=4%40dis%21NZD%21NZ%24%2071.14%21NZ%24%2071.14%21%21%21308.10%21308.10%21%402103011717162619069976790e1a6d%2112000032833515483%21sh01%21NZ%210%21

I have to get it working using a C/C++ environment and a Raspberry Pi Pico but I am really battling. I've got VS Code set up all good using CMake to build the files and have confirmed that everything works by using it to program the Pico to read from an IMU. My main problem is that I don't really have an idea of how to write code for the rangefinder. In the description of the rangefinder there is a bit of information on commands to use the device but I don't really understand how to use/write code for them.

Any help/advice would be greatly appreciated,

Cheers
 

Online darkspr1te

  • Frequent Contributor
  • **
  • Posts: 350
  • Country: zm
Re: Trying to get rangefinder sensor working
« Reply #1 on: July 11, 2024, 07:13:06 am »

from the link you provide it says it's a serial device at 9600 baud. If you send hex commands to it then it will send data back.






Code: [Select]
Baud rate:9600bps;
data bit:8 bit;
Start bit:1bit;
Stop Bit:1bit;
Parity:none.
Remarks: Because the environment light intensity is too large, the ambient temperature is too high or too low, the reflector is too weak or too strong, or the target of a rough surface, different measurement objectives and measurement environment may cause some error of the measurement range or measurement results.
• ADDR Device Address•Postion is 1, count from the top , when item is 0, count from the end (FA 04 08 01 F9),The default setting is from end•CS check byte, it sums all the bytes in front,Returns the reverse, plus 1, in the data returned by single measurements and successive measurements, in which the quotes are part of the data,Format is ASCII sample:123.456 m display 31 32 33 2E 34 35 36 ADDR Default value  80(128)
The command to read data when the parameter is factory setting:Single measurement:80 06 02 78  Continuous measurement:80 06 03 77
Shutdown device:
80 04 02 7A
Set address:
FA 04     01   80   81         
Distance modification:
FA 04     06   2D   01   CE  -1
FA 04     06   2B   01   D0   +1

time interval (1S) :
FA 04 05 01 FC 
Set start point: 
FA 04 08 01 F9    Top
FA 04 08       00   FA   back ends
Set range:
FA 04 09       05   F4   5m
FA 04 09       0A   EF   10m
FA 04 09       1E   DB  30m
FA   04   09   32   C7   50m
FA   04   09   50   A9   80m
Set frequency:
FA   04   0A   00   F8 
FA   04   0A   05   F3   5
FA   04   0A   0A   EE   10
FA   04   0A   14   E4   20
Set resolution: 
FA   04   0C   01   F5   1mm
FA   04   0C   02   F4   0.1mm
Set start the measurement when power on:
FA   04   0D   00   F5   turn off
FA   04   0D   01   F4   turn on
Single measurement (broadcast)
FA   06   06   FA         
Read cache:
80   06   07   73         
Control laser:
80   06   05   01   74   open
80   06   05   00   75   Close


there is also a discussion on it here with some code ,
https://forum.arduino.cc/t/laser-rangefinder-max485-communication/1154004

then theres a write up here with sample code , note the dropbox links dont work

https://blog.qartis.com/laser-distance-meter-update-serial-commands-timing-measurements/


and finally a arduino library that may work

https://github.com/hackerceo/LaserRanger



darkspr1te



 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf