Getting "Counter" Simulink block to switch direction?

17 ビュー (過去 30 日間)
Adam
Adam 2011 年 3 月 7 日
コメント済み: Noor Zeid 2016 年 4 月 27 日
Hey all,
I am trying to get position feedback using a quadrature encoder in Simulink. I'm using the "counter" block in Simulink to count pulses and correlate that to distance. The problem I'm having is I need to counter block to switch from increment to decrement when the encoder is turning in the opposite direction. It looks like the only way to do this is to change the count direction from UP to DOWN in the block. Is there a way to do this with a signal in Simulink? I know it can be done in Labview.
Basically, I need a block like FIGURE 3 in the following link:
Thanks!
adam
  1 件のコメント
Curtis
Curtis 2014 年 4 月 26 日
That National instruments block is exactly what I need as well. I tried putting it together with detect change, but the counting keeps running away. Maybe you can only do in C++ s-functions or state flow.

サインインしてコメントする。

回答 (7 件)

Guy Rouleau
Guy Rouleau 2011 年 3 月 8 日
I do not recommend using the Counter block for that. The counter block could be used to simulate the behavior of your sensor.
Using a few basic blocks like Memory and Sum, maybe a Detect change and a Triggered subsystem, you should be able to get what you are looking for.

Fangjun Jiang
Fangjun Jiang 2011 年 6 月 27 日
Based on Walter's suggestion, you could use a Switch block (or Manual Switch block) to pass either 1 or -1 and integrate it. It will go up or down based on your switch.

jack
jack 2011 年 3 月 8 日
have you solved the problem yet? im facing the same problem here as well

Adam
Adam 2011 年 3 月 9 日
I ended up doing something different. I don't think there is a way to switch the block automatically. You can make a work around using edge detect and two counters, then subtracting them to get a total count. Let me know if you have questions, I can send you an image of my block diagram. It counts up in one direction and down in another, depending on which input phase is leading.
  1 件のコメント
Noor Zeid
Noor Zeid 2016 年 4 月 27 日
Hi I am having the same problem, can you help me with this? I need to take a look at the block diagram my email is: nozeid@gmail.com

サインインしてコメントする。


elahe bakhtiari
elahe bakhtiari 2011 年 6 月 26 日
Hi.Do you solve this problem?"The problem I'm having is I need to counter block to switch from increment to decrement when the encoder is turning in the opposite direction."I need to have such block.please help me. can you help me?
  2 件のコメント
Walter Roberson
Walter Roberson 2011 年 6 月 26 日
Perhaps an integrator block would be appropriate?
elahe bakhtiari
elahe bakhtiari 2011 年 6 月 27 日
Can you explain this idea please?

サインインしてコメントする。


James
James 2012 年 5 月 23 日
Hope to get and answer for this too. I manage read the angular velocity from pulse reading but am stuck on how to detect direction change.

shayan
shayan 2012 年 7 月 18 日
Hello Adam;
Can you please send me the image of your block as I am also going through same sort of problem.

カテゴリ

Help Center および File ExchangeAdditional Math and Discrete についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by