Search code examples
sensorsbatteryjoystickcontiki

Contiki OS on Zolertia Z1 - Conflicting activation of phidget and battery sensors?


I build a small game controller for the Z1. I have a process reading values from a Joystick sensor. It works fine.

Then, I added a second process, reading the value of the battery sensor every 5 minutes. But it makes the Joystick stop working: the value does not update anymore!

I found a workaround: when I have to read the value of the battery, I deactivate the phidget_sensor, activate the battery_sensor, read the value and then deactivate the battery_sensor and reactivate the phidget_sensor.

But I would like to know why I can not have both sensors activated at the same time ?

Thanks


Solution

  • Comes from Here.

    The ADC is the "analogue to digital converter", basically is the component that provides you the voltage signal levels of an analogue sensor, so then it can later be used to translate to a meaningful value.

    What happens is the battery sensor driver and the phidget driver each when starts configures the ADC on its own, thus overwriting the ADC configuration.

    The expected use of both of these components is actually how you are actually using: enable, measure, then disable. This way you ensure at all times the ADC is configured the way your application expects. If you want to have this done in a single operation then I'm afraid you will need to modify probably the phidget driver and include this.

    I hope this is the answer you expected, as you are asking why does this happens.