Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: How to protect my program in ATmega328? on: February 26, 2012, 02:03:49 pm
Thank you about the information Nick. But my question is how to set the lock bits?

CrossRoads suggest AVRISP MKii, but this is hardware solution.

Is there a way to protect my code when I use only Arduino board and Arduino IDE? Can I set the lock bits from the program that I upload into the processor?

Sorry about the questions - maybe they are stupid, but I really don't have experience with these lock and protect things. Theoretically I know that I have to set the lock bits, but I don't know how to do that.
2  Using Arduino / Programming Questions / How to protect my program in ATmega328? on: February 26, 2012, 11:56:17 am
Is there a way to protect my arduino program?
I want to protect my device to be cloned. I would like to use the bootloader  to can I easy upload new program into the chip, but to disable chip reading.

I read that ATmega328 has some kind of lock bits, but it's not so clear to me. I decided to ask here in this forum, because I think here is my chance to find an answer.
3  Using Arduino / Programming Questions / Re: Arduino and SLEEP_MODE_IDLE on: January 28, 2011, 12:31:11 pm
For one day that's a range of ten seconds.
It is very well for my project.
I need to reset some variables after an hour or after 10, 20 each case the error is too small to be a problem.
4  Using Arduino / Programming Questions / Re: Arduino and SLEEP_MODE_IDLE on: January 27, 2011, 07:27:56 pm
It is possible to do much better.  But it requires work to get there.
I'm newbie in the electronics and my knowledges are ending with the using of 7805 as 5 volts voltage regulator. I think there is nothing more that I have to do with the arduino. If I have to do something better I have to work on 7805 regulator high power consumption.

I did a little program to measure the WDT overflow period with prescaler set for 8 seconds:
void loop()
  if (resetTimeWDT == 0) {
    resetTimeWDT = micros();
  if (overflowWDT > 0) {
    Serial.println(overflowWDT - resetTimeWDT);
    overflowWDT = 0;
    resetTimeWDT = 0;

  overflowWDT = micros();

Here are some of the results:

So you are right. WDT accuracy is really bad. Maybe I have to calibrate it somehow in each 10 or 30 minutes.
5  Using Arduino / Programming Questions / Re: Arduino and SLEEP_MODE_IDLE on: January 27, 2011, 07:04:53 pm
I implemented WDT wake up after 8 seconds logic and here are my results:

When in SLEEP_MODE_PWR_DOWN the current is only 5.8 mA
Even if I disconnect the Atmega328 from 7805 regulator there are 5.4 mA
When wake up the current is round 20-21 mA

I'm happy with these results. I think on 44 Ah battery this 5.8 mA are small load and will not discharge the battery quickly.

About the WDT accuracy I will calculate the worst case (8.1867 seconds instead of 8 sec):
60 / 8 = 7.5 times WDT will overflow for a minute
7.5 * 0.1867 = 1.40025
there are 1.4 seconds error on each minute

If my calculations are correct we have:
For an hour the error will be 60 * 1.4 = 84 seconds.
For 10 hours the error will be 14 minutes.
I think in my case the error is not a problem.
6  Using Arduino / Programming Questions / Re: Arduino and SLEEP_MODE_IDLE on: January 27, 2011, 04:57:12 pm
Coding, thank you about the explanation. Now I understand what happens.

In this case SLEEP_MODE_IDLE and millis() can't be used together? Or the processor will sleep and will wake up each 1 second and this will result in low power consumption?

Maybe I have to implement WDT interrupt and to wake up on each 8 seconds. I have to count big periods of time like an hour, 2.5 hours, that case I think WDT inaccuracy will not be big problem for me.

Actually I'm trying to do something like car board computer and I want it to resets itself if the vehicle is not running for user defined time. The time can be set in half hour steps. I want my device to be powered on always even when the vehicle is not running and I need low power consumption otherwise my device will discharge the battery really fast.
7  Using Arduino / Programming Questions / Re: Arduino and SLEEP_MODE_IDLE on: January 27, 2011, 11:13:47 am
Thank you about the link. I will review it.

Actually I'm not sure whether I will use millis(), but I wonder why my code is not working. I just want to put arduino on sleep with working millis() and to measure consummated current. Then I will decide whether to use SLEEP_MODE_IDLE or some other sleep mode.
8  Using Arduino / Programming Questions / Arduino and SLEEP_MODE_IDLE on: January 27, 2011, 10:24:16 am

I'm newbie with the arduino and with the electronics. But I try to do some projects with my new arduino.

I'm trying to put the arduino to sleep so that his timer0 will stay working and millis() will count. I try to use SLEEP_MODE_IDLE sleep mode, but without big success. I have an arduino standalone on a breadboard and a LED attached to arduino pin 13 (pin 19 on Atmega328). When I execute the code which hate to put arduino on sleep nothing happens. The LED continue to blink and the current consumption is the same.

Here is my sleepNow() function:
void sleepNow()
  set_sleep_mode(SLEEP_MODE_IDLE);   // sleep mode is set here
  attachInterrupt(0,wakeUpNow, LOW);
  //power_timer0_disable();            //millis() clock

  //Wake up



If I uncomment the line
//power_timer0_disable();            //millis() clock
arduino is going to sleep, but in this case millis() are not working.

I'm using 12V DC with 7805 regulator. Here are my current measurements on +12V line:
7805 itself is using round 5 mA
LED ON - round 29 mA
LED OFF - 21 mA

After sleepNow() is called the current remain the same. If I uncomment the line
//power_timer0_disable();            //millis() clock
when arduino sleeps the consumption is round 11 mA.

Can you help me and tell me what I'm doing wrong and what exactly have to do to put arduino on sleep in SLEEP_MODE_IDLE and millis() function to work?
Pages: [1]