Example #1
0
def init_hardware():
    watchList = []

    # load low-level drivers
    rt.loadrt('hal_bb_gpio',
              output_pins='807,808,810,819,828,840,841',
              input_pins='809,831,832,833,835,837,838')
    prubin = '%s/%s' % (c.Config().EMC2_RTLIB_DIR, c.find('PRUCONF', 'PRUBIN'))
    rt.loadrt(c.find('PRUCONF', 'DRIVER'),
              pru=1,
              num_stepgens=4,
              num_pwmgens=3,
              prucode=prubin,
              halname='hpg')

    # Python user-mode HAL module to read ADC value and generate a thermostat output for PWM
    defaultThermistor = 'semitec_103GT_2'
    hal.loadusr(
        'hal_temp_bbb',
        name='temp',
        interval=0.10,
        filter_size=5,
        cape_board='CRAMPS',
        r_pu=2185,  # measured value of my 2.2k pullup resistor
        channels='04:%s,05:%s' %
        (c.find('HBP', 'THERMISTOR', defaultThermistor),
         c.find('EXTRUDER_0', 'THERMISTOR', defaultThermistor)),
        wait_name='temp')
    watchList.append(['temp', 0.2])

    base.usrcomp_status('temp', 'temp-hw', thread='servo-thread')
    base.usrcomp_watchdog(watchList,
                          'estop-reset',
                          thread='servo-thread',
                          errorSignal='watchdog-error')
def init_storage(fileName):
    # Python user-mode HAL module for storing values
    hal.loadusr('hal_storage',
                name='storage',
                file=fileName,
                autosave=True,
                wait_name='storage')
Example #3
0
def init_hardware():
    watchList = []

    # load low-level drivers
    rt.loadrt('hal_bb_gpio', output_pins='816,822,823,824,825,826,914,923,925', input_pins='807,808,809,810,817,911,913')
    prubin = '%s/%s' % (c.Config().EMC2_RTLIB_DIR, c.find('PRUCONF', 'PRUBIN'))
    rt.loadrt(c.find('PRUCONF', 'DRIVER'),
              pru=0, num_stepgens=6, num_pwmgens=6,
              prucode=prubin, halname='hpg')

    # Python user-mode HAL module to read ADC value and generate a thermostat output for PWM
    defaultThermistor = 'semitec_103GT_2'
    hal.loadusr('hal_temp_bbb',
                name='temp',
                interval=0.05,
                filter_size=1,
                cape_board='CRAMPS',
                channels='04:%s,05:%s,02:%s,03:%s'
                % (c.find('HBP', 'THERMISTOR', defaultThermistor),
                   c.find('EXTRUDER_0', 'THERMISTOR', defaultThermistor),
                   c.find('EXTRUDER_1', 'THERMISTOR', defaultThermistor),
                   c.find('EXTRUDER_2', 'THERMISTOR', defaultThermistor)),
                wait_name='temp')
    watchList.append(['temp', 0.1])

    base.usrcomp_status('temp', 'temp-hw', thread='servo-thread')
    base.usrcomp_watchdog(watchList, 'estop-reset', thread='servo-thread',
                          errorSignal='watchdog-error')
Example #4
0
def init_hardware():
    watchList = []

    # load low-level drivers
    rt.loadrt('hal_bb_gpio',
              output_pins='816,822,823,824,825,826,914,923,925',
              input_pins='807,808,809,810,817,911,913')
    prubin = '%s/%s' % (c.Config().EMC2_RTLIB_DIR, c.find('PRUCONF', 'PRUBIN'))
    rt.loadrt(c.find('PRUCONF', 'DRIVER'),
              pru=0,
              num_stepgens=6,
              num_pwmgens=6,
              prucode=prubin,
              halname='hpg')

    # Python user-mode HAL module to read ADC value and generate a thermostat output for PWM
    defaultThermistor = 'semitec_103GT_2'
    hal.loadusr('hal_temp_bbb',
                name='temp',
                interval=0.05,
                filter_size=1,
                cape_board='CRAMPS',
                channels='04:%s,05:%s,02:%s,03:%s' %
                (c.find('HBP', 'THERMISTOR', defaultThermistor),
                 c.find('EXTRUDER_0', 'THERMISTOR', defaultThermistor),
                 c.find('EXTRUDER_1', 'THERMISTOR', defaultThermistor),
                 c.find('EXTRUDER_2', 'THERMISTOR', defaultThermistor)),
                wait_name='temp')
    watchList.append(['temp', 0.1])

    base.usrcomp_status('temp', 'temp-hw', thread='servo-thread')
    base.usrcomp_watchdog(watchList,
                          'estop-reset',
                          thread='servo-thread',
                          errorSignal='watchdog-error')
Example #5
0
def setup_tclab():
    #import hal_tclab
    # from hal_tclab import prepare
    # prepare()
    hal.loadusr("hal_tclab",
                name="hal_tclab",
                wait_name="hal_tclab",
                wait_timeout=30)
    hal.Pin("hal_tclab.enable").link(hal.Signal("ALLenable"))
Example #6
0
def main():
    c.load_ini('hardware.ini')

    init_hardware()
    configure_stepgen()
    create_rcomp()
    setup_functions()

    # ready to start the threads
    hal.start_threads()

    # start haltalk server after everything is initialized
    # else binding the remote components on the UI might fail
    hal.loadusr('haltalk', wait=True)
Example #7
0
    def __init__(self):
        self.pru = rtapi.loadrt('hal_pru_generic', 
            pru=0, num_stepgens=5, num_pwmgens=0, halname='hpg',
            prucode='%s/xenomai/pru_generic.bin' % (config.Config().EMC2_RTLIB_DIR))

        hal.addf('hpg.capture-position', SERVO_THREAD)
        hal.addf('hpg.update', SERVO_THREAD)
        hal.addf('bb_gpio.read', SERVO_THREAD)
        hal.addf('bb_gpio.write', SERVO_THREAD)

        for i in xrange(5):
            self.get_pru_pin('stepgen.%02i.dirsetup' % i).set(200)
            self.get_pru_pin('stepgen.%02i.dirhold' % i).set(200)
            self.get_pru_pin('stepgen.%02i.steplen' % i).set(1000)
            self.get_pru_pin('stepgen.%02i.stepspace' % i).set(1000)
            self.get_pru_pin('stepgen.%02i.dirpin' % i).set(self.pru_dir_pin(i))
            self.get_pru_pin('stepgen.%02i.steppin' % i).set(self.pru_step_pin(i))
            self.get_pru_pin('stepgen.%02i.maxvel' % i).set(0)
            self.get_pru_pin('stepgen.%02i.maxaccel' % i).set(0)

        self.pwm = hal.loadusr(USR_HAL_PATH + 'hal_replicape_pwm',
            name='replicape_pwm',
            wait_name='replicape_pwm')

        self.watchdog_sigs = []
        for pin in self.get_watchdog_pins():
            s = hal.newsig('replicape.watchdog.%d' % len(self.watchdog_sigs), hal.HAL_BIT)
            pin.link(s)
            self.watchdog_sigs.append(s)
Example #8
0
def setupGyro(thread='base_thread'):
    name = 'balance'
    sigReq = hal.newsig('%s-req' % name, hal.HAL_BIT)
    sigAck = hal.newsig('%s-ack' % name, hal.HAL_BIT)
    sigDt = hal.newsig('%s-dt' % name, hal.HAL_FLOAT)
    sigNewAngle = hal.newsig('%s-new-angle' % name, hal.HAL_FLOAT)
    sigNewRate = hal.newsig('%s-new-rate' % name, hal.HAL_FLOAT)

    gyroaccel = hal.loadusr('./hal_gyroaccel', name='gyroaccel',
                            bus_id=1, interval=0.05,
                            wait_name='gyroaccel')
    gyroaccel.pin('req').link(sigReq)
    gyroaccel.pin('ack').link(sigAck)
    gyroaccel.pin('dt').link(sigDt)
    gyroaccel.pin('angle').link(sigNewAngle)
    gyroaccel.pin('rate').link(sigNewRate)
    gyroaccel.pin('invert').set(True)  # invert the output since we mounted the gyro upside down

    kalman = rt.loadrt('kalman', 'names=kalman')
    hal.addf(kalman.name, thread)
    kalman.pin('req').link(sigReq)
    kalman.pin('ack').link(sigAck)
    kalman.pin('dt').link(sigDt)
    kalman.pin('new-angle').link(sigNewAngle)
    kalman.pin('new-rate').link(sigNewRate)
Example #9
0
def setupGyro(thread='base_thread'):
    name = 'balance'
    sigReq = hal.newsig('%s-req' % name, hal.HAL_BIT)
    sigAck = hal.newsig('%s-ack' % name, hal.HAL_BIT)
    sigDt = hal.newsig('%s-dt' % name, hal.HAL_FLOAT)
    sigNewAngle = hal.newsig('%s-new-angle' % name, hal.HAL_FLOAT)
    sigNewRate = hal.newsig('%s-new-rate' % name, hal.HAL_FLOAT)

    gyroaccel = hal.loadusr('./hal_gyroaccel',
                            name='gyroaccel',
                            bus_id=1,
                            interval=0.05,
                            wait_name='gyroaccel')
    gyroaccel.pin('req').link(sigReq)
    gyroaccel.pin('ack').link(sigAck)
    gyroaccel.pin('dt').link(sigDt)
    gyroaccel.pin('angle').link(sigNewAngle)
    gyroaccel.pin('rate').link(sigNewRate)
    gyroaccel.pin('invert').set(
        True)  # invert the output since we mounted the gyro upside down

    kalman = rt.loadrt('kalman', 'names=kalman')
    hal.addf(kalman.name, thread)
    kalman.pin('req').link(sigReq)
    kalman.pin('ack').link(sigAck)
    kalman.pin('dt').link(sigDt)
    kalman.pin('new-angle').link(sigNewAngle)
    kalman.pin('new-rate').link(sigNewRate)
Example #10
0
    def _create_lamp_control(self):
        blink_interval_s = 0.5
        interval_s = 0.1
        name = 'lamp-control'
        hal.loadusr('lamp_control.py -n {} -i {}'.format(name, interval_s),
                    wait_name=name)
        lamp = hal.components[name]
        lamp.pin('power-on').link('power-on')
        lamp.pin('estop-active').link('estop-active')
        lamp.pin('blink-interval').set(blink_interval_s)
        lamp.pin('lamp-red').link('lamp-red')
        lamp.pin('lamp-green').link('lamp-green')
        lamp.pin('lamp-yellow').link('lamp-yellow')
        lamp.pin('signal').link('lamp-signal')

        self.user_comps.append(
            UserComp(name=name, timeout=(interval_s * TIMEOUT_OVERHEAD)))
Example #11
0
    def __init__(self):
        self.gpio = rtapi.loadrt('hal_bb_gpio', 
            output_pins='', 
            input_pins='810,809,924,818,923,925,916,918,911,913')

        self.dac = hal.loadusr(USR_HAL_PATH + 'hal_replicape_dac',
            name='replicape_dac',
            wait_name='replicape_dac')

        self.hwconfig = hal.loadusr(USR_HAL_PATH + 'hal_replicape_A4_hwconfig',
            name='replicape_hwconfig',
            wait_name='replicape_hwconfig')

        for i in xrange(5):
            # Default: microstepping=1/32, fast decay
            self.hwconfig.pin('stepper.%i.microstepping' % i).set(config.find('FDM','STEPPER_%i_MICROSTEPPING' % i, 5))
            self.hwconfig.pin('stepper.%i.decay' % i).set(config.find('FDM','STEPPER_%i_DECAY' % i, 0))

        super(ReplicapeA4A, self).__init__()
Example #12
0
    def __init__(self):
        self.gpio = rtapi.loadrt('hal_bb_gpio', 
            output_pins='', 
            input_pins='810,809,924,818,923,925,916,918,911,913')

        self.dac = hal.loadusr(USR_HAL_PATH + 'hal_replicape_dac',
            name='replicape_dac',
            wait_name='replicape_dac')

        self.hwconfig = hal.loadusr(USR_HAL_PATH + 'hal_replicape_A4_hwconfig',
            name='replicape_hwconfig',
            wait_name='replicape_hwconfig')

        for i in xrange(5):
            # Default: microstepping=1/32, fast decay
            self.hwconfig.pin('stepper.%i.microstepping' % i).set(config.find('FDM','STEPPER_%i_MICROSTEPPING' % i, 5))
            self.hwconfig.pin('stepper.%i.decay' % i).set(config.find('FDM','STEPPER_%i_DECAY' % i, 0))

        super(ReplicapeA4A, self).__init__()
Example #13
0
    def _init_gripper(self):
        if not self.tool.startswith('hand_e'):
            return

        name = 'robotiq-gripper'
        interval_s = 0.1
        hal.loadusr(
            'robotiq_modbus.py -n {name} -i {interval} -s {serial}'.format(
                name=name, interval=interval_s, serial=ROBOTIQ_USB_SERIAL_ID
            ),
            wait_name=name,
        )
        self.user_comps.append(
            UserComp(name=name, timeout=(interval_s * TIMEOUT_OVERHEAD))
        )

        comp = hal.components[name]
        error = hal.Signal('{}-error'.format(name), hal.HAL_BIT)
        comp.pin('error').link(error)
        self.error_signals.append(error)
Example #14
0
    def _init_modbus(self):
        name = 'i620p-abs'
        interval_s = 0.2
        hal.loadusr(
            'i620p_modbus.py -c {count} -n {name} -i {interval} -s {serial}'.format(
                count=NUM_JOINTS,
                name=name,
                interval=interval_s,
                serial=I620P_USB_SERIAL_ID,
            ),
            wait_name='i620p-abs',
        )
        self.user_comps.append(
            UserComp(name=name, timeout=(interval_s * TIMEOUT_OVERHEAD))
        )

        comp = hal.components[name]
        error = hal.Signal('{}-error'.format(name), hal.HAL_BIT)
        comp.pin('error').link(error)
        self.error_signals.append(error)
Example #15
0
def init_hardware():
    watchList = []

    # Python user-mode HAL module to read ADC value and generate a thermostat output for PWM
    defaultThermistor = 'semitec_103GT_2'
    hal.loadusr('hal_temp_atlas',
                name='temp',
                filter_size=20,
                channels='00:%s,01:%s,02:%s,03:%s' %
                (c.find('HBP', 'THERMISTOR', defaultThermistor),
                 c.find('EXTRUDER_0', 'THERMISTOR', defaultThermistor),
                 c.find('EXTRUDER_1', 'THERMISTOR', defaultThermistor),
                 c.find('EXTRUDER_2', 'THERMISTOR', defaultThermistor)),
                wait_name='temp')
    watchList.append(['temp', 0.1])

    base.usrcomp_status('temp', 'temp-hw', thread='servo-thread')
    base.usrcomp_watchdog(watchList,
                          'estop-reset',
                          thread='servo-thread',
                          errorSignal='watchdog-error')
Example #16
0
    def __init__(self):
        self.gpio = rtapi.loadrt('hal_bb_gpio', 
            output_pins='941', 
            input_pins='810,809,924,818,923,925,928,918,911,913')

        self.hwconfig = hal.loadusr(USR_HAL_PATH + 'hal_replicape_B3_hwconfig',
            name='replicape_hwconfig',
            wait_name='replicape_hwconfig')

        for i in xrange(5):
            # Default: spreadMode, microstepping=1/16
            self.hwconfig.pin('stepper.%i.mode' % i).set(config.find('FDM','STEPPER_%i_MODE' % i, 0x80))

        super(ReplicapeB3A, self).__init__()
Example #17
0
    def __init__(self):
        self.gpio = rtapi.loadrt('hal_bb_gpio', 
            output_pins='941', 
            input_pins='810,809,924,818,923,925,928,918,911,913')

        self.hwconfig = hal.loadusr(USR_HAL_PATH + 'hal_replicape_B3_hwconfig',
            name='replicape_hwconfig',
            wait_name='replicape_hwconfig')

        for i in xrange(5):
            # Default: spreadMode, microstepping=1/16
            self.hwconfig.pin('stepper.%i.mode' % i).set(config.find('FDM','STEPPER_%i_MODE' % i, 0x80))

        super(ReplicapeB3A, self).__init__()
    def __init__(self, replicape, enable_sig, estop_reset_sig):
        config_name = 'HBP'
        thermistor = config.find(config_name, 'THERMISTOR', '')
        if thermistor == '':
            raise ValueError('[%s] THERMISTOR must be defined' % (config_name))

        temp_hal = hal.loadusr(USR_HAL_PATH + 'hal_bbb_temp',
            name='ThermHbp',
            wait_name='ThermHbp',
            cape_board='Replicape',
            channel=replicape.get_hbp_adc_channel(),
            thermistor=thermistor)

        super(HbpTemperature, self).__init__(
            temp_hal, replicape.get_hbp_pwm_pin(), replicape.get_hbp_on_pin(), 
            enable_sig, estop_reset_sig,
            config_name, 'fdm-hbp', 'temp.hbp', 0)
    def __init__(self, replicape, index, enable_sig, estop_reset_sig):
        config_name = 'EXTRUDER_%s' % (index)
        thermistor = config.find(config_name, 'THERMISTOR', '')
        if thermistor == '':
            raise ValueError('[%s] THERMISTOR must be defined' % (config_name))

        temp_hal = hal.loadusr(USR_HAL_PATH + 'hal_bbb_temp',
            name='Therm%s' % (index),
            wait_name='Therm%s' % (index),
            cape_board='Replicape',
            channel=replicape.get_extruder_adc_channel(index),
            thermistor=thermistor)

        super(ExtruderTemperature, self).__init__(
            temp_hal, replicape.get_extruder_pwm_pin(index), replicape.get_extruder_on_pin(index), 
            enable_sig, estop_reset_sig,
            config_name, 'fdm-e%s' % (index), 'temp.e%s' % (index), 
            index + 2
        )
Example #20
0
    def __init__(self):
        self.pru = rtapi.loadrt('hal_pru_generic', 
            pru=0, num_stepgens=5, num_pwmgens=0, halname='hpg',
            prucode='%s/rt-preempt/pru_generic.bin' % (config.Config().EMC2_RTLIB_DIR))
# 4.14.18-ti-rt-r33 kernel and rt-preempt
        hal.addf('hpg.capture-position', SERVO_THREAD)
        hal.addf('hpg.update', SERVO_THREAD)
        hal.addf('bb_gpio.read', SERVO_THREAD)
        hal.addf('bb_gpio.write', SERVO_THREAD)
        minvel = config.find('TRAJ','MIN_VELOCITY', 0.001)
        for i in xrange(5):
            self.get_pru_pin('stepgen.%02i.dirsetup' % i).set(200)
            self.get_pru_pin('stepgen.%02i.dirhold' % i).set(200)
            self.get_pru_pin('stepgen.%02i.steplen' % i).set(1000)
            self.get_pru_pin('stepgen.%02i.stepspace' % i).set(1000)
            self.get_pru_pin('stepgen.%02i.dirpin' % i).set(self.pru_dir_pin(i))
            self.get_pru_pin('stepgen.%02i.steppin' % i).set(self.pru_step_pin(i))
# setting to zero: pru_generic adapts to maximum velocity and acceleration
# see http://www.machinekit.io/docs/man/man9/hal_pru_generic/           
            self.get_pru_pin('stepgen.%02i.maxvel' % i).set(0)
            self.get_pru_pin('stepgen.%02i.maxaccel' % i).set(0)
            
# use new pru stepgen minvel pin to avoid pru hunting problem (without PID loop)
# see this discussion https://groups.google.com/forum/#!topic/machinekit/ATEwvfgoIb4
# except for extruder(s)
            if i < 3 :
                self.get_pru_pin('stepgen.%02i.minvel' % i).set(minvel)

        self.pwm = hal.loadusr(USR_HAL_PATH + 'hal_replicape_pwm',
            name='replicape_pwm',
            wait_name='replicape_pwm')

        self.watchdog_sigs = []
        for pin in self.get_watchdog_pins():
            s = hal.newsig('replicape.watchdog.%d' % len(self.watchdog_sigs), hal.HAL_BIT)
            pin.link(s)
            self.watchdog_sigs.append(s)
Example #21
0
    def __init__(self):
        self.pru = rtapi.loadrt('hal_pru_generic',
                                pru=0,
                                num_stepgens=5,
                                num_pwmgens=0,
                                halname='hpg',
                                prucode='%s/xenomai/pru_generic.bin' %
                                (config.Config().EMC2_RTLIB_DIR))

        hal.addf('hpg.capture-position', SERVO_THREAD)
        hal.addf('hpg.update', SERVO_THREAD)
        hal.addf('bb_gpio.read', SERVO_THREAD)
        hal.addf('bb_gpio.write', SERVO_THREAD)

        for i in xrange(5):
            self.get_pru_pin('stepgen.%02i.dirsetup' % i).set(200)
            self.get_pru_pin('stepgen.%02i.dirhold' % i).set(200)
            self.get_pru_pin('stepgen.%02i.steplen' % i).set(1000)
            self.get_pru_pin('stepgen.%02i.stepspace' % i).set(1000)
            self.get_pru_pin('stepgen.%02i.dirpin' % i).set(
                self.pru_dir_pin(i))
            self.get_pru_pin('stepgen.%02i.steppin' % i).set(
                self.pru_step_pin(i))
            self.get_pru_pin('stepgen.%02i.maxvel' % i).set(0)
            self.get_pru_pin('stepgen.%02i.maxaccel' % i).set(0)

        self.pwm = hal.loadusr(USR_HAL_PATH + 'hal_replicape_pwm',
                               name='replicape_pwm',
                               wait_name='replicape_pwm')

        self.watchdog_sigs = []
        for pin in self.get_watchdog_pins():
            s = hal.newsig('replicape.watchdog.%d' % len(self.watchdog_sigs),
                           hal.HAL_BIT)
            pin.link(s)
            self.watchdog_sigs.append(s)
Example #22
0
def init_storage(fileName):
    # Python user-mode HAL module for storing values
    hal.loadusr('hal_storage', name='storage', file=fileName,
                autosave=True, wait_name='storage')
Example #23
0
# -*- coding: utf-8 -*-
from machinekit import hal

hal.loadusr('haltalk', wait=True)
Example #24
0
    base.create_temperature_control(name='e%i' % i, section='EXTRUDER_%i' % i,
                                    coolingFan='f%i' % i,
                                    hotendFan='exp%i' % i,
                                    hardwareOkSignal='temp-hw-ok',
                                    thread='servo-thread')

# LEDs
for i in range(0, numLights):
    base.setup_light('l%i' % i, thread='servo-thread')

# Standard I/O - EStop, Enables, Limit Switches, Etc
errorSignals = ['temp-hw-error', 'watchdog-error', 'hbp-error']
for i in range(0, numExtruders):
    errorSignals.append('e%i-error' % i)
base.setup_estop(errorSignals, thread='servo-thread')
base.setup_tool_loopback()
# Probe
base.setup_probe(thread='servo-thread')
# Setup Hardware
hardware.setup_hardware(thread='servo-thread')

# write out functions
hardware.hardware_write()

# read storage.ini
storage.read_storage()

# start haltalk server after everything is initialized
# else binding the remote components on the UI might fail
hal.loadusr('haltalk', wait=True)
Example #25
0
                       axisIndex=5,
                       pwm='hpg.pwmgen.00.out.00',
                       thread='servo-thread')
servo.setup_servo_axis(servoIndex=1,
                       section='AXIS_3',
                       axisIndex=3,
                       pwm='hpg.pwmgen.00.out.01',
                       thread='servo-thread')
#hal.Pin('motion.digital-out-10').link('mirror-deploy')
#servo.setup_servo_toggle(servoIndex=1,section='MIRROR',pwm='hpg.pwmgen.00.out.01', selectSignal='mirror-deploy', thread='servo-thread')

#errorSignals = ['temp-hw-error', 'watchdog-error', 'hbp-error']
errorSignals = []
base.setup_estop(errorSignals, thread='servo-thread')
base.setup_tool_loopback()
# Probe
base.setup_probe(thread='servo-thread')
# Setup Hardware
hardware.setup_hardware(thread='servo-thread')

# write out functions
hardware.hardware_write()

# read storage.ini
storage.read_storage()

# start haltalk server after everything is initialized
# else binding the remote components on the UI might fail
#hal.loadusr('haltalk', wait=True)
hal.loadusr('linuxcncrsh')
# create the signal for connecting the components
input0 = hal.newsig('input0', hal.HAL_BIT)
input1 = hal.newsig('input1', hal.HAL_BIT)
output = hal.newsig('output', hal.HAL_BIT)

# and2 component
and2 = rt.newinst('and2', 'and2.demo')
and2.pin('in0').link(input0)
and2.pin('in1').link(input1)
and2.pin('out').link(output)
hal.addf(and2.name, 'main-thread')

# create remote component
rcomp = hal.RemoteComponent('anddemo', timer=100)
rcomp.newpin('button0', hal.HAL_BIT, hal.HAL_OUT)
rcomp.newpin('button1', hal.HAL_BIT, hal.HAL_OUT)
rcomp.newpin('led', hal.HAL_BIT, hal.HAL_IN)
rcomp.ready()

# link remote component pins
rcomp.pin('button0').link(input0)
rcomp.pin('button1').link(input1)
rcomp.pin('led').link(output)

# ready to start the threads
hal.start_threads()

# start haltalk server after everything is initialized
# else binding the remote components on the UI might fail
hal.loadusr('haltalk')
def setup_storage():
    hal.loadusr('hal_storage',
                name='storage',
                file='storage.ini',
                autosave=True,
                wait_name='storage')
Example #28
0
def setup_lcec(configfile=None):
    # load ethercat config parser
    print('lcec_conf %s' % configfile)
    hal.loadusr('lcec_conf %s' % configfile, wait=True)
    # load ethercat realtime module
    rt.loadrt('lcec')
Example #29
0
base.setup_stepper(section="AXIS_0", axisIndex=0, stepgenIndex=0, stepgenType="sim")
# Y [J1] Axis
base.setup_stepper(section="AXIS_1", axisIndex=1, stepgenIndex=1, gantry=True, gantryJoint=0, stepgenType="sim")
# YY[J2] Axis
base.setup_stepper(section="AXIS_1", axisIndex=1, stepgenIndex=2, gantry=True, gantryJoint=1, stepgenType="sim")
# Z [J3] Axis
base.setup_stepper(section="AXIS_2", axisIndex=2, stepgenIndex=3, stepgenType="sim")
# A [J4] Axis
base.setup_stepper(section="AXIS_3", axisIndex=3, stepgenIndex=4, stepgenType="sim")
# B [J5] Axis
base.setup_stepper(section="AXIS_4", axisIndex=4, stepgenIndex=5, stepgenType="sim")

# update gantry position feedback
base.gantry_read(gantryAxis=1, thread="servo-thread")

# Standard I/O - EStop, Enables, Limit Switches, Etc
errorSignals = ["temp-hw-error", "watchdog-error", "hbp-error"]
base.setup_estop(errorSignals, thread="servo-thread")
base.setup_tool_loopback()

# testing
base.setup_extras()

# write out functions
hal.addf("motion-controller", "servo-thread")
base.gantry_write(gantryAxis=1, thread="servo-thread")

# start haltalk server after everything is initialized
# else binding the remote components on the UI might fail
hal.loadusr("haltalk", wait=True)
Example #30
0
def load_hal_io_component():
    # Load hal_io user component
    hal.loadusr('hal_io', wait=True)
Example #31
0
def setupStorage():
    hal.loadusr('hal_storage', name='storage', file='storage.ini',
                autosave=True, wait_name='storage')
Example #32
0
def init_hardware():
    watchList = []

    # load low-level drivers
    rt.loadrt('hal_bb_gpio', output_pins='807,819,826,926', input_pins='941')
    prubin = '%s/%s' % (c.Config().EMC2_RTLIB_DIR, c.find('PRUCONF', 'PRUBIN'))
    rt.loadrt(c.find('PRUCONF', 'DRIVER'),
              pru=0,
              num_stepgens=5,
              num_pwmgens=0,
              prucode=prubin,
              halname='hpg')

    # Python user-mode HAL module to interface with an I2C gpio extender
    hal.loadusr('hal_gpio_mcp23017',
                name='i2c-gpio',
                bus_id=2,
                address=32,
                interval=0.05,
                delay=2.5,
                input_pins='A00,A01,A02,A03,A04,A05,A06,A07,B06,B07',
                output_pins='B00,B01,B02,B03,B04,B05',
                wait_name='i2c-gpio')
    watchList.append(['i2c-gpio', 0.1])

    # Python user-mode HAL module to interface with an I2C PWM generator
    hal.loadusr('hal_pwm_pca9685',
                name='i2c-pwm',
                bus_id=2,
                address=67,
                interval=0.1,
                delay=2.6,
                wait_name='i2c-pwm')
    watchList.append(['i2c-pwm', 0.2])

    # Python user-mode HAL module to interface with an I2C ADC and convert it to temperature
    defaultThermistor = 'semitec_103GT_2'
    hal.loadusr(
        'hal_temp_ads7828',
        name='i2c-temp',
        bus_id=2,
        address=72,
        interval=0.05,
        delay=2.7,
        filter_size=1,
        channels='00:%s,01:%s,02:%s,03:%s,04:%s,05:none,06:none,07:none' %
        (c.find('HBP', 'THERMISTOR', defaultThermistor),
         c.find('EXTRUDER_0', 'THERMISTOR', defaultThermistor),
         c.find('EXTRUDER_1', 'THERMISTOR', defaultThermistor),
         c.find('EXTRUDER_2', 'THERMISTOR', defaultThermistor),
         c.find('EXTRUDER_3', 'THERMISTOR', defaultThermistor)),
        wait_name='i2c-temp')
    watchList.append(['i2c-temp', 0.1])

    base.usrcomp_status('i2c-gpio', 'gpio-hw', thread='servo-thread')
    base.usrcomp_status('i2c-pwm', 'pwm-hw', thread='servo-thread')
    base.usrcomp_status('i2c-temp', 'temp-hw', thread='servo-thread')
    base.usrcomp_watchdog(watchList,
                          'estop-reset',
                          thread='servo-thread',
                          errorSignal='watchdog-error')
Example #33
0
def load_hal_io_component():
    # Load hal_io user component
    cmd = 'rosrun hal_hw_interface hal_io'
    hal.loadusr(cmd, wait=True, wait_name='hal_io', wait_timeout=10.0)