Changing the " waitcnt" on the fly.
msiriwardena
Posts: 301
I have successfully constructed the "Computer controlled air/steam engine" which was featured in
the March 2011 Edition of NUTS and VOLTS.
I have the engine running with air using a propeller but does not run very smoothly.
I think if I can change the timing on the fly using " waitcnt" - it will run better.
I really need some help here with code as I am not a good programmer.
Thank you.
Siri
P.S - The code I am using is attached.
the March 2011 Edition of NUTS and VOLTS.
I have the engine running with air using a propeller but does not run very smoothly.
I think if I can change the timing on the fly using " waitcnt" - it will run better.
I really need some help here with code as I am not a good programmer.
Thank you.
Siri
P.S - The code I am using is attached.
Comments
Just keep in mind that division by YourVariable will result in an integer.
EDIT: markaeric might be right about your other programming issues; I was just answering the question about waitcnt.
Also, welcome to the forum!
This loop will always run the amount of time (clock ticks) specified in the global variable valvetiming, no matter which path is taken in the loop. Be careful, though, if valvetiming is too small then the waitcnt target will be missed and you'll end up with a big problem. Note, too, that ":= 1" is faster than "~~" and easier for Spin newbies to comprehend.
I will add a repeat loop to the main Pub.My reason for running continuous loops is because since the the continuously rotates it needs to read the - Total dead Center(High point of the piston at each stroke) and also to read the lower most position - to get the intake and exhaust valves to open/close.
By the way I am using an old 2 stroke gasoline engine from a old weed-whacker - just the block and cylinder only.
What I am planing is to program another Pub to change the waitcnt using UP and Down buttons - so I an change the timing on the fly.The Hall-Effect sensors that I am using does not
get correct timing.
ElectricAye - This exactly what I had in mind but I wan't to change the value of the variable on the fly.
Thanks for the quick reply. - Going to change some code as suggested.
Siri
I will make changes as you suggested and try it.
Thanks
Siri