AVR controlled DDS generator software writing

During my spare time I am developing the program for AVR controlled DDS generator. I decided to write software using WinAVR tool-set. How far ahead I have moved with this? I have implemented: Menu system; Reading previous generator configuration from EEPROM; Setting signal mode; Storing last generator configuration to EEPROM to be loaded after reset; Four types of signal output (square, sawtooth, triangle and sine wave); Still need to do: Ability to change signal frequency; Implement other signals (listed bellow); Make program clean-up; Signals in AVR controlled generator: 0 – OUT_|¯|_ – square wave(done); 1 – OUT|/|/| – sawtooth(done); 2 – OUT|\|\| – reverse sawtooth(awaiting); 3 – OUT/\/\/\ – triangle(done); 4 – OUT~~~~ – sine wave(done); 5 – OUT-NOISE – noise signal(awaiting); 20 – PWM-OCC – timer output compare mode(awaiting); 21 – PWM-SINMDS  sine wave modulated PWM(awaiting); 22 – PWMSQSMDS – sine wave modulated PWM. PWM positive, SQ  negative polarity(awaiting);…

Continue reading

Reading AVR button status using WinAVR

If you want to bring some interactivity to your embedded projects, one option is to add buttons. This allows you to control program flow, set parameters and much more. Few words about AVR ports. AVR Port pins can be configured as input or output. See table for all general pin configurations: DDRx register is so called direction register; PORTx – is port output register; PINx – is pin input regsiter; So there can be three options for input and two for output. If you are doing some simple routines with AVR microcontrollers, you maybe are familiar with configuring output from port. Just write ‘1’ to DDRx register and then send data to PORTx register: For instance: DDRD=0x0F; //sets lower nibble as output; PORTD=0x05 //output ‘1’ to PORTD pins 0 and 2; If you want to read input signals there are normally couple ways to do this. For input DDRx register…

Continue reading

Simple routine how to store data in microcontroller flash and read from it using WinAVR

I’ve been asked about how to store data table in flash memory using winavr toolset. I decided to post an answer here. Might be someone find this useful. To demonstrate this I have set up a project using VMLAB simulator. The files you can download from here: Small project using VMLAB simulator So I created project in VMLAB. You should read my previous article ho to do this: Using VMLAB as virtual oscilloscope In project window I have connected 8 LED’s to port D by typing this: D1 VDD PD0 D2 VDD PD1 D3 VDD PD2 D4 VDD PD3 D5 VDD PD4 D6 VDD PD5 D7 VDD PD6 D8 VDD PD7 Then I wrote a simple C program: In program you see, that data can be stored in flash memory using data describing sentence: const uint8_t digits[] PROGMEM={your data}; To make PROGMEM macro work you have to include library pgmspace.h.…

Continue reading

Internal microcontroller ADC

Many microcontrollers contains internal on-chip ADC. Typical devices would be Atmel Atmega series microcontrollers like Atmega8 and further. Internal ADC are successive way to integrate analog world in to your embedded systems using only one microcontroller die. Many applications doesn’t require high speed or high accuracy ADC conversions, thus on-chip ADC is best choice. Lets look at Atmega8. It contains 10-bit approximation ADC with analog input multiplexer of 8-single-ended input voltage (refers to 0V) channels. Atmega microcontrollers have separate analog supply voltage pins – AVCC (Atmega8 has known bug – digital and analog grounds are interconnected inside chip). Reference voltage is provided inside chip. It is nominally 2.56V or AVCC. AREF pin is used to decouple voltage reference by a capacitor for better noise performance. The reference voltages nay be selected between: Internal reference 2.56V; AVCC (must not differ from VCC more than ±0.3V); Or reference voltage can be connected…

Continue reading

How to measure wind direction

I found this wind direction measurement circuit simple and interesting. If you are doing some home automation project, this might be another sensor that can be included in you project. For Wind direction measurement you will need a circle from some material (you might even use CD disc.) Then stick an arrow on top. One end of arrow should have a fin. Other end of arrow sould have piece of magnet. Then put eight magnetic sensors around the circle in the magnets way. See drawing: I think working of this sensor is very obvious. Turning Arrow depending on wind direction turns ON magnetic switches. Circuit has 8 outputs corresponding to wind direction. These outputs can be connected to simple indication circuit, which can be in your room: Depending on switch turned on the led indicator shows where the wind blows. Of course this sensor can be easily adapted to any…

Continue reading

Creating custom LCD characters using WinAVR

Standard LCD modules comes with built in Character MAP stored in LCD ROM memory. There is plenty of characters for your needs, but still you may need some special ones like backslashes, or some symbols that are in different languages. For this LCD has a reserved RAM area for storing eight 5×7 dot matrix character patterns. In the table above this area is in first column with addresses starting from 0 to 7 (from 0b00000000 to 0b00000111). This means, that you can define any type of characters in these 8 fields as you like and use them by calling them by addresses from 0 to 7. To define one character, you will need to write eight bytes in row to CGRAM memory For 0 character address (DDRAM=0): So for the first character creation procedure would be: Cycle of 8 iterations: Send command to LCD with CGRAM address from 40h to…

Continue reading

Ease way to desolder SMD

Today I came across this video in http://video.google.com. The guy Thomas Pfeifer solved the problem how to desolder SMD elements from old boards using iron and tweezers. Not everyone has hot air solder stations. So this method might be helpful for many of hobbyists. I bet in some cases this should be good method to solder BGA packages. Did anyone try this? WPvideo 1.10 Download!

Continue reading