What you learn today
- Make panels follow the sensor
- Convert angles
- Night parking position
A fixed solar panel only delivers full output briefly around noon. A tracked panel faces the right way all day – if the chip translates the angles correctly.
What a wrong angle costs
According to the game code (SolarPanelArm) a panel's efficiency is 1 minus the distance between its facing direction and the direction to the sun. For a deviation θ that means 1 − 2 · sin(θ/2):
| Deviation | Efficiency (Ratio) |
|---|---|
| 0° | 100 % |
| 10° | 83 % |
| 30° | 48 % |
| 60° | 0 % |
So from 60° of error the panel delivers nothing at all. Tracking pays off a lot.
What the panel accepts
| LogicType | Range |
|---|---|
Horizontal | 0 … 360 degrees, larger values are wrapped onto the circle |
Vertical | 15 … 165 degrees, limited outside |
Ratio | alignment efficiency, 0 … 1 (read only) |
Charge | current output in W (read only) |
The panel turns slowly towards the new value. It does no harm to write every tick. Only a panel with a joint can be tracked: flat and angled panels do not turn at all.
Converting angles
Sensor and panel measure in different frames of reference. What has proved itself: orient the sensor exactly like the panels, take Horizontal over directly and convert Vertical with an offset:
mul v v DIRECTION # 1 or -1
add v v OFFSET # e.g. 90
clamp v v V_MIN V_MAX
The starting values 90 and −1 come from the IC10 coder's “Solar tracking” template. If Ratio stays clearly below 1 at noon, OFFSET or DIRECTION does not match your build – then adjust them there, not in the code.
Parking at night
Without light (Activate 0) the field drives to a parking position towards the sunrise. Then the morning harvest starts without a long swing.
If the sensor fails, all angles are NaN. Writing NaN to a panel is the worst thing you can do. That is why bnan h start jumps back before every write – the panels simply stay put.
How sensor and panel angles relate depends on how they are built and cannot be read from the game code alone. Measure it once at noon and put the matching values into the defines.
Exercise
Task
The daylight sensor “Sonne” steers the panels “Solar”.
- Day: panel
Horizontal= sensorHorizontal, panelVertical= 90 − sensorVertical, limited to 15 … 165 - Night (
Activate0): parking position 90 / 60 - Sensor gone: the panels keep their position
Hints
Hint 1
First bnan h start – without a sensor nothing is written.
Hint 2
Vertical: mul v v DIRECTION, add v v OFFSET, clamp v v V_MIN V_MAX.
Hint 3
Parking: select h light h PARK_H and the same for v.
Quiz
4 questions. You pass from 60 % – the server does the grading.
Complete the day
- Passed the simulator exercise
- Passed the quiz with at least 60 %
Without an account progress is saved in this browser only.
Report a mistake in this lesson
Please sign in to report. Sign in