from tinkerforge.bricklet_industrial_quad_relay import IndustrialQuadRelay

if __name__ == '__main__':
    try:
        host = sys.argv[1]
        port = int(sys.argv[2])
        uid = sys.argv[3]
        pin = int(sys.argv[4])
        trigger = int(sys.argv[5])
        wait = int(sys.argv[6])
    except:
        print('usage: {0} <host> <port> <iqr-uid> <relay> <trigger-duration> <wait-duration>'.format(sys.argv[0]))
        sys.exit(1)

    ipcon = IPConnection()
    iqr = IndustrialQuadRelay(uid, ipcon)
    sema = Semaphore(0)

    ipcon.connect(host, port)

    def monoflop_done(selection_mask, value_mask):
        sema.release()

    iqr.register_callback(iqr.CALLBACK_MONOFLOP_DONE, monoflop_done)
    iqr.set_monoflop(1 << relay, 1 << relay, trigger)

    sema.acquire()
    sleep(wait / 1000.0)

    ipcon.disconnect()
    take_photo()

    steps += STEPS_PER_ROTATION
    if steps >= FULL_ROTATION:
        lock.release()
        return

    print "Starting next rotation: " + str(steps / STEP_MODE * 1.8) + "°"
    print
    stepper.set_steps(STEPS_PER_ROTATION)


if __name__ == "__main__":
    ipcon = IPConnection()  # Create IP connection
    stepper = Stepper(UID_STEPPER, ipcon)  # Create device object
    iqr = IndustrialQuadRelay(UID_QUAD_RELAY, ipcon)

    ipcon.connect(HOST, PORT)  # Connect to brickd
    # Don't use device before ipcon is connected

    stepper.full_brake()
    stepper.disable()

    stepper.set_motor_current(1000)
    stepper.set_step_mode(STEP_MODE)
    stepper.set_max_velocity(100)

    stepper.set_speed_ramping(25, 25)

    stepper.register_callback(stepper.CALLBACK_POSITION_REACHED,
                              lambda x: cb_reached(stepper, ipcon, x))
#!/usr/bin/env python
# -*- coding: utf-8 -*-

HOST = "localhost"
PORT = 4223
UID = "ctG" # Change to your UID

VALUE_A_ON  = (1 << 0) | (1 << 2) # Pin 0 and 2 high
VALUE_A_OFF = (1 << 0) | (1 << 3) # Pin 0 and 3 high
VALUE_B_ON  = (1 << 1) | (1 << 2) # Pin 1 and 2 high
VALUE_B_OFF = (1 << 1) | (1 << 3) # Pin 1 and 3 high

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_industrial_quad_relay import IndustrialQuadRelay

if __name__ == "__main__":
    ipcon = IPConnection() # Create IP connection
    iqr = IndustrialQuadRelay(UID, ipcon) # Create device object

    ipcon.connect(HOST, PORT) # Connect to brickd
    # Don't use device before ipcon is connected

    iqr.set_monoflop(VALUE_A_ON, 15, 1500); # Set pins to high for 1.5 seconds

    ipcon.disconnect()
Beispiel #4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

HOST = "localhost"
PORT = 4223
UID = "ctG"  # Change to your UID

VALUE_A_ON = (1 << 0) | (1 << 2)  # Pin 0 and 2 high
VALUE_A_OFF = (1 << 0) | (1 << 3)  # Pin 0 and 3 high
VALUE_B_ON = (1 << 1) | (1 << 2)  # Pin 1 and 2 high
VALUE_B_OFF = (1 << 1) | (1 << 3)  # Pin 1 and 3 high

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_industrial_quad_relay import IndustrialQuadRelay

if __name__ == "__main__":
    ipcon = IPConnection()  # Create IP connection
    iqr = IndustrialQuadRelay(UID, ipcon)  # Create device object

    ipcon.connect(HOST, PORT)  # Connect to brickd
    # Don't use device before ipcon is connected

    iqr.set_monoflop(VALUE_A_ON, 15, 1500)
    # Set pins to high for 1.5 seconds

    ipcon.disconnect()