Indino.analogRead runs into infinite loop

Hi guys

I'm have an Industrino connected to a sensor with a current loop. In about 75% of the time a call to the function Indino.analogRead(4) results in an infinite loop. In between the reading of the input channel is working fine. 

My settings regarding the input are the following:

setup(){

Indio.setADCResolution(16);

Indio.analogReadMode(4, mA_raw);

}

loop(){

...

tc_4 = Indio.analogRead(4);

...

}

 

What could be the reason for this behavior?

 

Thank you very much

Thorhallsson

Björgvin R Þórhallsson
Björgvin R Þórhallsson
7
| 2 1 2
Asked on 3/6/18, 2:31 PM
0
vote
1949 Views

Hi, can you tell us what you mean with 'infinite loop', do you mean your code gets stuck at the analogRead? How you are powering the INDIO unit? If it is also connected to USB, do you get any messages in the Serial Monitor? Please note that at 16-bit resolution, you can only get 15 samples per second, see doc https://github.com/Industruino/libraries#analog-input

Tom
on 3/8/18, 6:18 AM

Hi Tom. Thanks for your answer. By infinite loop I mean the program gets stuck whenever it makes a call to the function Indio.analogRead(*) It is powered by an external power source and the program is running analogRead once every minute. What I have done since I posted this is to break up my program. One part containing only the analogRead part is working fine. It is basically the Indio.analogRead example program. The other part of my program is connecting to a GSM module we I'm using TinyGsmClient to send message to my server build on this example: https://github.com/vshymanskyy/TinyGSM/blob/master/examples/WebClient/WebClient.ino This usually stops at “Waiting for network… Fail”. The device manages to send messages to the server in about 5% of the cases when the device is restarted. Given that it works every now and then I can eliminate: jumper config, SIM card not functioning and data plan. Are there any known problems with the GSM module or any ideas what could be wrong at my setup? Thanks!

Efla verkfraedistofa, Björgvin R Þórhallsson
on 3/15/18, 4:41 PM

Hi, my guess is that it has to do with the power on/off of the GSM module. The sketch you link to is not specific to the Industruino GSM module, please have a look at https://github.com/Industruino/democode/blob/master/GPRSwebclientTinyGSM_D21G_HardwareSerial/GPRSwebclientTinyGSM_D21G_HardwareSerial.ino

So, the module can be switched on/off with a 1s HIGH pulse on D6. My guess is that your module is switched off most of the time. I suggest you include a function in your code to check if the module is on, and if not, switch it on with a pulse.

 

Tom
Tom
5675
| 1 1 3
Answered on 3/15/18, 11:30 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

43 follower(s)

Stats

Asked: 3/6/18, 2:31 PM
Seen: 1949 times
Last updated: 3/15/18, 11:30 PM