To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.loc.itOpen lugnet.loc.it in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Local / Italia / 895
894  |  896
Subject: 
Re: domanda per esperti nqc
Newsgroups: 
lugnet.loc.it
Date: 
Wed, 12 Jan 2000 01:13:23 GMT
Viewed: 
441 times
  
Mario Ferrari wrote:

Non è che per caso i timers interni siano tutti aggiornati ogni
decimo di secondo da un unico evento di clock, che quindi ignora
i differenti decimali di partenza?

Per fortuna no. Funziona che e' una bellezza!

Approfitto dell'occasione per postare la bozza del codice del
cronometro. Fate i bravi beta tester, mi raccomando ;)
Aspetto vostri commenti.

(Il robot di riferimento e' ormai il mio classico con due sensori
di contatto nelle porte 1 e 3 che suonano quando sono premuti.  ;)
Se fate i cattivi e premete due volte il sensore 1 peggio per voi
riazzerate tutto :)

------------------- crono.nqc ----------------------

int t, t0, t1, t2, t3;

task main()
{
  SetSensor(SENSOR_1,SENSOR_TOUCH);
  SetSensor(SENSOR_3,SENSOR_TOUCH);

  CreateDatalog(5);

  while (true)
  {
     if(SENSOR_1 == 1)
     {
        PlaySound(2);
        StartTimer();
     }

     if(SENSOR_3 == 1)
     {
        StopTimer();
        PlaySound(3);
        break;
     }
  }
}

void StartTimer()
{
   ClearTimer(0);
   Wait(2);
   ClearTimer(1);
   Wait(3);
   ClearTimer(2);
   Wait(3);
   ClearTimer(3);
}

void StopTimer()
{
   t0 = Timer(0);
   t1 = Timer(1);
   t2 = Timer(2);
   t3 = Timer(3);

   AddToDatalog(t0);
   AddToDatalog(t1);
   AddToDatalog(t2);
   AddToDatalog(t3);

   if( t1 < t0 )
     t = t0 * 10;
   else if( t2 < t0 )
     t = t0 * 10 + 2;
   else if( t3 < t0 )
     t = t0 * 10 + 5;
   else
     t = t0 * 10 + 8;

   AddToDatalog(t);
}

--------------- end of crono.nqc ----------------------------

Due esempi di Datalog che ho ottenuto sono:

Variable  1:      47
Variable  2:      47
Variable  3:      47
Variable  4:      46
Variable  0:     475

e

Variable  1:     104
Variable  2:     104
Variable  3:     103
Variable  4:     103
Variable  0:    1042


Ovviamente il cronometro definitivo non avra' bisogno di mettere
t0, t1, t2 e t3 nel Datalog, ne' di sprecare l'ulteriore variabile t.

Ciao,

       Antonio (che e' in fissa sull'ottimizzazione delle risorse :)



Message has 1 Reply:
  Re: domanda per esperti nqc
 
iant <iant@libero.it> wrote in message news:387BD533.6D0AF8...bero.it... (...) Grazie Antonio, mi hai curato dalla solita "sindrome della pagina bianca"..... -- Cheers Carlo. LUGNET member page: (URL) member of ItLUG: (URL) (25 years ago, 12-Jan-00, to lugnet.loc.it)

Message is in Reply To:
  Re: domanda per esperti nqc
 
(...) Non è che per caso i timers interni siano tutti aggiornati ogni decimo di secondo da un unico evento di clock, che quindi ignora i differenti decimali di partenza? Ciao Mario (25 years ago, 11-Jan-00, to lugnet.loc.it)

13 Messages in This Thread:




Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR