Hi everyone, a friend asked me to help him fix a polyester/plastic cutting machine.
In simple terms, he has two stepper motors (
https://www.oyostepper.com/) connected to an H-bridge, driven by pulses for stepping and two other inputs for direction. I'm supposed to make a bunch of routines where the main routine will read three parameters, an X, a Y, and a TIME value. Based on these values, the subroutines will generate two pulses within TIME (clock), one called X (which will trigger the motor to move on the X axis) and the other called Y.
I don't know what the best way to implement this is. I thought about using an equidistant clock (which would be a different clock, "created" by the picture), which should at least be the triggering time for the FET transistors in the bridge. I then have two variables, crtx and crty. They are initially set to 0 and are decremented once per clock (I will only refer to the clock created by the picture here, not the actual clock created using a crystal. The reason I need this is because this time slice needs to be modifiable). When they underflow (is there such a word?

) I would reset them to default values (e.g. every 3 pulses for x, every 97 pulses for y) which would be taken from another set of x/y variables and set their respective pins high for one clock.
I've done something similar before, generating PWM (on a 12F675) that was able to vary the intensity of three leds without multitasking but comparing their "current" values to thresholds. I think it's somewhat similar to this, but I'm not sure.
What do you think? What's the best approach I should use?