PID Basics: dsPIC® DSC Implementation Part 2

dsPIC® DSCs Implementation Operations

The first operation is to set the two pointers to point at the first location of each buffer in the RAM. W8 in the following diagram is the pointer to the coefficients buffer; W10 is the pointer to the error buffer.

PID-operation-1.png

The new error value is computed as the difference between the reference voltage (Vref) and the new output voltage read by the ADC (ADCBUF1). See figure below.

PID-operation-2.png

movsac Instruction

The movsac instruction performs a number of different tasks. The following diagram and steps demonstrate the movsac instruction.

PID-operation-3.png

1

Move RAM contents

1a: Moves the content of the RAM location pointed by W8 into register W4.
1b: Moves the content of the RAM location pointed by W10 into register W5.

PID-operation-4-new.png

2

Update Working Registers

2a: Updates the W8 register, so that it is now pointing to the following RAM location.
2b: Updates the W10 register, so that it is now pointing to the following RAM location.

PID-operation-5-new.png
PID-operation-6.png

PID term computation

Below are the computation steps of the first term of the PID:

1

The W4 and W5 registers content are multiplied and the result is added to the 40-bit accumulator B.

PID-operation-7.png

2

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

3

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

PID-operation-8-new.png

4

Updates the W8 register, so that it is now pointing to the following RAM location.

5

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

PID-operation-9-new.png

6

The W4 and W5 registers content are multiplied and the result is added to the 40-bit accumulator B.

PID-operation-10-new.png

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.