Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

High side measurement Current Sensor

Status
Not open for further replies.

gilardino

New Member
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.
 
I think that you should sample the current at the end of the "1" period:

Code:
for( a=0, a<30, a++) {
    portd.f7 = 1 ;
    delay_us( 1000) ;
    [B]my_analog = adc() ;[/B]
    portd.f7 = 0 ;
    delay_us( 19000) ;
}
 
The function adc() has a delay built in to wait for the ADC to do it conversion. If you do it like this you can do the conversion without changing you delay.

Code:
for( a=0, a<30, a++) {
    delay_us( 500) ;   // let current stablize
    portd.f7 = 1 ;
    startAdcConversion();  // fake function name
    delay_us( 500) ;
    my_analog = adcResult() ; // fake function name
    portd.f7 = 0 ;
    delay_us( 19000) ;
}
Check your compiler docs for the correct adc function names of write your own.

The delay times will need adjusting. You need a scope to see how long it takes the current to settle.

My motors do not turn with 1/20th duty cycle :)

3v0
 
thanks.

i don't understand why the on time 1000us need to be split into 500us before the portd.f7=1. Referring to the code, not the total time only become 19500us because the first 500us is not included inside the duty cycle?Correct me if i am wrong...:)

And i only know my_analog=adc result is where we calculate the ADC. I do not understand the startADC conversion(). What is the difference?

Thanks...
 
Is there some kind of gear mechanism that causes a latching action on your arm, because normal servo's still draw quiet a bit of current when at their set position. At 90 degrees if there's feedback from the gear train the current through the servo will be proportional to the weight on the swing arm. In motion the current will sway dramatically.
 
yes. I tried it already. It has small current through the servo. But are there are any current differences if the servo swing to 90degrees with carrying different weights? I tried attaching something to servo to make it heavier,but there are no any differences. The value of the small current remains the same.
 
The only thing I can think of is to either redesign the gear train so there's feedback from a static load on the servo arm, or 'shake' the arm back and forth at a set point and measure the RMS current.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top