Thank you for your generous contribution, Julien. I have been posting in another thread (Raspberry Pi connect to tic with I2C) and getting nowhere, but after implementing your example with my hardware I am finally over the hurdle. I am using I2C over the GPIO pins 23 and 24, and it works like a charm. I had to combine the short I2C example you provided with the example code, which is obvious enough. I did find one additional thing that needed to be adjusted in the example to make it work – backend=SMBus2Backend(bus) needs to include the address as a second argument. Here is the adjusted code:
from smbus2 import SMBus
from ticlib import TicI2C, SMBus2Backend
from time import sleep
bus = SMBus(3) # Represents /dev/i2c-3
address = 14 # Address of the Tic, that is its device number
backend = SMBus2Backend(bus, address)
tic = TicI2C(backend)
tic.halt_and_set_position(0)
tic.energize()
tic.exit_safe_start()
positions = [500, 300, 800, 0]
for position in positions:
tic.set_target_position(position)
while tic.get_current_position() != tic.get_target_position():
sleep(0.1)
tic.deenergize()
tic.enter_safe_start()
