Page 3 of 4
Re: Heightsensor VL6180
Posted: Mon Aug 24, 2015 2:18 pm
by mwall002
Here is the vl6180x.c code (make file code in the previous post). I obviously call the vl6180xInit function in the vl6180x.h file. I don't see any reason why it doesn't print just like the eeprom code.
Code: Select all
#define DEBUG_MODULE "vl6180x"
#include "stm32fxxx.h"
#include "FreeRTOS.h"
#include "task.h"
#include "console.h"
#include "config.h"
#include "param.h"
#include "vl6180x.h"
#include "debug.h"
#include "eprintf.h"
#include "i2cdev.h"
#include "stdint.h"
#include "string.h"
#include "log.h"
static uint8_t devAddr;
static I2C_Dev *I2Cx;
static bool isInit;
bool vl6180xInit(I2C_Dev *i2cPort)
{
DEBUG_PRINT("vl6180x connection [OK].\n");
I2Cx = i2cPort;
devAddr = VL6180X_I2C_ADDR;
if (isInit)
return true;
I have tried the debug_print inside and outside of the if statement and it doesn't matter.
Re: Heightsensor VL6180
Posted: Wed Aug 26, 2015 8:01 am
by tobias
You makefile looks OK to me so I don't think it is that. You can check the compiler output to see that your file is there or look in the bin folder that the object file vl6180x.o is there. You could also try making an obvious compile error to see that the file gets compiled.
Are you calling the vl6180xInit function from system.c or where do you call the init? If you have your code in a fork on github you could commit it and I could give it a quick try.
Re: Heightsensor VL6180
Posted: Thu Aug 27, 2015 12:02 am
by mwall002
It is compiling and is creating the .o file.
I'm calling the vl6180xInit( ) function from the vl6180x.h file just like the eeprom.h file. But I see there is a configblockeeprom.c file in the utils folder that is also calling the eepromInit( ) function. Is that is the one that is really working?
I will work on getting my project going on git hub. Thanks again for all of your help.
Re: Heightsensor VL6180
Posted: Mon Aug 31, 2015 12:13 am
by mwall002
Hi Tobias,
I made some good progress over the weekend. The sensor is now initializing and testing OK (even debug_printing now!!). I just need to get the default settings loaded into the sensor and it to begin reading the distance.
Here is my code for you to check out
https://github.com/mwall002/crazyflie-f ... 02-patch-1. Hopefully I used github correctly, I have never used it like that before.
Do I need to call all of the function in the system.c file to get them to work? Thanks again for all the help
Re: Heightsensor VL6180
Posted: Tue Sep 01, 2015 8:04 am
by tobias
That is good news!
Do I need to call all of the function in the system.c file to get them to work?
Yes you should call the init function from there. When it comes to doing the actual ranging I would put it in the
stabalizer task as it gets called repeatedly.
Re: Heightsensor VL6180
Posted: Thu Sep 03, 2015 2:37 am
by mwall002
Thanks Tobias. The function is already called in stabilizer.c. Maybe if you get a chance, can you look at my code? Not sure what to try next.
I think the get register functions are working since that is how it is initializing but I have a feeling the set register functions aren't actually working with the sensor.
Re: Heightsensor VL6180
Posted: Fri Sep 04, 2015 6:12 am
by tobias
Have you checked that the data, e.g.
here, that you read is correct? Is there any WO_AM_I register you can read to check this?
One possible problem might be the
endianness when reading and writing.
I see that you don't call the loop function in stabilizer.c you defined anywhere. I would start by calling it from
here and it will be read at 100Hz.
Re: Heightsensor VL6180
Posted: Mon Sep 07, 2015 6:23 am
by mwall002
VL6180X_IDENTIFICATION_MODEL_ID (0x0000) should return 0xB4 if it is working correctly... and when I put the following code in it is not.
Code: Select all
status = i2cdevRead16(I2Cx, devAddr, VL6180X_IDENTIFICATION_MODEL_ID, 2, &data);
if (status == 0xB4)
{
DEBUG_PRINT("vl6180x Initialized.\n");
i2cdevWrite16(I2Cx, devAddr, VL6180X_SYSTEM_FRESH_OUT_OF_RESET, 1, 0);
}
else DEBUG_PRINT("vl6180x FAILED to Initialize.\n");
Could this be the endianness problem you are referring to? How can I Debug_Print the status value? I am not sure where to start to even try to fix it..
Also, I found code written in C from ST Microelectronics for the vl6180x sensor meant for integrating with projects like this, which probably solves all of these issues but it seems even more complicated and I don't know how to integrate it either
http://www.st.com/web/en/catalog/tools/PF261710#. It's the download button down at the bottom.
Re: Heightsensor VL6180
Posted: Mon Sep 07, 2015 1:33 pm
by tobias
It would probably be better to us ST driver. We actually got a protoboard with the vl6180 now. I will try to find some time to give it a try tonight.
Re: Heightsensor VL6180
Posted: Wed Sep 09, 2015 5:40 am
by mwall002
Can't wait to see what you are able to do with your vl6180x.
