Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stepper motor with two limit switches #147

Open
DarwinWasWrong opened this issue Dec 21, 2022 · 14 comments
Open

Stepper motor with two limit switches #147

DarwinWasWrong opened this issue Dec 21, 2022 · 14 comments

Comments

@DarwinWasWrong
Copy link

Making a element as the stepper motor but with 2 limit switches

At present the number of steps is fixed at 14000 from limit to limit

stepperlimits

@DarwinWasWrong
Copy link
Author

wokwi/wokwi-features#444

@DarwinWasWrong
Copy link
Author

image

various sizes with pins
image

@urish
Copy link
Collaborator

urish commented Dec 22, 2022

Thanks! My current thought is that it'll probably make more sense to have the limit switches element separate from the stepper motor, even though I'm not sure yet how.

Do you have a specific use case for the stepper motor with limit switches in mind?

@DarwinWasWrong
Copy link
Author

I was unsure if there was a method to report the number of steps the stepper unit (as a separate element) to the limit switch element if they were separate.

the reason for the limit switches is for homing and limit usage - such as with a unit like a cnc, robotic arm etc

I am doing a project at present
https://wokwi.com/projects/350617907511689812
where I am emulating a product placement machine which has a table and a shelf
this uses limit switches for home positions and calibration

@DarwinWasWrong
Copy link
Author

image

been working on the graphics as well and looking at sideways options

image

@DarwinWasWrong
Copy link
Author

I did end up making a limit switches "chip"

image

this takes the direction and steps from the controller pins and keeps score -
if its over home_threshold - it outputs on home
if its over limit_threshold - it outputs on limit

works ok but doesnt look that nice

@urish
Copy link
Collaborator

urish commented Jan 1, 2023

I did end up making a limit switches "chip"

Good work! Mind sharing the link so people who need it can take inspiration in the future?

We'll probably have a way to customize the look of chips later this year, so it'll both work ok and look nice!

@DarwinWasWrong
Copy link
Author

Working on the variables etc.
When I said messy, it was more to be on the requirement for additional wires that don't exist in real life.

since there is no "channel" to link or report steps from the stepper as we are really looking at physical not electrical.

@urish
Copy link
Collaborator

urish commented Jan 4, 2023

since there is no "channel" to link or report steps from the stepper as we are really looking at physical not electrical.

It's a good point. I'm trying to think of other use cases for such "channels". Internally, we have something similar for the IR Receiver / IR Remote, even though for IR the channel is "global", and here we need a private channel - a way to link a stepper and its corresponding limit switch.

@DarwinWasWrong
Copy link
Author

I cant think of any other situation where a mechanical link would be required. Apart from an positional encoder.
I am moving back to the idea of adding the switches as options to the stepper itself - much like the arrow etc
select one or two switches - set the limits in number of steps.

@urish
Copy link
Collaborator

urish commented Jan 9, 2023

Thanks! What would a positional encoder look like?

My intuition says that it makes sense to have the graphics for the limit switches separate from the motor. Another direction, which is probably worth exploring, is some kind of a physics playground - where the simulation models (e.g. custom chips) could control the 2d position (rotation too?) of some of the elements in the diagram. This way, one could build potentially build custom setups involving several motors (#119 comes to mind). These are just some initial thoughts, and definitely much more complex than what you are proposing.

@DarwinWasWrong
Copy link
Author

the encoder would be part of the motor.
For example in tinkercad you have a motor, but then you have another element with is motor with encoder
image

@avonwyss
Copy link

I'm new to Wokwi so I might be missing something, however I also wanted to simulate something with endstops and was surprised to find that there doesn't seem an easy way to do this yet.

What about the follwing general approach, which should cover pretty much any "physical simulation" case:

  • Let physical elements such as motors, leds etc. publish one or several "physical state variables". In the case of the stepper here this would be the number of steps, any maybe also the current angle.
  • Allow input elements, such as the PushButton or the IR Receiver, consume other "physical state variables" using a formula to represent their own state, e.g. "button pushed: $stepper1.steps >= 14000" - or something with some logic "button pushed: $stepper1.steps >= 14000 && $stepper2.steps <= 1000".

One could then also add some purely physical display elements such as linear gauges to visually represent the physical state. Some elements, such as a potentiometer which is not hooked up, could be used as source for publishing manually manipulated physical state during simulation (such as provide ambient temperature, or some other physical input).

I think this approach could cover most (if not all) physical things one might want to simulate.

One thing to consider: Some elements, such as a PushButton, may both publish a physical state, and consume physical states. In this case, there could be dependencies across multiple elements, so that a order of evaluation would have to be determined. This would be static for the duration of the simulation; loops should be disallowed.

@DarwinWasWrong
Copy link
Author

https://discord.com/channels/787627282663211009/1106462441048653855

yeah there was some discussion on this.
I was looking at how the IR remote unit sends commands to the ir receiver - thinking this might be an avenue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants