Tic36v4 - i2c- change max speed

Hello,

I’m trying to change the “Max speed” setting of my Tic, without using the "Tic Control Center.
A part of my code :

import tkinter as tk
from tkinter import ttk, Button, Label, StringVar
import pigpio
import time

class MonMoteur:
    def __init__(self, bus, addresse):
        # Initialisation de la connexion Pigpio
        self.pi = pigpio.pi()
        # Ouvrir la connexion I2C avec le bus et l'adresse spécifiés
        self.h = self.pi.i2c_open(bus, addresse)

    def get_max_speed(self):
        # Gets the "Maximum speed" variable from the Tic.
        b = self.get_variables(0x16, 4)
        bytes_list = list(b[1])  # Récupérer la partie bytearray
        max_speed = sum(value << (8 * i) for i, value in enumerate(bytes_list))
        if max_speed >= (1 << 31):
            max_speed -= (1 << 32)   
        return max_speed

    def set_max_speed(self, max_speed):
        # Sets the "Maximum speed" variable of the Tic.
        # Convert max_speed to Tic units (e.g., pulses per second)
        max_speed_units = int(max_speed)
        # Split the max_speed_units into bytes (little-endian)
        max_speed_bytes = [(max_speed_units >> i) & 0xFF for i in range(0, 32, 8)]
        # Construct the command to set the max speed
        command = [0x47] + max_speed_bytes
        self.pi.i2c_write_device(self.h, command)

addresseDuTic1 = 0x0E
bus = 3
Moteur1 = MonMoteur(bus, addresseDuTic1)
Moteur1.set_max_speed(10000000)

The “get_max_speed” function seems to be working well,
But I cannot manage to change the “Max speed” setting eventhough the signals looks fine to me.

If I’m checking in the TicControlCenter, the Max seed is still the same.
Any advices ? (I have the same problem with the “Current limit” setting)
Thanks a lot for the reading time :slight_smile:
Bastien

Hello.

Are you sure your changes are not actually taking effect? It is normal for settings that are changed through the I2C interface to not change what you see in the Tic Control Center. So, you might try doing some testing by making some exaggerated changes to try to verify that it is working as expected. Additionally, you can use the “Get setting” and “Get variable” commands to compare and check that the variable has been updated.

To clarify, the Tic essentially stores two separate values for those settings. One is stored in EEPROM and is essentially the “default” value that the configuration setting will get set to whenever the Tic is reset or power cycled (you can find more information about these in the “Setting reference” section of the Tic user’s guide). The other is stored in volatile memory and acts as a temporary override (you can find more information about these in the “Variable reference” section of the Tic user’s guide). The I2C commands will only change the temporary override values, and the Tic Control Center only displays the values stored in EEPROM.

Brandon