Go Down

Topic: Stopwatch with Pause/Lap  6 digit 7 seg LED. HELP! (Read 186936 times) previous topic - next topic


CrossRoads

Yes they could - but why install 2 sets of chips when you could purchase one that will do the job?
500mA drive capability is also way more than the 30mA at 12v to drive the segments of the display.  Extra chips means extra board space, extra inventory, slightly more installation time, ultimately just extra cost.

Looks like an awesome display. I believe the bottom 2 ICs and extra pullup resistors could have all been replaced with just the one tpic6b595.  Ultimately it comes down to the tradeoffs made between design goals, production cost, reuse of existing designs and or material with or without rework, time to do new design effort, spin new artwork, re-tool for production, etc.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

David_Rudla

I agree with you about costs  :). My mistake is that with 595 it could be ULN 2803 instead ULN 2804. ULN 2804 is for CMOS logic. Resistors at drawings drive current for each led strip and could be placed here. This decision with 2 chips was due size at that time. I work on this display 6 years ago. Because size metters. :) Sorry for my English. English is not my native language. There is also smaller display on site:
http://translate.google.cz/translate?hl=cs&sl=cs&tl=en&u=http%3A%2F%2Fmcu.cz%2Fnews.php%3Fextend.230.2

warrenreeve

Hi Robert, I got that sorted earlier today. This is what I used;
Code: [Select]
void loop()
{//Reset Button Here
reset_button_state = digitalRead (reset_button);
 if (reset_button_state == 0){
         
          paused = 1;
         
        hundredths= 0;
        tenths = 0;
        ones_seconds = 0;
        tens_seconds = 0;
        ones_minutes = 0;
        tens_minutes = 0;
        ones_hours = 0;
        tens_hours = 0;
        time_update = 0;

       digitalWrite(latchpin, LOW); // send the digits down to the shift registers!
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[hundredths]); // print the hundredths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[tenths]);     // print the tenths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[ones_seconds]); // print the lower seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[tens_seconds]); // print the upper seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[ones_minutes]); // print the lower sinutes digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[tens_minutes]); // print the upper minutes digit
       digitalWrite(latchpin, HIGH);
started = 0;
paused = 0;
     }

Works perfectly!  :)

Powering the displays:
1. I agree with the motorcycle battery idea. Those lead acid ones are cheap and narrow enough to fit in the unit although if I could get lithium batteries to do the same that would be allot better as the lead acid ones are really heavy and they are approx 2.5 inch depth which may make the whole unit 3 inches.  :-/

2. I am ordering the tpic6b595 chips in the next couple of days. Are they very similar to wire up?

3. I was wondering how to connect the 12 volts. You said about a step-down regulator for the 5V?? I thought the 12 was connected to the Arduino and then I suppose transistors or something go between the outage to the digits?? As you can see I'm not up to speed on the voltage/amp's set up. Any help in this department for connecting and regulating the power would be very much appreciated.

4. I thought about having the digits flash upon power up just to let the user know all is well and all digit's/segments are working. I repeated the shift-out quite a few times in the Void Setup to make it blink.. is this the best way?
Example below but not all;
Code: [Select]
digitalWrite (reset_button, HIGH); // enable pullup
 
 //############## POWER UP #############//
         

       digitalWrite(latchpin, LOW); // send the digits down to the shift registers!
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[8]); // print the hundredths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[8]);     // print the tenths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[8]); // print the lower seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[8]); // print the upper seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[8]); // print the lower sinutes digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[8]); // print the upper minutes digit
       digitalWrite(latchpin, HIGH);
 delay(300);
         digitalWrite(latchpin, LOW); // send the digits down to the shift registers!
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[11]); // print the hundredths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[11]);     // print the tenths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[11]); // print the lower seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[11]); // print the upper seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[11]); // print the lower sinutes digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[11]); // print the upper minutes digit
       digitalWrite(latchpin, HIGH);
  delay(100);
          digitalWrite(latchpin, LOW); // send the digits down to the shift registers!
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[8]); // print the hundredths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[8]);     // print the tenths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[8]); // print the lower seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[8]); // print the upper seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[8]); // print the lower sinutes digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[8]); // print the upper minutes digit
       digitalWrite(latchpin, HIGH);
 delay(100);
         digitalWrite(latchpin, LOW); // send the digits down to the shift registers!
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[11]); // print the hundredths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[11]);     // print the tenths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[11]); // print the lower seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[11]); // print the upper seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[11]); // print the lower sinutes digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[11]); // print the upper minutes digit
       digitalWrite(latchpin, HIGH);
  delay(100);

warrenreeve

Code: [Select]
I agree with you about costs
Thanks for sharing those digit's David.. they're amazing looking although I agree with Robert about the cost and complexity of all that wiring with the extra chip too. I'd sooner just stick the tpic6b595 chips in and know they're done.
Thanks again,
Warren

CrossRoads

#95
Jan 07, 2011, 02:31 am Last Edit: Jan 07, 2011, 07:10 am by CrossRoads Reason: 1
Warren,
Nice job on the reset code.
I'm in between fencing classes - go to www.ti.com and download the datasheet for the shift register, is similar to other shift registers, let me know if you don't understand any pins.
Then, go to www.pololu.com and look at regulators, read the descriptions. If you end up with a 12V source, a stepdown regulator will make 5V without wasting a lot of battery juice heating up the onboard regulator.  You can try just the onboard, do some tests and see how the batteries hold up.
For the displays, the 12V will connect to the common anode on each part, then each segment is wired to a shift register pin (with its built-in high voltage transistor).
Blinking in setup - that way certainly works, I have done similar. The other way is to put a single set of shiftouts in a loop,
something like

Code: [Select]

// loop to flash the displays, in pseudo code
byte i=0;
byte toggle=0;
while (i<6){ // lop thru as many times as you want
toggle=1-toggle; // results in toggle = 1,0,1,0 ...
 if (toggle==1){
 displaychar = 8;}
 else{
 displaychar = 11;}
shiftout (dataline, clockline, MBS first, displaychar); // for digit 1
:
:
shiftout (dataline, clockline, MBS first, displaychar); // for digit 6

delay (300) ;
i=i+1;
}

etc  with your delays & stuff. What you had will work just as well also, this is just a little smaller.
I have some code in some of my stuff that looks like yours, could have probably preloaded all the date into an array and read out from there for display or something - but just writing it out 'longhand' gets it done & over, let the compiler deal with optimizing it :-)

gotta run ...
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

warrenreeve

#96
Jan 07, 2011, 10:39 pm Last Edit: Jan 08, 2011, 12:19 am by warrenreeve Reason: 1
Hi Robert, I knew there would have been an easier way to do it.. :D.
That's great, it saves all that extra text!! I added a bunch of 00's at the end so when the unit is switched on it flashes on/off a few times and then settles on 00:00:00 ready for the user to start the lap. Really chuffed with it, here's what I have;
Code: [Select]
// loop to flash the displays, in pseudo code
byte i=0;
byte toggle=0;
byte displaychar;
while (i<26){ // lop thru as many times as you want
toggle=1-toggle; // results in toggle = 1,0,1,0 ...
 if (toggle==1){
 displaychar = 8;}
 else{
 displaychar = 11;}
     digitalWrite(latchpin, LOW); // send the digits down to the shift registers!
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[displaychar]); // for digit 1
         shiftOut(datapin, clockpin, MSBFIRST, segdisp[displaychar]);
         shiftOut(datapin, clockpin, MSBFIRST, segdisp[displaychar]);
         shiftOut(datapin, clockpin, MSBFIRST, segdisp[displaychar]);
         shiftOut(datapin, clockpin, MSBFIRST, segdisp[displaychar]);
         shiftOut(datapin, clockpin, MSBFIRST, segdisp[displaychar]);
     digitalWrite(latchpin, HIGH);
delay (100);
i=i+1;
}
delay (500);
  digitalWrite(latchpin, LOW); // send the digits down to the shift registers!
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[0]); // print the hundredths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[0]); // print the tenths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[0]); // print the lower seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[0]); // print the upper seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[0]); // print the lower minutes digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[0]); // print the upper minutes digit
       digitalWrite(latchpin, HIGH);
}
void loop()

I was looking at the lithium batteries.. they seem a little dear whereas the lead acid ones are around £10 / $14. I also looked at AA batt set up. Could they be joined up to 12 volt (8 x 1.5v)? Would I be right in saying that a 1800mah x 8 = 14400mah. If the unit ran at 2amps per hour would this set up last approx 7hrs?

I'm taking the family off to see my parents for the weekend so wont be back on till Monday.
Have a great weekend!  :)

LATE ADDITION:
Hi Robert, I have also been looking into adding some kind of memory.. would it be possible to capture the segment display pause time around 20 times and scroll through them with some up/down buttons. Could be a very valuable tool for the unit rather than the times being written at track-side or even worse.. lost!?  :o
I have looked at the EEprom example but can't figure how I would write that for 7 segments?
Any idea's or examples would be great.
Cheers Warren.

CrossRoads

Looks like you're getting the hang of it!

Battery: Yes, you could put multiple AA batteries in series for higher voltage. mAH capacity does not add  up tho, it is only the capacity of 1 battery, but at the higher voltage. Maybe go with D cells instead.
Do you have a cordless power tool? I was just looking at 12V battery packs for a cordless drill, 12V, 3000mAH. Should last quite a while, especially if you add a dimming feature - I will look at the shift register datasheet, see if there is an easy way to toggle the output so the output is cycling on/off while you are waiting for your guy to come around, then go full brightness as he needs to see it.
I am out of town also, back Sunday night. Will look into EEPROM writing. Should be pretty straightforward, just write as block of 8 bytes as an example:
0: race #
1: lap #
2: min
3: min
4: sec
5: sec
6: tenth
7: hundredth

or 10, add in month & day. Just define what you want.

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

warrenreeve

Hi Robert, just wondering if you had a look at eeprom? I've been looking at it myself but not finding a good source to check through. I have found a few that will write and read numbers (+1) counting (or at least I think that's what they're doing??) but I can't find an example of someone actually saving data from a seven segment x 6 digit. Think they need broke up into bytes but not sure how this is done.

Just to clarify what I'm after;
1. Each time the pause button is pressed it would save the 6 digit time.
2. There will be 2 extra buttons, up and down. If up button pressed then memory would show the 1st lap/time.. user can scroll through the times using the buttons.
3. Holding both buttons together for 3 seconds would clear all memory.

I have a reset button to return to lap feature.

Cheers
Warren

CrossRoads

That's certainly doable.
Look here for info on writing/reading EEPROM. Looks pretty simple, just use the command and wait.

http://www.arduino.cc/en/Reference/EEPROMWrite
perform 6 writes, 1 for each digit. You already have the info:
hundredths
tenths
ones_seconds
tens_seconds
ones_minutes
tens_minutes

when pause is pressed, make a copy of the current state
copy_hundredths = hundreths;
etc.
then start writing them to EEPROM, keeping track of the last address you used.
You are updating the time every 10mS, so once a cycle make writing a byte of EEPROM a part of the loop, keeping track of which byte you wrote last so you can advance to the the next one:
if (EEPROM_writing == 1){
switch (byte_to_write){

case 1: // hundredths
EEPROM.write (EEPROM_address, copy_hundredths);
byte_to_write = byte_to_write+1; // increment for next digit
EEPROM_address = EEPROM_address+1; // increment for next bye
break;
...
case 6: // tens_minutes
EEPROM.write (EEPROM_address, copy_tens_minutes);
byte_to_write = 1; // reset for next group
EEPROM_address = EEPROM_address+1; // increment for next group
EEPROM_writing = 0; // all bytes written
break;

} // end switch
} end if


http://arduino.cc/en/Reference/EEPROMRead
perform 6 reads, 1 for each digit. Shift it out to the display, or serial.write it out over the TX line to your PC.

The other stuff is just a matter of reading the buttons like you did the reset button and writing the functionality into the code.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

warrenreeve

Hi Robert, I have been trying my best with what you have given me and I think I have it writing to the Eeprom?? This is what I have to write;
Code: [Select]
//PAUSED HERE
     if (pause_button_state == 0){
       paused = 1;
       start_pausetime =  end_pausetime;
//MAKE COPPIES
                 copy_hundredths= hundredths;
                 copy_tenths = tenths;
                 copy_ones_seconds = ones_seconds;
                 copy_tens_seconds = tens_seconds;
                 copy_ones_minutes = ones_minutes;
                 copy_tens_minutes = tens_minutes;
                 copy_ones_hours = ones_hours;
                 copy_tens_hours = tens_hours;
//WRITE THE COPPIES TO EEPROM
                 if (EEPROM_writing == 1){
                 switch (byte_to_write){
                 
           case 1: // hundredths
                 EEPROM.write (EEPROM_address, copy_hundredths);
                 byte_to_write = byte_to_write+1; // increment for next digit
                 EEPROM_address = EEPROM_address+1; // increment for next bye
                 break;
           case 2: // copy_tenths
                 EEPROM.write (EEPROM_address, copy_tenths);
                 byte_to_write = byte_to_write+1; // increment for next digit
                 EEPROM_address = EEPROM_address+1; // increment for next bye
                 break;
           case 3: // copy_ones_seconds
                 EEPROM.write (EEPROM_address, copy_ones_seconds);
                 byte_to_write = byte_to_write+1; // increment for next digit
                 EEPROM_address = EEPROM_address+1; // increment for next bye
                 break;
           case 4: // copy_ones_minutes
                 EEPROM.write (EEPROM_address, copy_ones_minutes);
                 byte_to_write = byte_to_write+1; // increment for next digit
                 EEPROM_address = EEPROM_address+1; // increment for next bye
                 break;    
           case 5: // copy_tens_minutes
                 EEPROM.write (EEPROM_address, copy_tens_minutes);
                 byte_to_write = byte_to_write+1; // increment for next digit
                 EEPROM_address = EEPROM_address+1; // increment for next bye
                 break;      
           case 6: // tens_minutes
                 EEPROM.write (EEPROM_address, copy_tens_minutes);
                 byte_to_write = 1; // reset for next group
                 EEPROM_address = EEPROM_address+1; // increment for next group
                 EEPROM_writing = 0; // all bytes written
                 break;
           }
        }
//##############################  

This compiles fine but I don't know weather it works as I can not figure how to call and show the Eeprom? I did attempt to put the eeprom.read together even though I know it's wrong but I haven't a clue how to do it.
This is what I tried and it just freezes the display;
Code: [Select]
{//Memory Up Button Here
memory_up_button_state = digitalRead (memory_up_button);
 if (memory_up_button_state == 0){
         
          paused = 1;
         
       value = EEPROM.read(EEPROM_address);
 
          if (EEPROM_writing == 1){
                 switch (byte_to_write){
                 
           case 1: // hundredths
                 EEPROM.read (EEPROM_address, copy_hundredths);
                 byte_to_write = byte_to_write+1; // increment for next digit
                 EEPROM_address = EEPROM_address+1; // increment for next bye
                 break;
           case 2: // copy_tenths
                 EEPROM.read (EEPROM_address, copy_tenths);
                 byte_to_write = byte_to_write+1; // increment for next digit
                 EEPROM_address = EEPROM_address+1; // increment for next bye
                 break;
           case 3: // copy_ones_seconds
                 EEPROM.read (EEPROM_address, copy_ones_seconds);
                 byte_to_write = byte_to_write+1; // increment for next digit
                 EEPROM_address = EEPROM_address+1; // increment for next bye
                 break;
           case 4: // copy_ones_minutes
                 EEPROM.read (EEPROM_address, copy_ones_minutes);
                 byte_to_write = byte_to_write+1; // increment for next digit
                 EEPROM_address = EEPROM_address+1; // increment for next bye
                 break;    
           case 5: // copy_tens_minutes
                 EEPROM.read (EEPROM_address, copy_tens_minutes);
                 byte_to_write = byte_to_write+1; // increment for next digit
                 EEPROM_address = EEPROM_address+1; // increment for next bye
                 break;      
           case 6: // tens_minutes
                 EEPROM.read (EEPROM_address, copy_tens_minutes);
                 byte_to_write = 1; // reset for next group
                 EEPROM_address = EEPROM_address+1; // increment for next group
                 EEPROM_writing = 0; // all bytes written
                 break;
 
  EEPROM_address = EEPROM_address + 1;

 if (EEPROM_address == 512)
   EEPROM_address = 0;

 
 digitalWrite(latchpin, LOW); // send the digits down to the shift registers!
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[copy_hundredths]); // print the hundredths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[copy_tenths]);     // print the tenths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[copy_ones_seconds]); // print the lower seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[copy_tens_seconds]); // print the upper seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[copy_ones_minutes]); // print the lower sinutes digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[copy_tens_minutes]); // print the upper minutes digit
       digitalWrite(latchpin, HIGH);




started = 0;
paused = 0;
     }

//#############################################################

Any help on this would be greatly appreciated.

PS. I have ordered the 6.5 inch numbers and some buttons etc. I am also trying to design a case to house the whole thing with handles. I will have to dig out the camera and get a few shots up on here for you soon.
Cheers
Warren

CrossRoads

Warren,
I fixed a couple of {} issues, pulled the end of your switch case before the shiftouts so the display gets updated after every read (I think that will help with freeze up), and gave the read address byte counter their own name.
The memory_up_button will bounce when you push it, I added in an OR of the pause flag so the 6 reads will continue once started. Maybe paused isn't the right flag, maybe a different flag should be used to indicate read-back in process, but you can get the idea of what to do.

You have something that puts EEPROM_address to type 'int' (512 is 10 bits)?
You could be writing & writing all day, right? Any chance you'd be reading occasionally too? And maybe not reading everything that was written? I'm thinking maintain seperate EEPROM_write_address & EEPROM_address_read counters so if you do read something, it won't screw up your addressing for the writes.
Robert

Code: [Select]

//Memory Up Button Here
memory_up_button_state = digitalRead (memory_up_button);
if (memory_up_button_state == 0 | paused == 1){ // add in paused check, lets us finish reading after button goes back high
/* if the lap times seem to read out/udpate more than once on a button push, may need to add in time check delay (ex. check millis, make sure 1000 goes by before button is read again) so don't get false read commands from button bouncing */

 paused = 1;

 value = EEPROM.read(EEPROM_address);

 if (EEPROM_reading == 1){
   switch (byte_to_read){

   case 1: // hundredths
     EEPROM.read (EEPROM_address, copy_hundredths);
     byte_to_read = byte_to_read+1; // increment for next digit
     EEPROM_address = EEPROM_address+1; // increment for next bye
     break;
   case 2: // copy_tenths
     EEPROM.read (EEPROM_address, copy_tenths);
     byte_to_read = byte_to_read+1; // increment for next digit
     EEPROM_address = EEPROM_address+1; // increment for next bye
     break;
   case 3: // copy_ones_seconds
     EEPROM.read (EEPROM_address, copy_ones_seconds);
     byte_to_read = byte_to_read+1; // increment for next digit
     EEPROM_address = EEPROM_address+1; // increment for next bye
     break;
   case 4: // copy_ones_minutes
     EEPROM.read (EEPROM_address, copy_ones_minutes);
     byte_to_read = byte_to_read+1; // increment for next digit
     EEPROM_address = EEPROM_address+1; // increment for next bye
     break;    
   case 5: // copy_tens_minutes
     EEPROM.read (EEPROM_address, copy_tens_minutes);
     byte_to_read = byte_to_read+1; // increment for next digit
     EEPROM_address = EEPROM_address+1; // increment for next bye
     break;      
   case 6: // tens_minutes
     EEPROM.read (EEPROM_address, copy_tens_minutes);
     byte_to_read = 1; // reset for next groupex.
     EEPROM_address = EEPROM_address+1; // increment for next group
     EEPROM_reading = 0; // all bytes read
     started = 0;
     paused = 0;
     break;

     EEPROM_address = EEPROM_address + 1;

     if (EEPROM_address == 512){
       EEPROM_address = 0;
     }  // end of end-of-address check
   } // end if switch-case


   digitalWrite(latchpin, LOW); // send the digits down to the shift registers!
   shiftOut(datapin, clockpin, MSBFIRST, segdisp[copy_hundredths]); // print the hundredths digit
   shiftOut(datapin, clockpin, MSBFIRST, segdisp[copy_tenths]);     // print the tenths digit
   shiftOut(datapin, clockpin, MSBFIRST, segdisp[copy_ones_seconds]); // print the lower seconds digit
   shiftOut(datapin, clockpin, MSBFIRST, segdisp[copy_tens_seconds]); // print the upper seconds digit
   shiftOut(datapin, clockpin, MSBFIRST, segdisp[copy_ones_minutes]); // print the lower sinutes digit
   shiftOut(datapin, clockpin, MSBFIRST, segdisp[copy_tens_minutes]); // print the upper minutes digit
   digitalWrite(latchpin, HIGH);

 } // end of EEPROM reading
 
} // end of checking memory button state
//#############################################################

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

warrenreeve

#102
Jan 15, 2011, 03:14 pm Last Edit: Jan 15, 2011, 03:17 pm by warrenreeve Reason: 1
Hi Robert, I am getting an error that I don't understand??  :-/ I have checked through and looked at all the code for spelling mistakes etc but can't see where the problem is?
This is the error I am getting;
Quote
StopWatch_with_memory.cpp: In function 'void loop()':
StopWatch_with_memory:121: error: no matching function for call to 'EEPROMClass::read(byte&, byte&)'
F:\Program Files\Arduino\arduino-0021\libraries\EEPROM/EEPROM.h:28: note: candidates are: uint8_t EEPROMClass::read(int)
StopWatch_with_memory:126: error: no matching function for call to 'EEPROMClass::read(byte&, byte&)'
F:\Program Files\Arduino\arduino-0021\libraries\EEPROM/EEPROM.h:28: note: candidates are: uint8_t EEPROMClass::read(int)
StopWatch_with_memory:131: error: no matching function for call to 'EEPROMClass::read(byte&, byte&)'
F:\Program Files\Arduino\arduino-0021\libraries\EEPROM/EEPROM.h:28: note: candidates are: uint8_t EEPROMClass::read(int)
StopWatch_with_memory:136: error: no matching function for call to 'EEPROMClass::read(byte&, byte&)'
F:\Program Files\Arduino\arduino-0021\libraries\EEPROM/EEPROM.h:28: note: candidates are: uint8_t EEPROMClass::read(int)
StopWatch_with_memory:141: error: no matching function for call to 'EEPROMClass::read(byte&, byte&)'
F:\Program Files\Arduino\arduino-0021\libraries\EEPROM/EEPROM.h:28: note: candidates are: uint8_t EEPROMClass::read(int)
StopWatch_with_memory:146: error: no matching function for call to 'EEPROMClass::read(byte&, byte&)'
F:\Program Files\Arduino\arduino-0021\libraries\EEPROM/EEPROM.h:28: note: candidates are: uint8_t EEPROMClass::read(int)

This is what I have in full. The highlighted section is where the error shows;
Code: [Select]
#include <EEPROM.h>

unsigned long currentmicros = 0;
unsigned long previousmicros = 0;
unsigned long interval = 10000;
unsigned long elapsedmicros = 0;

byte latchpin = 8; // connect to pin 12 on the 74HC595
byte clockpin = 12; // connect to pin 11 on the 74HC595
byte datapin = 11; // connect to pin 14 on the 74HC595

int value;

byte hundredths= 0;
byte tenths = 0;
byte ones_seconds = 0;
byte tens_seconds = 0;
byte ones_minutes = 0;
byte tens_minutes = 0;
byte ones_hours = 0;
byte tens_hours = 0;

byte copy_hundredths= 0;
byte copy_tenths = 0;
byte copy_ones_seconds = 0;
byte copy_tens_seconds = 0;
byte copy_ones_minutes = 0;
byte copy_tens_minutes = 0;
byte copy_ones_hours = 0;
byte copy_tens_hours = 0;
byte EEPROM_address = 0;
byte byte_to_read = 0;
byte byte_to_write = 0;
byte EEPROM_writing =0;
byte EEPROM_reading =0;
byte EEPROM_read =0;

int segdisp[10] = {
 63,6,91,79,102,109,125,7,127,111 }; //segment references using 74HC595 Shift Registers
//The above numbers light up different segments of a digit

byte memory_up_button_state = 0;
byte memory_up_button = 10;

byte reset_button_state = 0;
byte reset_button = 2;

byte pause_button_state = 0;
byte pause_button = 6;

byte paused = 0;
byte started = 0;

unsigned long start_pausetime = 0;   // start_pausetime, end_pausetime used for button debounce
unsigned long end_pausetime = 0;
unsigned long elapsed_pausetime = 0;

byte time_update = 0;// added new flag



void setup()
{
 pinMode(latchpin, OUTPUT);
 pinMode(clockpin, OUTPUT);
 pinMode(datapin, OUTPUT);
 pinMode(pause_button, INPUT);
 digitalWrite (pause_button, HIGH); // enable pullup
 
 pinMode(reset_button, INPUT);
 digitalWrite (reset_button, HIGH); // enable pullup
 
 //############## POWER UP #############//
         
// loop to flash the displays, in pseudo code
byte i=0;
byte toggle=0;
byte displaychar;
while (i<26){ // lop thru as many times as you want
toggle=1-toggle; // results in toggle = 1,0,1,0 ...
 if (toggle==1){
 displaychar = 8;}
 else{
 displaychar = 11;}
     digitalWrite(latchpin, LOW); // send the digits down to the shift registers!
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[displaychar]); // for digit 1
         shiftOut(datapin, clockpin, MSBFIRST, segdisp[displaychar]);
         shiftOut(datapin, clockpin, MSBFIRST, segdisp[displaychar]);
         shiftOut(datapin, clockpin, MSBFIRST, segdisp[displaychar]);
         shiftOut(datapin, clockpin, MSBFIRST, segdisp[displaychar]);
         shiftOut(datapin, clockpin, MSBFIRST, segdisp[displaychar]);
     digitalWrite(latchpin, HIGH);
delay (100);
i=i+1;
}
delay (500);
  digitalWrite(latchpin, LOW); // send the digits down to the shift registers!
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[0]); // print the hundredths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[0]); // print the tenths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[0]); // print the lower seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[0]); // print the upper seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[0]); // print the lower sinutes digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[0]); // print the upper minutes digit
       digitalWrite(latchpin, HIGH);
}
void loop()
//#############################################################
//Memory Up Button Here
{memory_up_button_state = digitalRead (memory_up_button);
if (memory_up_button_state == 0 | paused == 1){ // add in paused check, lets us finish reading after button goes back high
//* if the lap times seem to read out/udpate more than once on a button push, may need to add in time check delay (ex. check
//millis, make sure 1000 goes by before button is read again) so don't get false read commands from button bouncing */

 paused = 1;

 value = EEPROM.read(EEPROM_address);

 if (EEPROM_reading == 1){
   switch (byte_to_read){

   case 1: // hundredths
     [glow]EEPROM.read (EEPROM_address, copy_hundredths);[/glow]
     byte_to_read = byte_to_read+1; // increment for next digit
     EEPROM_address = EEPROM_address+1; // increment for next bye
     break;
   case 2: // copy_tenths
     EEPROM.read (EEPROM_address, copy_tenths);
     byte_to_read = byte_to_read+1; // increment for next digit
     EEPROM_address = EEPROM_address+1; // increment for next bye
     break;
   case 3: // copy_ones_seconds
     EEPROM.read (EEPROM_address, copy_ones_seconds);
     byte_to_read = byte_to_read+1; // increment for next digit
     EEPROM_address = EEPROM_address+1; // increment for next bye
     break;
   case 4: // copy_ones_minutes
     EEPROM.read (EEPROM_address, copy_ones_minutes);
     byte_to_read = byte_to_read+1; // increment for next digit
     EEPROM_address = EEPROM_address+1; // increment for next bye
     break;
   case 5: // copy_tens_minutes
     EEPROM.read (EEPROM_address, copy_tens_minutes);
     byte_to_read = byte_to_read+1; // increment for next digit
     EEPROM_address = EEPROM_address+1; // increment for next bye
     break;
   case 6: // tens_minutes
     EEPROM.read (EEPROM_address, copy_tens_minutes);
     byte_to_read = 1; // reset for next groupex.
     EEPROM_address = EEPROM_address+1; // increment for next group
     EEPROM_reading = 0; // all bytes read
     started = 0;
     paused = 0;
     break;

     EEPROM_address = EEPROM_address + 1;

     if (EEPROM_address == 512){
       EEPROM_address = 0;
     }  // end of end-of-address check
   } // end if switch-case


   digitalWrite(latchpin, LOW); // send the digits down to the shift registers!
   shiftOut(datapin, clockpin, MSBFIRST, segdisp[copy_hundredths]); // print the hundredths digit
   shiftOut(datapin, clockpin, MSBFIRST, segdisp[copy_tenths]);     // print the tenths digit
   shiftOut(datapin, clockpin, MSBFIRST, segdisp[copy_ones_seconds]); // print the lower seconds digit
   shiftOut(datapin, clockpin, MSBFIRST, segdisp[copy_tens_seconds]); // print the upper seconds digit
   shiftOut(datapin, clockpin, MSBFIRST, segdisp[copy_ones_minutes]); // print the lower sinutes digit
   shiftOut(datapin, clockpin, MSBFIRST, segdisp[copy_tens_minutes]); // print the upper minutes digit
   digitalWrite(latchpin, HIGH);

 } // end of EEPROM reading

} // end of checking memory button state
//#############################################################


Part 2 of the code to follow;

warrenreeve

Quote
Part 2 of the code to follow;

Code: [Select]
{//Reset Button Here
reset_button_state = digitalRead (reset_button);
 if (reset_button_state == 0){
         
          paused = 1;
         
        hundredths= 0;
        tenths = 0;
        ones_seconds = 0;
        tens_seconds = 0;
        ones_minutes = 0;
        tens_minutes = 0;
        ones_hours = 0;
        tens_hours = 0;
        time_update = 0;

       digitalWrite(latchpin, LOW); // send the digits down to the shift registers!
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[hundredths]); // print the hundredths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[tenths]);     // print the tenths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[ones_seconds]); // print the lower seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[tens_seconds]); // print the upper seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[ones_minutes]); // print the lower sinutes digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[tens_minutes]); // print the upper minutes digit
       digitalWrite(latchpin, HIGH);
started = 0;
paused = 0;
     }

{// If not started, read the pause button, set started flag once pressed
 pause_button_state = digitalRead (pause_button);
 if (pause_button_state == 0 & started == 0){
   started = 1;
   start_pausetime = millis(); // start_pausetime, end_pausetime used for button debounce
 }

 // when started flag is pressed, start counting in 10mS increments
 if (started == 1){
   currentmicros = micros();  // read the time.
   elapsedmicros = currentmicros - previousmicros;

   if (elapsedmicros >= interval) // 10 milliseconds have gone by
   {
     previousmicros  = previousmicros + elapsedmicros;  // save the time for the next comparison
     time_update = 1; // set flag to shift out the new time
   }

   if (time_update == 1){  // no updating if not at 10ms interval, skip this whole section
     // increment the counters, roll as needed, shift the digits out

     time_update = 0; // reset for next pass thru

     hundredths = hundredths +1;

     if (hundredths == 10){
       hundredths = 0;
       tenths = tenths +1;
     }

     if (tenths == 10){
       tenths = 0;
         ones_seconds = ones_seconds +1;
     }

         if (ones_seconds == 10){
     ones_seconds = 0;
       hundredths = hundredths +3;   // Speed up the clock!
       tens_seconds = tens_seconds +1;
   }

           if (tens_seconds == 6){
      tens_seconds = 0;
        hundredths = hundredths +6;   // Speed up the clock!
        ones_minutes = ones_minutes +1;
   }

     if (ones_minutes == 10){
       ones_minutes = 0;
       tens_minutes = tens_minutes +1;
     }
     if (tens_minutes == 6){
       tens_minutes = 0;
       ones_hours = ones_hours +1;  // not used in actual application, only here for stability test over longer time periods
     }
     if (ones_hours == 13){  // not used in actual application, only here for stability test over longer time periods
       ones_hours = 0;
       tens_hours = tens_hours +1;
     }
     if (paused == 0){
       // not paused, update the display

       // counters are all updated now, just do the shiftout one time here:
       digitalWrite(latchpin, LOW); // send the digits down to the shift registers!
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[hundredths]); // print the hundredths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[tenths]);     // print the tenths digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[ones_seconds]); // print the lower seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[tens_seconds]); // print the upper seconds digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[ones_minutes]); // print the lower sinutes digit
       shiftOut(datapin, clockpin, MSBFIRST, segdisp[tens_minutes]); // print the upper minutes digit
       digitalWrite(latchpin, HIGH);
       if (tenths == 0 && hundredths == 0){ // update on screen once a second
         
       }  // end of 1 second check
     } // end of time update is not paused
   }  // end if time to be updated

   // read the pause button, set a flag if pressed, capture the time it was pressed, reset the lap time
   end_pausetime = millis();
   if (paused == 0 & (end_pausetime - start_pausetime > 500)){  // not paused, debounced if had been (long time used due to crappy button)
     pause_button_state = digitalRead(pause_button);
//PAUSED HERE
     if (pause_button_state == 0){
       paused = 1;
       start_pausetime =  end_pausetime;
//MAKE COPPIES
                 copy_hundredths= hundredths;
                 copy_tenths = tenths;
                 copy_ones_seconds = ones_seconds;
                 copy_tens_seconds = tens_seconds;
                 copy_ones_minutes = ones_minutes;
                 copy_tens_minutes = tens_minutes;
                 copy_ones_hours = ones_hours;
                 copy_tens_hours = tens_hours;
//WRITE THE COPPIES TO EEPROM
                 if (EEPROM_writing == 1){
                 switch (byte_to_write){
                 
           case 1: // hundredths
                 EEPROM.write (EEPROM_address, copy_hundredths);
                 byte_to_write = byte_to_write+1; // increment for next digit
                 EEPROM_address = EEPROM_address+1; // increment for next bye
                 break;
           case 2: // copy_tenths
                 EEPROM.write (EEPROM_address, copy_tenths);
                 byte_to_write = byte_to_write+1; // increment for next digit
                 EEPROM_address = EEPROM_address+1; // increment for next bye
                 break;
           case 3: // copy_ones_seconds
                 EEPROM.write (EEPROM_address, copy_ones_seconds);
                 byte_to_write = byte_to_write+1; // increment for next digit
                 EEPROM_address = EEPROM_address+1; // increment for next bye
                 break;
           case 4: // copy_ones_minutes
                 EEPROM.write (EEPROM_address, copy_ones_minutes);
                 byte_to_write = byte_to_write+1; // increment for next digit
                 EEPROM_address = EEPROM_address+1; // increment for next bye
                 break;    
           case 5: // copy_tens_minutes
                 EEPROM.write (EEPROM_address, copy_tens_minutes);
                 byte_to_write = byte_to_write+1; // increment for next digit
                 EEPROM_address = EEPROM_address+1; // increment for next bye
                 break;      
           case 6: // tens_minutes
                 EEPROM.write (EEPROM_address, copy_tens_minutes);
                 byte_to_write = 1; // reset for next group
                 EEPROM_address = EEPROM_address+1; // increment for next group
                 EEPROM_writing = 0; // all bytes written
                 break;
           }
        }
//##############################  

       currentmicros = micros();  // read the time.
       previousmicros = currentmicros;
       elapsedmicros = currentmicros - previousmicros;
     
        hundredths= 0;
        tenths = 0;
        ones_seconds = 0;
        tens_seconds = 0;
        ones_minutes = 0;
        tens_minutes = 0;
        ones_hours = 0;
        tens_hours = 0;
     
     }
   }

   // read the pause button; unpause to let time display be shown
   end_pausetime = millis();
   if (paused ==1 & (end_pausetime - start_pausetime >500)){  // sitting in paused state now, is debounced
     pause_button_state = digitalRead (pause_button);
     if (pause_button_state == 0){
       paused = 0;// back to unpaused
       start_pausetime = end_pausetime;
     
     }
   }}
 }
 }  // end of if-started
} // end void loop

warrenreeve

Hi Robert, I have came across some info on the eeprom. It seems the the Arduino Uno does not support eeprom?! :o

Quote
I believe the Uno ships with Optiboot.  I don't think Optiboot supports EEPROM commands.

Quote
You are correct. I was just looking at the optiboot code and it explicitly states that it only reads and writes flash memory. Thanks for your help anyway.


Full thread here;
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1289849174/0

The first quote was made by 'Coding Badly'.. I'm just trying my best to find answers to this problem but if the above is correct then how do we go about it?  :-/

Go Up