mirror of
https://github.com/eclipse/upm.git
synced 2025-07-12 14:51:12 +03:00
otp538u: some fixes to get working on the Arduino 101 with Firmata
There are some issues using this device on the 101 with Firmata: 1. You cannot use any other ADC resolution than 1024. By default the driver would try to set 12b resolution for improved accuracy. Doing this on the 101 yielded nonsensical readings causing the driver to fail. Using 10b resolution will yield less accuracy, but at least the driver will function. 2. After the first ADC read, and for some time period after, the MRAA aio_read() calls will always return 0. This would cause an exception to be thrown by the driver since this is an invalid reading. Now, we do an analog read on each channel and sleep for .5 seconds in the ctor to get around this problem. It is a hack and should be properly fixed somewhere else (firmata? MRAA?). Some code was reworked/renamed to make it more clear what is actually going on. In addition a setDebug() method was added to enable some debugging output. Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
@ -65,6 +65,10 @@ namespace upm {
|
||||
* These tables assume the object to be measured is 9 cm (3.54
|
||||
* inches) from the sensor.
|
||||
*
|
||||
* This sensor will not work at 3.3v on the Edsion or the Galileo 2.
|
||||
* It works fine on both systems at 5v. It will work at 3.3v on the
|
||||
* Arduino 101 (tested via firmata subplatform on edison).
|
||||
*
|
||||
* @image html otp538u.jpg
|
||||
* @snippet otp538u.cxx Interesting
|
||||
*/
|
||||
@ -135,13 +139,22 @@ namespace upm {
|
||||
* looking at the EAGLE files containing their schematics for this
|
||||
* device.
|
||||
*
|
||||
* @param vref Reference voltage of the internal sensor; default is 2.5 V
|
||||
* @param vref Reference voltage of the internal sensor; default
|
||||
* is 2.5
|
||||
*/
|
||||
void setVRef(float vref) { m_vref = vref; };
|
||||
void setVRef(float vref) { m_internalVRef = vref; };
|
||||
|
||||
/**
|
||||
* Enable debugging output.
|
||||
*
|
||||
* @param true to enable some debug output, false otherwise
|
||||
*/
|
||||
void setDebug(bool enable) { m_debug = enable; };
|
||||
|
||||
|
||||
private:
|
||||
float m_vref;
|
||||
bool m_debug;
|
||||
float m_internalVRef;
|
||||
float m_aref;
|
||||
int m_vResistance;
|
||||
float m_offsetVoltage;
|
||||
|
Reference in New Issue
Block a user