Show Posts
Pages: 1 [2]
16  Using Arduino / General Electronics / Re: iS my photoresistor (LDR) too slow ? || tachometer on: January 28, 2011, 10:28:54 pm
100hz is too fast for the Arduino? *shrug*  smiley-roll

After debugging, the aforementioned program was reliably reading a 26,000 rpm signal from a signal generator while updating four display values, polling two inputs without interrupts, and having a compiled size of almost 8K. It started getting flaky at about 28,000 rpm. Ditching use of the string class in favor of character arrays roughly doubled the speed. Not executing every display command on every loop iteration roughly doubled the speed once more while still achieving an approximate 100 Hz refresh rate.
17  Using Arduino / General Electronics / Re: iS my photoresistor (LDR) too slow ? || tachometer on: January 27, 2011, 06:04:10 pm
100hz is too fast for the Arduino? *shrug*  smiley-roll

No it isn't but I've found I have to be clever when polling anything at the same time as I'm reading and writing to lcd's. I suspect the same might be true for serial devices. To keep loop execution speed below 5ms on this latest project, I had to limit the reading and writing to one command per loop.

Code:
switch (lcd_command % 11) // display updated one command at a time
{ // to decrease loop execution time
case 0:
lcd.setCursor(0, 0); // column 0 line 0
break;
case 1:
if (run_state == RUN_RUNNING)
lcd.print("Running   ");
else
lcd.print("Stopping  ");
break;
case 2:
lcd.setCursor(10, 0); // column 9 line 0
break;
case 3:
lcd.print(cycle_count);
break;
case 4:
lcd.print("c     ");
break;
case 5:
lcd.setCursor(0, 1); // column 0 line 1
break;
case 6:
lcd.print(lcd_tenths / 10);
break;
case 7:
lcd.print("s     ");
break;
case 8:
lcd.setCursor(10, 1); // column 9 line 1
break;
case 9:
lcd.print(sense_count);
break;
case 10:
lcd.print("p     ");
break;
}
lcd_command++; // increment for next iteration

18  Forum 2005-2010 (read only) / Troubleshooting / Re: Help Required - RPM Counter With Analog input on: January 22, 2011, 09:31:11 pm
Code:
   if       (hallState == 0 && oldHallstate == 1)
             {
                startTime = millis();
                delay(5);
                oldHallstate = hallState;  
             }
    
    else if  (hallState == 0 && oldHallstate == 1)
             {
                elapsedTime = millis() - startTime;
                oldHallstate = hallState;  
             }  

Have I been smoking something or is this basically:

if X

else if X

How is it supposed to reach elapsedTime = ?
Pages: 1 [2]