Go Down

Topic: Change Code on the fly - submit commands faster (without loading) (Read 583 times) previous topic - next topic

MiddleAge

Hi, maybe someone has an idea for a solution.

I use arduino m328p, everything works fine :smiley-mr-green:. Program is extremly simple, based on the blink sketch under the examples the led on pin 13 blinks once and after that never again.

My task is: let the led blink now, and after that in 3 seconds again, and after that my be in 5 seconds again, and then in 2 seconds again and so on and so on. The time between is not predictable.

At the moment I can do this by loading the blink.hex to arduino by the command line:
avrdude -C c:\etc\ardude.conf -c arduino -p m328p -P com3 -U flash:w:Blink.hex", wait 3 seconds, avrdude again, wait 5 seconds, avrdude, wait 2 seconds and so on.

(In reallity not a lamp should blink but a mini motor should run and do something - but to simplify it, lets use a lamp).

So everything is fine but a little unpretty. I have to load the whole stuff (although it is very small) to the flash every few seconds, that consumes time (about 1 second). So I can never let the lamp light after 1/2 second.

My question: is there a way to start the program again faster without loading the flash. As arduino is always connected to the pc I would prefer to set on the light by submitting a command directly to the unit.

Any idea from the gurus?
Thanks and regards
Rudolf



Osgeld

#1
Aug 06, 2012, 07:34 am Last Edit: Aug 06, 2012, 07:38 am by Osgeld Reason: 1
just send it something via the serial port to change. There is no reason to constantly burn new software to the chip over a simple variable change. (nevermind your killing the write cycles on your arduinos flash ram, which is huge but an erase and rewrite every couple seconds ...)

Krodal

Start the Arduino program.
Select the board, the serial port in the 'Extra' menu.
Write your code and use the upload button.
That's all.

If you have overwritten your boot loader, use the extra menu to burn that again (just once). After that you only have to 'upload' your code.

The goal of Arduino is to make it simple, and you never have to use avrdude yourself.

In your sketch, use the random() function to wait for an unpredictable time.
http://arduino.cc/en/Reference/random

PeterH


My task is: let the led blink now, and after that in 3 seconds again, and after that my be in 5 seconds again, and then in 2 seconds again and so on and so on. The time between is not predictable.


How is the time between defined? Is something outside the Arduino deciding when to perform the blink, or do you want the Arduino to decide?
I only provide help via the forum - please do not contact me for private consultancy.

MiddleAge


How is the time between defined? Is something outside the Arduino deciding when to perform the blink, or do you want the Arduino to decide?

Decision occurs outside Arduino. Only a program, independent from Arduino knows when its time to blink.

Go Up