microcontroller solution using interrupts, including code
* microcontroller polling mode, including code
... there are many thousands sites, documents, examples, even videos in the internet. Just do a search.
Blue box:
As said, for the given requirements you don't need a microcontroller at all. We just see: step/dir in, step/dir out. So we miss informations what it is good for. Please tell us.
Hello
KlausST,
While I acknowledge your statement about my NOT understanding of step/dir and encoder, I disagree with your conclusion that I am trying to find a solution for a non-existent problem.
The context is, I want to learn the encoder, the step/dir, and the microcontroller programming and I want to combine everything together and learn the mechanism by playing with the code and probing the waveforms.
Here are my inputs to your comments and any feedback is highly appreciated.
(1)
[KlausST] If you just want the functions 1), 2) and 3) .... what keeps you from directly connecting the encoder to the step/dir driver (no need for red and blue boxes at all)
[ my Answer:
(a) direct connect the rotary encoder to the step/dir driver is to create an open loop system, while in my case this is a closed loop system, which uses the step/dir signals and also the feedback signal from the encoder signal from the motor's rotation. This encoder is not the rotary encoder
(b) you can say a typical use case is to let dir/step run in an open loop condition. However, in my case, I want to follow the multiple examples online to create the closed-loop system, so I can play with the PID control library.
(c) in addition to the closed loop one, if you look at my signal from the rotatry encoder, you can see we definably cannot connect them together to the step/dir directly. The rotary encoder's output in channel A and channel B are normally high and only dips to 0V, while the step signal should be a normally low signal with some pulses, and the dir signal is either high or low. I think you also realized this because you also mention this in some of your comment
(d) in my immediate need, I t want the functions 1), 2) and 3) ...., but in my final implementation, I want to use my manual rotation speed to control the speed of the motor as well. Therefore, I want to solve the problem one by one.
(2)
[KlausST] Red box: What's the benefit of a rotary-to-step/dir interface in front of a microcontroller? The red box has two digital inputs and two digital outputs, and the "position information" comes with the same frequency on both sides. So in either case you need to decode a two-input-signal "simultaneously" because you never know which one comes first.
The red box usually is used when there is a solution without microcontroller.
Thus for every solution:
* hardware using logic ICs
* hardware using PLD including code
* microcontroller solution using interrupts, including code
* microcontroller polling mode, including code
[Answer:
in no.2 of my previous questions, I tried to do this as a part of the microcontroller, which means it is the same as the green box. As I mentioned in (d) part of the answer to your question 1, I do not know MCU, step/dir, and encoder enough to see if I should make its first order right]
(3) [KlausST] Blue box: As said, for the given requirements you don't need a microcontroller at all. We just see: step/dir in, step/dir out. So we miss informations what it is good for. Please tell us.
[Answer: if you look at my schematic carefully, you can see this is a closed-loop system. The blue box is a simple driver that converts the command signal to the power level, while the step/dir in of it should be a processed signal based on the PID control code inside the microcontroller]
(4) [KlausST] In either case I recommend to do an internet search and to watch some videos ... to understand how the encoder and the driver works. ..
Then find out "if there is a problem at all".
And if there is:
* tell us your requirements (especially the problematic ones)
* tell us the problem you see
* don't try to find a solution without a clear description of the problem
... there are many thousands sites, documents, examples, even videos in the internet. Just do a search.
[Answer:
I acknowledge that if I'm asking a straightforward question that can be easily answered with a quick Google search, it's my responsibility to search before asking. However, this project is something I came up with on my own, and I've put effort into learning both from theory and practical aspects. I'm asking questions based on the unique hardware on my bench and the specific problems I'm facing. It is not something I can get by a simple search.
While I appreciate your time and technical input, your comment doesn't directly address my issue or positively contribute to the community. It discourages me from further participating in discussions on this forum.]