wokwi / wokwi-elements

Web Components for Electronics and IoT Parts
https://elements.wokwi.com/
MIT License
185 stars 49 forks source link

Stepper motor with two limit switches #147

Open DarwinWasWrong opened 1 year ago

DarwinWasWrong commented 1 year ago

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 commented 1 year ago

https://github.com/wokwi/wokwi-features/issues/444

DarwinWasWrong commented 1 year ago

image

various sizes with pins image

urish commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

image

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

image

DarwinWasWrong commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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:

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 commented 1 year ago

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