Difference between revisions of "Alpha Clock Firmware v2"
m (→Uploading firmware) |
m (→Setting up the environment) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 10: | Line 10: | ||
=== Alpha Clock Five firmware version 2.0 === | === Alpha Clock Five firmware version 2.0 === | ||
− | The latest version of the Alpha Clock Five Firmware, (currently v. 2. | + | The latest version of the Alpha Clock Five Firmware, (currently v. 2.2) is hosted [https://github.com/oskay/AlphaClock at our github repository]. Download the .zip archive of the repository there, or follow [https://github.com/oskay/AlphaClock/archive/master.zip this direct link] to download and save it to your computer. This .zip archive contains the Alpha Clock Five library for Arduino, for which the standard firmware is included as one of the example files. The necessary setup to install that library and upload the firmware is discussed in the sections that follow on this page. |
Line 19: | Line 19: | ||
== Bootloader (Arduino style) programming == | == Bootloader (Arduino style) programming == | ||
− | The microcontroller in Alpha Clock Five kit comes preprogrammed with the | + | The microcontroller in Alpha Clock Five kit comes preprogrammed with the "Sanguino" Bootloader-- an Arduino bootloader designed to run on the ATmega644 processor. Because of this, Alpha Clock Five can be reprogrammed right in the Arduino environment, through a USB-TTL interface such as the [http://shop.evilmadscientist.com/productsmenu/partsmenu/130-usbttl FTDI USB-TTL cable] or the [http://shop.evilmadscientist.com/productsmenu/accessories/210 Adafruit FTDI Friend], and doing so is our recommended procedure. |
The bootloader itself can only be written (or rewritten) with an AVR ISP programmer, such as the [http://shop.evilmadscientist.com/productsmenu/tinykitlist/106-usbtiny USBtinyISP]. While most users will not ever need to do this, see below (under [http://wiki.evilmadscientist.com/index.php?title=Alpha_Clock_Firmware#AVR_ISP_Programming AVR ISP Programming]) if you should need to do so. | The bootloader itself can only be written (or rewritten) with an AVR ISP programmer, such as the [http://shop.evilmadscientist.com/productsmenu/tinykitlist/106-usbtiny USBtinyISP]. While most users will not ever need to do this, see below (under [http://wiki.evilmadscientist.com/index.php?title=Alpha_Clock_Firmware#AVR_ISP_Programming AVR ISP Programming]) if you should need to do so. | ||
Line 30: | Line 30: | ||
Required software: | Required software: | ||
− | * Arduino 1. | + | * Arduino 1.8.10 (available [http://arduino.cc/en/Main/Software here]). |
− | * Arduino Time library, available [ | + | * Arduino Time library, available [https://github.com/PaulStoffregen/Time here]. |
+ | * Arduino DS1307 library, available [https://github.com/PaulStoffregen/DS1307RTC here]. | ||
* Alpha Clock Five library, as discussed above. | * Alpha Clock Five library, as discussed above. | ||
− | * Sanguino | + | * The MightyCore extensions to Arduino, which include the Sanguino configuration files. |
First, install the Arduino program on your computer. Open Arduino to ensure that it runs correctly, and then quit. (Please do not skip this step!) | First, install the Arduino program on your computer. Open Arduino to ensure that it runs correctly, and then quit. (Please do not skip this step!) | ||
− | Secondly, install the Time | + | Secondly, install the Time and DS1307 libraries in your Arduino libraries folder. The exact location of this libraries folder depends a bit on your operating system. For example, on Mac OSX, the directory would be ~/Documents/Arduino/libraries/. On Windows, it would be My Documents\Arduino\libraries\ . Copy the Time folder (the one with the time.h file, not the top-level Time folder) to your libraries folder. If your library is installed correctly, it will show up in (and be importable from) the '''Sketch > Import Library''' menu in the Arduino program when you restart it. |
Third, install the Alpha Clock Five library. When you download [https://github.com/oskay/AlphaClock/archive/master.zip the .zip file] from github, it will show up on your computer as "AlphaClock-master.zip". Unzip that file, and open that folder to find the file within called just "alphafive". Place this "alphafive" folder in your Arduino libraries folder, just as you did with the Time library. If your library is installed correctly, it will show up in the '''Sketch > Import Library''' menu in the Arduino program when you restart it. | Third, install the Alpha Clock Five library. When you download [https://github.com/oskay/AlphaClock/archive/master.zip the .zip file] from github, it will show up on your computer as "AlphaClock-master.zip". Unzip that file, and open that folder to find the file within called just "alphafive". Place this "alphafive" folder in your Arduino libraries folder, just as you did with the Time library. If your library is installed correctly, it will show up in the '''Sketch > Import Library''' menu in the Arduino program when you restart it. | ||
+ | Finally, the MightyCore additions need to be installed. This can be done from directly inside the Arduino application, following the [https://github.com/MCUdude/MightyCore#how-to-install directions here]. Once added, you can select the following from your Tools menu in Arduino to configure the device: | ||
− | + | * Board> MightyCore: ATmega644 | |
+ | * Clock: External 16 MHz | ||
+ | * BOD: 2.7V | ||
+ | * Variant: 644P (See technical note about device signature below, if you're curious.) | ||
+ | * Bootloader: Yes, UART 0 | ||
+ | * Pinout: Sanguino pinout | ||
+ | * Port: Select the FTDI adapter that you have connected to your computer by USB | ||
+ | ==== Setting the upload baud rate ==== | ||
− | + | For historical reasons related to the original "Sanguino" core, the speed that the Arduino application uses to upload firmware to Alpha Clock Five needs to be set to 57600 baud. (Some kits that shipped in 2012 or earlier, prior to the release of [https://www.evilmadscientist.com/2012/alpha-clock-five-v2/ firmware 2.0], require a baud rate of 38400.) The upload speed can only be changed by rewriting the microcontroller's bootloader, with an AVR ISP programmer. | |
− | + | If you happen to have an AVR ISP programmer, you are welcome to write a fresh bootloader to the Alpha Clock Five (once the environment above is set up), which will set the upload speed to the modern default of 115200 baud. Otherwise, you will need to modify the upload speed. If you choose to do neither, programming will not work, and you will get an error. (Likely error: "avrdude: stk500_getsync(): not in sync: resp=0x00".) | |
+ | When you try to upload, you will get a message that indicates (in part) where the configuration files are stored. Something like: | ||
+ | <code>System wide configuration file is "/Users/oskay/Library/Arduino15/packages/MightyCore/hardware/avr/2.0.3/avrdude.conf"</code>. (The exact location will depend upon your operating system and configuration.) Open the folder that contains that file on your computer, and locate the "boards.txt" file from within that same directory. For example, one might be located at | ||
− | + | <code>/Users/oskay/Library/Arduino15/packages/MightyCore/hardware/avr/2.0.3/boards.txt</code> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | Open that boards.txt file with a text editor, and locate the <code>644.menu.clock.16MHz_external.upload.speed</code> parameter. Change it to read: | |
+ | <code>644.menu.clock.16MHz_external.upload.speed=57600</code> | ||
− | + | Then, save the file and restart Arduino. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== Uploading firmware === | === Uploading firmware === | ||
Line 94: | Line 78: | ||
4. Make sure that Alpha Clock Five is powered on. | 4. Make sure that Alpha Clock Five is powered on. | ||
− | 5. Open up the "sketch" file for firmware | + | 5. Open up the "sketch" file for the standard firmware. You can find it in your menu under File > Examples > alphafive > AlphaClock. |
− | 6. Then, click the "Upload" button in your Arduino window to upload the sketch. ( | + | 6. Then, click the "Upload" button in your Arduino window to upload the sketch. (If you get a "not in sync" error, check the note above about upload baud rate.) |
There are additional example files included with the library to demonstrate simpler applications of the Alpha Clock Five library, as well as processing sketches that can send serial data to the Alpha Clock Five. See [[Alpha_Clock_Serial_v2| Alpha Clock Serial]] for more information. | There are additional example files included with the library to demonstrate simpler applications of the Alpha Clock Five library, as well as processing sketches that can send serial data to the Alpha Clock Five. See [[Alpha_Clock_Serial_v2| Alpha Clock Serial]] for more information. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Line 126: | Line 91: | ||
Most users will not need to reprogram the bootloader at any point. | Most users will not need to reprogram the bootloader at any point. | ||
− | + | If you choose to do so, you will need an AVR ISP programmer, and can burn the bootloader from within Arduino by selecting your programmer type and using Tools>Burn Bootloader. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Line 147: | Line 103: | ||
== AVR ISP Programming == | == AVR ISP Programming == | ||
− | The Alpha Clock Five PCB features a 6-pin AVR ISP connector (J4), which can be used to program the microcontroller through any suitable AVR ISP programmer. We recommend the Adafruit [http://shop.evilmadscientist.com/productsmenu/tinykitlist/106-usbtiny USBtinyISP] programmer for most purposes. The Alpha Clock Five should be powered separately | + | The Alpha Clock Five PCB features a 6-pin AVR ISP connector (J4), which can be used to program the microcontroller through any suitable AVR ISP programmer. We recommend the Adafruit [http://shop.evilmadscientist.com/productsmenu/tinykitlist/106-usbtiny USBtinyISP] programmer for most purposes. The Alpha Clock Five should be powered separately through its regular power supply while programming, not through the ISP programmer. |
The circuit can be programmed through AVR-GCC or any other AVR software environment, including AVR Studio. If using AVR-GCC, you may find it helpful to target (set the MCU type as) the ATmega644P rather than the ATmega644A, as it is better supported. | The circuit can be programmed through AVR-GCC or any other AVR software environment, including AVR Studio. If using AVR-GCC, you may find it helpful to target (set the MCU type as) the ATmega644P rather than the ATmega644A, as it is better supported. | ||
− | Please refer to the electrical schematics for pinouts and other hardware features of the Alpha Clock Five | + | Please refer to the electrical schematics for pinouts and other hardware features of the Alpha Clock Five. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 21:39, 20 November 2019
The Alpha Clock Five is an alarm clock and alphanumeric LED data display device based on the ATmega644A AVR microcontroller. While most users will not need to reprogram Alpha Clock Five, we are making this page of documentation available for those who would like to modify the programming or simply would like to update an existing unit to firmware version 2.x.
Alpha Clock Five can be programmed through an FTDI USB-TTL interface, using a modified version of the Arduino development environment, or through an AVR ISP programmer using standard AVR programming techniques. The default firmware is designed to under the modified Arduino environment, which is described below in the section titled "Bootloader (Arduino style) programming."
Contents
Standard Firmware for Alpha Clock Five[edit]
Alpha Clock Five firmware version 2.0[edit]
The latest version of the Alpha Clock Five Firmware, (currently v. 2.2) is hosted at our github repository. Download the .zip archive of the repository there, or follow this direct link to download and save it to your computer. This .zip archive contains the Alpha Clock Five library for Arduino, for which the standard firmware is included as one of the example files. The necessary setup to install that library and upload the firmware is discussed in the sections that follow on this page.
(The previous major firmware version, v. 1.0 of the Alpha Clock Five firmware is discussed here.)
Bootloader (Arduino style) programming[edit]
The microcontroller in Alpha Clock Five kit comes preprogrammed with the "Sanguino" Bootloader-- an Arduino bootloader designed to run on the ATmega644 processor. Because of this, Alpha Clock Five can be reprogrammed right in the Arduino environment, through a USB-TTL interface such as the FTDI USB-TTL cable or the Adafruit FTDI Friend, and doing so is our recommended procedure.
The bootloader itself can only be written (or rewritten) with an AVR ISP programmer, such as the USBtinyISP. While most users will not ever need to do this, see below (under AVR ISP Programming) if you should need to do so.
Setting up the environment[edit]
Alpha Clock Five requires a rather specialized programming environment:
Required software:
- Arduino 1.8.10 (available here).
- Arduino Time library, available here.
- Arduino DS1307 library, available here.
- Alpha Clock Five library, as discussed above.
- The MightyCore extensions to Arduino, which include the Sanguino configuration files.
First, install the Arduino program on your computer. Open Arduino to ensure that it runs correctly, and then quit. (Please do not skip this step!)
Secondly, install the Time and DS1307 libraries in your Arduino libraries folder. The exact location of this libraries folder depends a bit on your operating system. For example, on Mac OSX, the directory would be ~/Documents/Arduino/libraries/. On Windows, it would be My Documents\Arduino\libraries\ . Copy the Time folder (the one with the time.h file, not the top-level Time folder) to your libraries folder. If your library is installed correctly, it will show up in (and be importable from) the Sketch > Import Library menu in the Arduino program when you restart it.
Third, install the Alpha Clock Five library. When you download the .zip file from github, it will show up on your computer as "AlphaClock-master.zip". Unzip that file, and open that folder to find the file within called just "alphafive". Place this "alphafive" folder in your Arduino libraries folder, just as you did with the Time library. If your library is installed correctly, it will show up in the Sketch > Import Library menu in the Arduino program when you restart it.
Finally, the MightyCore additions need to be installed. This can be done from directly inside the Arduino application, following the directions here. Once added, you can select the following from your Tools menu in Arduino to configure the device:
- Board> MightyCore: ATmega644
- Clock: External 16 MHz
- BOD: 2.7V
- Variant: 644P (See technical note about device signature below, if you're curious.)
- Bootloader: Yes, UART 0
- Pinout: Sanguino pinout
- Port: Select the FTDI adapter that you have connected to your computer by USB
Setting the upload baud rate[edit]
For historical reasons related to the original "Sanguino" core, the speed that the Arduino application uses to upload firmware to Alpha Clock Five needs to be set to 57600 baud. (Some kits that shipped in 2012 or earlier, prior to the release of firmware 2.0, require a baud rate of 38400.) The upload speed can only be changed by rewriting the microcontroller's bootloader, with an AVR ISP programmer.
If you happen to have an AVR ISP programmer, you are welcome to write a fresh bootloader to the Alpha Clock Five (once the environment above is set up), which will set the upload speed to the modern default of 115200 baud. Otherwise, you will need to modify the upload speed. If you choose to do neither, programming will not work, and you will get an error. (Likely error: "avrdude: stk500_getsync(): not in sync: resp=0x00".)
When you try to upload, you will get a message that indicates (in part) where the configuration files are stored. Something like:
System wide configuration file is "/Users/oskay/Library/Arduino15/packages/MightyCore/hardware/avr/2.0.3/avrdude.conf"
. (The exact location will depend upon your operating system and configuration.) Open the folder that contains that file on your computer, and locate the "boards.txt" file from within that same directory. For example, one might be located at
/Users/oskay/Library/Arduino15/packages/MightyCore/hardware/avr/2.0.3/boards.txt
Open that boards.txt file with a text editor, and locate the 644.menu.clock.16MHz_external.upload.speed
parameter. Change it to read:
644.menu.clock.16MHz_external.upload.speed=57600
Then, save the file and restart Arduino.
Uploading firmware[edit]
1. Connect your FTDI interface (e.g., USB-TTL cable) to location J2 on the circuit board (the 6-pin SIL right-angle header also labeled "LOGIC-LEVEL (TTL) SERIAL"), watching the polarity. For the cables with rainbow-wires on the end, black goes down, green goes up.
2. Make sure that the correct serial port is selected in the Tools>Serial Port menu. (Hint: you might need to install the FTDI USB drivers from here: http://www.ftdichip.com/Drivers/VCP.htm)
3. Select "Sanguino W/ ATmega644P" from your Tools>Board menu
4. Make sure that Alpha Clock Five is powered on.
5. Open up the "sketch" file for the standard firmware. You can find it in your menu under File > Examples > alphafive > AlphaClock.
6. Then, click the "Upload" button in your Arduino window to upload the sketch. (If you get a "not in sync" error, check the note above about upload baud rate.)
There are additional example files included with the library to demonstrate simpler applications of the Alpha Clock Five library, as well as processing sketches that can send serial data to the Alpha Clock Five. See Alpha Clock Serial for more information.
Programming the bootloader[edit]
Most users will not need to reprogram the bootloader at any point.
If you choose to do so, you will need an AVR ISP programmer, and can burn the bootloader from within Arduino by selecting your programmer type and using Tools>Burn Bootloader.
Technical note on device signature[edit]
The device signature that the Alpha Clock's bootloader returns is that of the ATmega644P (not the ATmega644A). This is intentional. It is (1) code compatible and (2) better supported under both AVR-GCC and the Arduino/Sanguino environments. There are longstanding bugs in support for the 644A, and this is a stable and sane workaround.
The "hardware" device signatures-- those that you will read if you try to reprogram the AVR through an ISP interface --do remain those of the ATmega644A.
AVR ISP Programming[edit]
The Alpha Clock Five PCB features a 6-pin AVR ISP connector (J4), which can be used to program the microcontroller through any suitable AVR ISP programmer. We recommend the Adafruit USBtinyISP programmer for most purposes. The Alpha Clock Five should be powered separately through its regular power supply while programming, not through the ISP programmer.
The circuit can be programmed through AVR-GCC or any other AVR software environment, including AVR Studio. If using AVR-GCC, you may find it helpful to target (set the MCU type as) the ATmega644P rather than the ATmega644A, as it is better supported.
Please refer to the electrical schematics for pinouts and other hardware features of the Alpha Clock Five.