9 years, 4 months ago.

PWM reading

Hi,

I am using PWMin library in conjunction with p16 on the LPC1768 to read RC values being passed down. The problem is that I cannot get a good value for the any of the parameters (PW,DutyCycle,Period).

The numbers for all 3 params come out positive, zero, negative and bounce back n forth. The numbers seem to be all integers that continuously change over and over.

I did put a scope on the p16 and clearly there is a pulse width there and doesnt change unless I change the throttle value on the remote. Print outs are sent thru UART through XBEE to the computer.

Code to relevant to this : << code>> PwmIn throttle_in(p16); float throt_temp=0.0; float throt_per=0.0; float throt_dut=0.0; throt_dut=throttle_in.dutycycle(); throt_temp=throttle_in.pulsewidth(); throt_per=throttle_in.period(); pc_Xbee->printf("\t ThrottlePW = %d\n\r",throt_temp); pc_Xbee->printf("\t ThrottlePER = %d\n\r",throt_per); pc_Xbee->printf("\t ThrottleDUT = %d\n\r",throt_dut); <</code>>

output RC off: ThrottlePW = 0 ThrottlePER = 0 ThrottleDUT = 0 output RC on to minimum position:

ThrottlePW = 1073741824 ThrottlePER = 1073741824 ThrottleDUT = -1610612736 ThrottlePW = -1073741824 ThrottlePER = 536870912 ThrottleDUT = -1073741824 ThrottlePW = -1073741824 ThrottlePER = 1073741824 ThrottleDUT = -536870912 ThrottlePW = -1073741824 ThrottlePER = 1610612736 ThrottleDUT = 536870912

As you can see its all over the place. The only thing I can think of is that the RC feeds 1.2 Volt not 3.3V ^ if this is the issue how can I fix this?

Thank you.

Be the first to answer this question.