IR distance sensor

44 views
Skip to first unread message

Multitrain

unread,
Jul 5, 2024, 4:58:45 AM7/5/24
to jallist

Rob CJ

unread,
Jul 6, 2024, 5:41:34 AM7/6/24
to jal...@googlegroups.com
Hi Patrick,

I have seen it before but have never used it. 

I had a quick look at the datasheet but it does not give any information for making a library. Apparently you need an application note:


Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens Multitrain <patfr...@gmail.com>
Verzonden: vrijdag 5 juli 2024 10:58
Aan: jallist <jal...@googlegroups.com>
Onderwerp: [jallist] IR distance sensor
 
--
You received this message because you are subscribed to the Google Groups "jallist" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallist+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jallist/2d0071f7-29ee-49fa-a948-b0aec7ee5d4bn%40googlegroups.com.

Patrick FROUCHT

unread,
Jul 6, 2024, 10:38:54 AM7/6/24
to jal...@googlegroups.com
I'm afraid it seems very complex, anyway too much for me...
I have found the C listing for Adafruit_VL53L0X.h :  https://github.com/adafruit/Adafruit_VL53L0X/blob/master/src/Adafruit_VL53L0X.h

It is out of my capability to understand....but the product seems very powerful

Perhaps you can explain to me how to handle all that information.
If I understand,  according to the documentation you attached, it needs to set a lot of parameters before getting reliable behaviour.


Patrick.

Rob CJ

unread,
Jul 6, 2024, 11:25:25 AM7/6/24
to jal...@googlegroups.com
Hi Patrick,

What do you want to measure? I made a library some time ago for an ultrasonic ranging module that can measure a distance type HCRS04.


Would this help you?

I do not know this sensor so in order to create a library I need to study the datasheet and the info you provided and I would need a module to test.

It is not a very expensive module so I could order one or you can send me one 🙂 (I think sending from France to The Netherlands will be expensive so you could order one at Aliexpress and send it to me directly) but it would take some time before a library is available. It would be good to know if somebody from the JAL community had used it already, that would be much faster.

Kind regard,

Rob






Van: jal...@googlegroups.com <jal...@googlegroups.com> namens Patrick FROUCHT <patfr...@gmail.com>
Verzonden: zaterdag 6 juli 2024 16:38
Aan: jal...@googlegroups.com <jal...@googlegroups.com>
Onderwerp: Re: [jallist] IR distance sensor
 

Patrick FROUCHT

unread,
Jul 6, 2024, 5:13:37 PM7/6/24
to jal...@googlegroups.com
Hello Rob

I know the ultrasonic distance ranger but for me it is much too big.
I want to model the very famed lisbon tram line #28 each tram in HO scale is about 92 mm length, 26 mm width and 45 mm height
with a very unusual track configuration and gauntlet.

You can find a lot of images on the web..

With IR sensor,it allows to have a configuration for trams like on image   img_5380 

I need to have a processor in the tram for distance sensing, acceleration and deceleration. I'll use an AC square power supply and rectify it to get the supply for electronics and motor. For the stopping  section in front of a special track arrangement I'll make a dissymmetry in the supply ac voltage and the detection of it (easily made with a transistor) will stop the car. For a tight route between the building, the distance sensor will detect approaching the buildings and automatically the processor decreases speed.

There is still a problem: when two trams are facing each other in a standard double track arrangement, what will be  the behaviour of the distance detector. I can slightly rotate the detecteur to the right in each car but I can't be sure of the result without testing it.  

I have a B plan in case my dream can't be done; simply using a block system,  and having no electronics in the car. very attractive but less realistic. The electronic will manage priority between cars in the special track arrangement like gantlet and single track. Reducing speed will be made easily by adding diodes in the dc supply.

It's all my thinking about how to get my Lisboa tram system going.

Regards
Patrick


609px-Lisbon_tramways_(28)_(7922256676).jpg
800px-Tram_28,_Lisbon,_20051011.jpg
img_1218_a.jpg
alfama05.jpg
1_005.jpg
Virage serre.jpg
8895036_b10ce4033f.jpg
IMG_5380.JPG
IMG_5295.JPG

Patrick FROUCHT

unread,
Jul 7, 2024, 2:07:02 AM7/7/24
to jal...@googlegroups.com
Hello Rob

I slept on it and there is another big problem: cross-talk. I tried positioning the sensor within the model. Because it's rounded front, the sensor has to be fixed a few millimeters back  the rounded front window. and cross-talk won't be small.
About cross talk, fig 4 page 9 of document UM2039, it should be written "Exclusion area  for low(medium) Xtalk Calibration

Before doing big, I'll start with a small layout using only 2 cars running on the two track loop, one in each direction, so no need for a collision avoidance system, just a management system with a PIC for special track arrangement.
It is wiser, easier, faster, letting me have more time for analysing the use of this ranging sensor.

Regards
Patrick
.

Rob CJ

unread,
Jul 7, 2024, 4:07:07 AM7/7/24
to jal...@googlegroups.com
Hi Patrick,

Looks like a nice project. I had a look at some existing libraries and downloaded the API but from ST (a French company 🙂) and I saw that it is a bit more work than I initially thought. I think the easiest approach is to look at an existing library and port it to JAL.

Let me know when it get's serious, I may want to pick it up later.

Kind regards,

Rob




Van: jal...@googlegroups.com <jal...@googlegroups.com> namens Patrick FROUCHT <patfr...@gmail.com>
Verzonden: zondag 7 juli 2024 08:06

Patrick FROUCHT

unread,
Jul 7, 2024, 7:42:47 AM7/7/24
to jal...@googlegroups.com
Hi Rob,

As I told you, I slept on it, And I prefer to start small and make it more complex later.
A friend of mine also has 2 trams and will give me them. So with 4 of them I'll build a simple block system to control them on a small layout.
Going back, the sensor ST is 2.4 x 4.4 mm while the surface of the "mother board" is 16 x 10 mm without fixing ears. It is not possible to separate them once soldered. The front window is 9 x 6 mm.
I have to check for compatibility of the sensor and the front window and find a way to measure the Xtalk. It is not for today, perhaps in a few months.

Regards
Patrick


Joep Suijs

unread,
Jul 7, 2024, 8:50:49 AM7/7/24
to jal...@googlegroups.com
Hi Rob, Patrick,

This is a nice sensor, but quite complicated to interface with. And afaik there is no real interface-specification, they assume you use their code.
I do have some working (C++) code as part of a bigger project. It is based on this code: https://groups.google.com/forum/#!topic/diyrovers/lc7NUZYuJOg

Note there is also a module named GY-53, based on this sensor. This module has (amongst others) a PWM output. More expensive but much easier to interface.

Feel free to contact me off-list if you have any questions or would like to receive my code.

Regards,
Joep


Op zo 7 jul 2024 om 10:07 schreef Rob CJ <rob...@hotmail.com>:

Patrick FROUCHT

unread,
Jul 7, 2024, 1:45:06 PM7/7/24
to jal...@googlegroups.com
Hello all,
For arduino it is "easy" to play with, because they use just VL53L0X.h  . You can find at:   https://github.com/adafruit/Adafruit_VL53L0X/blob/master/src/Adafruit_VL53L0X.h
My aim was to use it with a "standard" PIC.
I have an arduino board "somewhere" and I'll try to make the sensor work. just as a test.

Regards

Patrick

Joep Suijs

unread,
Jul 7, 2024, 4:59:38 PM7/7/24
to jal...@googlegroups.com
Hi Patrick,

You also might want to try the pololu arduino-library for this sensor. In my experience, Pololu libraries have less dependancies, than libraries from Adafruit, making them easier to comprehend and hence to port.

Regards,
Joep

Op zo 7 jul 2024 om 19:45 schreef Patrick FROUCHT <patfr...@gmail.com>:

Rob CJ

unread,
Jul 8, 2024, 1:27:58 AM7/8/24
to jal...@googlegroups.com
Hi Joep, Patrick,

The Pololu library for Arduino is the 'standard'  Arduino library for the VL53L0X. I think it could be ported to JAL.

Maybe I will give it a try.

Kind regards,

Rob




Van: jal...@googlegroups.com <jal...@googlegroups.com> namens Joep Suijs <jsu...@gmail.com>
Verzonden: zondag 7 juli 2024 22:59

Multitrain

unread,
Jul 8, 2024, 2:48:41 AM7/8/24
to jallist
Hello,

I have ordered 2 items GY-53 to give them a try. The PWM output if less accurate  but very easier to use.

Regards
Patrick

rob...@hotmail.com

unread,
Jun 30, 2025, 11:18:03 AMJun 30
to jallist
Hi Patrick,

An old topic but since I was on vacation I had some time to look at the VL53L0x Time-Of-Flight ranging sensor.

It seems like a complex chip so I looked at an existing Arduino library: https://github.com/pololu/vl53l0x-arduino

I started a port of this library to JAL and it already took me more than 2 days to work on the initialization routine (and not yet finished  but getting there). Later I need to order some samples to see if the library works and I saw the modules are quite cheap. 

Are you - or any other JAL users - interested in using this sensor in the near future?

Kind regards,

Rob




Op maandag 8 juli 2024 om 08:48:41 UTC+2 schreef Multitrain:

Zet Weeh

unread,
Jul 1, 2025, 4:48:17 PMJul 1
to jal...@googlegroups.com
Hi Rob
Be careful with your vacation. 
Yes, I’m interested in this sensor. 
Greetings Peter

Groeten 

Op 30 jun. 2025 om 17:18 heeft rob...@hotmail.com <rob...@hotmail.com> het volgende geschreven:



Patrick FROUCHT

unread,
Jul 2, 2025, 4:15:46 AMJul 2
to jal...@googlegroups.com
Hi Rob

To make it simpler, I used the GY-53 with its PWM output which was enough for my purpose.
The advantage of the VL53L0X is its size 25mm x 12 mm versus 25mm x 15.6mm, sometimes the 3.6 mm are  prohibitive!
I tried to understand the huge init and the API.  I supposed the JAL development team had a C+ to Jal automatic translator!

Regards

Patrick

Rob CJ

unread,
Jul 2, 2025, 12:59:32 PMJul 2
to jal...@googlegroups.com
Hi Patrick, Peter,

Thanks for the response. Nice solution with the GY-53, new to my (the VL53L0X was also new to me btw).

I will continue with the library for the VL53L0X, I understood that you could use it also with the GY-53 module when using the IIC interface of that module.

Status so far: Port is done and it compiles (finally). I need to order a sample to test if it works.

The library occupies quite some ROM code. With a simple test program compiled for a 16F1825 I need 3.5 kbyte of ROM. Advantage is that the VL53L0X is much cheaper than the GY-53 but of course you get a fully working device with the GY-53.

I really have no idea how long testing will take since I did a simple port without diving into the details of why thing are done in the Arduino library in the way that it is done. I also changed it a bit since the Arduino library uses floats for some procedures and I wanted to avoid that as to prevent that the library gets even bigger. I also noticed that in the Arduino library some functions that return a value if the function is completed succesfully or not, the return value is not used. Not sure if that is on purpose or just forgotten (it is in C and maybe the C compiler does not report on that). Next to that - thanks to the JAL compiler warnings - I noticed that some variables where not matching the size of the arguments since they where to big (possible data loss) so I explicitely casted them to a smaller type. I assume that is OK since it would also not work in C.

Keep you posted. First order some modules ...

Kind regards,

Rob


Verzonden: woensdag 2 juli 2025 10:15

rob...@hotmail.com

unread,
Jul 18, 2025, 6:50:26 AMJul 18
to jallist
Hi Patrick and others,

I tested the JAL library for the vl53l0x time-of-flight ranging sensor and it seems to work. I added two sample programs, one for continuous mode and one for single mode.

Samples and library are based on an Arduino library that I ported to JAL (without understanding exactly how the module works since it is quite a complex device).

I added the library and samples to Jallib so they will be in the next bee-package coming Sunday.

I used a standard module. The nice thing about the module is that it an has on-board voltage regulator and on-board level shifters so you can connect it directly to your PIC operating at 5 Volt.

I purchased a few modules from AliExpress: https://nl.aliexpress.com/item/1005008119148487.html

If there are JAL users that are going to use this sensor in the - near - future, let me know if it works OK for you.

The library uses the default calibration of the module (from the factory) and there is no calibration software. This means that you need to use the module without any smoke glass in front of it.

Kind regards,

Rob


Op woensdag 2 juli 2025 om 18:59:32 UTC+2 schreef rob...@hotmail.com:
Reply all
Reply to author
Forward
0 new messages