Comments (24)
What's the speed of your SPI bus? I remember having some issues if the speed was over 500k. I'm currently running w/ 200k\
I was running at 10MHz. I lowered to 200KHz and still no change.
from arduino_mcp3x6x_library.
If you have access to a scope, can you check the activity on MISO?
from arduino_mcp3x6x_library.
Sorry for the delay. Was feeling rather unwell this weekend. Working on it now.
from arduino_mcp3x6x_library.
If you have access to a scope, can you check the activity on MISO?
I have this tool that can view SPI. Does this help? Please ignore the CS line, it is not connected as i didn't break out a header for that pin, however the analyzer is set to ignore the CS line for now.
from arduino_mcp3x6x_library.
MISO and MOSI seem to show reasonable signals. Seems like the second picture is showing a 1Byte command followed by another 2Byte command... I did not try to figure out which are these. But it seems save to say MCP3x6x::read(Adcdata *data)
is never executed as this would result in a 3-5Byte command. At least this is not shown in any of these pictures.
I still suspect the issue in this little snippet:
settings.mux = ch;
_status = write(settings.mux);
_status = conversion();
while (!_status.dr) {
_status = read(&adcdata);
}
please put an Serial.print(_status.dr)
inside the loop and right in front of it, it looks like this is currently not executed. This bit should be set when conversion started and reset when valid data available. As this bit is part of the status byte endianness is important, but also timing of spi speed vs conversion speed might cause it.
from arduino_mcp3x6x_library.
Here's the change and here is the output:
only one appears to be running.
from arduino_mcp3x6x_library.
Here's the change and here is the output: only one appears to be running.
I've had issues with the while loop, in my implementation I just directly read instead of waiting for the data ready bit. I have to be careful with my sample rate or it returns the same value for each of the channels.
from arduino_mcp3x6x_library.
No change to the output.
from arduino_mcp3x6x_library.
from arduino_mcp3x6x_library.
still no change to the output:
Trying to read MCP_TEMP.
from arduino_mcp3x6x_library.
Question on why the int32 is truncated to 25 bits in adcdata? The ADC can return either left aligned or right aligned 32 bit values. The assignment in the result struct retains all 32 bits
from arduino_mcp3x6x_library.
Question on why the int32 is truncated to 25 bits in adcdata? The ADC can return either left aligned or right aligned 32 bit values. The assignment in the result struct retains all 32 bits
yes, the dataformat is choosen within the begin() funtion
from arduino_mcp3x6x_library.
Question on why the int32 is truncated to 25 bits in adcdata? The ADC can return either left aligned or right aligned 32 bit values. The assignment in the result struct retains all 32 bits
yes, the dataformat is choosen within the begin() funtion
I see that, but my point is that if somebody chooses a left aligned output, then the 7 leftmost bits get masked out? Or am I understanding it wrong?
from arduino_mcp3x6x_library.
I assume you are right.
My intention was to make this library for getting easy started as the component is really complex. This is why the begin functions sets a few default parameters... they might be not good for every case, but if someone chooses to set up their own config than I would suspect it is on him self to handle this. This is also why I refactored settings to be a class by its own so in future it could be a parameter of begin().
from arduino_mcp3x6x_library.
Any other idea's I can try?
from arduino_mcp3x6x_library.
Any other idea's I can try?
Maybe try returning adcdata.value
directly at the end of analogRead?
So
return adcdata.value;
instead of
return result.raw[(...
Otherwise I don't really have a clue/it has to be in hardware? I've been testing the same code revisions on my hardware and it's been working (though I'm not using the R revision).
I remember that you put the pins in the constructor of whichever MCP3x6x class you used, I instead opted to redefine the consts in the default constructor.
So my object declaration is just
MCP3561 mcp;
with #defines for MOSI, MISO, SS, SCK, and IRQ (if required). The default SPI interface through Arduino is selected.
from arduino_mcp3x6x_library.
I actually think you HAVE to use #define to select pins instead of using the constructor, it doesn't look like parameters are properly passed through the constructor to the SPI object
The parameters required are
#define MOSI
#define MISO
#define SS
#define SCK
from arduino_mcp3x6x_library.
I actually think you HAVE to use #define to select pins instead of using the constructor, it doesn't look like parameters are properly passed through the constructor to the SPI object
The parameters required are
#define MOSI #define MISO #define SS #define SCK
as his logic analyzer pictures have proven some SPI communication I don't see why this should be the case.
from arduino_mcp3x6x_library.
from arduino_mcp3x6x_library.
@LeKrakenTheCode please publish your code. either setup a new repository as minimal example which reproduces your issue or the original code.
from arduino_mcp3x6x_library.
from arduino_mcp3x6x_library.
from arduino_mcp3x6x_library.
seems like it could be fixed by something like this, will work on a better fix later.
MCP3x6x::status_t MCP3x6x::_transfer(uint8_t *data, uint8_t addr, size_t size) {
_spi->beginTransaction(SPISettings(MCP3x6x_SPI_SPEED, MCP3x6x_SPI_ORDER, MCP3x6x_SPI_MODE));
noInterrupts();
digitalWrite(_pinCS, LOW);
_status.raw = _spi->transfer(addr);
#ifdef ARDUINO_ARCH_ESP32
_spi->writeBytes(data, size);
#else
_spi->transfer(data, size);
#endif
digitalWrite(_pinCS, HIGH);
interrupts();
_spi->endTransaction();
return _status;
}
from arduino_mcp3x6x_library.
Just changed the _transfer function, still getting a reply of zero. I am LeKrakenTheCode, I just ended up creating the issue under the wrong account and never changed it.
*** I have removed a println from the analogread function, i am now getting a constant value of 130 (raw adc value) regardless of what i am reading in the mux. i have updated code on github.
from arduino_mcp3x6x_library.
Related Issues (11)
- Problems with SDO on MCP3464 HOT 3
- Some questions about the SPI HOT 4
- Strange issue with MCP3561 HOT 3
- How do I add license in my source code ? HOT 2
- mcp 3462 with Arduino Zero definition-question not issue! HOT 6
- Not really an issue :) HOT 3
- Get stuck in mcp.analogRead loop HOT 7
- Function: _getValue(uint32_t raw) wrong return HOT 8
- How is the “_status.dr” logic changed? HOT 8
- Difficulty with compiling for RP2040 using earlephilhower core HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduino_mcp3x6x_library.