The V53L0X is surrounded in un-nessessary mystery.
If all you want is range...it is a range finder..then all you need is 2 registers.
This is like gold so I am posting here so it does not get lost so easy.
Originally I posted on picaxe forum and Buzby wrote code for the device.
I posted the code on gcb forum and mmotte converted it to gcb.
I simplified it to just distance and 2 variables.
#chipmega328p, 16
#optionExplicit;for terminal distance out
#defineUSART_BAUD_RATE9600
#defineUSART_TX_BLOCKING
#defineUSART_DELAY1ms;set up v53l0x
#defineHI2C_DATAPORTC.5;sda
#defineHI2C_CLOCKPORTC.4;scl
#defineHI2C_BAUD_RATE400HI2CModeMasterdimdistance_lo,distance_hiasbyteHI2CStart;software restartHI2CSend(0x52)HI2CSend(0x89)HI2CSend(0x01)HI2CStopwait200msdo;------------------------HI2CStart;Sys Range StartHI2CSend(0x52)HI2CSend(0x00)HI2CSend(0x01)HI2CStopHI2CStart;read distanceHI2CSend(0x52)HI2CSend(0x1e)HI2CReStartHI2CSend(0x53);set the read flagHI2CReceive(distance_hi, ACK)HI2CReceive(distance_lo, NACK)HI2CStophserprint" Distance: "+str(distance_hi*256+distance_lo)+" mm ";loop
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The problem with many STM device is that they like to be mysterious. They provide C dll's that perform initialization and interpretation routines, full of magic numbers. If you don't either use their dll's or port to GCB you will get poor results. OK for yes/no object detection (but there are much easier ways to do that) but awful for measurement.
I do have some code for VL6180X (less range I think) but it's in a different dialect of PIC basic. I've gotten in trouble for offering that in the past but it does demonstrate the device.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes,it's under C:\GCB@Syn\GreatCowBasic\Demos\distance_sensor_solutions.
It seems Not to need all the info setup to work near mm so is fine for my robots.
I was impressed with it in a real world use only the stepper robot doesn't like carpet. https://www.youtube.com/watch?v=s5-5DNa36jk
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If it give appropriate resolution for your app then who cares but just out of curiosity check out the mad code in their dll. I really liked this impressive device, got down to 2 or 3 mmm repeatably over a series of ranges.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@Haroen
Hope you get to like gcb as it has proper variable use. handy functions and above all makes fast hex code.
It's under development all the time to keep up with users wants like new device drivers
but it's open source not a commercial program so users programs of interest to others
are posted in demos or new include devices.
Like picaxe it has been around many years but is continually being improved.
How gcb has changed and improved in the 4 years I've been using it!
So many new devices supported.
and I still think a 328p nano uno best gear to use when starting to use gcb imho.
not a pickit or pic fan..it all works but it's less bother for me as I need motivating to use it.
I'm a 328p board fan, ie plug and play..I know..it's sad :(
Last edit: stan cartwright 2020-12-12
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@Stan Cartwright
Thanks for introducing me to gcb!
I had to check how to fit gcb in some of my old, current and future projects and how to proceed.
Also to try your V53L0X code and the TOF10120 code.
First step is only for me to figure out the bare minimum components and connections:
I don't have anything of arduino yet, so when you mentioned it the first time I tried gcb on both PICkit2 and PICkit3 and eventually worked fine on the demoboard.
I have not tried it on my Atmel-ICE programmer for AVR's yet.
Second step is to get started with arduino small, cheap and with maximum specifications:
You posted the LGT8F328P-LQFP32 32MHz miniEVB replaces Arduino nano V3.0
Does the V3.0 stands for version or 3.0Volts? The 5V type I would prefer.
Don't know if this is the one on 5V with a regulator AMS1117_5.0: LGT8F328P
Pickit and me sometimes get along.messy hardware probably.
Just easier options and like lots of pins and ram.
I can do basic ok but pic hardware is another step so I'm not much use for hardware advice.
pics can run off 3.3v so have logic levels that drive £5 320x240 coloured graphics lcd displays,
which makes wiring easier.
1) Cnc Shield UNO (select UNO+8825KIR)
2) CNC Shield Mega 2560 (select package C)
I got a 2560..lots of ports
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What doesn't work on the PIC I'll try on the arduino's.
Important is to get it to work for drivng 320x240 coloured graphics lcd displays!
I'm just starting gcb but hope that I can help developing.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I had it working with a 18f25k22 running on 3.3v and it went straight to display spi as logic was 3.3v so compatible. I posted a video as it was new to me...pics at 3.3v supply.
If you use the hardware spi then use the hardware clk,mosi stuff.
Ili9341 reset can be tied hi for display so save a pin.
a vid showing pic at 3.3v and avr at 5v on same ili9341 https://www.youtube.com/watch?v=zTWHTgf9fw0
Last edit: stan cartwright 2020-12-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@Haroen -"I'll start to try your V53L0X code as soon everything has arrived."
It is working code but not mine. It was started on Oshunsoft or somewhere,got put on picaxe and ended up on gcb. I can't take the credit for others help.
I never got far with using TOF10120 Laser Range Sensor Module.
nothing to demo that works properly and it uses serial as well as i2c..frustrating.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Any info about TOF10120 would be interesting and could be helpful. cheers...
like convert to gcb so it works.
Jokin..but not really. I think you could do it and a few picaxe to gcb code questions answered.
Accurate? well not bad for the price. A real one might cost hundreds.
edit TOF10120 not comparable yet as not working ok.yawn
Last edit: stan cartwright 2020-12-16
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Do video through youtube is more universal as you can not post video to gcb forum only images.
youtube lets you explain things better than words...even if it's faults.
Youtube is nice way of getting ideas across so signup and post stuff. ....
you have a camera with video I hope. or an expensive phone.
My videos are poor and my voice but shows the code working... or sometimes not
and it's a good way of showing the fault
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Depending on your camera's abilities then filming and talking is better than words.
It is easy to download videos to youtube but takes a while.
Not many forums allow videos other than links...storage.
I have problems with TOF10120 and will set it up again to show results in youtube
on gcb forum. Maybe get it sorted without others efforts.
lots of projects to sort but distance sensing is useful for my projects.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would like to try these V53L0X (and TOF10120) now on Arduino with GCB.
My Arduino's (Nano, Uno and Mega) arrived yesterday and was trying it on gcb with here my findings:
1. When connecting it to the pc all the arduino's where not recognized and I needed to install a driver for the CH341SER Chinese clone Arduino serial chips.
2. For the Arduino NANO and UNO it was enough for the boards to work with gcb by testing it by flashing only the on-board LED (portB.5).
3. The Arduino Mega2560 however the LED does NOT flash at all.
The Mega2560 was recognized by Windows Device Manager in Port(COM & LPT) as USB-SERIAL CH340 (COM6) and I was able to program the Mega2560.
To flash the on-board LED did not work.
I did switch between Programmers in the GCB-Preferences to "Arduino Mega2560".
This is the code I used:
The V53L0X is surrounded in un-nessessary mystery.
If all you want is range...it is a range finder..then all you need is 2 registers.
This is like gold so I am posting here so it does not get lost so easy.
Originally I posted on picaxe forum and Buzby wrote code for the device.
I posted the code on gcb forum and mmotte converted it to gcb.
I simplified it to just distance and 2 variables.
I intend to use the v53l0x on a robot that avoids obstacles.
the
dim distance_lo,distance_hi as byte
and
HI2CStart ;software restart
HI2CSend(0x52)
HI2CSend(0x89)
HI2CSend(0x01)
HI2CStop
wait 200 ms
at the start
then in robot code to see object
HI2CStart ;Sys Range Start
HI2CSend(0x52)
HI2CSend(0x00)
HI2CSend(0x01)
HI2CStop
HI2CStart ;read distance
HI2CSend(0x52)
HI2CSend(0x1e)
HI2CReStart
HI2CSend(0x53) ;set the read flag
HI2CReceive(distance_hi, ACK)
HI2CReceive(distance_lo, NACK)
HI2CStop
if distance <150 then.....
I will try this ASAP with some help when I receive mine from China.
They are good for 1 metre or so. good luck
The problem with many STM device is that they like to be mysterious. They provide C dll's that perform initialization and interpretation routines, full of magic numbers. If you don't either use their dll's or port to GCB you will get poor results. OK for yes/no object detection (but there are much easier ways to do that) but awful for measurement.
I do have some code for VL6180X (less range I think) but it's in a different dialect of PIC basic. I've gotten in trouble for offering that in the past but it does demonstrate the device.
There is a demo V53L0X mega328p terminal.gcb in the demo folders. Should this demo have a 'buyer' beware message? Seems to work to me.
Yes,it's under C:\GCB@Syn\GreatCowBasic\Demos\distance_sensor_solutions.
It seems Not to need all the info setup to work near mm so is fine for my robots.
I was impressed with it in a real world use only the stepper robot doesn't like carpet.
https://www.youtube.com/watch?v=s5-5DNa36jk
Cool video. I just 'liked' it!
The code clearly works. :-)
If it give appropriate resolution for your app then who cares but just out of curiosity check out the mad code in their dll. I really liked this impressive device, got down to 2 or 3 mmm repeatably over a series of ranges.
@Haroen
Hope you get to like gcb as it has proper variable use. handy functions and above all makes fast hex code.
It's under development all the time to keep up with users wants like new device drivers
but it's open source not a commercial program so users programs of interest to others
are posted in demos or new include devices.
Like picaxe it has been around many years but is continually being improved.
How gcb has changed and improved in the 4 years I've been using it!
So many new devices supported.
and I still think a 328p nano uno best gear to use when starting to use gcb imho.
not a pickit or pic fan..it all works but it's less bother for me as I need motivating to use it.
I'm a 328p board fan, ie plug and play..I know..it's sad :(
Last edit: stan cartwright 2020-12-12
@Stan Cartwright
Thanks for introducing me to gcb!
I had to check how to fit gcb in some of my old, current and future projects and how to proceed.
Also to try your V53L0X code and the TOF10120 code.
First step is only for me to figure out the bare minimum components and connections:
I don't have anything of arduino yet, so when you mentioned it the first time I tried gcb on both PICkit2 and PICkit3 and eventually worked fine on the demoboard.
I have not tried it on my Atmel-ICE programmer for AVR's yet.
Second step is to get started with arduino small, cheap and with maximum specifications:
You posted the LGT8F328P-LQFP32 32MHz miniEVB replaces Arduino nano V3.0
Does the V3.0 stands for version or 3.0Volts? The 5V type I would prefer.
Don't know if this is the one on 5V with a regulator AMS1117_5.0: LGT8F328P
Third future step with arduino's is based on my
unfinished CNCsoftware compatability R&D:
1) Cnc Shield UNO (select UNO+8825KIR)
2) CNC Shield Mega 2560 (select package C)
Then I could also use the two arduino boards for testing gcb separately without the CNC-shields.
Pickit and me sometimes get along.messy hardware probably.
Just easier options and like lots of pins and ram.
I can do basic ok but pic hardware is another step so I'm not much use for hardware advice.
pics can run off 3.3v so have logic levels that drive £5 320x240 coloured graphics lcd displays,
which makes wiring easier.
1) Cnc Shield UNO (select UNO+8825KIR)
2) CNC Shield Mega 2560 (select package C)
I got a 2560..lots of ports
What doesn't work on the PIC I'll try on the arduino's.
Important is to get it to work for drivng 320x240 coloured graphics lcd displays!
I'm just starting gcb but hope that I can help developing.
Well using a logic level converter is messy wiring.
This is using touch pins so looks extra messy.
An arduino youtube guy says use 100k resistors
I had it working with a 18f25k22 running on 3.3v and it went straight to display spi as logic was 3.3v so compatible. I posted a video as it was new to me...pics at 3.3v supply.
If you use the hardware spi then use the hardware clk,mosi stuff.
Ili9341 reset can be tied hi for display so save a pin.
a vid showing pic at 3.3v and avr at 5v on same ili9341
https://www.youtube.com/watch?v=zTWHTgf9fw0
Last edit: stan cartwright 2020-12-14
yesterday I ordered all 3 arduino's I mentioned earlier:
a) Nano 328P
b) Cnc Shield UNO (select UNO+8825KIR)
c) CNC Shield Mega 2560 (select package C)
I know that all 3 are chinese clones and hope that with gcb (and cnc-shields software) it won't be a problem.
I'll start to try your V53L0X code as soon everything has arrived.
@Haroen -"I'll start to try your V53L0X code as soon everything has arrived."
It is working code but not mine. It was started on Oshunsoft or somewhere,got put on picaxe and ended up on gcb. I can't take the credit for others help.
I never got far with using TOF10120 Laser Range Sensor Module.
nothing to demo that works properly and it uses serial as well as i2c..frustrating.
Ok, V53L0X code has started by others but is it as accurate like the TOF10120?
Didn't the picaxe code worked for your TOF10120 to get it going?
Let me know if you want a video how I did it for you to replicate.
Would be nice if we could get it also to work with gcb later.
@Haroen - please look at https://sourceforge.net/p/gcbasic/discussion/579126/thread/1fe0a785f5/
Any info about TOF10120 would be interesting and could be helpful. cheers...
like convert to gcb so it works.
Jokin..but not really. I think you could do it and a few picaxe to gcb code questions answered.
Accurate? well not bad for the price. A real one might cost hundreds.
edit TOF10120 not comparable yet as not working ok.yawn
Last edit: stan cartwright 2020-12-16
I wil post a picaxe video about the working TOF10120 to your supplied gcb link.
PLease try it for checking distance accuracy at overall range 1,993m.
Do video through youtube is more universal as you can not post video to gcb forum only images.
youtube lets you explain things better than words...even if it's faults.
Youtube is nice way of getting ideas across so signup and post stuff. ....
you have a camera with video I hope. or an expensive phone.
My videos are poor and my voice but shows the code working... or sometimes not
and it's a good way of showing the fault
Youtube it is then, it's uploading!
Check your other topic TOF10120 conversion.
Your video's are great and amazing giving all the info needed.
Last edit: Haroen 2020-12-18
Depending on your camera's abilities then filming and talking is better than words.
It is easy to download videos to youtube but takes a while.
Not many forums allow videos other than links...storage.
I have problems with TOF10120 and will set it up again to show results in youtube
on gcb forum. Maybe get it sorted without others efforts.
lots of projects to sort but distance sensing is useful for my projects.
I would like to try these V53L0X (and TOF10120) now on Arduino with GCB.
My Arduino's (Nano, Uno and Mega) arrived yesterday and was trying it on gcb with here my findings:
1. When connecting it to the pc all the arduino's where not recognized and I needed to install a driver for the CH341SER Chinese clone Arduino serial chips.
2. For the Arduino NANO and UNO it was enough for the boards to work with gcb by testing it by flashing only the on-board LED (portB.5).
3. The Arduino Mega2560 however the LED does NOT flash at all.
The Mega2560 was recognized by Windows Device Manager in Port(COM & LPT) as USB-SERIAL CH340 (COM6) and I was able to program the Mega2560.
To flash the on-board LED did not work.
I did switch between Programmers in the GCB-Preferences to "Arduino Mega2560".
This is the code I used:
What did I do wrong?
Add
#option explicit
to your program (as you always should do).This will help you.