Closed AirmanEpic closed 3 years ago
I just reviewed the teensy SPI implementation. It seems fully compatible with the AS5X47 library. The SPI clock configuration is made here :
SPISettings(100000, MSBFIRST, SPI_MODE1)
The maximum SPI frequency is set very low (100kHz) but that should not be an issue. According to the SPI library references, the chosen frequency is the greatest clock frequency lower or equal to the specified value. If no clock has a frequency lower than the specified one, the lowest available is used.
In the case of an Arduino Uno or a Teensy, the lowest clock frequency available is chosen because there is no clock as low as 100kHz.
However, it is a good idea to expose this parameter and let the opportunity for the user to use a custom one.
If you want to test changing the frequency, you can edit the file AS5X47Spi.cpp in your Arduino library folder. Let me know if you have results. I will acquire a Teensy 4.0 board to run some tests here and see if I can reproduce the issue.
I am afraid I have tried many clock speeds, varying them up and down by as much as 3 orders of magnitude to see which would work, to no success. null
It seems to be a hardware issue. Have you tried the same sensor with the same cables connected to an Arduino, in order to check if the issue is not from the sensor or a cable itself ?
Do you have to possibility to monitor the signals at MOSI and MISO pins with an oscilloscope ?
I have checked with an Arduino uno, using your code, and had no issues.
However, I do not have an o-scope so I cannot check pins.
Hi, I made some updates, can you please try to install the following alpha version of the library and tell me if it is better ? I had great results here.
Let me know if you have good results so I can release a new version of the library.
I'm afraid not. Tested on Teensy 4.0 and 3.6 with a variety of clock speeds and still no results.
I begin to wonder if I installed the library properly but it seems very straightforward. I did unzip the folder first and rename it to AS5X47 instead of including the commit code behind it.
Please ensure that you downloaded and installed the correct version :
delayMicroseconds(1);
is present in both writeData and readData methods.It is present.
https://i.gyazo.com/a00f24f1137f0a52da5652e8a8bc8c04.png
I have attempted a similar technique and not had any luck. Thank you for continuing to work on this.
Perhaps the problem is with my specific hardware, though it's odd that it persists across two different boards.
With the previous version of the library, there was no delay between two SPI communications and thus bewteen the ChipSelect signal level changes. With an Arduino it is not an issue because of the clock frequency relatively low. But with the Teensy clock frequency, the AS5147 sensor was not able to detect the changes.
Adding the delay is sufficient to establish the communication between the Teensy 4.0 and the custom AS5147P board I have.
Thus, I now suspect a hardware issue : do you have any other SPI device to test if the teensy SPI still working ?
I'm afraid I do not. And it may well be that problem. I may be not configuring the teensy's SPI properly too.
As the ReadAngle example is working for me with a Teensy 4.0, the problem is not from the library, I can't do more for you. I will close the issue and update the library version with the delay modification. I hope you find a solution for your application.
Unfortunately it seems as though the teensy series controllers do not have the ability to use this library properly or the library does not use the teensy SPI system properly.
while using the readangle example files on both teensy 4.0 and 3.6, for a variety of CPU speeds, the output is 0 for any values of rotation. SPI bus is plugged in correctly with all pins in the correct ports.
If purchasing components is necessary to fix this issue, please write me a bill.