Re: program to slow Kategorie: CC2-Unit & Appl.Board / CC2-Station (von André H. - 1.05.2006 22:04) | ||
Als Antwort auf program to slow von Bram - 30.04.2006 23:09 | ||
| ||
Hallo Bram, Your main problem is the obsolete Software you use. Please use at least OSOPT V3.0 an the up to date moduls. The old Software breaks the C-Control II. There aro also aome errors in Your Code: byte f; ... hwcom.receive(f,2,1); if f > 100 // motor starts with speed data { ... Here, you use the receive()-Funktion with a byte-variable for receive-buffer. But the function hwcom.receive needs a byte-buffer-variable. (e.g.byte f[10]) ... station_io.RELon(1); str.putint(s,f); ... Here, you put a value to the string s. But you don't use this String here to make an output. if ports.get(8) == -1 // 1 puls per rpm from encoder A { station_io.LEDon(1); i = 0; wait ports.get(8) == 0; // wait for low } if ports.get(9) == -1 // 200 puls per rpm from encoder A = ca 1 kHz { wait ports.get(9) == 0; // wait for low i = i+1; station_io.LEDon(2); m[i] = ports.adc(0); } Here, you should use the counter-Ports directly. I don't know what you want to do exactly, but this ist the slowest way. Try this: The Programm should do nearly the same, but much faster. //------------ thread main //------------ { byte i,f; int x,m[210] ; string s,output ; stports.init(); lcdext.init(); hwcom.init(); hwcom.setspeed(5); plm.settimebase(0, 1); plm.setperiod(0, 999); lcdext.print("TEST UNIT"); lcdext.line(2); lcdext.print("MODULE II"); x = 0; i = 0; sleep 100; loop { stports.setLED(1,0); stports.setLED(2,0); if hwcom.rxd() f=hwcom.get(); else f=0; if f > 100 // motor starts with speed data { stports.setRel(1,1); x = (f - 100)* 10; } else if f==63 // ? motor stop speed data 0 { x = 0; stports.setRel(1,0); } else if f==64 // @ data to PC { for i= 0...<200 { hwcom.num(m[i]); hwcom.ret(); } } //======================================================================== if ports.getcount(0) // 1 puls per rpm from encoder A { stports.setLED(1,1); i = 0; } if ports.getcount(1) // 200 puls per rpm from encoder A = ca 1 kHz { i = i+1; stports.setLED(2,1); m[i] = ports.adc(0); } //========================================================================= plm.out(0,x); // motor speed duty cycle to 99 % } } Perhaps it would be better to use multithreading. Regards, André H. > Hello everybody: > I have a C-Control II Station and written this file for a proto type machine ( suspension movments) > the following programme in C2 according to the appropriate tools. However, it is way too slow and > I cannot get to work the interrupts. (See the blocked section). > I know assembler (8051) fairly well and I want to know if somebody can help me get started to > transfer this programme in assembler C164. > > //------------ > thread main > //------------ > { > byte i,f ; > int x,m[210] ; > string s,output ; > station_lcd.init(); > station_io.init(); > hwcom.init(); > hwcom.setspeed(5); > plm.settimebase(0, 1); > plm.setperiod(0, 999); > station_lcd.cursorpos(1,0); > output = "TEST UNIT"; > station_lcd.print(output); > output = "MODULE II"; > station_lcd.cursorpos(2,0); > station_lcd.print(output); > x = 0; > i = 0; > sleep 100; > loop > { > station_io.LEDoff(1); > station_io.LEDoff(2); > hwcom.receive(f,2,1); > if f > 100 // motor starts with speed data > { > station_io.RELon(1); > str.putint(s,f); > x = f ; > f = 0; > x = (x - 100)* 10; > } > if f == 63 // ? motor stop speed data 0 > { > f = 0; > x = 0; > station_io.RELoff(1); > } > if f == 64 // @ data to PC > for i= 0...200 > { > f = 0; > str.clear(s); > str.putint(s,m[i]); > hwcom.send(s,3); > hwcom.put(13); > hwcom.put(10); > hwcom.flush(); > } > //======================================================================== > if ports.get(8) == -1 // 1 puls per rpm from encoder A > { > station_io.LEDon(1); > i = 0; > wait ports.get(8) == 0; // wait for low > } > if ports.get(9) == -1 // 200 puls per rpm from encoder A = ca 1 kHz > { > wait ports.get(9) == 0; // wait for low > i = i+1; > station_io.LEDon(2); > m[i] = ports.adc(0); > } > //========================================================================= > plm.out(0,x); // motor speed duty cycle to 99 % > } > > Thanks, Bram > > Antworten bitte nur ins Forum! Fragen per EMail auf Forum-Postings werden nicht beantwortet! Das macht meine Heizung gerade | ||
Antwort schreiben Antworten: |