Re: programme is to sluggish Kategorie: Progr. Assembler, TaskingTools, OS (von André H. - 7.05.2006 21:16) | ||
Als Antwort auf programme is to sluggish von Bram - 7.05.2006 20:05 | ||
| ||
Hallo Bram, First: Please use the right category. This belongs to "Programmierung", not to "Progr.Assembler, TaskingTools, OS" ! Second: Please update your CC2-Station to OSOPT V3.0 or OSOPT V3.1 Beta 1. There ist no more support to the original OS. > //======================================================================== > if ports.getcount(0) // pulse rotating encoder A in (1 pulse 360 grd.) > i = 0; > if ports.getcount(1) // pulse rotating encoder A in speed 1,5 kHz (300 rpm: 200 pulse per 360 grd.) > { > i = i + 1; > m[i] = ports.adc(0); // is this my time problem: m[i] or the adc? it works but till to +/- 50 rpm. > } > //========================================================================= I think your main problem is the whole thread, which needs to much Time. Make an own thread for these few lines: int i, m[250]; thread encoder { i=0; loop { if ports.getcount(0) i = 0; if ports.getcount(1) { i = i + 1; m[i] = ports.adc(0); } } } thread main { // Initializations // ... loop { // main-program-loop //... if <start-condition> run encoder; //start-condition for encoder-thread //... if <stop-condition> reset encoder; //stop-condition for encoder-thread //also: halt encoder; (without resetting thread) //... } } regards, André H. Antworten bitte nur ins Forum! Fragen per EMail auf Forum-Postings werden nicht beantwortet! Das macht meine Heizung gerade | ||
Antwort schreiben Antworten: |