DigiKey-eMag-Sensors-Vol 19

encoders on the same bus. To facilitate this, an additional digital I/O pin needs to be allocated for each encoder, allowing for individual chip select (CS) control. In the example code (Listing 8), an array of CS pins is utilized to support an arbitrary number of encoders. This design allows for scalable communication, enabling the user to easily add more encoders as needed. By modifying the functions to accept the pin number corresponding to the desired device, the code can dynamically control which encoder is active on the SPI bus, ensuring

To monitor the output, open the serial monitor in the Arduino IDE and ensure that the data rate is set to 115200 baud. This will allow users to observe the encoder's operation and view the reported position data in real time. Once the serial monitor is active, the encoder should start transmitting its position information, demonstrating its functionality within the system (Figure 3). Multiple encoders One significant advantage of using an SPI device is the ability to communicate with multiple

that each device can be accessed and operated independently. The next step is to loop through each CS pin in the array and read the position from each connected encoder. This allows the system to activate each encoder by asserting its chip select line, performing the SPI transfer, and retrieving the position data. The code will sequentially select each encoder, execute the SPI communication, and release the CS line, ensuring that all connected devices are queried for their position information (Listing 9). After the data transfer, a minimum wait time is required before releasing the chip select line. According to the datasheet, this minimum time is 3 microseconds. While this delay is typically observed naturally at slower data rates, it is good practice to implement it explicitly in the code to ensure proper operation and adherence to the timing specifications. This ensures reliable communication with the AMT22 encoder. Conclusion Users should now have a basic understanding of configuring and reading data from Same Sky’s AMT22 absolute encoders. This article focused on the AMT22 absolute encoders. Same Sky also has a line of AMT modular encoders which offer a range of incremental, absolute, and commutation versions.

Listing 8: Setting up an array for reading multiple encoders.

Listing 9: Reading the encoderPosition variable from multiple encoders.

we get technical

53

Powered by