Electronic spindle gearbox

More
11 years 7 months ago #56537 by andypugh
Replied by andypugh on topic Electronic spindle gearbox
You seem to have some surplus spaces in the relay output names, but you have probably found those by now.

The main problem with the comp is that you can't wait. Execution has to run right through every time or the thread will over-run.

Typically to wait you use the fperiod macro and a counter:
Code:
variable timeout; ... ;; if (condition){ if (timeout > 0){ timeout -= fperiod; } else { timeout = 10 } } ...

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #56565 by microsprintbuilder
Haven't seen any of the issues you talk about I'm new to programming c. I was thinking that you would want to constantly monitor the commanded speed and if it changes ranges then interrupt the spindle command , wait until the spindle slow command, change the parameters then reengage the spindle command. I'm not real pontificate in programming so I'm taking some online courses. I'm thinking a while loop is what I should use. Does that sound right?

I've been writing and testing in classic ladder because that's what I know best and have wrote something like the following. if commanded speed is <=1200 its gear 1 if it's 1200> and < 2500 it's gear 2 and if its >=2500 it's gear 3 then if the commanded gear # different than set gear # stop spindle wait for spindle slow and then set the gear. then wait a second and turn the spindle back on. also somewhere in the mix needs to be if its this gear true these parameters are true. I wrote this in classic ladder to test my theory and it seams to work. I did't impalement it into my machine just ran in ladder changing the values thou.

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #56567 by andypugh
Replied by andypugh on topic Electronic spindle gearbox

microsprintbuilder wrote: I'm thinking a while loop is what I should use. Does that sound right?.


Only of the loop is guaranteed to exit in a known time much less than the thread period.

Bear in mind that the code gets called every thread period. If it hasn't finished when it is called again then very bad things happen....

So, to "wait" in a HAL component you set a flag or timer, then check whether the wait has finished the next time the component is run. You don't wait inside the code.
The following user(s) said Thank You: SOLD

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #56570 by microsprintbuilder
gotcha, so how do you determine the waited time amount?

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #56571 by andypugh
Replied by andypugh on topic Electronic spindle gearbox

microsprintbuilder wrote: gotcha, so how do you determine the waited time amount?


"fperiod" is a variable that is supplied in a .comp that tells you the period of the thread that the function is running in. You can therefore add or subtract "fperiod" from a static variable (or HAL pin) to track how long the wait has been.

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #56572 by microsprintbuilder
is the timeout = 10 ten seconds? or ten of something else?

Please Log in or Create an account to join the conversation.

Time to create page: 0.074 seconds
Powered by Kunena Forum