Exemple #1
0
def test_asservissement_ch2():
    pin_ch_a = Pin(21)
    pin_ch_b = Pin(20)
    encoder = Encoder(pin_ch_a, pin_ch_b,reverse_direction = False)

    pin_dir = Pin(6)
    pin_speed = Pin(7)
    motor = Motor(pin_dir, pin_speed,reverse_sense=True)
    motor.off()

    Kp = 1
    Ki = 0
    Kd = 0
    filter = Filter(Kp, Ki, Kd)

    controler = Controler(encoder, motor, filter)

    ramp_inc = generate_ramp(0, 100, 4)
    plateau = generate_plateau(400,2)
    ramp_dec = generate_ramp(400, -100, 4)

    controler.position_loop(ramp_inc)
    controler.position_loop(plateau)
    controler.position_loop(ramp_dec)
    motor.off()
Exemple #2
0
def test_asservissement_2chan():
    ch1_pin_ch_a = Pin(19)
    ch1_pin_ch_b = Pin(18)
    ch1_encoder = Encoder(ch1_pin_ch_a, ch1_pin_ch_b,reverse_direction = False)

    ch1_pin_dir = Pin(8)
    ch1_pin_speed = Pin(9)
    ch1_motor = Motor(ch1_pin_dir, ch1_pin_speed,reverse_sense=True)
    ch1_motor.off()

    ch2_pin_ch_a = Pin(21)
    ch2_pin_ch_b = Pin(20)
    ch2_encoder = Encoder(ch2_pin_ch_a, ch2_pin_ch_b,reverse_direction = False)

    ch2_pin_dir = Pin(6)
    ch2_pin_speed = Pin(7)
    ch2_motor = Motor(ch2_pin_dir, ch2_pin_speed,reverse_sense=True)
    ch2_motor.off()

    Kp = 1
    Ki = 0
    Kd = 0
    ch1_filter = Filter(Kp, Ki, Kd)
    ch2_filter = Filter(Kp, Ki, Kd)

    ch1_controler = Controler(ch1_encoder, ch1_motor, ch1_filter)
    ch2_controler = Controler(ch2_encoder, ch2_motor, ch2_filter)

    dual_controler = ControlerMultiChannel(ch1_controler, ch2_controler)

#     ramp_inc = generate_ramp(0, 100, 1)
    ramp_inc = generate_ramp(0, 100, 4)
    plateau = generate_plateau(400,2)
    ramp_dec = generate_ramp(400, -100, 4)

    dual_controler.position_loop(ramp_inc, ramp_inc)
    dual_controler.position_loop(plateau, plateau)
    dual_controler.position_loop(ramp_dec, ramp_dec)
    ch1_motor.off()
    ch2_motor.off()
Exemple #3
0
def test_asservissement_ch1_speed():
    
    pin_ch_a = Pin(21)
    pin_ch_b = Pin(20)
    encoder = Encoder(pin_ch_a, pin_ch_b,reverse_direction = False)

    pin_dir = Pin(6)
    pin_speed = Pin(7)
    motor = Motor(pin_dir, pin_speed,reverse_sense=True)
    motor.off()

    Kp = 20
    filter = Filter(Kp, 0, 0)

    controler = Controler(encoder, motor, filter)

    ramp_inc = generate_ramp(0, 5, 1)
    plateau = generate_plateau(5,5)
    ramp_dec = generate_ramp(5, -5, 1)

    controler.speed_loop(ramp_inc)
    controler.speed_loop(plateau)
    controler.speed_loop(ramp_dec)
Exemple #4
0
def test_asservissement_2chan_speed():
    ch1_pin_ch_a = Pin(19)
    ch1_pin_ch_b = Pin(18)
    ch1_encoder = Encoder(ch1_pin_ch_a, ch1_pin_ch_b,reverse_direction = False)

    ch1_pin_dir = Pin(8)
    ch1_pin_speed = Pin(9)
    ch1_motor = Motor(ch1_pin_dir, ch1_pin_speed,reverse_sense=True)
    ch1_motor.off()

    ch2_pin_ch_a = Pin(21)
    ch2_pin_ch_b = Pin(20)
    ch2_encoder = Encoder(ch2_pin_ch_a, ch2_pin_ch_b,reverse_direction = False)

    ch2_pin_dir = Pin(6)
    ch2_pin_speed = Pin(7)
    ch2_motor = Motor(ch2_pin_dir, ch2_pin_speed,reverse_sense=True)
    ch2_motor.off()

    Kp = 0.1
    Ki = 0
    Kd = 0
    ch1_filter = Filter(Kp, Ki, Kd)
    ch2_filter = Filter(Kp, Ki, Kd)

    ch1_controler = Controler(ch1_encoder, ch1_motor, ch1_filter)
    ch2_controler = Controler(ch2_encoder, ch2_motor, ch2_filter)

    dual_controler = ControlerMultiChannel(ch1_controler, ch2_controler)

#     # Acceleration
#     ramp_inc = generate_ramp(0, 180, 1)
#     # plateau
#     plateau = generate_plateau(180, 2)
#     
#     # rotation
#     rot1 = generate_plateau(320, 2)
#     rot2 = generate_plateau(-320, 2)
#     
#     # Deceleration
#     ramp_dec = generate_ramp(180, -180, 1)
#     


#     dual_controler.speed_loop(ramp_inc, ramp_inc)
#     dual_controler.speed_loop(plateau, plateau)
#     dual_controler.speed_loop(rot1, rot2)
#     dual_controler.speed_loop(plateau, plateau)
#     dual_controler.speed_loop(ramp_dec, ramp_dec)
#     dual_controler.speed_loop(rot2, rot1)

    ramp_inc = generate_ramp(0, 400, 1)
    plateau = generate_plateau(400, 1)
    ramp_dec = generate_ramp(400, -400, 1)

    dual_controler.speed_loop(ramp_inc, ramp_inc)
    dual_controler.speed_loop(plateau, plateau)
    dual_controler.speed_loop(ramp_dec, ramp_dec)


    ch1_motor.off()
    ch2_motor.off()