Years ago I helped develop a programmable PID process controller with auto-tuning in C, and found that it helps to keep the integrator in reset (0.0) as long as abs(Setpoint - ActualValue) is > ProportionalBand. Resetting the integrator as soon as 100% output is given might work even better. The integrator only needs to regulate away the steady state error.
yes you are correct, well spoted Jerry!
This is an easy fix, but with 2 instructions extra: ; sameroutine as above, but result stored in (SRC) MOVF (SRC),W ; Get low byte of subtrahend SUBWF (DST),W ; Subtract DST(low) - SRC(low), --> W MOVWF (SRC) ; store W result in (SRC) MOVF (SRC)+1,W ; Now get high byte of subtrahend BTFSS STATUS,C ; If there was a borrow, rather than INCF (SRC)+1,W ; decrement high byte of dst we inc src SUBWF (DST)+1,W ; Subtract the high byte, result in W MOVWF (SRC) ; store W result in (SRC)
This is an easy fix, but with 2 instrcutions extra: ; sameroutine as above, but result stored in (SRC) MOVF (SRC),W ; Get low byte of subtrahend SUBWF (DST),W ; Subtract DST(low) - SRC(low), --> W MOVWF (SRC) ; store W result in (SRC) MOVF (SRC)+1,W ; Now get high byte of subtrahend BTFSS STATUS,C ; If there was a borrow, rather than INCF (SRC)+1,W ; decrement high byte of dst we inc src SUBWF (DST)+1,W ; Subtract the high byte, result in W MOVWF (SRC) ; store W result in (SRC)
another way might be to take the high bytes of the input values, increment them if the low byte is <> 0, and then multiply those bytes. If the result is < 65536 then no overflow will occur in the full 16 x 16 bit multiplication. This will be faster than doing a 32 bit division.
Dear Evan, There now exist two different encodings forthe MOVLB instruction on Enhanced Mid-range devices; see https://www.microchip.com/forums/m1131489.aspx One for devices with 32 banks: "00 0000 001k kkkk" The 9-bit prefix 00 0000 001 was unassigned in the Baseline Mid-range devices. And one for Enhanced Mid-range devices with 64 banks: "00 0001 01kk kkkk" Which uses some of the unused encodings previously occupied by CLRW; CLRW must now be encoded as: "00 0001 0000 00xx" See the PIC16F18857 datasheet,...
I think I caused trouble here; I see that my 16f19197.dat file is from 21 december 2018. Sorry for troubling you again!
Sorry for wasting your time, Evan! I thought that ChipVariant=1 only indicated the new movlb instruction encoding for 16F1xx devices. I learn every day! ;-)