Showing posts with label Arduino IDE. Show all posts
Showing posts with label Arduino IDE. Show all posts

Sunday, July 24, 2016

Countdown timer for a PhotoBox

One day a colleague from our Laser department (YES we have Lasers!) stood next to my desk and started to ask some suspicious questions about 7-Segment displays and how to control them with an Arduino.

In general its not a problem, I like to share my knowledge about electronics and programming etc., but I hate it to answer questions without knowing the circumstances. So I asked him what the target of the project would be and he said he wanted to program a countdown timer and that he also has not really the time to do it. He also told ne that the project is not for him, its for Murat (Also a guy from the Laser department).

Later that day I went to Murat and asked him about the details of the project and what the main goal would be. He told me that he want to build a PhotoBox for his sisters wedding. I told him that if it is for his sisters wedding it should not only be some 7-Segment displays. He would need something which looks much fancier with more animation and special effects than a 7-Segment display is able to provide, and I showed him my work that I have done with the 3208 lattice clock and that something similar could be done for a countdown display.

He said he would like to have something that does the following:

  • Push a button
  • Countdown starts
  • End of the countdown a Relay is triggered
On that evening I went home and started to dig out my spare 3208 Lattice Clock module and a relay board. I soldered some connectors for power supply, relay output and programming to the board, and started to play with it. After some hours I came up with the following animation:


In the video itself it is not very clear, but the sequence is as follows:
  • Press RESET or reconnect the power to start
  • Dim up the first number in the middle of the screen
  • Shift the number out to the left while the new number comes from the right
  • When the 0 is reached then dim it out
  • Actuate the relay output for one second
  • Wait in idle until RESET or re-power
The complete code including the control for the HT1632C is in one single Arduino sketch with less than 300 lines of code. I apologize for the German comments in the code But it was quick and dirty written. The code can be found in my GitHub repository

So far my work was done for this project. Murat also sent me some pictures of the finished project where he put it all together into a nice box with a tablet as picture preview.
Sadly Instagram changed their logo recently.










Monday, August 19, 2013

3208Clock Part 3: Implement the board into the Arduino IDE

General overview

In this post we take a closer look into the configuration of the Arduino IDE and we also upload the first test sketch to the 3208Clock.

UPDATE:

24. Jul.2016:
I figured out that the following descriptions does not work anymore for the actual Arduino IDEs (> 1.5.x). I have no clue how its done now and i assume its a similar way to implement the new board but at the moment i dont have the time to do it.

Add the new board to the configuration files of the Arduino IDE

There is a configuration file called boards.txt in the program folder of the Arduino IDE. It can be found here .../arduino-1.0.5/hardware/arduino/boards.txt. Open this file in a text editor and add the following lines at the end of the file and save the file. Then start/restart the Arduino IDE. Now there is an entry called "Lattice Clock w/ ATmega8" in the Arduino IDE which can be found in the menu Tools - Boards.

atmega8.name=Lattice Clock w/ ATmega8
atmega8.upload.maximum_size=8192
atmega8.bootloader.low_fuses=0xe4
atmega8.bootloader.high_fuses=0xc9
atmega8.build.mcu=atmega8
atmega8.build.f_cpu=8000000L
atmega8.build.core=arduino
atmega8.build.variant=standard

The entries in the boards.txt are more or less self explaining but we still want to venture a further look on the parameters.

atmega8.name=Lattice Clock w/ ATmega8

With this parameter the name which will be shown in the Arduino IDE under the boards section can be set. In this case its "Lattice Clock w/ ATmega8"

atmega8.upload.maximum_size=8192

This parameter sets the maximum upload size of the hex-file. in this case we can use the complete 8192 bytes (8kB) of the ATmega8L program space. It is not necessary to install a boot loader on the device because the ICSP connection will be used.

atmega8.bootloader.low_fuses=0xe4
atmega8.bootloader.high_fuses=0xc9

With this two parameters the two bytes of the fuses will be set. The fuses are the internal configuration of the Atmel chips.
With this fuse settings the reservation for the boot loader in the flash space is disabled and it is also set to a clock frequency of 8MHz from the internal oscillator.

IMPORTANT! If you don't know exactly what you are doing with the fuse settings then it is very easy to reduce the usage of the device to a paperweight. Changes are at your own risk.

atmega8.build.mcu=atmega8

This parameter tells the compiler of the Arduino IDE which micro controller is used.

atmega8.build.f_cpu=8000000L

This parameter sets the information of the clock speed (in this case 8000000Hz or 8MHz). This parameter is used by the compiler to calculate some constants which will be used by some of the internal hardware of the ATmega e.g. usart / serial connection.

atmega8.build.core=arduino
atmega8.build.variant=standard

I'm not sure what this two parameters are doing. If someone has an idea please leave me a message in the comments.

Burn the fuses

Select the board "Lattice Clock w/ ATmega8" in the boards menu and select the programmer (If you use an Arduino as a programmer then select ArduinoISP). Both can be found in the Tools menu.

IMPORTANT! If the wrong board is selected for example the Arduino NG or older w/ ATmega8 then you will brick the 3208Clock because the fuses for this board configure the clock source to external 16MHz quartz. The 3208Clock does not have an external 16MHz quartz.

After the correct programmer and board has been selected go again to the tool menu and click on Burn Bootloader. In our case it only flashes the fuses and erases the chip.

Build a "Test LED" and flash the test sketch to the device

I guess a picture says more than thousand words. I have used a 1kOhm resistor. Everything between 330 and 1000 Ohm will be fine. Also the selection of the LED is not critical any common LED which emits visible light will fit. It is also not necessary to solder the LED to the board for the first test it only needs to be plugged through the holes of the DS18x20 footprint.


If the LED is prepared so far then please download the test sketch from my github repository or use the blink sketch from the examples and change the ledPin from 13 to 15.

To burn the test sketch to the 3208Clock you must hold the shift key while clicking the upload button. Otherwise the Arduino IDE tries to use the serial connection to upload the sketch which will cause an error message.


In the next posts we will take a closer look on how to get in contact with the Holtec HT1632C display driver to get something shown on the display.