r/c circuit problem
mikea
Posts: 283
in Propeller 1
I'm using an r/c circuit to read a pot, and output pwm on a different pin. The circuit diagram I started with shows a 1uf cap and 10k ohm pot. In the serial terminal I see the pot value go up and voltage rise on the pwm pin as the pot goes from zero to 10k ohm. When the pot is almost to the mechanical limit, the pwm pin voltage goes to zero and stays there. I changed the capacitance to .8uf and this problem went away. It works fine now, but I would like to understand why the output pin quit working. I do have a 100ohm resistor between the pot and ground so at the zero end it won't be a short, but the problem occurs at the higher resistance end. The r/c pin goes to +capacitor, and one side of pot. Wiper goes to -capacitor through 100ohm res. to ground.
Comments
Your measured poti value may go higher than the PWM range, and you don't have it limited to the max possible PWM value. In this case the PWM uses just the lower bits and starts again at zero for higher values.
Say your PWM works with 8 bits and goes therefore from 0 to 255. If you give it a value of 256, it's the same as 0, a value of 257 is the same as 1 and so on.
Andy
With lower capacitance the max. poti value you get will be lower.
But I see you limit the potivalue anyway to 1..255. There is a little chance that the potivalue gets picked by the PWM cog before it is limited, so it would be better to limit it in the same line as you do the scaling:
I think the actual problem is in your PWM code. You modify the PWM frequency according the potivalue, which is not how this kind of PWM normally is done. The pwm periode and therefore your wt value should be constant, and the puls modulation is done by the counter phsa values. Something like:
With lower p values you can make the PWM much faster, if you need it. Or you can improve the resolution of the PWM.
Andy
Yes, but it does need 2 pins, - one IP sense pin, and a Charge Balancing output pin + sundry passives.]
A Sigma Delta does not have the Cap C value, or Pot R value as part of the timing equation - that makes it more repeatable, especially in production volumes.
SDM is also linear with voltage, and thus linear with 3 terminal wired pot rotation.