Komet
-
Gesamte Inhalte
2 -
Benutzer seit
-
Letzter Besuch
Posts erstellt von Komet
-
-
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 IPConnectionfrom tinkerforge.bricklet_rs232_v2 import BrickletRS232V2from tinkerforge.brick_master import BrickMasterfrom tinkerforge.bricklet_industrial_counter import BrickletIndustrialCounterimport timeHOST = "localhost"PORT = 4223UID = "6eSrKP" # Change XXYYZZ to the UID of your Master BrickUID_RS = "W9P"UID_COUNTER = "QV8"ipcon = IPConnection() # Create IP connectionrs232 = BrickletRS232V2(UID_RS, ipcon) # Create device objectcounter = BrickletIndustrialCounter(UID_COUNTER, ipcon) # Create device objectipcon.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 = 0speed = 40while 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 directionrs232.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))
How to get the HAT Brick UID without brick viewer
in General Discussion
Geschrieben · bearbeitet von Komet
Hello,
Which sensors do you want to use, there is really well made example code in the doc for python ? No idea how you can get the UID without brick viewer