... | ... | @@ -93,7 +93,7 @@ The motor power range is now 200 which yields a conversion factor of |
|
|
|
|
|
*conversion factor = 200/1023 = 0.196*
|
|
|
|
|
|
To introduce negative motor power 100 is substracted from the calculated output
|
|
|
To introduce negative motor power 100 is subtracted from the calculated output
|
|
|
|
|
|
*power = (sound level * 0.196) - 100*
|
|
|
|
... | ... | @@ -102,7 +102,7 @@ This is implemented as a function which takes the sound level (0-1023) as parame |
|
|
```java
|
|
|
static int calcOutput(int soundLvl)
|
|
|
{
|
|
|
// Exitatory - 200/1023 = 0.196
|
|
|
// Excitatory - 200/1023 = 0.196
|
|
|
float output = soundLvl * 0.196f;
|
|
|
return (int)(output-100);
|
|
|
}
|
... | ... | @@ -112,7 +112,7 @@ static int calcOutput(int soundLvl) |
|
|
|
|
|
**Excitatory** (0 to 100)
|
|
|
|
|
|
The result of the Excitatory setup is seen in the video in the references section. This video shows the initial test setup where the car is turned upside down and placed on a table. Next to the sound sensor a mobile phone is placed with the loudpeaker pointing towards the sound sensor of the lego car. The mobile phone is playing a piece of music and the louder the music gets the faster the wheels spin which is as we expected.
|
|
|
The result of the Excitatory setup is seen in the video in the references section. This video shows the initial test setup where the car is turned upside down and placed on a table. Next to the sound sensor a mobile phone is placed with the loudspeaker pointing towards the sound sensor of the lego car. The mobile phone is playing a piece of music and the louder the music gets the faster the wheels spin which is as we expected.
|
|
|
|
|
|
**Inhibitory** (0 to 100)
|
|
|
|
... | ... | @@ -124,9 +124,32 @@ The result of the Excitatory setup is seen in the video in the references sectio |
|
|
|
|
|
### Setup
|
|
|
|
|
|
The setup for this exercise refer to Braitenbergs vehicle 2a and 2b where two light sensors are mounted in front of the vehicle, as seen in the figure below.
|
|
|
|
|
|
![Vehicle 2](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson6/Images/Vehicle2.JPG)
|
|
|
|
|
|
**Excitatory vs inhibitory** The two vehicles 2a and 2b are somewhat opposite of each other. Vehicle 2a will drive towards the dark in excitatory mode, and towards the light in inhibitory mode. Vehicle 2b on the other hand will drive towards light in excitatory mode, and towards the dark in inhibitory mode. This means that vehicle 2a in excitatory mode will perform similar as vehicle 2b in inhibitory mode, and vice versa. Therefore the two vehicles are both tested in excitatory mode.
|
|
|
|
|
|
The conversion from light to motor power is basically the same as was used with the sound with vehicle 1. The only difference is that the motor offset now is set to 60 instead of 40. This was needed since the battery level had decreased when the experiments with vehicle 2 was performed. The conversion factor was thus:
|
|
|
|
|
|
*conversion factor = 40/1023 = 0.039*
|
|
|
|
|
|
And the motor power was calculated as:
|
|
|
|
|
|
*power = (light level * 0.039) + 60*, which is also shown in the code snippet below:
|
|
|
```java
|
|
|
static int calcDirectOutput(int lightLvl)
|
|
|
{
|
|
|
// Excitatory - 40/1023 = 0.039
|
|
|
return (int)(lightLvl * 0.039f) + 60;
|
|
|
}
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### Results
|
|
|
The result of the two vehicles 2a and 2b in excitatory mode is seen in the videos in the references section. Here it is clearly shown that vehicle 2a drives towards the darkness, whereas vehicle 2b drives towards the light, just as expected.
|
|
|
|
|
|
|
|
|
|
|
|
## Vehicle 3
|
... | ... | |