I am using servo motor to lift an object to a particular position (ex 90degree). I want to differentiate the weight of 3 objects. So heavier object will draw more current to lift the object. I am planning to use high side current sensor (ZXCT1009) using shunt resistor connected to the servo motor. So when the servo is moving and lifting the object, i want the current sensor to read the output voltage to give to an ADC.
This is the PWM code,
if(a=0,a>30,a++)
{
portd.f7=1;
delay_us(1000);
portd.f7=0;
delay_us(19000);
}
My question is, where should i put the code [adc();]to read the output voltage?
because i only can measure the voltage different, only when the servo is moving to 90 degrees. When it moves, the current will pass through the shunt resistor and the servo. When it stop, the current will be zero.
Thanks.