Hello. What I want is to be able to detect from which pin on the MCP23017 (MCP1-Arduino1) is detecting the HIGH signal on a specific pin on another MCP23017 (MCP1-Arduino2) this because I want to kind of develop a cable tester which also considers not just continuity but also cable sequence or order. I already make it work on one single Arduino and up to 8 MCPs, however, when doing the same thing by now using a second Arduino with another set of 8 MCPs, I still dont know a way on how to detect (address or location) incoming HIGH signal from MCP1-Arduino1 to MCP1-Arduino2. I already used a common ground cable and communication between Arduinos works fine, but when I change cable order, Arduino still detects the HIGH but not where this HIGH is coming from, so for this project is important to "see" or "detect" address or location so I can then determine if location or address is correct and then able to determine if cable is ok or not (crossed wires). Hope it makes sense.
The problem is in your code. Until you post it we can't tell exactly what it is you have done wrong or misunderstood.
You may want to read this before you proceed to see how to post code correctly here:-
how to get the best out of this forum
#include "Adafruit_MCP23017.h"
Adafruit_MCP23017 mcp1; // Instantiate mcp module object 1, (MCP001)
int dly = 1000; // 1/4 second delay
void setup() {
Wire.begin();
Serial.begin(9600);
Serial.println("MCP module 1 Ready");
mcp1.begin(); // "Start" the mcp object
mcp1.pinMode(0, OUTPUT); //set pin "0" on MCP1 as output
mcp1.pinMode(1, INPUT); //set next pin "1" on MCP1 as input
}
void loop() {
mcp1.digitalWrite(0, HIGH); // Set pin HIGH (on)
if (mcp1.digitalRead (1 == HIGH)) {
Serial.println("Continuity Detected at Pin 1 ");
}
delay(dly); // On for 1/4 second
}
As I mentioned code works ok on same Arduino or the another one. However what I need is to use one Arduino and all MCPs as Output and the opposite on second Arduino with all MCPs and on Second Arduino have a function to "detect" from which pin address the signal if read on Second Arduino. Thanks.
I was rather hoping you would post the code that is going wrong rather that something that works.
It would be handy to see how these chips are wired up to your Arduino.
Why a second Arduino?
This is a cable tester, the two ends of the cable can be in the same place, yes? So why not use a single arduino?
Using two or more Arduino in any project can make the project significantly more difficult. Especially for a beginner. When a beginner thinks that using more than one Arduino is needed in a project, it's frequently because of some misconception. That's why I ask.
Hello, I mentioned cable tester to keep it simple as in theory Im only testing a bunch of cables, but actually Im working on a wire harness tester which has hundreds of cable, connectors, terminals, etc. So That's why I need more Arduinos (2 or up to 10 that depends on the amount of circuits to tests) but right now, Im able to add up to 8 MCPs (I2C) using all A0,A1,A2 wiring for address assignation. That means that with this setup, Im going to be able to test up to 128 test points on that wire harness as I'll be using 8 MCPS on Arduino1 as Output and the other Arduino2 (with also 8 MCPS) as Input. And Again, I already solved that part, it works. However what I need now is to solve the problem that if these wire harness has one, two or more cross cables (assembled in wrong connector, for example circuit 1 goes to connector 1 but user, made a mistake and inserted on Connecter 2) that kind of thing I need to know if there is a way or function on Arduino to determine send or "detect" from which pin on Arduino1 the HIGH signal is coming from (received on Arduino2) Hope this makes more sense. Thanks.
There would be no problem of there was only one Arduino.
Take a look at tca9548 i²c multiplexer:
Still not a lot of sense can I make from that. What is this HIGH signal of which you speak? Is it the interrupt pin from the MCP23017? Are they all wired together, so you can't tell where they come from? Are you actually reading the registers in the MCP23017 so you know what bit has changed?
Again how are these connected to the Arduino?
You know where this are coming from, by the address you use to read the individual bits in the MCP23017.
As I have said before we need to see both a schematic and the code that is not working.
Maybe You'll have more success doing it the other way round. Assuming the wiring harness has multiple connectors, you set all the arduino pins (or in your case port expander pins) to input high on all but one connector. On the remaining connector, you systematically go through each pin bringing it low then scanning all the pins on the other connectors to see which are now low also. You the repeat the exercise until evey pin on every connector has been brought low while scanning every other pin.
This should even work in the case of a harness where a wire could loop back onto the same connector or where multiple wires join within the harness.
You'll have difficulties if you attempt to spread the activities over multiple arduinos .
You appear to be extremely confused here on a couple of points, a number of points actually.
Firstly, you do not use more microcontrollers merely because you need more I/O "pins". You use the "port expanders" such as the PCF8575 or the MCP23017 to access sixteen I/O at a time.
Nominally, you can use eight PCF8575 or MCP23017 modules (to total 128 I/O pins) but in fact there are simple "tricks" to increase this several times. So you can have hundreds of connections controlled by the one Arduino.
Secondly, if you were to use multiple Arduinos, you have a big problem of arranging communications between them. This alone is a serious reason not to attempt to do so.
But it seems you simply do not understand the testing process. As 6v6gt explains, you start by setting all I/O pins to INPUT and enable all the pull-ups. On the PCF8575 this happens by writing all register bits as "1". On the MCP23017 it is rather more complex. You have an option here - you either distinguish between one cable end and the other, or you just treat all pins the same. You then set just one pin as an output LOW and interrogate all the registers to see which input or inputs are now reading LOW.
There are a couple of matters here. Since you with to test the actual order of connections, then you must have some sort of table to indicate what the correct connections will be. Of course, you also verify that not only is the correct connection made, but even if it is, no other connection occurs, which would indicate a short circuit in the cable.
Now the effective internal pull-ups of these port expanders approximate to values between 40k and 100k, so a cable may have a leakage of a similar value. You then have to decide whether such a leakage is a fault, or simply acceptable. If you consider it a fault, then the built-in pullups of the port expanders will be overcome by such a leakage and the fault will be demonstrated. If however you wish to tolerate such leakage, then you need to provide additional pull-ups (to every pin) of a lower value such as 10k or 5k.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.