VL6180X on PICAXE08M2

Gustavo70

New member
Buenas tardes, necesito ayuda con el código para hacer funcionar el sensor vl6180x con un picaxe08m2.
Tengo conectado el sensor aL PIN 5 con SDA Y PIN 6 con SCL del sensor. Además hay un Led en el PIN
3. La idea es que cuando el sensor detecte algo próximo, unos 50mm, se enciende el LED.
Disculpen si no publico el circuito, creo se entiende como lo he conectado. Si es necesario publico el código que estoy utilizando, pero no me funciona para nada.
Agradecería si me pueden ayudar.
Saludos
 
Last edited by a moderator:

AllyCat

Senior Member
Hi,
Good afternoon, I need help with the code to make the vl6180x sensor work with a picaxe08m2.
I have connected the sensor to PIN 5 with SDA AND PIN 6 with SCL of the sensor. There is also a LED on the PIN
3. The idea is that when the sensor detects something close, about 50mm, the LED lights up.
Sorry if I don't publish the circuit, I think you understand how I connected it. If necessary I publish the code I am using, but it doesn't work for me at all.
I would appreciate if you can help me.
Greetings
Welcome to the forum. Have you seen the program in THIS THREAD particularly post #8 ? But it's difficult to predict what might be wrong with your program (or hardware) if you don't post any details !

Cheers, Alan.
Bienvenido al foro. ¿Has visto el programa en ESTE HILO particularmente en la publicación n.° 8? ¡Pero es difícil predecir qué podría estar mal con su programa (o hardware) si no publica ningún detalle!

Saludos, Alan.
 

Gustavo70

New member
Hi,

Welcome to the forum. Have you seen the program in THIS THREAD particularly post #8 ? But it's difficult to predict what might be wrong with your program (or hardware) if you don't post any details !

Cheers, Alan.
Muchas gracias por tu respuesta. Este es el códico que utilicé con el picaxe08m2.
El led enciende y apaga porque no logro poder medir con el vl6180x. El conexionado está bien.
Code:
Symbol I2CSpeed = i2cslow

Symbol VL6180X = 0x52    'ALS/proximity sensor

Symbol GPIO1 = B.0
Symbol GPIO1Pin = pinB.0


init:

  hi2csetup i2cmaster, VL6180X, I2CSpeed, i2cbyte      'Announce there will be I2C
  hi2cout 0x010, (0)                                                        'Disable (Hi-Z) GPIO0
  hi2cout 0x011, (%00010000)                                        'Set GPIO1 as interrupt pin
  hi2cout 0x014, (0)                                                        'Disable all interrupts for testing
'  hi2cout 0x2A3, (1)                                                        'Interleaved mode of range and ALS measurements
  hi2cout 0x018, (%00000001)                                        'Start range measurements only
  hi2cout 0x01B, (%00000010)                                        '20ms in between measurements
  hi2cout 0x02D, (0)                                                        'Disable signal-to-noise, range-ignore and convergence features

main:

  hi2cin 0x000, (b0) 
  sertxd (#b0, LF, CR)
  pause 100
 
  IF b0 < 50 THEN
      high c.4
  else
    low c.4
    END IF

goto main
 

AllyCat

Senior Member
Hi,
init:
hi2csetup i2cmaster, VL6180X, I2CSpeed, i2cbyte 'Announce there will be I2C
The first obvious difference is that bgrabowski and edmunds have used I2CWORD not I2CBYTE. The reason is explaned by inglewoodpete in post #6 of the linked thread above: "You will see that the last addressable register is at 0x2A3, requiring more than a byte to address it."

I have not looked at the Data Sheet to see why their initialisation routines are more complex than yours:
Code:
' Load the required settings onto the VL6180X
Init_I2C:            
' Mandatory register settings
    Address_16 = 0x0207
    Data_Byte = 0x01
    GoSub Write_I2C
;  ETC.  =  MORE THAN 30 bytes WRITTEN
Cheers, Alan.
La primera diferencia obvia es que bgrabowski y edmunds han usado I2CWORD, no I2CBYTE. El motivo lo explica inglewoodpete en la publicación número 6 del hilo vinculado anteriormente: "Verá que el último registro direccionable está en 0x2A3, lo que requiere más de un byte para direccionarlo".

No he mirado la hoja de datos para ver por qué sus rutinas de inicialización son más complejas que las suyas:
Code:
'Carga la configuración requerida en el VL6180X
Inicio_I2C:
'Configuraciones de registro obligatorias
   Dirección_16 = 0x0207
   Byte_datos = 0x01
   GoSub Escritura_I2C
; ETC. = MÁS DE 30 bytes ESCRITOS
Saludos, Alan.
 
Last edited:

Gustavo70

New member
Estimado Alan!!. Muchas gracias por tu ayuda, finalmente logré que funcionara el VL6180X con el Picaxe08m2, utilicé el código que me indicaste,
publicación número 6 del hilo.
Cordiales Saludos
 
Top