The __ init ___ method of picarx.py creat 3 instance of SERVO
each is on canal P0, P1, P2,
servo_pins:list=[‘P0’, ‘P1’, ‘P2’]
51 self.cam_pan = Servo(servo_pins[0])
52 self.cam_tilt = Servo(servo_pins[1])
53 self.dir_servo_pin = Servo(servo_pins[2])
There are no specific features that distinguish them, apart from the channel.
The _init_ method of the SERVO class creates an instance of the PWM class with the following property: period == 4095
The instance of the PWM class calculates the prescaler value, which is equal to 352 for a frequency of 50 Hz and a clock speed of 72 MHz.
The PWM class instance then creates an instance of the I2C class. This opens a communication channel at address 0x14 on bus 1.
The PWM class instance can then write the previously calculated data to a register.
-
The prescaler traces the value 352 (0x15F) to address 0x40
I2C-write( self, data=[64, 1, 95]==[0x40, 0x1, 0x5f, ] -
And for the period, the value 4095 (0xFFF) is written to address 0x44
I2C-write( self, data=[68, 15, 255]==[0x44, 0xf, 0xff, ]So far, so good.
This process is repeated three times:
once for channel P0, once for channel P1 and once for channel P2
OK, that makes sense…
But where I’m getting stuck is that these configuration values are written to exactly the same registers at addresses 0x40 and 0x44.
Everything works perfectly, so I understand why the same data is written for three different servo motors, but I don’t understand why the same write registers are used.
Any ideas, perhaps? Thanks