I want to build a digital LED stop watch with inputs for start timing, stop timing and reset.
I have some PLC Programming time but nothing else and very little of that.
This stop watch must be accurate (crystal timebase) and I want it to be an all in one unit. In other words I want the drivers for the LED display to be on the same board as everything else. I do not know which unit I need to do this. I have an idea but not completely sure. I have seen a program on this site somewhere that looks like the program close to what I will need but just asking for some help in making the the right unit purchase and maybe some programing help in the future. The display should read as follows. 3.123 or could simple be .123 leaving off the digit to left of the decimal. Is this possible with any of these Arduino units?
I just posted a new sketch in the Playground 5 minutes ago called CountUpDownTimer. HOWEVER... This sketch does not replace the precision of a RTC module. If you need a precise crystal timebase, then you need to get a RTC module.
Thank you
I'm totally new here and I've been going through the tutorials and one of the things that this brought back to me was scan time of the unit itself.
I had forgotten about that until I saw the video but it reminded of the first few times I worked on PLC's many many years ago. The emergency stops were always located outside of the PLC (hard wired) because of several reasons but one of them was PLC program scan rate. I will need scan rate to not be an issue and I assume that can be done with programming in the Arduino that we didn't have available to us in the early PLC. I understand that a simple program will be quicker for scan rate but it needs to be exactly the same every time. I will not start and stop the watch multiple times, It will be started with contact closure and stopped with contact closure and at that point I want it to be sitting there with it's readout visible until reset for another go.
I really just need at this point to be advised on which unit or units I need to do what I want to do and I will pretty much take it from there. I may need some help on this digital readout though. My plans are to purchase a unit and to bread board what I need to do and go from there.
I'm trying to look through all the forums for other post and data but I'm absolutely new as a friend pointed out that this site might be a place I could do what I wanted to do.
Thanks in advance
Oh, what is playground?
Get one of these DS1302 RTC Module, DS1307 RTC Module or DS3231 RTC Module (More precise)
Libraries and example sketches can be found here Time Section.
How does an RTC chip that tracks:
•Real-Time Clock Counts Seconds, Minutes, Hours, Date of the Month, Month, Day of the Week,
help as a stop watch?
Any Arduino with a MAX7219 and 7-segment displays is all that is needed.
code to read 2 buttons and capture micros() like this at the very basic level (flesh out declarations, setup(), etc)
void loop(){
if (digitalRead(startButton) == LOW){
timeStart = micros();
running = 1;
}
if (running == 1){
while (digitalRead(stopButton) == HIGH){
// hang out
}
// stop button pressed!
timeStop = micros();
running = 0;
duration = timeStop - timeStart;
Serial.print (duration);
Serial.printlm (" microseconds ");
// add code to send to MAX719, with desired formatting
// then wait for a reset
while (digitalRead(resetButton) == HIGH){
// hang out
}
// reset pressed!
Serial.println ("ready");
}
} // end loop
Edit: Updated playground sketch.
@CrossRoads
The OP wanted to have crystal timebase precision, so I gave the OP a crystal timebase solution.
The sketch I posted, will kinda do what he wants, but it is not as precise as an RTC and I did not give the option to show the milliseconds or microseconds (
Actually, I will add that now). Now does the OP really need absolute precision? most likely not, but it's what the OP wants.
Absolute precision is the most critical aspect here.
I'm willing to listen to reasons why I don't need a crystal time base but everything I deal with has a crystal time base for precision so I suspect it's needed.
I'm not trying to instigate an argument here. I truly appreciate the help and suggestions because I know absolutely nothing about the Arduino.
The thing I'm having the most trouble wrapping my mind around is the display.
Found this:
http://playground.arduino.cc/Main/MAX72XXHardware
3.123 or could simple be .123
That's in seconds? A crystal-based Arduino can easily track time to multiples of 4uS, 0.000004.
It's a stopwatch, not a long-term clock display. Timing to 0.0000x and displaying 0.xxx would seem to meet the requirement, yes?
(I've also posted code numerous times that shows an Uno and Duemilanove can track time to the official US time and run for days and not drift.
http://www.nist.gov/ )
The MAX7219 is easy to use driver to control display of digits. In setup() you write to 5 control registers; in loop() you send it an address from 1 to 8 and a number and it displays that number on a LED digit. 8 addresses, 8 digits. Pretty simple. My Bubblicious card is just a very small 8 x 7-segment display. Seems like it would be great for a stopwatch. Larger 7-segment displays are also easily obtained.
MAX7219-MAX7221.pdf (451 KB)
CrossRoads:
That's in seconds? A crystal-based Arduino can easily track time to multiples of 4uS, 0.000004.It's a stopwatch, not a long-term clock display. Timing to 0.0000x and displaying 0.xxx would seem to meet the requirement, yes?
(I've also posted code numerous times that shows an Uno and Duemilanove can track time to the official US time and run for days and not drift.
http://www.nist.gov/ )The MAX7219 is easy to use driver to control display of digits. In setup() you write to 5 control registers; in loop() you send it an address from 1 to 8 and a number and it displays that number on a LED digit. 8 addresses, 8 digits. Pretty simple. My Bubblicious card is just a very small 8 x 7-segment display. Seems like it would be great for a stopwatch. Larger 7-segment displays are also easily obtained.
Yes, It's a stop watch only.
4uS would be accurate enough.
Are you saying that the unit will do that without crystal osc.?
I will look for your code.
So I need the Uno, Duemilanove and the display driver and a display?
Would this do what I want?
4x 7-Segment Arduino Compatible Digit Shield
Product Code : RB-Noo-03
http://www.robotshop.com/en/4x-7-segment-arduino-compatible-digit-shield.html
What range are you looking at? Seconds, milliseconds or microseconds and to what place, tens, hundredths or thousandths?
That display will work, but it all depends on how precise your timing will be or what you're looking for.
HazardsMind:
What range are you looking at? Seconds, milliseconds or microseconds and to what place, tens, hundredths or thousandths?That display will work, but it all depends on how precise your timing will be or what you're looking for.
Range is zero to 5 seconds with 3 digits to the left of the decimal. Example would be 3.123 seconds.
I was under the impression I could power these units with 12 volts and they regulated to 5 or 3.3. Is that the case? If I can't power with 12 volts it won't work for me.
I was looking at the UNO and a few others.
What units, the Arduino or display? Yes for the arduino, and no for the display (unless you regulate the 12V down to a safe 5V, with a (7805) 5V regulator.)
Example would be 3.123 seconds.
That's not hard at all. Simply use either millis() and divide it by 1,000.0 or micros() and divide it by 1,000,000.0 (And yes, the .0 is important to have on the end of them)
Start with this file, counts up. Track the elapsed interval at a finer amount than I did.
simpleCountUpTimer.ino (2.27 KB)
Another punter is running over here
https://forum.arduino.cc/index.php?topic=413202.0
