Hello everyone, I purchased the encoder module and the encoder itself. I am going to control the speed of the motor by setting the input value with an encoder, and the output signal will be 0-10 V(0-200 rpm), which will be applied to the input of the frequency converter. Encoder module WAGO 750-631 / 000-011 has a pulse counter that increments or decrements the value depending on the direction of rotation of the encoder. But I can't hard-code this counter because I can set the speed directly from the interface (absolute value). I need to somehow track only the change in the value on the counter for a certain amount of time (for example, 1 sec) and add this value to the value that is currently outputting.
Example: I set the engine speed to 100(5 V out) rpm via the interface. On the counter (encoder module) the value (conditionally) 63 is set, I turned the encoder and increased the value by 120 rpm(6 V out), the value on the counter became 263, 1 pulse is equal to the change in revolutions by 0.1 rpm(0.005 V out). Then I again set 50 (2.5 V out) rpm through the interface, but since I am not tied to the output rigidly, the counter remained at 263 and then I want to add again, so I only need to track the change in the counter value per unit of time, please tell me how best to do it, with some blinks, timers or interrupts, so far nothing comes out for me.
some very basic psuedocode, but seems something like this should get you sorted. will need to watch for rollovers and call this at some relevant interval...
timeDelta:=timeNow - lastTime;
counterDelta:=CounterVal - lastCounterVal;
Thank you for your answer
So, I put this in one block and can I call this block with a blink, say once every 500 ms? And instead of CounterVal, there should be an address to the counter value at the moment?
Just run this solution in a separate task if you must (every x msec) and then write the value's into a global var list (GVL) from which you read in a slower / different task.
Log in to post a comment.