MuntyScruntfundle
Posts: 235
Joined: Fri Oct 27, 2017 11:14 pm

Measuring PRi PWM cycles?

Fri Dec 15, 2017 5:49 pm

Hi folks.

Is there any built in way to measure the movement of a motor controlled with the PWM modules?

It would be really handy for my app to have a 'return to home' button. My first thought is to have a variable that tracks the amount of time the motor has been turning in either direction, I guess this would work, but I'm not sure it would be very accurate.

Any thoughts?

Many thanks.

Heater
Posts: 16548
Joined: Tue Jul 17, 2012 3:02 pm

Re: Measuring PRi PWM cycles?

Fri Dec 15, 2017 6:20 pm

If you are driving a motor using PWM you basically have no idea how far the motor moves in response to your drive signal. It will vary according to the load on the motor and so on. Besides, how does the Raspi even know what the position of the motor was when it starts?

As a minimum you need something to sense the "home" position, then you can drive the motor in the home direction until the home position is detected. Could be as simple as a micro-switch connected to a GPIO input pin. https://en.wikipedia.org/wiki/Miniature ... ion_switch which is often used for such things.

Hmmm....I assume you are not using a servo?
Memory in C++ is a leaky abstraction .

Return to “General discussion”