1 Reply Latest reply on May 12, 2017 9:47 AM by rola_264706

# Need help with Quadrature Decoder in 32 Bit Mode

Microcontroller: PSoC 5LP Prototyping Kit

I am building a linear measuring device, it will measure the travel of a 40 foot long table on a large milling machine.

It will have a resolution of 0.0005 inch so I am using an encoder strip with 2000 LPI ( lines per inch).

A distance of 40 feet (480 inches) at 0.0005 inch from one encoder strip line marking to the next equals: 480 inch / 0.0005 = 960,000 pulses in 480 inches

So it will take a minimum of a 20 bit number to represent the full travel of 480 inches - ( LOG(960000) / LOG(2) = 19.87 bits )

A 20 bit number should allow me to have a value of 2^20 = 1,048,576 which is greater than my required 960,000.

That is why I need the Quadrature Decoder in 32 bit mode.

According to the data sheet:

The ranges for counting are the following:
> 8-bit counter: -128 to +127
> 16-bit counter: -32,768 to +32,767
> 32-bit counter: -2,147,483,648 to +2,147,483,647

So I should be able to get a count of 2,147,486,647 in the positive direction but when I run the project it only counts to 32,767 and then resets back to zero.

I also found this in the data sheet:

The 32-bit counter implements the lower 16 bits in the hardware counter and the upper 16 bits in software to reduce hardware resource use. For this target, an additional ISR is used. To work properly with the 32-bit counter, interrupts must be enabled. You can add ISR code to source files as needed; see the Interrupt Component datasheet for more details.

So my question is: how do I do that?  Right now I have no clue as to where/how to start, will someone help?

Doug

• ###### 1. Re: Need help with Quadrature Decoder in 32 Bit Mode

Doug Here is an example program I set it for 32 bits and it should give you some ideals.