What you learn today
- Daylight sensor: SolarAngle, Horizontal and Vertical
- Interpret the readings
Before a solar field can follow the sun, the chip has to know where it is. That is what the daylight sensor (StructureDaylightSensor) is for.
What it delivers
| LogicType | Meaning |
|---|---|
Activate | 1 when the sensor has sunlight, otherwise 0 |
SolarAngle | angle in degrees between the sensor's facing direction and the sun |
Horizontal | direction of the sun around the sensor axis, −180 … 180 degrees |
Vertical | angle of the sun to the sensor axis, 0 … 180 degrees |
SolarIrradiance | solar radiation in W, 0 without light |
All angles refer to the sensor itself. The Stationpedia says so explicitly: how you build it changes the values.
Reading SolarAngle
If the sensor points straight up, SolarAngle is the sun's distance from the zenith: 0° is noon with the sun exactly overhead, 90° is the horizon, anything above is night. The sun's elevation above the horizon is then
sub elev 90 angle # 90 degrees minus distance from the zenith
If the sun is 15° above the horizon, the sensor shows 75°.
Mode picks what SolarAngle is
Mode has three values from DaylightSensorMode.: Default (0) delivers the angle as above in SolarAngle, Horizontal (1) and Vertical (2) deliver one of the two spherical directions there instead. Horizontal and Vertical as LogicTypes of their own are always available. If you rely on SolarAngle, set the mode yourself:
define NORMAL DaylightSensorMode.Default
sbn SENSOR HASH("Sonne") Mode NORMAL
Telling day from night
Activate is the simplest day signal: 1 means light. It also takes into account whether something shades the sensor. For a dusk stage you combine it with the sun's elevation.
A sensor that sits tilted or on a wall delivers completely different angles. Always build the sensor you calculate with the same way – ideally oriented exactly like the panels it is meant to steer. Check it at noon: then SolarAngle must be small for a sensor pointing up.
Activate also becomes 0 when the sensor is in shadow. For a lamp that is right; for the time of day better use the sun's elevation.
Exercise
Task
The daylight sensor “Sonne” points straight up.
- Set the sensor's
ModetoDaylightSensorMode.Default - Display “Hoehe”: sun elevation = 90 −
SolarAngle(−999 without sensor) - Display “Phase”: 2 = day (light and elevation above 15°), 1 = dusk (light, elevation up to 15°), 0 = night (no light), −1 = sensor missing
- Lamp “Aussenlicht” on at phase 0 or −1
Hints
Hint 1
Sun elevation: sub elev VERTICAL angle.
Hint 2
Phase as a select cascade: first day or dusk by elevation, then night without light, finally −1 without sensor.
Hint 3
Lamp: slez tmp phase is exactly 1 for 0 and −1.
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