Andy Lindsay's PID Object
joeld
Posts: 49
I had a couple of questions reguarding the code in Andy's PID object. In the init method he uses longmove to copy the variables passed to the method into similar variables defined in the VAR section of the object. Is the point of this so that these values will be available to other methods in the object? Is my understanding correct that·variables passed to a method are only readable in that method and not other methods in the same object? Also is the longmove used because it generates less code that using the := to assign the values to local variables? Are there ever issues with variables not being written in sequential locations and this causing problems with this type of code?
PUB init (_Kp, _Ki, _Kd, setPoint, offset, maxArea, minArea)
· ' Start floating point object.
· f.start
· ' Set values of kp, ki, etc.
· longmove(@kp, @_Kp, 7)
Sorry if these are mundane questions but I'm trying to get a grasp of what's going on?
PUB init (_Kp, _Ki, _Kd, setPoint, offset, maxArea, minArea)
· ' Start floating point object.
· f.start
· ' Set values of kp, ki, etc.
· longmove(@kp, @_Kp, 7)
Sorry if these are mundane questions but I'm trying to get a grasp of what's going on?
Comments
Yes, longmove uses less space and is a lot quicker. I think that you would find that it is quicker than even starting a cog in assembly to do the same job.
If you use this type of code than the variables in the other object must be sequential and in the same order or else the code won't work.