Variable pitch belt driven spindle

More
6 years 6 months ago #163706 by fungus
I dug into some windows line endings issues, but it changed nothing in the behavior.
I wrote a python script in place of the bash script, same deal.
I'm frustrated and tired, sounds like a good time to sleep and consider spending time on the realtime version later. Wish I could have the last 7 hours back!
Apparently there are some issues with the scripting side, or at least with the way I'm doing it. If anyone has ideas, I'd love to figure out what's wrong for future use cases.

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

More
6 years 6 months ago #163843 by fungus
Ok, first C program I've ever written. I'm sure there are issues.

Once I get the encoder fitted I can make sure the counts are above a certain value rather than the "spindle_spinning" bit I'm using right now.

One issue I might see happening is if a request comes through for a float RPM (say 40.5RPM), this might freak out the S32? I'm also probably not using it correctly.
Code:
component varipitch "Controls the range of a variable pitch belt"; pin in bit spindle_spinning "spindle is turning"; pin in bit range_0 "range 0 sensor"; pin in bit range_1 "range 1 sensor"; pin in bit range_2 "range 2 sensor"; pin in s32 spindle_rpm_req "requested RPM"; pin out bit speed_up "increases range if too low"; pin out bit speed_down "decreases range if too high"; function _ nofp; license "GPL"; option singleton yes; ;; #define ZERO_RANGE 1000 #define ONE_RANGE 2500 #define TWO_RANGE 3500 FUNCTION(_) { if(spindle_spinning){ if(spindle_rpm_req <= ZERO_RANGE){ while(!range_0){ speed_down = 1; } speed_down = 0; speed_up = 0; } else if(spindle_rpm_req > ZERO_RANGE && spindle_rpm_req <= ONE_RANGE){ while(!range_1){ if(range_0){ speed_up = 1; } else if(range_2){ speed_down = 1; } } speed_down = 0; speed_up = 0; } else if(spindle_rpm_req > ONE_RANGE && spindle_rpm_req <= TWO_RANGE){ while(!range_2){ speed_up = 1; } speed_down = 0; speed_up = 0; } else { speed_down = 0; speed_up = 0; } } }

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

More
6 years 6 months ago #164104 by fungus
Potential feature creep ahead...

As it sits right now, I am using the gearchange component to handle my spindle backgear. After I get done with this automated belt adjuster, I will need to externally handle the ratios for gearchange.
I see a couple options to combine this.
I have six potential ratios: LOW 1, LOW 2, LOW 3, HIGH 1, HIGH 2, HIGH 3.
For portability reasons, it would be great to not have these ratios hardcoded into the component.

I could either make 6 float input pins (one for each ratio), then one float output (basically letting you set the ratios external to the realtime component)
~OR~
I could use multiple logic outputs that selected external ratios based on HAL logic (I'm still fuzzy on exactly how I would implement this, probably with mux-gen?)

I'm leaning toward the second option. Any experienced perspectives here?
If I need to start a different thread for the current topic of RT component building, please advise.

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

More
6 years 6 months ago #164122 by rodw
Have a look at lincurve. It may do what you want.

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

More
6 years 6 months ago #164140 by fungus
Say, that looks very graceful.
So it looks like I could leave my "varipitch" component as a nofp, and use a single s32 out to drive the x of the "lincurve" component.
~OR~
Completely external to the component, I could drive the x of "lincurve" with the incoming RPM request.

I need to do something, however, to limit the spindle speed during these changes. If I use the first option, I can keep sensible spindle request speeds until the belt drive is in the correct ratio, whereas I would be entirely at the mercy of requested RPM and current belt position in the second option (read: potential overdrive condition)

Thank you rodw for the recommendation, and Andy for another great component!

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

More
6 years 6 months ago #165180 by fungus
Yahoo! Got it working this evening. Not that what I've done is pretty, but would this be something worth packing up for reuse?
The following user(s) said Thank You: tommylight

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

Time to create page: 0.151 seconds
Powered by Kunena Forum