Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8082

Automation, sensing and robotics • Re: Programming a shipmodel and transmitter continued 2.0

$
0
0
These steppers are not so simple https://www.kollino.de/arduino/schrittmotor-28byj-48/
One of the problems is that the 'gear ratio' is not an integer (depending on what motor type you have).

I would propose to design a class which handles the current state and the desired set position. The commands from the radio module should be sent to a command input queue; the class should have a thread which handles the movements. This thread also allows a quick series of over the air commands to be processed. This avoids delay/commands lost when lengthy movements occur on the steppers.

An interesting point is that when the system is shut down then the zero point is lost. Either you need a 'zero point switch' or some procedure to 'set zero point' aka trim command.

For the set value, current value angle calculations, this could be like this, (simplified, zero dist not handled; hopefully correct):
current is in [0..3599]
set in [0..3599]

dist = set - current;
pos_rotation_distance = 0;
if ( current < set) pos_rotation_distance = dist; // dist > 0
if ( current > set) pos_rotation_distance = 3600 + dist; // dist < 0

neg_rotation_distance = 0;
if ( current < set) neg_rotation_distance = 3600 - dist; // dist > 0
if ( current > set) neg_rotation_distance = - dist; // dist < 0

// pos_rotation_distance > 0
//neg_rotation_distance > 0
if (pos_rotation_distance < neg_rotation_distance) move_pos_direction( pos_rotation_distance );
else move_neg_direction( neg_rotation_distance );

For each step done, incr or decr current by 1 and perform a modulo 3600.

Statistics: Posted by ghp — Mon May 12, 2025 9:31 pm



Viewing all articles
Browse latest Browse all 8082

Trending Articles