Other Parts Discussed in Thread: TMS320F28335
Tool/software:
Description of Problem: I have an analog absolute encoder which gives a current output of 4-20mA every 45 degrees. In order to read position data from this encoder, I use an ADC pin together with a 120 ohm pulldown resistor. Since the output is between 4-20mA, I get output voltages between 480 and 2400 milivolts as expected. Using this, the raw ADC value is offsetted to 0, then divided by maximum output value to scale it between 0-1. Finally, the per unit position is converted to radians by multiplying with 4pi. However, I am using this encoder for position sensing in a 32 pole PMSM motor, which means I need 2 22.5 degree cycles for each 45 degree cycle of the encoder. In order to accomplish this, I am using a mod function in order to divide the 45 degree signal into two cycles. The problem starts right after the mod operation, there appears to be a spike roughly at the middle of every second 22.5 degree cycle, as attached in the image.
Solutions tried: I am using Simulink for writing and generating code. Observing the raw ADC values shows no spikes, neither does checking the input voltage to the ADC with an oscilloscope. The scaled value is also between 0-1 and does not go out of bounds. I also tried with a different encoder and got the same result. Running the same code on a F280049C Launchpad instead of my own hardware also does not solve the problem. However, running this exact same algorithm for a different processor, TMS320F28335 Control Card, I had no problems with position sensing from the encoder.
What other steps should I take for troubleshooting? As I said, using a TMS320F28335 Control card along with a custom made docking card presents no issues, which means that the algorithm itself runs fine. The custom hardware has everything related to ADC's and analog subsystems that the Control Card has (except for ESD protection), so it also does not appear to be hardware related. Below are the settings I use for the ADC input.