Menu

V53L0X

2020-05-24
2021-01-19
1 2 > >> (Page 1 of 2)
  • stan cartwright

    stan cartwright - 2020-05-24

    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.

    #chip mega328p, 16
    #option Explicit
    ;for terminal distance out
    #define USART_BAUD_RATE 9600
    #define USART_TX_BLOCKING
    #define USART_DELAY 1 ms
    ;set up v53l0x
    #define HI2C_DATA PORTC.5;sda
    #define HI2C_CLOCK PORTC.4 ;scl
    #define HI2C_BAUD_RATE 400
    HI2CMode Master
    
    dim distance_lo,distance_hi as byte
    
    HI2CStart ;software restart
    HI2CSend(0x52)
    HI2CSend(0x89)
    HI2CSend(0x01)
    HI2CStop
    wait 200 ms
    do ;------------------------
      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
    
      hserprint " Distance: "+str(distance_hi*256+distance_lo)+" mm ";
     loop
    
     
  • stan cartwright

    stan cartwright - 2020-05-24

    I intend to use the v53l0x on a robot that avoids obstacles.
    the
    dim distance_lo,distance_hi as byte
    and

    #define distance distance_hi*256+distance_lo ;...so just use distance
    

    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.....

     
  • Haroen

    Haroen - 2020-12-12

    I will try this ASAP with some help when I receive mine from China.

     
  • stan cartwright

    stan cartwright - 2020-12-12

    They are good for 1 metre or so. good luck

     
  • George Towler

    George Towler - 2020-12-12

    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.

     
  • Anobium

    Anobium - 2020-12-12

    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.

     
  • stan cartwright

    stan cartwright - 2020-12-12

    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

     
    • Anobium

      Anobium - 2020-12-12

      Cool video. I just 'liked' it!

      The code clearly works. :-)

       
    • George Towler

      George Towler - 2020-12-13

      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.

       
  • stan cartwright

    stan cartwright - 2020-12-12

    @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
  • Haroen

    Haroen - 2020-12-13

    @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.

     
  • stan cartwright

    stan cartwright - 2020-12-13

    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

     
  • Haroen

    Haroen - 2020-12-14

    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.

     
    • stan cartwright

      stan cartwright - 2020-12-14

      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

       
  • stan cartwright

    stan cartwright - 2020-12-14

    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
  • Haroen

    Haroen - 2020-12-15

    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.

     
  • stan cartwright

    stan cartwright - 2020-12-15

    @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.

     
  • Haroen

    Haroen - 2020-12-15

    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.

     
  • stan cartwright

    stan cartwright - 2020-12-16

    @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
  • Haroen

    Haroen - 2020-12-17

    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.

     
    • stan cartwright

      stan cartwright - 2020-12-17

      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

       
  • Haroen

    Haroen - 2020-12-17

    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
  • stan cartwright

    stan cartwright - 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.

     
  • Haroen

    Haroen - 2021-01-16

    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:

    #chip mega2560, 16
    
      #define Led DIGITAL_13 'OnBoard LED
      Dir Led Out
    
       Do
          Set Led On
          Wait 1 s
          Set Led off
          Wait 1 s
        Loop
    

    What did I do wrong?

     
    • Anobium

      Anobium - 2021-01-16

      Add #option explicit to your program (as you always should do).

      This will help you.

       
1 2 > >> (Page 1 of 2)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.