What is it?
“A highly stable controller capable of producing accurate time delays, or oscillation.”
-Philips Components and Semiconductors
The 555 is a 8-pin intergrated circuit with 2 modes of opperation. The time delay (stable) mode is controlled by one capacitor and one resistor. The oscillation (astable) mode is controlled by a capacitor and two resistors. There is also a third mode Bistable mode or Schmitt trigger : the 555 can operate as a flip-flop, if the DIS pin is not connected and no capacitor is used. This post will focus on some of the basics of 555 ic.
1. 555 ic introduction
2. Pin configuration
3. Operation modes
4. Component selection
5. Specifications for NE555
Its very handy to keep track of time in embedded programs. In this post I will implement a function called millis() which can be used to track time. Arduino users will be familiar with this one. I would be doing it for AVR MCUs you can easily port it for others. this function returns the number of milliseconds since the MCU began running the current program. This number will overflow (go back to zero), after approximately 50 days.
It uses a hardware timer , in this post i will use timer0 . The first step is to initialize timer0 and interupts. lets start.
// To set clock:
// 1MHZ is 1,000,000 ticks per second
// 1000 milli in 1 second
// xMHZ = 1000millis
// so MHZ/millis gives # HZ per millis
// (HZ/millis)/prescaler= Top counter number
// EG:for 8MHZ clock
// 31.2500000000 TOP counter
//set CTC (clear timer on compare match mode)
TCCR0A = (1< <WGM01);
//sets prescaler clkIO/256 ***THIS MIGHT CAUSE ISSUES SETS FOR ALL CLOCKS**!!!!
TCCR0B = (1<<CS02);
//sets interrupt enable for OCF0A (TIMER_COMPA_vect)
TIMSK0 = (1<<OCIE0A);
//sets TOP counter match A at 31
OCR0A = 31;
In the code shown above we have initialized timer/counter 0 to make an interrupt after every millisecond. Next we have to update our millisecond count.
//OCR0A = 10; //sets upper breakpoint A
That’s it. Lets see how to use it! First we copy the current value in milis() to a variable.
and later we compare the new values with the start value. Here’s an example of a 25 second.
if(millis()-starttime > 25000)
// some code here
Note that the parameter for millis() is an unsigned long, errors may be generated if a programmer tries to do math with other datatypes such as ints.
There are a number of ways you can use this. Hope this post will help you
Just wanted to share this small piece of information that can help many . If you want to Run your AVR at 8MHz from the internal oscillator you need to disable the CLK/8 Fuse. You can do this by burning new fuse values. This can also be done in you main function as well. Below is a piece of code that will change the pre-scaler to zero.
// set the clock speed to "no pre-scaler" (8MHz with internal osc or
// full external speed)
// set the clock prescaler. First write CLKPCE to enable setting of clock the
// next four instructions.
CLKPR=(1< <CLKPCE); // change enable
CLKPR=0; // "no pre-scaler"
_delay_us(60); // 60us
Hope this will help!
Adding sound to your projects is great, there can be several methods to do it. In this post i will show how we can use wtv020-sd module to get this task done. I wont go in detailed description of the module and will keep the post short and to the point. The module can be operated in a number of modes including pushbutton modes but the one we are going for is the 3 wire serial mode. its actually SDA,SCL and reset wires that we use. The module would play back the ad4 files stored on uSD Card. and spk+ and spk- pins can be connected directly to a speaker. More details about the module can be found in the datasheet and the webpage link.
The interface is simple. you only need to connect Supply , DI ,CLK and reset Pins to get it working although you may also connect some other pins also but this is what is really needed to get the module working.
On request of Shamas Akhtar Awan :
This is the function to return a string of binary equivalent of an int. The function takes in an integer value and returns a string of 0′s and 1′s of binary equavalet of that integer.
char * int2binarystr(int value)
char binstr;// adjust the size of the string to your needs
return binstr; // returns the string
You can use this in your code as needed. One example is to write to uart the string
Uart0_write_text(int2binarystr(20)); // writes the string conataing the binary equavalent of 20 to uart
By default when you make a voice call Sim900 doesn’t send any response if the called party picks the call. Sometime its important to know if the other side is getting ring or has picked the call. In order to show the state we have to configure the module using the following AT Command
After sending the is command if a number is dialed, a URC string “MO RING” will be received if the other mobile is alerted and “MO CONNECTED” will be received if the call is answered.