![]() ![]() It is not necessary to define the main pins for SPI communication, but it is helpful to do as a reference. Moving all the numbers to the top also makes the code easier to read. This way if the code needs to be modified for a different board, or we want to change which pins we use, it can easily be done here in one place. We also want to use defines at the top for the SPI pins. So, we will create two defines for the resolution of the encoder that we can use with our function calls. The AMT22 encoder is available as a 12-bit or 14-bit encoder, but we only want to write code once. Let us also define a couple of characters we can send over serial for formatting our data. Because the encoder does not care about the content of the first byte, we will define it as a NOP (no-operation). We should also define the commands used by the AMT22. We will set the baud rate to 115200 in a define macro. We want to get the position from the Arduino to the computer, so we will use the built-in serial connection to the Arduino IDE. The connections to various Arduino boards will be different than this example, so consult Arduino documentation for additional information.įirst, since we are using the Arduino's SPI bus we need to include the SPI library. The following connections are for the Arduino Uno board, however, most all Arduino boards will be compatible with this code. Now mount the AMT22 encoder to your motor or assembly using the AMT mounting instructions to ensure proper installation. You can use the programming module for the AMT22 and our AMT Viewpoint software to verify the encoder firmware is up-to-date.Īfter confirming the encoder has the correct firmware, put the encoder into RUN mode by moving the switch on the back of the encoder to the proper position. With the ability to zero the encoder's position, you can define where the encoder should have its origin.īefore beginning make sure that the AMT22 encoder has the latest firmware. Knowing the absolute position means that you will always know the exact angle of the device. No matter how many times the device is rotated the encoder will always know its absolute position. For a 12-bit encoder there are 4096 distinct positions, and for a 14-bit encoder there are 16384 positions. This means that over a single revolution the encoder will have that many distinct positions. The AMT22 is available as a 12-bit or 14-bit absolute encoder. ![]() AMT-06C-1-036 or any cable with the proper connector for the encoder. ![]()
0 Comments
Leave a Reply. |