ATMEGA USB 005

There are lots of chips with serial control. Some of them use Philips I2C buss. There two data lines and two power lines to transmit all data. There DTMF encoders, switches, Dolby surround audio processors, multiplexers and many many other devices. Just open any TV set and you can find some- like TV tuner. ATMEL chip has build in serial interface, but it is called TWI. In my PCB there are two bigger SMD pads to connect I2C buss. Don’t forget to solder 10K pull up resistors.

FM75

For testing TWI bus I selected I2C temperature sensor. It is LM75 or any other clone. I am using small PCB from old plasma display panel with Fairchaild FM75 chip. It is smarter and more precise clone of original LM75. FM75 is backwards compatible with LM75. It has more precision and this means more data bytes available to read. At full precision it used 12 bits for temperature. In my software I used simplified algebra to convert 1/16 fractions to metric system. For more precise calculations, read FM75 and LM75 datasheet. And maybe AD7416 datasheet too.

FM75 ATMEGA16

I am using i2c.c from internet, from USB Tenki project. This project is very interesting, pay a visit to original Tenki web page for more advanced device. lm75.c is from same source. LCD modules are same as in older my web blog posts. When you connect your LM75 chip, don’t forget to check the device address- base address is the same, but user selected pins maybe connected in other way.

Programa: 20070919.zip.

With these chips and software example it is possible to build some thermostat project. But don’t write all controll stuff for ATMEL chip. Read the datasheet again and use LM75 thermostat option. Use ATMEGA only for control, display and setup.

Posted in Anything | Tagged , | Leave a comment

ATMEGA USB 004

There is ADC in ATMEGA16 with 8 multiplexed inputs. This analog to digital converter have several interesting options. Here is abstract from datasheet:

• 10-bit Resolution
• 0.5 LSB Integral Non-linearity
• ±2 LSB Absolute Accuracy
• 13 – 260 μs Conversion Time
• Up to 15 kSPS at Maximum Resolution
• 8 Multiplexed Single Ended Input Channels
• 7 Differential Input Channels
• 2 Differential Input Channels with Optional Gain of 10x and 200x(1)
• Optional Left adjustment for ADC Result Readout
• 0 – VCC ADC Input Voltage Range
• Selectable 2.56V ADC Reference Voltage
• Free Running or Single Conversion Mode
• ADC Start Conversion by Auto Triggering on Interrupt Sources
• Interrupt on ADC Conversion Complete
• Sleep Mode Noise Canceler

The ATmega16 features a 10-bit successive approximation ADC. The ADC is connected to an 8-channel Analog Multiplexer which allows 8 single-ended voltage inputs constructed from the pins of Port A. The single-ended voltage inputs refer to 0V (GND). The device also supports 16 differential voltage input combinations. Two of the differential inputs (ADC1, ADC0 and ADC3, ADC2) are equipped with a programmable gain stage, providing amplification steps of 0 dB (1x), 20 dB (10x), or 46 dB (200x) on the differential input voltage before the A/D conversion. Seven differential analog input channels share a common negative terminal (ADC1), while any other ADC input can be selected as the positive input terminal. If 1x or 10x gain is used, 8-bit resolution can be expected. If 200x gain is used, 7-bit resolution can be expected.
The ADC contains a Sample and Hold circuit which ensures that the input voltage to the ADC is held at a constant level during conversion. The ADC has a separate analog supply voltage pin, AVCC. AVCC must not differ more than ±0.3 V from VCC. Internal reference voltages of nominally 2.56V or AVCC are provided On-chip. The voltage reference may be externally decoupled at the AREF pin by a capacitor for better noise performance.

Software is very simple. It just read data from ADC and prints the results to LCD module. With small change in the source (just uncomment fre lines) and it is possible to read data from all channels.

ATMEGA ADC

Changing value near text “Stepas” just indicate the cycle number (in default program version) or ADC channel number. And if this number is changing, we can determine, that software is still working 🙂

Sorftware, source code: 20070918.zip.

Posted in Anything | Tagged , | 1 Comment

ATMEGA USB 003

Blinking LED is not very cool. And not very informative. But we can use LCD module. It is very cheap and available device. There are many types of LCD modules in the world. I am using most popular- HD44780 controller based alphanumerical module. It is 2 lines, 16 symbols. There are 14 or 16 pins on this module. Two extra pins are used for backlight. All other pins are used in 8 bit mode. As MCU pins can be used for more usefull purposes, we use 4 bit mode- every byte is transfered in two cycles. As MCU is very fast, we can not notice any lag here.
LCd module has selftest mode. When we connect power supply we must see upper line in black. If, not black square are here, try to adjust contrast using the only available trimmer on the PCB.

LCD AVR

LCD control software is from internet. After several experiment I selected Peter Fleury program. Other versions I tested had some hardware limitations. LCD connection is described in lcd.h file. No need to change lcd.cfile. But you can peek to it to find what procedures are in here.

Testing program is in test_lcd.c file. There is some push button routines here too. I am using jumper named “firmware” as button.

LCD AVR

If you power this device from computer’s USB slot, don’t pay attention to windows messages about unknown device connected to USB buss. We solve this problem later.

Software source and hex file for testing is here: 20070917.zip.

Posted in Anything | Tagged , | Leave a comment

ATMEGA USB 002

Now we need to test PCB and MCU. To test this hardware we need to run some program. And to build program we need tools. I downloaded and used free software from internet. WinAVR package: http://winavr.sourceforge.net/. Also, I am using programmers notepad2. It is useful tool for MCU programmer.

First program is simple LED flasher. We will test if MCU is working and if all LED diodes are working and all pins of MCU is properly soldered. The only LED will be on all the time is power LED. As the photo is made with long exposure, it seams, that all LEDs are on. In real, they are flashing in binary way.

ATMEGA 16 LED flasher
(My printer is dead, so the PCB is ver ugly)

Software source and hex file: 20070916.zip

Software is very simple- we just set some pin to output and start counting cycle. Counting results are set to output pins. It is bad programming practice to put whole byte to several pins. In real world we need to alter only these bits we need to change- never put data to unused pins or input pins. But this program is for testing only.

Few comments. As I mentioned, mine LPT port is damaged, so I am using add on card. So, edit “makefile” for your programmer. You must check the “program”section. In my version there is few words to describe port address of my add on card:

program: $(PRG).hex
avreal32 -pBC00 -ab -e +$(AVREALMCU)
avreal32 -pBC00 +$(AVREALMCU) -ab -w -c $(PRG).hex -v

Just change -pBC00 to you port. Use “avreal32 -h” for more information. Or, if you use other programmer, replace these line according your programmer manual. Or, don’t use “make program” menu item in editor’s toolbar.

Also, some words for absolute beginners. Typically you can find information about simple things- everybody know how to do and they even don’t think, that somebody will not know how to do simple compile things. So, to compile software use “make all” menu item from programmers notepad or from CMD prompt. The computer will print lots of stuff on screen, but the main message is at the end:Process Exit Code: 0 and if you don’t see any ERROR.
Command “make clean” or Tools->[WinAVR] Make Clean, cleans all compiled files. So if you change something in the source, use make clean to be sure.

And the last menu item, make program or Tools->[WinAVR] Program we program firmware to MCU.

Few words about security bits. Carefully read original Atmel documentation. Sometimes these bits are mixed in various documents. Some tell that “set” means write 1, others- vice versa. It is possible to set MCU to “closed” mode and it will not be visible by programmer. As I am using “second hand” MCU I don’t need to change fuse bits. Mine bit looks like this:

Fuses
OSCCAL = AD, AB, A7, A8
BODLEVEL = 0
BODEN = 1
SUT = 2
CKSEL = F
BLB1 = 3
BLB0 = 3
OCDEN = 1
JTAGEN = 1
CKOPT = 1
EESAVE = 0
BOOTSZ = 3
BOOTRST = 1

As it is still working I am not changing any bit. Use this online tool http://palmavr.sourceforge.net/cgi-bin/fc.cgi

You can find HEX file in archive, so you can test hardware without any compilation.

Posted in Anything | Tagged , | Leave a comment

ATMEGA USB 001

In older posts I mentioned, that I resoldered several ATMEL ATMEGA16 processors. So, I decided to build something usefull using this MCU. As this controller has more ROM and RAM, I decided to use only high level programming language- C. All software in these web pages are compiled and tested on my hardware. So, if you download something here and it is not working, first of all check your hardware and software. Then you may as some questions. Also, I will try to fix possible errors in software loaded from the internet. For example, simple error in LSB ans MSB handling caused one big program to be useless. This error stopped me for two days- it is very hard to find error in alien source code.

AVR USB

As I selected several independant projects in the internet I constructed universal circuit diagram and PCB. So almoust all software is working without modifications or just small modifications on PCB.
To build this project, you need: ATMEGA16 (maybe other mega will work too, but with change in software and harware), LCD module, few LEDs, some resitors, capacitors and 12MHz quartz. One trimmer is usefull too. Also some connectors for programming and USB.

This project will deal with various ideas. From simple LED flasher to complicated USB driven devices. It will be simple ADC, IR (infra red) receivers, I2C bus, LCD manipulating and etc.

After the software and hardware is tuned, user can build small PCB with everything designed for end product.

Circuit diagram (schematics) of the device:

AVR USB
(press on image for larger view)

Image of the PCB:
AVR USB

Circuit diagram and PCB layout for Eagle software .

MCU is programmed using Altera ByteBlaster MV
and AVREAL software. Also, I want to tell, that I damaged my default printer port in my experiments. So I am now using add-on card. This is important when using my software- the programming section of make file must be edited to your needs.

avreal/WIN32 - AVR controllers LPT programmer by Redchuk Alexandr
v1.25rev5 (Jan 15 2007 20:02:38) http://www.ln.com.ua/~real/avreal
bug-reports, suggestions and so on mail to avreal@real.kiev.ua

Posted in Anything | Tagged , | Leave a comment

DVB-T

Step by step, digital television is conquering our country. From this spring, DVB-T (digital video broadcasting, terrestrial) is broad-casted in my home city. In our country someone decided to use MPEG4, h.264 video compression. All cheap available DVB-T receivers didn’t understand this compression method, so he have some problems here. In other internet pages I discovered some solutions to these problems. So I bought simple DVB-T add-on card for my computer. It is Leadtek WinFast DTV1000T. Original software from this card is not usable- it supports only mpeg2. So, I downloaded AltDVB software from internet. Next problem is h264 decoder. Freeware one from ffdshow package is not very good. I think it is intended to use with pure h.264 video stream. But, as I tested my card with small antenna, there is lots of stream errors in DVB broadcasting. And these errors cause ffdshow to freeze video or even crash operating system. I also tested some commercial h.264 decoders. First one is from Nero suite, second one is downloaded from sat users internet forum: CoreAVC Professional. Also there is usable codec in PowerDVD package. But only in some release version. Current PowerDVD player is not letting to use codec in other software.

Here is program interface:
DVB-T
(press on image for larger view).

I can see 10 “free” channels, 3 of them are just test table. And 10 coded, pay-TV channels.
The quality of the image is good compared to distorted analog TV image. But it is not perfect. If the signal strength is low there is lots of decoding artifacts.

Here is error free image:
DVB-T

And what you get is some crow is sitting on your antenna.

DVB-T

It is possible to record transport stream to hard disk. I was using free VLC player to play these images. Here is 1:1 snapshot of the frames.

DVB-TDVB-T
(Press on image for real size).

Posted in Anything | Leave a comment

Cleaning HP970cxi printer

In Lithuanian blog there is detailed instruction how to disassemble and clean this good ink jet printer.
As I am too lazy to translate all these instructions, I only posted few images. I don’t know, if the readers of my weblog need information about cleaning (in fact washing) ink jet printers and how to fill print cartridges by yourself. If you want this information, please contact me by email or by weblog comment.

HP970cxi

Continue reading

Posted in Anything | Leave a comment

Brain Cooler 2

First version of brain cooler failed. So I returned to my old idea. The first thought was to build ceiling made from small computer fans. Second idea was to build suspension ceiling segment from small computer fans. The third idea was to build doors or windows (something like mosquito net) from computer fans.

So here is version 1.0 of idea no 2.

Coooooler

This “device” is very noisy if powered from 12V, but when I used 9V power supply everything was ok. You can feel air movement from few meters from this multi-fan device.

I collected fans from computer power supply’s. I used same dimension fans and glued them. For more strength, I used plastic bands.

The device is looking pretty cool… 🙂

Posted in Anything | Leave a comment

Brain cooler

It was hot. And very damp air. The windows was open, 00:15AM, but the computer inside room raised temperature to 26°C and humidity is 90%. I needed brain cooler. Some time ago, I wrote that in eBay I bought some Peltier heat pump. So I connected it to some CPU cooler and here is some device:

brain cooler

As mine brains are well closed, I used copper cylinder for my testing. I is removed from some big P4 cooler. The fan in connected to simple wall adapter. But for Peltier I used car battery charger- I need lots of power.

brain cooler

This car charger have dual output 6 and 12V. When I connected Peltier to 6V output, build in ampermeter was showing about 6A. Total power used for heat pump is about 36W. When I connected it to 12V output, the ampermeter was overloaded. If the heat pump is linear device, total power could be 144W. The current is high, the wires connected to the elements become hot and very flexy. It’s a pity, but the CPU cooler can handle such powers and hot side of the element is overheated. And all system fails. The only result is a bit cold copper cylinder with few drops of condensed watter. Some sort of mini dew machine.

Posted in Anything | Leave a comment

Transformer TC-180-2

I need some transformer for one experiment (I’ll post it in near future). So I dig my trash pile and found Soviet transformer with double windings. The idea was to run the transformer with double overload. The transformer I selected was TC-180-2 from old tube tv set (in real, if you find cool Russian device, try to run web search using original Cyrillic. Even if the English version look same. So, check the ТС-180-2. This is different to TC-180-2 🙂 . Here is the photo:

TC-180-2

Then writing TC means “power transformer”, in Russian-трансформатор сетевой. Next numbers is the nominal power in Wats. Nominal power, not some RMS or other Chinese or western invention. Nominal power means that I can get such power for unlimited time without any damage to the device. So I can get 180W of pure power from it. In bigger TV set I’ve seen even 270W transformers. Such 270W transformers are bigger than in my Maranz audio amplifier. And Maranz is rated 6x80W (480W!)…

These transformers gets to many hobbyist hands with removed connection wires. It is great luck, that mine transformer was with the sticker. But this sticker have some caveats.

It is written: 1-2-3, 1`-2`-3` = 127V/220V, 1.51/0.87A. But this text is quite uninformative. The real description of primary winding must be something like this:
1-2-3 means 0-110V-127V on one coil. On the second coild something similar: 1`-2`-3` means 0-110V-127V.

It is symmetrical coils. Now the simple arithmetic’s come to the first place: between 2 and 3 pin there is 17V.

If we have mains output 220V (old Soviet standard), we need to connect 2x110V. The connection is made in such way: mains cord is connected to 1 and 1`. The jumper wire is placed between 2 and `2. Now we have EU and more wide standard: the average voltage is 230V. (Also, this transformer is a bit overloaded, so we need to use more windings to improve the efficiency of the device). So we can place jumper between 2 and `3 or even 3 and `3. So we get 237 and 254V primary.

Secondary winding are made in similar way. The only difference, that the sticker now is correct:

5-6 is 59.5V/0.5A
7-8 is 43.5V/0.38A
9-10 is 6.4V/4.7A
11-12 is 6.4V/1.5A.

The out voltage is calculated holding in mind the circumstance, that input voltage is standard. As transformer is linear device- if we put a bit more volts in the input, in the out we get more too.

For my experiment I needed higher voltage. So I connected transformer in auto-transformer schematics.
Input 1 and 1`. Jumpers placed 2 and 2`, 6 and 6`, 5 connected to 1`. So I get: 220+59.5+59.5=339V. The output is connected to 1 and 5`.
In real world the output is a bit more, as mine mains voltage is 235V. This all stuff will be connected to variable auto-transformer and I’ll receive output from 0 to 400V.

Few warnings: out voltages are lethal. Auto-transformer connection is dangerous as even is device output few volts, the output pins can be at the high potential regarding ground. Before connecting untested transformer, measure isolation between primary and secondary windings and transformer core. As measure of the windings resistance didn’t show internal short circuit connections between same core windings, measure idle current of the transformer. It must be low. This particular transformer is overloaded from manufacturer, so idle current is about 150mA. It is high current for such power transformer. If we connect primary in “light mode”, the idle current is about 50mA. I recommend to use isolating transformer in your experiments and ground trip current relays. Don’t forget to ground the chassis of your devices.

Posted in Anything | 8 Comments