jessvi created page: Lab5 authored by Jesper Kurtzmann Svith's avatar Jesper Kurtzmann Svith
...@@ -71,6 +71,41 @@ In the datalogger class we had to replace FileOutputStream with BufferedOutputSt ...@@ -71,6 +71,41 @@ In the datalogger class we had to replace FileOutputStream with BufferedOutputSt
> >
> ![PID_gui](http://gitlab.au.dk/uploads/group-22/lego/56fed5f205/PID_gui.png) > ![PID_gui](http://gitlab.au.dk/uploads/group-22/lego/56fed5f205/PID_gui.png)
> ##### Fig. 4 - Control GUI used to adjust the PID values as well as offset (o) and SCALE (s). > ##### Fig. 4 - Control GUI used to adjust the PID values as well as offset (o) and SCALE (s).
>
> While using the GUI we ran into a problem where the values would not be sent correctly to the robot. Instead of just sending one value for the P parameter all the values would change to the same as the P value. We think the problem lies in the PCcarController.java program. In the part of the program that sends the values to to robot, we had forgot to change the I value from an int to a float value (see fig. 5). After fixing this the Bluetooth connection seemed to work normally again.
>
>```
try
{
String pString = pField.getText();
int p = new Integer(pString).intValue();
dos.writeInt(p);
dos.flush();
String iString = iField.getText();
float i = new Float(iString).intValue(); // The I value needs to be a float value in
dos.writeFloat(i); // order to send decimal numbers.
dos.flush();
String dString = dField.getText();
int d = new Integer(dString).intValue();
dos.writeInt(d);
dos.flush();
String oString = oField.getText();
int o = new Integer(oString).intValue();
dos.writeInt(o);
dos.flush();
String sString = sField.getText();
int s = new Integer(sString).intValue();
dos.writeInt(s);
dos.flush();
}
```
> >
>--- >---
> >
... ...
......