Datalogger Counter
-
Navigate to HSYCO Manager
-
Create a new project or open an existing one
- Go into the Home page
- Click "add"
- Add a "Datalogger"
- Go back to "edit" mode
- You can enlarge the object by dragging one of the corners
- Change the "Logger ID" to "logger1" (the counter logger we defined in the settings)
9. Change the "Controls" to "toolbar". This shows a toolbar to control live and browser modes
10. Change the "Value Label Type" to "popup". Value labels are now shown on mouseover or on touch
Tip: Now we'll add the button linked to the dummy light
- Click "add"
- Add a "Button"
- Click "edit"
- Align the button below the datalogger by clicking "Align" and then "Center Horizontally"
- Change the "Label" to "Dummy Light 1"
- Change the "Action" to "datapoint"
- Change the "Datapoint" to "dummy.light.1"
- Click "Save" to save the project
Tip: Great! Now we'll write some code to update the Datalogger when the button is pressed
- Go into "File Manager"
- Navigate into the "events" folder
- Click "New File"
- Give the file a name ("counterlogger.txt" for example) and click "New File"
**23. Copy the following code and save the file:
io dummy.light.1 = 1 : $loggercount + 1
$loggercount : DATALOGGER logger1 = $loggercount
What this does is, every time the "dummy.light.1" datapoint is on (or 1), it adds one to a local variable that counts the time this light has been light up. Then, when this variable changes, it updates the values of the Datalogger with ID "logger1" to the value of the local variable**
- Go back to the project and click "Run" and then "Default" to launch the application
- The page should look like this:
26. Press the button to light up the dummy light. As you can see, a bar has appeared in the graph and it shows that the light has been light up 1 time
27. If we press the button again, after turning off the light, a second bar shows up. If we head over the bar with the mouse, a popup value shows up and it shows the value of that bar. This because we previously set the "Value Label Type" to "popup"
- If we press the button twice in a short time (in this case in a minute because the datalogger has a resolution expressed in minutes as defines in the settings), the bar shows a value of 2 in the same bar