TL;DR version: How do I count pulses with programmable digital and use the count to shut off 5 PWMs. The count to shut off and the frequency of the PWMs would have to be set in software for each iteration.
I'm trying to figure out a good way to use programmable digital of the PSoC 4 on the pioneer kit to do coordinated stepper moves. Setting up a PWM module was pretty easy, I just need something to shut it off after a set number of pulses. The black box description is this, the software sets the pulse frequency for several modules, 5 in this case, with the timing already calculated so that they will finish their pulses in the same amount of time, then it starts them at the same time, then they all shut off when they're done and signal (probably via interrupt) back to the software that the move is done and they are ready for the next. I'm thinking the architecture would use one PWM module as the master, if there are not timing glitches they would all finish together, it would stop them, and interrupt that the move was done.
So far I have found that I can easily set a PWM module for a certain frequency from the software, but I'm not sure how to make a counter shut it off. The algorithm is pretty simple for these moves, you have a known speed in pulses at which each axis can move given the electrical and mechanical limitations of the system, given the number of steps required for a move on each axis and that speed you can find which one will take the longest, and divide the number of pulses for all the others to make them happen in that amount of time. At that point most controllers just use timers to generate and count those pulses, I'd like to figure out a nice efficient way to do it in programmable digital. I think it should be pretty simple if I can just figure out how to count pulses with a counter, then I would have it trigger an interrupt and stop the PWMs when the target is reached, can someone show me how to do that? I'd also be interested in other hardware architectures that can do this.
As a note, this is for the smarter life challenge, I'm not really worrying about my competitors seeing my code. If I win I want it to be by making the coolest project, not because they got stuck.
Thanks for reading