Skip to content

Viper: can't do binary op between 'int' and 'object' #13697

Discussion options

You must be logged in to vote

Viper is not as intelligent as MP. And if in doubt it always falls back to handle things as MP objects.
So the tuple assignment was the culprit.

@micropython.viper
def _update(self, measured: int, dt: int):
    """Update the PID controller.

    measured: The measured value of the system.
    dt: The change in time, in seconds.
    """

    kp_num = int(self._kp_num)
    kp_shr = int(self._kp_shr)
    ki_num = int(self._ki_num)
    ki_shr = int(self._ki_shr)
    kd_num = int(self._kd_num)
    kd_shr = int(self._kd_shr)    

    err = int(self.setpoint) - int(measured)
    p = int(0)
    if kp_num != 0:
        p = err * kp_num  # Line 294 **error here**
        p >>= kp_shr

does not have …

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@jaguilar
Comment options

@jaguilar
Comment options

@peterhinch
Comment options

@jaguilar
Comment options

@peterhinch
Comment options

Answer selected by jaguilar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants