Pages: [1] 2   Go Down
Author Topic: Running Arduino Micro 24/7  (Read 1877 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
Could you please tell me if its recommended/safe to run an Arduino micro 24/7 in a home environment?
So far I have 1 setup but would like to use 5 of them to control roller blinds in my house, my setup works as follows:

- Arduino Micro (input power 12v from  switching adapter vin/gnd)
- Qik 2s9v1 to control 2 motors when activated(1 motor is on each blind), it also uses the same 12v power from the power supply
- 2 reflectance sensors (only active when the motor moves to auto stop the blind)
- 1 Infrared receiver

When not in use, the void loop performs some logic checks and is listening for an infrared signal (using IRremote libary)
Also, would it be better to use less voltage for the input or is this not important?
Thanks in advance for your help!
Paul
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a number running 24/7. They work perfectly, month after month.

Quote
Also, would it be better to use less voltage for the input or is this not important?

You may find the voltage regulator getting hot with 12V input. You may want to scale that back to closer to the minimum recommended amount (7V).

Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Could you please tell me if its recommended/safe to run an Arduino micro 24/7 in a home environment?
So far I have 1 setup but would like to use 5 of them to control roller blinds in my house, my setup works as follows:

Yes, it's OK to run them 24/7. Avoid using dynamic memory allocation in general and the String class in particular, otherwise memory fragmentation may cause available RAM to be exhausted after a while. Also you'll probably want to use the watchdog timer to reset the mcu if the system locks up for any reason

Also, would it be better to use less voltage for the input or is this not important?

That depends on what you have connected to the +5V and +3.3V pins. If you have nothing connected to them, or just low-current devices, then 12V input is fine. If you draw more than about 50mA from them, then the regulator will get hot and a lower input voltage would be preferable.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
Thanks to all of you for your help! the comments are really useful and should help save me some headaches smiley

Regarding the input power of 12v, the only reason I'm using 12v is so that I can use the same supply for both the motor power and the Arduino).  The motor can operate with less than 12v but it will go a bit slower (not really a problem).
Do you know if theres an easy way to take 2 different voltages from 1 power supply? or would using a different supply with 9v be any better instead?

Regarding the connections, there are 2 devices consuming power from the 5v output of the Arduino whilst the system is in wait mode:

1) The Qik 2s9v1 motor controller requires logic power, it uses max of ~15ma when operating and can accept a voltage of 2.7 - 5.5v.
2) The IR receiver (TSOP38238), I can't fully understand the data sheet for this but it looks like it uses ~3ma and can accept a voltage of 2.5 V to 5.5 V.

There are also 2 reflectance sensors (QTR-1A) connected to the 5v but they are not called by the program until the motor is moving.  Each one uses 20-25 mA so I hope that this is not also consumed in standby mode.

I am also really interested to read the comment about monitoring the watchdog timer to reset the mcu if the system locks up, could you please give an example of how to do this in code?

Thanks again!
Paul
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 65
Posts: 3643
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Do you know if theres an easy way to take 2 different voltages from 1 power supply?
Add a voltage regulator to reduce the supply to the arduino - you can stick a heat sink on it too.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks,
Please excuse my questions but i'm new to the Arduino world and this is my first project.

For the Watchdog timer I found some example code and added it in my loop as below - so far it seems to be working so thanks for the idea!

#include <avr/wdt.h>
wdt_enable(WDTO_8S); // have the wdt reset the chip if 8s passes without a reset (in the setup)
wdt_reset(); // reset the wdt (in the void loop)

Can you also please give me some tips on how to check if i'm using dynamic memory allocation.  There are no string variables but apart from that my C knowledge is very rusty.
Most of the variables I use are defined at the top of the script as ints, there are also a few arrays without explicitly choosing a size, e.g.

int sensor_pin[]={0,1};
int sensor_output[] = {0,0};

and functions look like this:

int read_sens(int pin_no)
{

The last question I had was regarding the 'void loop()', in old school programming language we used to always make sure that there was a delay() in the script to avoid saturating the CPU, is this important with the Arduino?

Thanks in advance for your help,
Paul
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you don't use malloc, new, or the String class, you probably are not using dynamic memory (unless one of the libraries you include, does).

There is no need for delay. The processor is running full-speed anyway, inside delay it is just running full-speed checking if time has elapsed.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Regarding delay, you are probably thinking of a multi-programming operating system, like Apple or Windows. In those cases, doing a delay let other programs run. That doesn't apply here.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Great! That has answered a lot of questions for me and put my mind at rest so thanks!

On another note, today I had some other serious issues with my Arduino micro board so I was hoping that you might have some idea.
After putting in the Watchdog timer reset, it pretty much appeared to kill the board.
I could no longer upload any program (not even the BareMinimum), the upload just got stuck for about a minute before timing out.
Both reset and powering off/on didn't fix it, rebooting PC etc..
I did a bit more digging and eventually found 1 fix which got it going again:
   - Hold the reset button.  Start uploading.  Release the reset button.
Noting else worked!
I tried to reproduce the WDT issue again and the same thing happened, exactly as before
When testing this script on my Arduino Uno it worked without problem.
Do you know if this is some nasty bug on the Arduino micro only since it works on the UNO? or could my script be wrong?
I have put the script below, any ideas would be very helpful.
Thanks again,
Paul

#include <avr/wdt.h>
void setup() {  
  wdt_enable(WDTO_8S); // have the wdt reset the chip if 8s passes without a reset
}
void loop() {  
  wdt_reset(); // reset the wdt
}
« Last Edit: January 27, 2013, 06:34:56 pm by phthomps » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It's a well-known problem with some versions of the bootloader on the Arduino Mega.

Installing a corrected bootloader will fix it.

Your technique (of holding down reset) stops the sketch from loading after a power-off, so the problem WDT is not activated.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's a well-known problem with some versions of the bootloader on the Arduino Mega.

Installing a corrected bootloader will fix it.

Your technique (of holding down reset) stops the sketch from loading after a power-off, so the problem WDT is not activated.

Well he stated using an arduino micro board, which like the leonardo board uses a 32U4 chip, so I don't think his problem is based on the old 'doesn't handle WDT interrupts correctly' problem. I would think all the 32U4 based arduino products handle WDT correctly? And I would not think there are upgraded bootloaders avalible for this chip series anyway?

This sounds more like a problem the very first UNO boards had that if loaded with a sketch that started sending serial data immediatly effected the 8U2 USB serial chip from responding to the bootloader correctly, or something like that? It was fixed with a firmware upgrade to the 8U2, but I recall a work around was holding in the reset button, plug the board in and only release the reset when the upload started?

Lefty
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I would think all the 32U4 based arduino products handle WDT correctly?

Well the empirical evidence appears to be against that hope.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would think all the 32U4 based arduino products handle WDT correctly?

Well the empirical evidence appears to be against that hope.

 If anyone wants to try and knows how to reburn the bootloader in case the test results come out positive (or is that negative, I always seem to get that wrong  smiley-wink ), below is a sketch that will 'brick' any bootloader that doesn't disable the WDT upon entry to the bootloader. Bricked both my mega1280 boards until I upgraded them to a optiboot.

Code:
// Test sketch to see if WDT interrupts are handled properly by the bootloader

/*
 Warning Warning Warning this is a semi-destructive test in that
 if your bootloader does not reset WDT interrupts upon starting
 it will be forced into a tight loop of bootloader starts/WDT resets
 chip/bootloader starts again/lather rinse repeat. One can only
 recover to normal operation by reburning the bootloader with
 a ICSP programmer. If this sketch runs properly on a chip with a WDT aware bootloader,
 you will see continous serial output on the serial monitor.

Note that current arduino mega boards will fail this test and brick

*/

// Code from arduino forum poster (sorry name not remembered) 1/11/13

#include <avr/wdt.h>

void setup(){
  Serial.begin(57600);
  delay(100);
  Serial.println("Hello world");
  wdt_enable(WDTO_15MS);
}

void loop(){
  Serial.println("I am going to not get stuck..");
  for(int x=0; x<100; x++) {
    wdt_reset();
    x++;
    delay(10);
  }
  wdt_reset();
  Serial.println("I am going to get stuck now..");
  for(int x=0; 1; x++) {
    delay(10);
  }
}

« Last Edit: January 27, 2013, 09:41:58 pm by retrolefty » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I just happened to have an Arduino Micro to hand (recently received) so I tried your torture test.

It worked (the WDT did its stuff) and afterwards I could upload a new sketch.

Although ... this is strange. After powering it off and on again, even with the ASCII table sketch loaded (and nothing to do with watchdogs) the sketch didn't run. I could upload it again, and it would run, but it wouldn't run the existing one from power-off.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, it seems really flaky.

I can upload new sketches, and after opening the serial monitor it runs them ... the first time.
Logged

Pages: [1] 2   Go Up
Jump to: