In general, regardless of the timing for skiing on Arduino, you can make all sorts of convenient devices. One of these devices I need already for several years. The fact is that in training you need to comply with the usual (exact) time. We rent the slope strictly for two hours, and this time is strictly “scheduled”. But I have no watches with me. This had to be abandoned a long time ago, because the watch does not live long during slalom training. And everything else that can be damaged by hit of slalom poles, a smartphone and even a key fob-alarm on the keys to the car. Everything is in a backpack, which lies in a pile of the same near the start. Therefore, in the field of view is not harmful to have a clock. And it is desirable temperature, although it is not critical. And it is desirable that the watch tracked the training schedule, gave noticeable signals when to set a new course, and when to round out. I was looking for something similar in the sale, frost-resistant with sufficiently large indicators to be seen from a distance. Oddly enough, did not find. In the note I will describe such a unit.
The rules of our workouts are described in the note: Self-study slalom trainings. Firstly we set “warm-up” gummies. They need to be replaced strictly in half an hour by the first course, then after another half an hour set second course and must leave time for smoothing the slope. The effectiveness of training depends on the accuracy of compliance with schedule. It so happened that we installed a good course with omega, and after a couple of runs the rental time suddenly ended.
Modules (boards)
The unit “Schedule Control” uses several the same boards as for other modules. These boards are described here: Timing system for Alpine skiing based on Arduino. Order modules. More precisely, the Arduino Nano single chip computer is used, the battery charging board and the clock indicator with a colon.
In addition to these modules, the following are used.
Indicator “with dots” to display the temperature. Unfortunately, such indicators are on a different controller (TM74HC595), which is much more difficult to use. Ali price (here, above and further, with delivery to the nearest post office in Moscow) $ 1.45. Delivery was 25 days.
A real-time clock board (RTC – real time clock) DS3231. This is a fairly accurate watch with separate power supply on a 2032 battery, of course, with quartz. In addition, there is a built-in thermometer in order to correct the frequency of quartz, depending on temperature. In principle, this thermometer could be used, the documented accuracy is 0.5 degrees. I did not immediately find out about this, but I probably would not have used it, since the temperature is needed “clearly” outside. Cost $ 1.17, shipping 25 days.
Thermometer DS18b20. This is not a thermocouple, the thermometer on the chip from Dallas Semiconductor immediately gives the value of the temperature in numbers. In addition, the module has its own address and 1-wire protocol, through which many more thermometers can be hung on the same wire. Price $ 1.43, shipping 25 days. The declared accuracy is 0.5 degrees.
Active buzzer. There are also passive buzzers that reproduce the frequency that they are served. The active buzzer gives the signal itself, but only one frequency. Cost $ 0.49, delivery time 25 days. The delivery time is the same for all modules, since they were ordered at the same time in the very first and largest batch from one supplier. Perhaps that is why the delivery was quite fast for Ali Express.
Connection diagram
I think such schemes are not harmful for all units in case of repairs. The connection may not necessarily be such, since the Arduino Nano has many equivalent inputs/outputs. In the diagram, (+) and (-) are not completed in order not to complicate perception. It is just necessary to take into account that all red wires are connected and this is (+), and all black ones are connected and this is (-) or in another word “ground”.
Description of work
Both switches (power and the for schedule control) are located “under one finger”. When turned on, the “real” time is shown, as in ordinary clocks, and the temperature with tenths of degrees Celsius.
Rental schedule we have different, on weekdays, weekends and holidays. All this data is “hammered” into the program. When the “time for change” comes, the buzzer beeps intermittently for three minutes and the time indicator flashes. If this is not appropriate, you can turn off by the switch.
The clock is set when the program is compiled, certainly not up to a second. This accuracy can be caught by pressing a button that resets the setting of seconds to the nearest minute. That is, if there were more seconds, then the same minute, and if less, then the minute is added. In general, the most natural.
There is no DC-DC boost in the unit, as there is nothing responsible. That is, the logical “1” in all elements of the circuit corresponds not to 5 volts, but to the voltage supplied by the battery.
Measurements have shown that for this particular Arduin Nano, everything works in the voltage range from 4.1 volts (fully charged specific battery) to 2.86 volts.
When the battery is discharged to 3.0 volts, the red LED lights up. After that, there is still about half an hour of operation of the circuit. And maybe more.
Measured with an old battery from a smartphone, since I was not even trying to wait for the 18650 battery with the claimed capacity of 3000-3500 mAh to discharge.
In the final unit put the battery is weaker, these 18650 are very huge 🙂
Programming Features
It is necessary to dwell on four points: working with a temperature sensor, with a temperature indicator, with a clock, and measuring the supply voltage. Everything else is quite usual.
Temperature measurement
As already mentioned, temperature measurement is not just a thermocouple-ADC-calibration, but working with a protocol, finding a chip at the address, initialization, and reading. This can be done very difficult for a non-professional. This is done so in the examples based on the “OneWire” library, which are “lying on the surface” on the Internet. I could not figure it out. It was possible to deal with examples that use the library “DallasTemperature” as addition to above library. The ideology is about the following. First, to the air (more precisely to “one wire”), a request is sent for a response from all connected sensors. There may be many, more than a hundred. Responses are collected, although in the example it is known in advance that only one sensor is connected. This single responded sensor is recorded in the number “0”. Then a request for data is sent to the number “0”, the data is received.
In general, all this would not be important if all this did not take about 0.7 seconds of time, and all other processes stopped. Attempts to determine this address during initialization in the “Setup” section of the program in order to quickly access this chip and quickly read the data yielded little. The minimum time of “fading” of the program is 0.57 seconds and nothing can be done about it. Originally wanted to hang the temperature measurement on the Arduino module “Start”. Then, when, due to the fight against the radio channel, the “Start” module turned out to be loaded, I decided not to make it heavy. And it turns out nothing would have reached. The Start module “monitors” the starting wicket and the signal from the Finish module. He cannot be “frozen” for half a second 🙂
Indicator on TM74HC595 controllers
This indicator looks exactly the same as on the controller TM1637, and is more expensive. For some reason, the points in the indicators with Ali are only on this controller. I think that the indicators on the TM74HC595 controllers (there are two on the back of the board) is a mistake. The numbers need to be “set on fire” all the time, after about 300 microseconds (I did not find exact data, but no less than 1500 μs), otherwise the indicator blinks noticeably to the eye. In principle, nothing complicated, since Arduino is built on a cycle of “loop”. But when the temperature measurement takes over for half a second, this indicator blinks. In the 1637 controller, the ignition takes over the controller (and this is correct :)), everything is fine with it.
The problem is solved by jerking the program by interrupting by timer. It sounds crazy, and too difficult for me. For this you need to connect the library “TimerOne”. And the library itself for the indicator and an example of work on such an interruption was found exclusively in runet through the site AlexGyver (thanks!). The library is called “TM74HC595Display”. True, in this library there is no output of negative numbers and the display of near-zero temperatures is poorly processed. But it was easy to complete.
Real time clock DS3231
Unfortunately, with examples and libraries that “lie on the surface,” nothing I could done. But there was a library with a very simple work, called “DS3231”. I note that the clock can be connected to the Arduino Nano only on the “legs” of A4, A5, since I2C protocol, which is necessary for this module, is implemented only on them.
Reset seconds had to be done through an interrupt (because of the temperature module), the button is connected to the “leg” D2 (interrupt number 0). This interrupt somehow conflicts with a timer interrupt for serving the indicator. Therefore, the reset is not about the fact of pressing the button, but in fact “the button is already pressed”. In general, not much more complicated, but more crooked 🙁
Power supply measurement
Arduino Nano has several inputs which can do analog-digital convertion. Connecting the battery to any of these inputs for some reason immediately turned on the board, as if connected to the “leg” 5V. I did not begin to deal with this, since I decided to abandon the “booster”, that is, not to feed this particular unit with stabilized 5 volts. With such a scheme in general with the measurement of voltage everything is pretty sad. The ADC inputs measure the voltage relative to three options for the reference voltage (optional). I will not list them, because there is only one way to measure the “on-board” voltage – measure relative to the built-in reference voltage in the chip 1.1 volts. But also not easy, because you can measure the voltage only less than the reference. That is, you need to fence a voltage divider, which in itself will consume current.
Fortunately, there is a trick on the net, which is on the search “Secret Arduino voltmeter – measure battery voltage“. The point is that the “on-board” voltage is used as a reference, and by means of incomprehensible tricks, voltage of (known) 1.1 volts is being measured. That is, 1.1 volts is measured in fractions of the onboard voltage. From this, the on-board voltage is calculated by the inverse recalculation. Implemented as a procedure for working with registers, in which I do not understand a single line 🙂 But when you include the code in the program, everything works. The only thing, as the author pointed out, is to choose the coefficient, since the internal reference voltage is not exactly 1.1 volts.
Result
Here are collected all the notes on the theme “Timing for skiing on Arduino”.
Vadim Nikitin