Open ddgftw opened 6 years ago
Sometging is missing in the code.
Import java.util.*; is the right thing.
Wht asterisc is missing in your file I do not know.
El 28 ene. 2018 22:46, "ddgftw" notifications@github.com escribió:
I am confused how to use the pid tuning tool. i plug in my arduino uno, and i open the pidtuning.pde sketch. when i try to upload it, i get the errors below. how do i properly upload and use the pid tool?
PIDtunningTool:9: error: 'import' does not name a type import java.util.
; ^ PIDtunningTool:10: error: 'import' does not name a type import processing.serial.; ^ PIDtunningTool:12: error: 'Serial' does not name a type Serial myPort; // The serial port ^ /home/octo/Downloads/dcservo-master/PIDtunningTool/PIDtunningTool.pde: In function 'void setup()': PIDtunningTool:19: error: 'size' was not declared in this scope size(800, 400); ^ PIDtunningTool:21: error: 'PFont' was not declared in this scope PFont myFont = createFont(PFont.list()[2], 14); ^ PIDtunningTool:22: error: 'myFont' was not declared in this scope textFont(myFont); ^ PIDtunningTool:22: error: 'textFont' was not declared in this scope textFont(myFont); ^ PIDtunningTool:23: error: 'frameRate' was not declared in this scope frameRate(1); ^ PIDtunningTool:25: error: 'class HardwareSerial' has no member named 'list' println(Serial.list()); ^ PIDtunningTool:25: error: 'println' was not declared in this scope println(Serial.list()); ^ PIDtunningTool:26: error: 'class HardwareSerial' has no member named 'list' String portName = Serial.list()[3]; ^ PIDtunningTool:27: error: 'myPort' was not declared in this scope myPort = new Serial(this, portName, 115200); ^ PIDtunningTool:27: error: expected type-specifier before 'Serial' myPort = new Serial(this, portName, 115200); ^ /home/octo/Downloads/dcservo-master/PIDtunningTool/PIDtunningTool.pde: In function 'void draw()': PIDtunningTool:31: error: 'strokeWeight' was not declared in this scope strokeWeight(1); ^ PIDtunningTool:32: error: 'background' was not declared in this scope background(255,100); stroke(255,0,0); ^ PIDtunningTool:32: error: 'stroke' was not declared in this scope background(255,100); stroke(255,0,0); ^ PIDtunningTool:33: error: 'line' was not declared in this scope line(0,400-333,600,400-333); ^ PIDtunningTool:38: error: 'myPort' was not declared in this scope while(myPort.available()>0) print(char(myPort.read())); ^ PIDtunningTool:38: error: 'print' was not declared in this scope while(myPort.available()>0) print(char(myPort.read())); ^ PIDtunningTool:41: error: 'myPort' was not declared in this scope myPort.write('X'); ^ PIDtunningTool:56: error: 'Scanner' was not declared in this scope Scanner sc = new Scanner(s); ^ PIDtunningTool:59: error: 'sc' was not declared in this scope while(sc.hasNextInt()) { ^ PIDtunningTool:62: error: 'point' was not declared in this scope point(x++, 400-c); ^ /home/octo/Downloads/dcservo-master/PIDtunningTool/PIDtunningTool.pde: In function 'void keyPressed()': PIDtunningTool:73: error: 'key' was not declared in this scope if(key=='P') { ^ PIDtunningTool:75: error: 'myPort' was not declared in this scope myPort.write('P'); ^ PIDtunningTool:76: error: invalid operands of types 'const char [1]' and 'float' to binary 'operator+' String out=""+kp; for(int i=0; i<out.length();i++) myPort.write(out.charAt(i)); ^ PIDtunningTool:79: error: invalid operands of types 'const char [3]' and 'float' to binary 'operator+' println("P="+kp); ^ PIDtunningTool:79: error: 'println' was not declared in this scope println("P="+kp); ^ PIDtunningTool:81: error: 'key' was not declared in this scope if(key=='p') { ^ PIDtunningTool:83: error: 'myPort' was not declared in this scope myPort.write('P'); ^ PIDtunningTool:84: error: invalid operands of types 'const char [1]' and 'float' to binary 'operator+' String out=""+kp; for(int i=0; i<out.length();i++) myPort.write(out.charAt(i)); ^ PIDtunningTool:87: error: invalid operands of types 'const char [3]' and 'float' to binary 'operator+' println("P="+kp); ^ PIDtunningTool:87: error: 'println' was not declared in this scope println("P="+kp); ^ PIDtunningTool:89: error: 'key' was not declared in this scope if(key=='D') ^ PIDtunningTool:92: error: 'myPort' was not declared in this scope myPort.write('D'); ^ PIDtunningTool:93: error: invalid operands of types 'const char [1]' and 'float' to binary 'operator+' String out=""+kd; for(int i=0; i<out.length();i++) myPort.write(out.charAt(i)); ^ PIDtunningTool:96: error: invalid operands of types 'const char [3]' and 'float' to binary 'operator+' println("D="+kd); ^ PIDtunningTool:96: error: 'println' was not declared in this scope println("D="+kd); ^ PIDtunningTool:98: error: 'key' was not declared in this scope if(key=='d') { ^ PIDtunningTool💯 error: 'myPort' was not declared in this scope myPort.write('D'); ^ PIDtunningTool:101: error: invalid operands of types 'const char [1]' and 'float' to binary 'operator+' String out=""+kd; for(int i=0; i<out.length();i++) myPort.write(out.charAt(i)); ^ PIDtunningTool:104: error: invalid operands of types 'const char [3]' and 'float' to binary 'operator+' println("D="+kd); ^ PIDtunningTool:104: error: 'println' was not declared in this scope println("D="+kd); ^ PIDtunningTool:106: error: 'key' was not declared in this scope if(key=='I') { ^ PIDtunningTool:108: error: 'myPort' was not declared in this scope myPort.write('I'); ^ PIDtunningTool:109: error: invalid operands of types 'const char [1]' and 'float' to binary 'operator+' String out=""+ki; for(int i=0; i<out.length();i++) myPort.write(out.charAt(i)); ^ PIDtunningTool:112: error: invalid operands of types 'const char [3]' and 'float' to binary 'operator+' println("I="+ki); ^ PIDtunningTool:112: error: 'println' was not declared in this scope println("I="+ki); ^ PIDtunningTool:114: error: 'key' was not declared in this scope if(key=='i') { ^ PIDtunningTool:116: error: 'myPort' was not declared in this scope myPort.write('I'); ^ PIDtunningTool:117: error: invalid operands of types 'const char [1]' and 'float' to binary 'operator+' String out=""+ki; for(int i=0; i<out.length();i++) myPort.write(out.charAt(i)); ^ PIDtunningTool:120: error: invalid operands of types 'const char [3]' and 'float' to binary 'operator+' println("I="+ki); ^ PIDtunningTool:120: error: 'println' was not declared in this scope println("I="+ki); ^ PIDtunningTool:122: error: 'key' was not declared in this scope if(key=='W') { ^ PIDtunningTool:123: error: 'myPort' was not declared in this scope myPort.write('W'); ^ PIDtunningTool:126: error: 'println' was not declared in this scope println("Values stored."); ^ PIDtunningTool:128: error: 'key' was not declared in this scope if(key=='Q') { ^ PIDtunningTool:129: error: 'myPort' was not declared in this scope myPort.write('Q'); ^ PIDtunningTool:132: error: 'println' was not declared in this scope println("Values requested."); ^ exit status 1 'import' does not name a type
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/misan/dcservo/issues/42, or mute the thread https://github.com/notifications/unsubscribe-auth/AAccyDr1hMF8ZAOCUuyeLD2t55y3ymvhks5tPOqXgaJpZM4Rv3o4 .
@misan But it is in my code. here is the code:
// simple tool for testing the PID response using some of the features of new firmware (S command returns the last encoder positions from last X command // by misan 2015 // it is a loop of moves X100 .. X0 .. X100 .. X0 ... // "P", "I" or "D" keys increase existing PID values // p i d keys decrease respective values // it draws "almost" in real time motor response // modified for longer target values than 100
import java.util.; import processing.serial.;
Serial myPort; // The serial port
int targetVal = 220; // use this to set the target value //please note the warparound effect on th graph if using values > 255 as Arduino only recording 8 bits location values :-(
float kp=19, ki=0.5, kd=0.17; void setup() { size(800, 400); // create a font with the third font available to the system: PFont myFont = createFont(PFont.list()[2], 14); textFont(myFont); frameRate(1); // List all the available serial ports: println(Serial.list()); String portName = Serial.list()[3]; myPort = new Serial(this, portName, 115200); }
void draw() { strokeWeight(1); background(255,100); stroke(255,0,0); line(0,400-333,600,400-333); strokeWeight(.1); for(int i=1;i<6;i++) line(i100,0,i100,400); delay(500 + targetVal / 10); stroke(0,0,255); strokeWeight(2); while(myPort.available()>0) print(char(myPort.read()));
myPort.write('X'); String out = "" + targetVal; for(int i=0; i<out.length();i++) myPort.write(out.charAt(i)); myPort.write('\r'); myPort.write('\n'); delay(500 + targetVal / 10); myPort.write('S'); myPort.write('\r'); myPort.write('\n'); delay(500 + targetVal / 10); String s=""; while(myPort.available()>0) s+=char(myPort.read());
//println(s);
Scanner sc = new Scanner(s);
int x=0; while(sc.hasNextInt()) { float y = sc.nextInt(); float c = map (y,0,targetVal<255 ? targetVal : 255,0,300); point(x++, 400-c); }
myPort.write('X'); myPort.write('0'); myPort.write('\r'); myPort.write('\n'); delay(500 + targetVal / 10); }
void keyPressed() { if(key=='P') { kp+=1; myPort.write('P'); String out=""+kp; for(int i=0; i<out.length();i++) myPort.write(out.charAt(i)); myPort.write('\r'); myPort.write('\n'); println("P="+kp); } if(key=='p') { kp-=1; kp=max(0,kp); myPort.write('P'); String out=""+kp; for(int i=0; i<out.length();i++) myPort.write(out.charAt(i)); myPort.write('\r'); myPort.write('\n'); println("P="+kp); } if(key=='D') { kd+=0.01; myPort.write('D'); String out=""+kd; for(int i=0; i<out.length();i++) myPort.write(out.charAt(i)); myPort.write('\r'); myPort.write('\n'); println("D="+kd); } if(key=='d') { kd-=0.01; kd=max(0,kd); myPort.write('D'); String out=""+kd; for(int i=0; i<out.length();i++) myPort.write(out.charAt(i)); myPort.write('\r'); myPort.write('\n'); println("D="+kd); } if(key=='I') { ki*=2; myPort.write('I'); String out=""+ki; for(int i=0; i<out.length();i++) myPort.write(out.charAt(i)); myPort.write('\r'); myPort.write('\n'); println("I="+ki); } if(key=='i') { ki/=2; myPort.write('I'); String out=""+ki; for(int i=0; i<out.length();i++) myPort.write(out.charAt(i)); myPort.write('\r'); myPort.write('\n'); println("I="+ki); } if(key=='W') { myPort.write('W'); myPort.write('\r'); myPort.write('\n'); println("Values stored."); } if(key=='Q') { myPort.write('Q'); myPort.write('\r'); myPort.write('\n'); println("Values requested."); } }
oh wait. the markdown formatting code must have messed it up. here is the raw code: https://pastebin.com/bTbb1HAi
@misan
Are you really using Processing from processing.org? Please note this is not an Arduino sketch.
El 28 ene. 2018 23:43, "ddgftw" notifications@github.com escribió:
and here https://pastebin.com/SzaUWKQJ is the raw error
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/misan/dcservo/issues/42#issuecomment-361103207, or mute the thread https://github.com/notifications/unsubscribe-auth/AAccyBKVSNL-0cvte7v5vfYGbgyiOh31ks5tPPgGgaJpZM4Rv3o4 .
oh.
does it still run on arduino? and how do i use processing? how do i upload it @misan
No, it does not run on Arduino. It runs on a PC. https://processing.org/tutorials
On Mon, Jan 29, 2018 at 11:43 AM, ddgftw notifications@github.com wrote:
does it still run on arduino? and how do i use processing? how do i upload it @misan https://github.com/misan
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/misan/dcservo/issues/42#issuecomment-361206880, or mute the thread https://github.com/notifications/unsubscribe-auth/AAccyH8YrCdrJa66rAISsO4vQ9hMGPcJks5tPaDcgaJpZM4Rv3o4 .
@misan how do i connect the motor to do pid tuning them?
You connect the Arduino running dcservo to a PC running the PID tunning program. The USB connection will allow the PC to send commands and receive results from the Arduino board, so motor response is graphed in the PC display.
On Mon, Jan 29, 2018 at 11:47 AM, ddgftw notifications@github.com wrote:
how do i connect the motor to do pid tuning them?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/misan/dcservo/issues/42#issuecomment-361207848, or mute the thread https://github.com/notifications/unsubscribe-auth/AAccyINZl3KvytflRycV4WP8FuPnuayBks5tPaHHgaJpZM4Rv3o4 .
ok. thanks
@misan so the arduino is just running normal dcservo, with everything connected normally?
@misan where do i get the pid.h library for arduino?
@misan what should the portname be?
This code depends on the excellent Arduino PID library by Brett Beauregard: https://github.com/br3ttb/Arduino-PID-Library/
You need to install that library for my code to work.
Portname changes from system to system. Sometimes what I have chosen works ok sometimes you need to adapt it to your system.
println(Serial.list()); is listing the available ports, selected the number for the next line that matches your Arduino and place it here String portName = Serial.list()[3];
I am confused how to use the pid tuning tool. i plug in my arduino uno, and i open the pidtuning.pde sketch. when i try to upload it, i get the errors below. how do i properly upload and use the pid tool?
PIDtunningTool:9: error: 'import' does not name a type import java.util.; ^ PIDtunningTool:10: error: 'import' does not name a type import processing.serial.; ^ PIDtunningTool:12: error: 'Serial' does not name a type Serial myPort; // The serial port ^ /home/octo/Downloads/dcservo-master/PIDtunningTool/PIDtunningTool.pde: In function 'void setup()': PIDtunningTool:19: error: 'size' was not declared in this scope size(800, 400); ^ PIDtunningTool:21: error: 'PFont' was not declared in this scope PFont myFont = createFont(PFont.list()[2], 14); ^ PIDtunningTool:22: error: 'myFont' was not declared in this scope textFont(myFont); ^ PIDtunningTool:22: error: 'textFont' was not declared in this scope textFont(myFont); ^ PIDtunningTool:23: error: 'frameRate' was not declared in this scope frameRate(1); ^ PIDtunningTool:25: error: 'class HardwareSerial' has no member named 'list' println(Serial.list()); ^ PIDtunningTool:25: error: 'println' was not declared in this scope println(Serial.list()); ^ PIDtunningTool:26: error: 'class HardwareSerial' has no member named 'list' String portName = Serial.list()[3]; ^ PIDtunningTool:27: error: 'myPort' was not declared in this scope myPort = new Serial(this, portName, 115200); ^ PIDtunningTool:27: error: expected type-specifier before 'Serial' myPort = new Serial(this, portName, 115200); ^ /home/octo/Downloads/dcservo-master/PIDtunningTool/PIDtunningTool.pde: In function 'void draw()': PIDtunningTool:31: error: 'strokeWeight' was not declared in this scope strokeWeight(1); ^ PIDtunningTool:32: error: 'background' was not declared in this scope background(255,100); stroke(255,0,0); ^ PIDtunningTool:32: error: 'stroke' was not declared in this scope background(255,100); stroke(255,0,0); ^ PIDtunningTool:33: error: 'line' was not declared in this scope line(0,400-333,600,400-333); ^ PIDtunningTool:38: error: 'myPort' was not declared in this scope while(myPort.available()>0) print(char(myPort.read())); ^ PIDtunningTool:38: error: 'print' was not declared in this scope while(myPort.available()>0) print(char(myPort.read())); ^ PIDtunningTool:41: error: 'myPort' was not declared in this scope myPort.write('X'); ^ PIDtunningTool:56: error: 'Scanner' was not declared in this scope Scanner sc = new Scanner(s); ^ PIDtunningTool:59: error: 'sc' was not declared in this scope while(sc.hasNextInt()) { ^ PIDtunningTool:62: error: 'point' was not declared in this scope point(x++, 400-c); ^ /home/octo/Downloads/dcservo-master/PIDtunningTool/PIDtunningTool.pde: In function 'void keyPressed()': PIDtunningTool:73: error: 'key' was not declared in this scope if(key=='P') { ^ PIDtunningTool:75: error: 'myPort' was not declared in this scope myPort.write('P'); ^ PIDtunningTool:76: error: invalid operands of types 'const char [1]' and 'float' to binary 'operator+' String out=""+kp; for(int i=0; i<out.length();i++) myPort.write(out.charAt(i)); ^ PIDtunningTool:79: error: invalid operands of types 'const char [3]' and 'float' to binary 'operator+' println("P="+kp); ^ PIDtunningTool:79: error: 'println' was not declared in this scope println("P="+kp); ^ PIDtunningTool:81: error: 'key' was not declared in this scope if(key=='p') { ^ PIDtunningTool:83: error: 'myPort' was not declared in this scope myPort.write('P'); ^ PIDtunningTool:84: error: invalid operands of types 'const char [1]' and 'float' to binary 'operator+' String out=""+kp; for(int i=0; i<out.length();i++) myPort.write(out.charAt(i)); ^ PIDtunningTool:87: error: invalid operands of types 'const char [3]' and 'float' to binary 'operator+' println("P="+kp); ^ PIDtunningTool:87: error: 'println' was not declared in this scope println("P="+kp); ^ PIDtunningTool:89: error: 'key' was not declared in this scope if(key=='D') ^ PIDtunningTool:92: error: 'myPort' was not declared in this scope myPort.write('D'); ^ PIDtunningTool:93: error: invalid operands of types 'const char [1]' and 'float' to binary 'operator+' String out=""+kd; for(int i=0; i<out.length();i++) myPort.write(out.charAt(i)); ^ PIDtunningTool:96: error: invalid operands of types 'const char [3]' and 'float' to binary 'operator+' println("D="+kd); ^ PIDtunningTool:96: error: 'println' was not declared in this scope println("D="+kd); ^ PIDtunningTool:98: error: 'key' was not declared in this scope if(key=='d') { ^ PIDtunningTool:100: error: 'myPort' was not declared in this scope myPort.write('D'); ^ PIDtunningTool:101: error: invalid operands of types 'const char [1]' and 'float' to binary 'operator+' String out=""+kd; for(int i=0; i<out.length();i++) myPort.write(out.charAt(i)); ^ PIDtunningTool:104: error: invalid operands of types 'const char [3]' and 'float' to binary 'operator+' println("D="+kd); ^ PIDtunningTool:104: error: 'println' was not declared in this scope println("D="+kd); ^ PIDtunningTool:106: error: 'key' was not declared in this scope if(key=='I') { ^ PIDtunningTool:108: error: 'myPort' was not declared in this scope myPort.write('I'); ^ PIDtunningTool:109: error: invalid operands of types 'const char [1]' and 'float' to binary 'operator+' String out=""+ki; for(int i=0; i<out.length();i++) myPort.write(out.charAt(i)); ^ PIDtunningTool:112: error: invalid operands of types 'const char [3]' and 'float' to binary 'operator+' println("I="+ki); ^ PIDtunningTool:112: error: 'println' was not declared in this scope println("I="+ki); ^ PIDtunningTool:114: error: 'key' was not declared in this scope if(key=='i') { ^ PIDtunningTool:116: error: 'myPort' was not declared in this scope myPort.write('I'); ^ PIDtunningTool:117: error: invalid operands of types 'const char [1]' and 'float' to binary 'operator+' String out=""+ki; for(int i=0; i<out.length();i++) myPort.write(out.charAt(i)); ^ PIDtunningTool:120: error: invalid operands of types 'const char [3]' and 'float' to binary 'operator+' println("I="+ki); ^ PIDtunningTool:120: error: 'println' was not declared in this scope println("I="+ki); ^ PIDtunningTool:122: error: 'key' was not declared in this scope if(key=='W') { ^ PIDtunningTool:123: error: 'myPort' was not declared in this scope myPort.write('W'); ^ PIDtunningTool:126: error: 'println' was not declared in this scope println("Values stored."); ^ PIDtunningTool:128: error: 'key' was not declared in this scope if(key=='Q') { ^ PIDtunningTool:129: error: 'myPort' was not declared in this scope myPort.write('Q'); ^ PIDtunningTool:132: error: 'println' was not declared in this scope println("Values requested."); ^ exit status 1 'import' does not name a type