Self-contained implementation of CUI Devices' encoder AMT21 Series for PSoC.
Self-contained implementation of CUI Devices’ encoder AMT21 Series for PSoC.
The AMT21 encoder communicates via RS485 which isn’t supported by PSoC. You need to connect a transceiver inbetween the PSoC and the encoder to convert the RS485 signal into UART. CUI Devices suggest using Texas Instruments SN65HVD75 (for data rate at 2Mbps) or SN65HVD72 (for adjustable data rate). See datasheet page 3 and 5 to know which one you have.
If you have a long cable between the PSoC and the encoder, make sure to have a load resistance (CUI Devices suggest 54Ω) at both end of the cable.
This project has been tested on the following hardware:
AMT21 Series encoder product page: https://www.cuidevices.com/product/motion/rotary-encoders/absolute/modular/amt21-series
AMT21 Series encoder datasheet: https://www.cuidevices.com/product/resource/amt21.pdf.
The following code shows how to read the absolute position and the number of turns of the encoder.
#include <project.h>
#include "amt21_driver.h"
int main(void)
{
uint16 absolute_position = 0;
int16 number_of_turns = 0
// Initializations
CyGlobalIntEnable; // Enable global interrupts
amt21_init(); // Start and setup the AMT21 driver
// Application
for(;;) {
// Get absolute position
absolute_position = amt21_get_pos();
// Get number of turns
number_of_turns = amt21_get_turns();
}
}
Add the following components:
If you have an encoder with a 2Mbsp data rate, you’ll also need the following:
Configure tab:
Advanced tab:
If data rate is 2Mbps: