Variable Repeat
T Chap
Posts: 4,223
Xrun80 := some serial incoming integer that changes repeat Xrun80 'some stuff Xrun80 := (some formula of a newly received number added to Xrun80) term.dec(Xrun80) ' changes as input is received
I could be issing this somehow but the Xrun80 is showing as is should, it changes as new info received. However, the repeat is sticking with the first value received no matter what.
Any suggestions on how to update a repeat variable?
Comments
What do you actually·want to use for the number of times through the loop?· Do you want to stop when Xrun80 reaches a particular value?· In that case, using "repeat until Xrun80 == 0" might be what you want.· You could still decrement Xrun80 within the repeat loop which would probably give you what you want.
·
What I want to do is, while the main loop is running the motor to a destination X, if new position is rec'd, update the repeat loop to reflect the change. Xrun80 means 80% of the total length of travel. 10% goes to the accel loop length (with <# 500 max). 10% is the ramp down. So the 80% main run is able to be changed. If the direction is changed, the main loop exits to a ramp down. The nice thing about this approach is, the longer the length of travel, the smaller the rampup pauses get, meaing that for a long move, the speed increases, for short moves, the speed is low as the accel loop only had 10% of X to use, so it added less is that makes sense.
To answer your question though finally, I want to use (X(new pos) - Xcurrent pos)) - (X/10 +x/10). In other words, the New minus the Current - 20%. I have everything done except the repeat loop that can auto-adjust on incoming positions. Took about 20 hours to get the ramping just right and to be able to alter the motion without stopping or noticing anything being added. What happens now is that the last phase of the move(decel) is picking up any update in position and adding it to it's ramp down iteration size. The Xrun80 never hits 0 in this context. Not sure how to implement that. I was thinking for tring for next. The method didn't work as suggested btw.
Post Edited (originator99) : 11/8/2006 5:10:39 AM GMT
Post Edited (originator99) : 11/8/2006 8:54:17 AM GMT