Using 2 sensors with 1 motor controll

Hello Guys,

I am quite new and thought about some cool usecases of this amazing project. I thought about using two sensors with one closed-loop control motor and switch between them. It could enable the ability to have a redundant backup sensor or a second sensor for different usecases.

To get it to work, I thought about switching the sensors with motor.linkSensor(&sensor1) to motor.linkSensor(&sensor2) in the loop()-Function. This works when the sensors have similiar alignment. I tested it with a different sensor and different sensor position (inverted turn direction) but sadly this didnt work.
Is there a way to get it work? Or a workaround which I didnt think of?

Thank you in advice.

Liam

Hey @LiamMaxwell,
This could work but you need to be careful how you do it.

  1. you need to align both sensors with the motor, find both sensors motor.zero_electric_angle and remember it. You could first likn one sensor then do initFOC remember its motor.sensor_direction and motor.zero_electric_angle, then do the same for the second sensor.
  2. You need to call the sensor.update() function in the loop for the sensor that is not used with FOC (the one used for the foc will have update called in the loopFOC)
  3. When you switch in between sensors make sure to
    1. linkSensor
    2. change motor.zero_electric_angle
    3. change motor.sensor_direction
    4. add the other sensors sensor.update() call in the loop

Thank you for your fast answer. I try it :smiley:

Some of the sensors are available in redundant automotive configurations. In this case one sensor IC has two complete sensors in the same IC.
Not sure if this would be interesting to you…

https://www.allegromicro.com/en/products/sense/linear-and-angular-position/angular-position-sensor-ics/a1333

Hi, @Antun_Skuric,
today Ive tested your suggestions. Sadly its not working, when I call initFOC() the first sensor is initializing but when I call it a second time the second sensor doesnt initialize. The first sensor is a AS5048 and I have no problems working with it. So I think the problem has something to do with the other sensor. This sensor is a Megatron ETA25, its a single turn hall sensor with analog output.

EDIT: I found my problem: This sensor behaves not like a normal analog sensor. Cause it can spin indefinitly and starts after one rotation at 0. Is there a way to implement this sensor?

Thank you in advance.

Liam