I actually want cognew to complete first
lardom
Posts: 1,659
I'm completing an object that runs two steppers differentially which requires two cogs. Other operations can be executed by a single cog. I wanted to test a few robot commands such as "Rotate Left, Rotate Right, Accelerate, Arc Left and Decelerate...repeat 3"
The only way I've been able to get the test to run properly is to write waitcnt(clkfreq * 6 + cnt) which is the time it takes for the two-cog operation to execute. I was thinking I must be missing something.
The only way I've been able to get the test to run properly is to write waitcnt(clkfreq * 6 + cnt) which is the time it takes for the two-cog operation to execute. I was thinking I must be missing something.
PUB test | a, b repeat 3 workin.Spin_Left 'eight bit pattern workin.Start_B(a, b) 'two cognew commands waitcnt(clkfreq * 6 + cnt) 'wait for methods to finish
Comments
In your case, I'd modify .Start_B something like this:
there is a variant of the bresenham-algorithm for circles (or eliptic curves) that is able to create circle-moving with just one cog.
Aattached some documentation of the math.
Maybe the step/dir-gen-code from Mat-At-Work is useful to: it offers synchronised cogs
http://forums.parallax.com/showthread.php/142705-Step-Dir-signal-generator-for-CNC?
best regards
Stefan
-Phil
Rather than starting and stopping cogs, just use variable(s) for command processing or other data interaction. I use mailboxes for everything requiring event changes or other communications. Waiting for cogs to start is wasteful in my book.
I agree that starting cogs is wasteful and I wish I could find a single object/method call for the 'differential' operation.
It should be pointed out that that paper is AFAICT just wrong about helical paths - the Bressenham's circle algorithm is not constant angular velocity (not at all) so it can't be naively
tacked on to a Z-axis movement to give a true helix.