Hello, I've been on an epic saga today learning about things I wish I didn't have to understand , and for the most part don't have to due to the grace and glory of those who make libraries and make embedded programming nifty things with the teensy "easy."
But here's the deal, I think I have traced an issue I have using the Sparkfun HX711 loadcell reader on my Teensy 3.5. The same breakout board will give good values when I compile my test code for an UNO, and bad numbers when I compile for a Teensy. I think there's a function used that works differently on the Teensy than on the AVR.
HX711 gives me a 24-bit number in a simple two-wire protocol, and most libraries split that into 3 8-bits that get recombined into a padded 32-bit.
At first I chased what I saw to be the usual issues, doubles being actually-doubles with teensy, and people writing arduino libraries that aren't very explicitly on what an Int is, for example. Then I chased the code that combined the 3 8-bits into a padded 32-bit, thinking they were working differently due to [not really sure what reason, but I understand teensy can shift further than some processors in a single step]
But then I got to the point that I saw that the 3 8-bits that the Teensy was reading from the DOUT of the HX711 were not apparently the correct values.
I posted an issue to the library, here: https://github.com/bogde/HX711/issues/84
The .cpp file has a "read" function and it takes the reading from the HX711 using the following excerpt:
It seems shiftIn doesn't cause a compiling error on the Teensy, but it doesn't work the same as on the UNO...
Is this a really obvious issue that someone else can illuminate for me?
In the github issue I posted my 'solution' which was mashing together code from a raspberry pi HX711 library under the assumption the formatting would be more native to the Teensy. I have not fully tested it, but it seems to work. I have not yet understand the full context to the issue, and am eager to settle this more concretely.
If I have not posed a sensible question, I apologize, this realm of programming is far from whatever limited area I am comfortable with. I will be reviewing bitwise operations and all the relevant functions over the course of the next day, I just am about 16-hours into this saga of learning why the Teensy wasn't working with code that worked for the Arduino, and I am hopeful that my issues are relevant to other teensy users.
I will update this post if I get to the bottom of everything before anyone has a chance to explain.
But any help or pointers until then, will certainly be appreciated. !
But here's the deal, I think I have traced an issue I have using the Sparkfun HX711 loadcell reader on my Teensy 3.5. The same breakout board will give good values when I compile my test code for an UNO, and bad numbers when I compile for a Teensy. I think there's a function used that works differently on the Teensy than on the AVR.
HX711 gives me a 24-bit number in a simple two-wire protocol, and most libraries split that into 3 8-bits that get recombined into a padded 32-bit.
At first I chased what I saw to be the usual issues, doubles being actually-doubles with teensy, and people writing arduino libraries that aren't very explicitly on what an Int is, for example. Then I chased the code that combined the 3 8-bits into a padded 32-bit, thinking they were working differently due to [not really sure what reason, but I understand teensy can shift further than some processors in a single step]
But then I got to the point that I saw that the 3 8-bits that the Teensy was reading from the DOUT of the HX711 were not apparently the correct values.
I posted an issue to the library, here: https://github.com/bogde/HX711/issues/84
The .cpp file has a "read" function and it takes the reading from the HX711 using the following excerpt:
Code:
data[2] = shiftIn(DOUT, PD_SCK, MSBFIRST);
data[1] = shiftIn(DOUT, PD_SCK, MSBFIRST);
data[0] = shiftIn(DOUT, PD_SCK, MSBFIRST);
It seems shiftIn doesn't cause a compiling error on the Teensy, but it doesn't work the same as on the UNO...
Is this a really obvious issue that someone else can illuminate for me?
In the github issue I posted my 'solution' which was mashing together code from a raspberry pi HX711 library under the assumption the formatting would be more native to the Teensy. I have not fully tested it, but it seems to work. I have not yet understand the full context to the issue, and am eager to settle this more concretely.
If I have not posed a sensible question, I apologize, this realm of programming is far from whatever limited area I am comfortable with. I will be reviewing bitwise operations and all the relevant functions over the course of the next day, I just am about 16-hours into this saga of learning why the Teensy wasn't working with code that worked for the Arduino, and I am hopeful that my issues are relevant to other teensy users.
I will update this post if I get to the bottom of everything before anyone has a chance to explain.
But any help or pointers until then, will certainly be appreciated. !