Show Posts
Pages: 1 [2] 3 4 5
16  Forum 2005-2010 (read only) / Development / Re: safe way to prevent millis() wrap? on: November 03, 2009, 03:09:04 pm
I think I found my own answer, reading code tells all.
Here is the variable declaration Arduino uses to persist millis:
volatile unsigned long timer0_millis = 0;

So I presume this is how I'd whack it, in my code:
timer0_millis = 0;

So my problem is reduced to this:

setup()
{
  // quiesce chip features, change I/O pins, and enable power saves
  // setup external interrupt buttons (low level interrupt)
  // sleep here (power down mode)
  // wakes up here
  ...
  // setup the way I need things
  // do my job (transmit information - one shot)

  timer0_millis = 0;
}

loop()
{
  // listen for echo (if serial.Available() > 0)...
  ...
  if ( millis() >= 1000 )  {
    // reset (jump to address zero)
  }
}




17  Forum 2005-2010 (read only) / Development / Re: safe way to prevent millis() wrap? on: November 02, 2009, 08:15:59 pm
Even if it's static, won't the next iteration of loop overwrite it?
18  Forum 2005-2010 (read only) / Development / Re: safe way to prevent millis() wrap? on: November 02, 2009, 11:36:51 am
BenF - aha!  With all that type casting I must have missed the fact you are working with the least significant bits of the counter by truncating it.

For what I need to do, I think I have to move the following lines of code you show up to setup() so it only runs once, and get it out of the loop.

 // first sleep cycle after 1s
  static word loop_time = LOOP_INTERVAL;

What I see happening here is the first interval is not likely going to be a whole interval, but thereafter, I'll get the full 1s.  This means a glitch on the first cycle.

My application sleeps mostly.  External interrupt button wakes it up, it does something, then stays awake for a short period of time listening for a response which may or may not come, then goes back to sleep again.  So it's more of a one-shot timer per run, than a cyclic design.   Timing that first cycle, or one-shot, is the most important cycle.

Anyway, I get the message of ignoring millis() boundary conditions if you play in a safe zone of lower bits only.   I'll play with this idea.

It would be far easier to whack millis to zero for me, so if that secret is revealed shortly, I'll be in good shape.


19  Forum 2005-2010 (read only) / Development / Re: safe way to prevent millis() wrap? on: November 01, 2009, 11:41:33 pm
Your code snippet illustrates my point, it breaks when millis is near the top end of it range.  You'll end up getting a huge negative number in the comparison and it will never trigger... er ah, well in 49 days it will trigger.

So, given Arduino v0017, what's the commands to whack millis ?
I'm running on a 328P chip.
20  Forum 2005-2010 (read only) / Development / Re: safe way to prevent millis() wrap? on: November 01, 2009, 06:49:05 pm
The code I'm concerned about is millis() + 1000 exceeding the range of the variable.

I'm doing a one-shot fuse, not looping for pacing code in even intervals.

I do this at the end of setup():

fuse = millis() + 1000;

...

Then, in loop() I have an if statement comparing fuse to current millis().  When millis() exceeds fuse I put the CPU to sleep.


I'm lazy and don't want to do a bunch of conditional logic checking for boundary cases of millis().   I just want to whack millis() to zero in place of setting fuse.  Then in my loop() code, I'll just use
if ( millis() > 1000 )...


Anybody know how to whack millis() ?


21  Forum 2005-2010 (read only) / Development / safe way to prevent millis() wrap? on: October 31, 2009, 12:30:29 pm
I use ( millis() + 1000 ) to set a future time that I loop until reaching, and in the odd case when millis is at the high end of its range, this is not going to work well... like every 59 days or whatever.  

Nothing else in my code is timer sensitive, so I'd just as soon reset millis() to zero just prior to my need of adding 1000 to it, ever time.  Then I am guaranteed not to blow its variable size limits, and there is no concern about wrapping on the high end.

What's the command to set millis() back to zero?

Thanks
22  Forum 2005-2010 (read only) / Troubleshooting / Re: ATMega328P broken? on: March 10, 2010, 02:47:25 pm
You selected the right download COM port from the Arduino environment menu?
23  Forum 2005-2010 (read only) / Troubleshooting / Re: Help with Piezo element on: March 10, 2010, 02:55:31 pm
Mount the piezo element by one edge only.  Glue a small weight to the opposite edge.  This helps pick up smaller vibrations.  
24  Forum 2005-2010 (read only) / Troubleshooting / Re: Freeduino board problem on: October 25, 2009, 12:10:18 am
The back side of your board seems to show a lot of solder gaps and looks to be cold solder.  Use a little more heat and little long, and using flux core solder give that whole board a once-over.  Some of joints have enough solder so you might want to just use a flux pen on them and touch them up.
25  Forum 2005-2010 (read only) / Development / Re: why two regulators on Mega board? on: March 04, 2010, 12:15:54 am
Well, the transistor that switches power sources is similarly shown on the schematic.. two different part numbers wired in parallel.

Probably following the same kind of logic as the alternate parts for regulator.
26  Forum 2005-2010 (read only) / Development / Re: why two regulators on Mega board? on: March 03, 2010, 10:41:06 am
DOh!  I'll put on the glasses and look at little harder at the numbers mounted on the board next time.

thx
27  Forum 2005-2010 (read only) / Development / why two regulators on Mega board? on: March 02, 2010, 02:53:49 pm
On the schematic, shows wired in parallel:
MC33269ST-5.0T3
MC33269D-5.0

And both parts seem to be mounted on my Mega board... both spots occupied, one regulator is smaller package than the other.   I'm not used to seeing linear regulators ganged up like this.  It just seems odd.  

Is there some benefit for two regulator off the other for handling transient response, or is this just to offer up a little more current for loads?

I don't think both regulators would have the exact same Vout, what's the effect of that?

For example, if one is trying hard to supply say 5.1 volts until it maxes out and starts to sag under its full load... where it falls back and the other sitting at Vout = 5.0 starts to contribute.
28  Forum 2005-2010 (read only) / Development / Re: Arduino Mega with ATmega2560 on: March 04, 2010, 12:20:10 am
Hey, don't grow that multidisplay into an full blown OBD computer!

Speaking of which,   I couldn't help but to notice that I can go and buy and plug in a $70 item into my OBDII port on the car and get most of things you're trying to wire up to the Arduino.

It has buttons and LCD screen, and can scroll through all the reported parameters...
29  Forum 2005-2010 (read only) / Development / Re: What's consuming all the power on Mega board? on: March 04, 2010, 09:05:29 pm
That must be a typo 33Ah.   !?  

And yes, the wacky non-on-center 0.1" spacing of one side of the board is just stoooooopid.   That just p*sses a guy off.
30  Forum 2005-2010 (read only) / Development / Re: What's consuming all the power on Mega board? on: March 04, 2010, 12:01:48 pm
I like the ideas.

Quote
find an 80% efficient switching cell-phone regulator that outputs 7V

Further yet, find a 12 to FIVE volt switcher (I think I've got one kicking around for some old gadget / cell charger) and just connect its output to the Vcc rail directly.   Going around the whole on-board linear section.


And, cut the FTDI supply and connect directly to USB.. Brilliant.  20mA saved during run mode.   And still able to upload new code with the target installed in the car.  

Why wouldn't Arduino brand think of that?   Had I know Seeduino does this, I'd have picked it over Arduino.   Now I just have to get surgical.

Chiseling off the USB chip and the regulator gets me down to just the MEGA consuming 20mA at full clock... which is acceptable for me to leave connected to car battery all the time as a constant draw.

Plus... the load of my peripherals, but I can manage these ... keeping them switched off under the control of Arduino.




Pages: 1 [2] 3 4 5