From: Erik Andresen Date: Wed, 13 Jul 2016 08:00:53 +0000 (+0200) Subject: motor_ctrl: pid tuning X-Git-Url: https://defiant.homedns.org/gitweb/?p=ros_wild_thumper.git;a=commitdiff_plain;h=3bc8d7f92277a953cfcee5781d5875f040d7f028;hp=1d95fd8a372e93eafd14666c0145b8afcbc14700;ds=sidebyside motor_ctrl: pid tuning --- diff --git a/avr/motor_ctrl/main.c b/avr/motor_ctrl/main.c index d25271f..5c6a667 100644 --- a/avr/motor_ctrl/main.c +++ b/avr/motor_ctrl/main.c @@ -101,9 +101,9 @@ #define TWI_RESET TWCR &= ~((1 << TWSTO) | (1 << TWEN)); TWI_ACK #define TWI_NAK TWCR = (1<h", left)) + i2c_write_reg(0x50, 0x3, struct.pack(">h", left)) + i2c_write_reg(0x50, 0x5, struct.pack(">h", right)) + i2c_write_reg(0x50, 0x7, struct.pack(">h", right)) + +if __name__ == "__main__": + set_pwm(int(sys.argv[1]), int(sys.argv[2])) + + while True: + motor1, = struct.unpack(">B", i2c_read_reg(0x50, 0x2, 1)) + motor2, = struct.unpack(">B", i2c_read_reg(0x50, 0x4, 1)) + motor3, = struct.unpack(">B", i2c_read_reg(0x50, 0x6, 1)) + motor4, = struct.unpack(">B", i2c_read_reg(0x50, 0x8, 1)) + speed1, speed2, speed3, speed4 = struct.unpack(">hhhh", i2c_read_reg(0x50, 0x30, 8)) + error, = struct.unpack(">B", i2c_read_reg(0x50, 0xA1, 1)) + print "PWM:", motor1, motor2, motor3, motor4, "Speed:", speed1, speed2, speed3, speed4, "Error:", error + sleep(0.1)