Jump to content

Industrial counter on incremental encoder position drift


Komet
 Share

Recommended Posts

Hello everybody,

 

I'm working on an industrial special machine and i want to control some part of it with bricklet. My machine can do round trip on a rail with a motor and its coder. the PLC keep the control of all the power, I just send him order with a RS232 bricklet.

For a first test i want to go to 30 000 counts, wait 2 seconds and then go back to my initial position ( 0 ) and repeat forever. Here is the issue : my machine drift in a single direction about some centimeters each time. When I control it directly by the PLC i haven't that and I don't understand why it does it with the counter bricklet.

the coder is a sew eurodriver EH1C, I connect CH0- and CH2- to GND and CH0+ and CH2+ to A & B

Here is my code :

 

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_rs232_v2 import BrickletRS232V2
from tinkerforge.brick_master import BrickMaster
from tinkerforge.bricklet_industrial_counter import BrickletIndustrialCounter
import time
 
HOST = "localhost"
PORT = 4223
UID = "6eSrKP" # Change XXYYZZ to the UID of your Master Brick
UID_RS = "W9P"
UID_COUNTER = "QV8"
 
ipcon = IPConnection() # Create IP connection
rs232 = BrickletRS232V2(UID_RS, ipcon) # Create device object
counter = BrickletIndustrialCounter(UID_COUNTER, ipcon) # Create device object
ipcon.connect(HOST,PORT)
 
counter.set_counter_configuration(counter.CHANNEL_0,
                                      counter.COUNT_EDGE_RISING,
                                      counter.COUNT_DIRECTION_EXTERNAL_DOWN,
                                      counter.DUTY_CYCLE_PRESCALER_1,
                                      counter.FREQUENCY_INTEGRATION_TIME_1024_MS)
counter.set_all_counter_active([True, False, False, False])
counter.set_counter(0, 0)
 
i = 0
speed = 40
 
while True :
   
    message = [chr(i),chr(i),chr(i),chr(i),chr(i),chr(i),chr(i),chr(speed),chr(2)] # the first 7 control IR power the 8th the speed and the 9th the direction
    rs232.write(message)
    time.sleep(2)
 
    message = [chr(i),chr(i),chr(i),chr(i),chr(i),chr(i),chr(i),chr(speed),chr(1)]
    rs232.write(message)
    while counter.get_counter(0)<75000:
        print(counter.get_counter(0))
 
    message = [chr(i),chr(i),chr(i),chr(i),chr(i),chr(i),chr(i),chr(speed),chr(2)]
    rs232.write(message)
    time.sleep(2)
 
    message = [chr(i),chr(i),chr(i),chr(i),chr(i),chr(i),chr(i),chr(speed),chr(0)]
    rs232.write(message)
    while counter.get_counter(0)>0:
        print(counter.get_counter(0))
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...