on Electronics

Disable PIN code using Gsm modem AT commands

If you have a PIN code enabled SIM card and want to remove /disable PIN code using AT commands follow these commands,
suppose 9546 is the current PIN code , Replace 9546 with your PIN code, >>> shows the response from modem.

AT+CPIN?
>>> +CPIN: SIM PIN // pin codes need to be entered
>>> OK

AT+CPIN="9546"
>>>; OK

AT+CLCK="SC",0,"9546" // disable pin code
>>> OK

AT+CPIN?
>>> +CPIN: READY

 

 

GSM Modem/Module not responding to AT commands after firmware Upgrade??

I get a lot of queries about this issue, so I thought I should write a small post about it. For example the latest one was

Hello Muhammad,
I recently update SIM900 to firmware 1137B12SIM900M64_ST.cla using “Simcom – sim900 Customer flash loader V1.01″ at the baud rate 1498000. Everything went perfectly like but after I restart the module I get “þIIIIþþþ” response from SIM900 at 115200 baud rate, I could not get any AT commands working. Kindly do help me.

Some modems support AutoBaud by default. Auto Baud feature allows the modem to be used with any baud rate, and for this to be used the Modem waits for a input string “ATr” it uses this string to detect the baud rate being used. As the manual describes the modem when in Auto Baud will be looking for this string after it is powered and this should be in CAPS otherwise modem wont be able to detect the correct baud rate. Sim900 has the auto baud by default. Some modems don not support Auto Baud so for these modems after the firmware has been updated, you should use the default baud rate, 9600 and 115200 are the most common.

if you want to fix or change the baud rate you should use the AT+IPR command. For example if you need to fix it to 4800.

 AT+IPR=4800r
 

“The IC Time Machine”

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.

Navigation

1. 555 ic introduction

2. Pin configuration

3. Operation modes

4. Component  selection

5. Specifications for NE555

6. Derivatives

7. Resources

… 

 

Keeping track of time in embedded applications: millis();

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.

void timer0(){
  // 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
  // 8000000/1000
  // 8000.0000000000
  // 8000/256
  // 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;
}


volatile uint32_t millis()
{
 uint32_t mill;
 uint8_t oldSREG = SREG;
 // remember last value of interrupts
 // disable interrupts while we read timer0_millis or we might get an
 // inconsistent value (e.g. in the middle of a write to timer0_millis)
 cli();
 mill = millis_count;
 SREG = oldSREG; // rewrite reg value to turn back on interrupts
 return mill;
}

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.

//interrupt declaration
ISR(TIMER0_COMPA_vect)
{
  ++millis_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.

uint32_t starttime=millis();

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

 

Disable CLK Pre-scaler in AVR to use 8MHz Internal Oscilator

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< 

Hope this will help!

 

Add Voice /Audio to projects using WTV020SD

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.

connections … 

 

function to return binary equivalent of an int in a string format

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[23];// adjust the size of the string to your needs
    int i,b;
    b=value;
    i=0;
    while(b>0)
    {
        binstr[i]=b%2;
        b=b/2; i++;
    }
    binstr[i]=00;
    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
 

Show State if Sim900 originated call is recieved

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

AT+MORING=1

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.