|
| 1 | +# Arduino programming |
| 2 | + |
| 3 | +Programming the Arduino Nano can already be done before it is mounted on the PCB, but it is also possible to do it afterwards. Also, future updates of the software can be uploaded without removing the Arduino from the PCB. Once the Arrduino is programmed, the program is stored in its flash memory. Whenever you restart the Arduino, it will run the program from the flash memory. |
| 4 | + |
| 5 | +## Installing the Arduino IDE |
| 6 | + |
| 7 | +The Arduino IDE is available for all popular operating systems. You install it from one of the package managers supported by your OS or you can install it from the [Arduino download page](https://www.arduino.cc/en/software), whatever you trust better. Some OS may require to install the Java Runtime Enviromnemt first. Also here, install it from one of the package managers or get the full JDK17 from [https://www.oracle.com/java/technologies/downloads/](https://www.oracle.com/java/technologies/downloads/). |
| 8 | + |
| 9 | +Most likely you use Microsoft Windows and you can simply install the Arduino IDE legacy version (1.8.x) from the Microsoft Store, which includes a copy of the Java JRE. The Arduino program in this git repository was only tested with this legacy version. |
| 10 | + |
| 11 | +## Downloading the LCD shutter driving software |
| 12 | + |
| 13 | +The latest software for the GPS-controlled LCD shutter driver can be downloaded from: |
| 14 | + |
| 15 | +[https://github.com/hadoopmarc/gps-controlled-lcd-shutter/archive/refs/heads/main.zip](https://github.com/hadoopmarc/gps-controlled-lcd-shutter/archive/refs/heads/main.zip) |
| 16 | + |
| 17 | +Extract the archive at some place where it can easily be found back. Of course, if you know how to use git and want to contribute to the repository, you can git clone the repository instead of donwloading the archive. |
| 18 | + |
| 19 | +## Programming the Arduino |
| 20 | + |
| 21 | +Programming the Arduino Nano should now be so simple as: |
| 22 | + |
| 23 | +1. connect the Arduino to your PC/laptop using a USB-cable |
| 24 | +2. open the local file 'gps-controlled-lcd-shutter/arduino/waveform-h-bridge/waveform-h-bridge.ino' with the Arduino IDE. This will open three files in separate tabs. The file gps_shutter_control.cpp contains the actual program. The two other files prepare the Arduino for later extensions. |
| 25 | +3. select the Arduino Nano from the "Tools / Board / Arduino AVR boards" menu option |
| 26 | +4. select the right COM-port from the "Tools / Port" menu option (if no COM port is marked as Arduino Nano, disconnect and reconnect the Arduino to discover the right COM port) |
| 27 | +5. push the "Upload ->" button in the taskbar. If the compilation fails, please contact the repository owner. If the upload fails, disconnect and reconnect the Arduino and try again. |
| 28 | + |
| 29 | +## Checking the logs |
| 30 | + |
| 31 | +Once the uploaded program runs, it produces log statements over the serial interface. You can check these by opening the serial monitor of the Arduino IDE (far right button on the taskbar). On powering up the PCB, the GPS-module needs about half a minute to lock on one or more satellites and after that the LCD shutter program need 10 GPS pulses before generating second markers in the driver output. During that time the serial monitor only shows: |
| 32 | + |
| 33 | +```log |
| 34 | + Configuration of LCD shutter completed. |
| 35 | + Stabilizing... |
| 36 | +``` |
| 37 | + |
| 38 | +After this time the serial monitor shows something like the text below, every second: |
| 39 | + |
| 40 | +```log |
| 41 | + LCD phase: 0 0 0 42 |
| 42 | +``` |
| 43 | + |
| 44 | +These are variables used in synchronizing the timer outputs derived from MCU clock with the Pulse Per Second signal from the GPS module. The first three numbers should be zero, and the last number is the accumulated phase differerence in microseconds during one second, just before synchronization happens. This should be a figure between 0 and 128 microseconds. |
| 45 | + |
| 46 | +In addition to the logs that occur every second, another log message appears every 20 seconds and shows the result of calibrating the MCU clock frequency against the GPS PPS signal. It has the following format: |
| 47 | + |
| 48 | +```log |
| 49 | + Micros: 20 20000000 |
| 50 | + CPU: 16012345 |
| 51 | + Block: 7810 ticks |
| 52 | +``` |
| 53 | +The CPU frequency should be 16 MHz with an error margin of 0.5% (so large because of the cheap ceramic resonator used on the Arduino module). The CPU frequency should only show minor variations during operation. The block ticks refer to the number of required timer events during one half wave (block pulse) of the driver output. This number is derived from the measured CPU frequency and should also show only minor variations. |
0 commit comments