PID Basics: dsPIC® DSC Implementation Part 3

dsPIC® DSCs Implementation Operations

PID term computation continued…

7

Moves the content of the RAM location pointed by W8 into register W4

8

Moves the content of the RAM location pointed by W10 into register W5

PID-operation-11-new.png

9

Updates the W10 register, so that it is now pointing to the previous RAM location

PID-operation-12-new.png

Store Accumulator Instruction

The diagram below shows the operation of the store accumulator instruction, sac.r.

PID-operation-13.png

1

We store the high part (from 16th to 31th bit) of the accumulator into the W0 register. Before saving it, the value is shifted 8 bit positions to the left and the resultant value is rounded. See diagram below.

PID-operation-14.png

2

Copy the content of register W5 [that is e(n-1)] into the last location of the error buffer.

PID-operation-15.png

3

The content of RAM location pointed by [W10 -4] is then copied into the W5 register.

PID-operation-16.png

4

The pointer W10 is decremented, to point to the previous location of the error buffer

PID-operation-17-new.png

5

The content of register W5 (that is the current errer e(n)) is stored into the RAM location pointed by W10. The purpose of the operations performed in the last few diagrams is to make room for the next value of the error that will arrive in the next sampling period.

PID-operation-18-new.png

Example

The number of cycles required to perform the PID operations as indicated in the previous diagrams can be explained using the following example:

If the dsPIC® DSC is running at 40 MIPS, each machine cycle equals: 1/40 MHz = 25 ns. As a consequence, the total time required to perform the described task is 13 x 25 ns = 325 ns.

20th Annual
Microchip MASTERs Conference 2016
Register now - Deadline: July 29

JW Marriott Desert Ridge Resort-Phoenix, AZ

© 2016 Microchip Technology, Inc.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.