Encoder_get_tick_count() function not working

Greetings URCommunity,
I have the following script being sent via socket to a C# app.

def program():
set_standard_digital_out(3, True)
global var_1 = encoder_get_tick_count(0)
halt
end

When I run it, the value I get for var_1 is always 0 and yet I have a conveyor moving and an encoder.
If I type this on the teach pendant I will get a value different than 0 so I don’t really know what I am doing wrong.
Any help is much obliged
Best regards,
Pedro Monforte

Hi Pedro, have you initialized the encoder? You need to initialize it once before you can actually get the values from it.
Example: decode hall encoder quadratic signals on digital input 8 and 9:
encoder_enable_pulse_decode(0,1,8,9)

var_1=encoder_get_tick_count(0)

You might get incorrect encoder values after emergency stop, see my previous topic here: Pulse decoder function encoder_get_tick_count is drifting away after emergency stop or robot arm poweroff

Best regards,
Csaba

Hi Csaba,
Thank you for replying so promptly
I had tried that before and I still did not get any results.
I wrote a program on the teach pendant to do the exact same thing and it works perfectly.
It is only when I want to send a script via socket that I am unable to get the encoder tick.
var_1 always get a value of 0

I’ve tried just about everything with this. At one point I was reading and assigning a value. But the number it returned was a float which makes no sense for an encoder and the number itself was counting negative to positive. My thought is that this function was created for a virtual/simulated encoder and not a real one. If you solve this please let me know. All I wanted to do was reset an encoder value to zero at a certain spot and follow for a set number of pulses.

Two questions
Why is there a habit to say pins 8&9 even though standard ur10 comes with 0-7 digial inputs and especially for encoder you have to use pins 0-3 as they are the ones connected to the decoder.
Second question, this method does not reset the ticks I am getting continous ticks