Digital Inputs on IND.I/O always HIGH unless connected to PC

I have a strange problem with IND.I/O:

I am using 4 pins (CH1 - CH4) (of digital i/o) as input, 4 pins (CH5 - CH8) as output.

The pins are correctly defined with Indio.digitalMode(1,  INPUT); ... etc

After uploading the code, everything works normally. When I disconnect the 24 VDC supply and I connect it back again, all digital i/o channels are HIGH, no matter that they're defined as INPUT, or as OUTPUT with state LOW.

Only way (I found so far) is to connect Industruino to USB, then disconnect 24 VDC, then connect 24 VDC back, and then it works normally (until disconnection of 24 VDC)

The problem is, that other programms, with reading/writing I/O work well. Also with the same libraries as in this non-correctly-working programm (which is using the same pieces of code).

I've tested this on 2 pcs of Induistruino IND.I/O, with the same behaviour.

What can be reason of this? Does anybody has similar experience?

Richard Fela
Richard Fela
32
| 0 0 0
Asked on 7/22/16, 4:50 PM
0
vote
741 Views

I think the problem is in understanding the USB configuration of Industruino.

I suppose we are talking about the 32u4 platform, the two architectures are totally different.

This MCU is the same as Arduino Leonardo in that it has a separate USB for pc connection.

This USB behaves differently than usual RT-TX USB, it is named Serial, while normal RX-TX is named Serial0 or Serial1, I don't quite remember which.

Anyhow this Serial requires an extra instruction which waits for connection before starting. Usually this is the solution for it:

  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  } 

But when the pc is not connected the loop hangs indefinitely.

To avoid this a timeout should be inserted in the loop.

Something like:

int wait = 10000;   //milliseconds
long tOut = millis();

  Serial.begin(115200);
  while (!Serial) {
    if(millis() > tOut+wait) break; // wait for serial port to connect. Needed for Leonardo only
  } 

This should do the trick. Let me know if it helps.

Stefano Giuseppe Bonvini
Stefano Giuseppe Bonvini
47
| 0 0 0
Answered on 7/24/16, 8:26 AM
0
vote

Yes, this prevents infinite loops. But still, and it has nothing to do with serial communications, I guess, question is, why the dig. I/O became HIGH, although they're not defined as HIGH. To make it clear: Some dig. I/Os are defined as INPUT, some as OUTPUT. All inputs are HIGH (even they're not connected with any voltage), unless all outputs are not setted to HIGH or LOW. From the point of exact setting the outputs to HIGH or LOW (I am setting them to LOW in setup() ), also the inputs starts to work normally (became HIGH when the voltage is applied, otherwise they're LOW)...

Richard Fela
on 7/28/16, 5:40 PM

Reading carefully through your posts, there are a few different scenarios. The fact that an input reads HIGH could be due to pull-up resistors, which are activated by writing HIGH while in INPUT mode and could very well be on at startup. The fact that you disconnect power by maintaining USB power is not a proper operation, actually you shouldn't do that I think. The reason why I/O does not work after such operation resides in the fact that I/O in Industruino is handled by an external I2C IC, which is setup by Indio.begin() if I remember well, so if you keep the MCU running and connect I/O afterwards, it simply does not work, or shows a random state. You could solve this by cutting power in the USB line, so that when you switch off also MCU power goes off, or by pressing reset when you switch on power. But still I think it is not a normal operation procedure and should be avoided. Please let me know if I answered your question!

Stefano Giuseppe Bonvini
on 7/28/16, 6:34 PM

Yes, now it's clear, thanks for explanation. Well, normally I am not disconnecting external power supply, when USB is connected. I was just trying to do anything to make it work as expected/wanted.

Richard Fela
on 7/30/16, 10:59 AM

Yes, 0 V of the supply and GND on Digital I/O are connected to each other.

I uploaded the code here:  https://transfer.sh/UceZB/riadenie-test.zip

Yes, it's true that when supply is disconnected, then I/O, RS485 are not working. I am doing it, because then (Supply OFF, USB IN, Supply ON. USB OUT) the Dig. I/O pins started to working as defined in Indio.digitalMode...

 

EDIT: IT'S WORKING NOW

I found, by cutting out the parts of code, that digital OUTPUT must be set in any state (HIGH, LOW), in the loop() or setup()

(so I put in setup() all outputs to LOW)

Richard Fela
Richard Fela
32
| 0 0 0
Answered on 7/22/16, 5:44 PM
0
vote

Are you sure of your connexion between the 0V of your supply and the digital I/O GND ? Your problem sounds like it. I tend to use earth as a common connection inpower supply and any GND pin in the IndIO, except the RS485 serial port.

Anyway, when your supply is disconnected, the IndIO board is not supplied by the 5V from your USB connector (RS485 serial1 port does not work, for example).

Hope this helps.

Didier DORGUIN
Didier DORGUIN
17
| 0 0 0
Answered on 7/22/16, 5:26 PM
0
vote

Your answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

Ask a Question

Keep Informed

About This Forum

This community is for professionals and enthusiasts of our products and services.

Read Guidelines

Question tools

29 follower(s)

Stats

Asked: 7/22/16, 4:50 PM
Seen: 741 times
Last updated: 7/24/16, 8:26 AM