On Wed, 18 Feb 2015 20:38:24 +0800, Bruce Varley wrote:> On Tue, 17 Feb 2015 13:03:50 -0600, Tim Wescott > <seemywebsite@myfooter.really> wrote: > >>On Tue, 17 Feb 2015 20:14:02 +0800, Bruce Varley wrote: >> >>> On 16 Feb 2015 09:22:17 GMT, al.basili@gmail.com (alb) wrote: >>> >>>>Hi everyone, >>>> >>>>I have to control a sinusoidal BLDC through a PWM and an H-bridge, >>>>following a profile written in a table. >>>> >>>> I have encoders reading as feedback but I have not quite well >>>>understood how to measure the difference between the position table >>>>and the encoders reading. >>>> >>>>In general if the encoder reading is in the same turn as the table >>>>than everything is fine: >>>> >>>>p = 78 deg (position) >>>>m = 75 deg (measure) >>>> >>>>e = p - m = 3 deg >>>> >>>>But when I cross the 0 deg (360 deg) I have some stupid issues with >>>>signs: >>>> >>>>p = 359 deg m = 1 deg >>>> >>>>e = p - m = 358 deg >>>> >>>>while I would like to get -2 deg! >>>>Even with modulo function I'd not be better off: >>>> >>>>e = mod(p - m, 360) = 358 deg! >>>> >>>>Should it be dependent on the quadrant I'm in? >>>> >>>>I'm missing some basics here. And yes, a pointer to elementary school >>>>math is definitely appreciated! >>>> >>>>Al >>> >>> Have just solved this very problem for filtering the signal from a >>> wind indicator that sends an analog signal of 0 - 360 degrees. In >>> order to remove the discontinuity, you need to determine when it's >>> crossed, and in which direction, this requires a suitably fast >>> scanning rate. Say then that the direction goes 355-358-2, then you >>> know that the angle has 'increased'. So add 360 to get 362 degrees. >>> You can then apply a modulo function to get 2. Going the other way, >>> eg. 5-2-357, subtract 360 to get -3. The operation is fully >>> symmetrical in each direction. You extend the range of the angle to >>> +/- infinity, then use modulus to bring it back to a real range. >>> >>> If the rotation is always one way and the extended angle value is >>> likely to get very large in one direction, you need to do a reset when >>> it goes above a trigger value. >>> >>> You can also deal with this using coss and sins and their inverses, >>> but that's rather inelegant IMO. >> >>Yes, encoders can be an excellent way to measure motor speed, but only >>if you can insure that you sample the encoder position faster than twice >>per revolution. > > Hey, that's a nice visualisation of Shannons theorem (I think).I think it has some relation to Shannon's sampling theorem on more than a superficial level -- but I'm not sure what it is. I don't think it's a 1:1 correspondence. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
encoders measurements in speed control loop
Started by ●February 16, 2015
Reply by ●February 20, 20152015-02-20







