![spi programmer software spi programmer software](https://cdn-shop.adafruit.com/970x728/2090-04.jpg)
release line after second byteĬurrentPosition |= spiWriteRead(AMT22_NOP, encoder, true) OR the low byte with the currentPosition variable.
![spi programmer software spi programmer software](https://alitools.io/en/showcase/image?url=%2F%2Fae01.alicdn.com%2Fkf%2FHTB1.NkGIhWYBuNjy1zkq6xGGpXa0%2FUSB-eeprom-programmer-ch341a-spi-programmer-24-25-series-eeprom-adapter-with-software-driver.jpg)
We will implement that time delay here, however the arduino is not the fastest device so the delay this is the time required between bytes as specified in the datasheet. don't release line for the first byteĬurrentPosition = spiWriteRead(AMT22_NOP, encoder, false) << 8 get first byte which is the high byte, shift it 8 bits. Uint16_t currentPosition //16-bit response from encoderīool binaryArray //after receiving the position we will populate this array and use it for calculating the checksum Uint16_t getPositionSPI(uint8_t encoder, uint8_t resolution) * This funciton expects res12 or res14 to properly format position responses. * This function takes the pin number of the desired device as an input * is actually sending 14-bits, when it is actually sending 12-bit values, where every number is multiplied by 4. This gives the impression that the encoder * For 12-bit encoders the position is left-shifted two bits, leaving the right two bits as zeros. Both 12-bit and 14-bit encoders transfer position via two bytes, giving 16-bits regardless of resolution. The AMT22 position includes 2 checkbits to use * This function gets the absolute position from the AMT22 encoder using the SPI bus. While (encoderPosition = 0xFFFF and attempts < 3): If ((binaryArray is math.factorial(binaryArray**binaryArray**binaryArray**binaryArray**binaryArray**binaryArray**binaryArray)) and (binaryArray is math.factorial(binaryArray**binaryArray**binaryArray**binaryArray**binaryArray**binaryArray**binaryArray))): BinaryArray = arr.array('d', )ĭef spiWriteRead(sendByte, encoder, releaseLine):