on Electronics

PCB Design Tutorial [Altium]

This tutorial covers schematic entry and PCB design. Most of this material could be applied to any design tool; however, this tutorial focuses on Altium Designer/DXP/Protel.The first part of the tutorial consists of a set of slides which contain instructions for PCB design, and an overview of each step in the PCB design process.

The second part of this tutorial consists of a series of videos which go through each part of the PCB design process step-by-step using Altium Designer/DXP/Protel (Altium Designer 6.9 was used). Watching all videos will take you through a PCB design from start to finish; however, the videos are divided into the separate design steps so that you don’t need to watch all of them to learn a specific skill.

Tutorial Videos
Drawing Schematics
Creating a new PCB project, creating a new schematic sheet, and drawing schematics for PCB design.(This is a 3 part video)

Viewed best in fullscreen in 1080p

Viewed best in fullscreen in 1080p

… 

 

Atmel STK500 Manual Firmware Upgrade

Atmel Studio will automatically detect any old Atmel STK500 firmware version and request the user to upgrade the firmware. If for some reason the upgrade fails (the serial cable is detached during upgrade, the power goes out, …) the next time the Atmel Studio tries to connect to the STK500, the board will not be detected and the automatic upgrade procedure will not start.

Following is a procedure on how to manually upgrade an STK500 board. This procedure should work in all cases. The procedure is slightly different for AVR Studio 4 and AVR Studio 5

AVR Studio 4

  1. Power off the Atmel STK500
  2. On the STK500, push the PROGRAM button while turning on the power.
  3. Make sure there is a serial connection between the PC and the STK500 DSUB9 marked RS232 CTRL
  4. Start AVR Studio 4, and from the Tools menu start the program ‘Avr Prog’
  5. Locate the firmware upgrade hex-file stk500.ebn by pushing the Browse button in the Avr Prog Hex File window. The path for the stk500.ebn for a normal AVR Studio 4 installation is C:Program FilesAtmelAVR ToolsSTK500STK500.ebn.
  6. Push the Program button in the Avr Prog Flash window. A progress bar will now appear while showing additional information messages. Wait until the verify operation is finished.
  7. Close the Avr Prog program
  8. Power off and on the STK500 PCB. The STK500 is now ready to be used with the new firmware.

Atmel Studio and AVR Studio 5

The AVR Prog program is not distributed with the Atmel Studio installer. There is a separate installer for a set of command line tools which also includes AVR Prog.

  1. Make sure the command line tools are installed
  2. Power off the Atmel STK500
  3. On the STK500, push the PROGRAM button while turning on the power.
  4. Make sure there is a serial connection between the PC and the STK500 DSUB9 marked RS232 CTRL
  5. Start ‘AvrProg.exe’. The default installation location is C:Program FilesAtmelAVR ToolsAvrProgAvrProg.exe or C:Program Files (x86)AtmelAVR ToolsAvrProgAvrProg.exe on 64-bit OS.
  6. Locate the firmware upgrade hex-file stk500.ebn by pushing the Browse button in the Avr Prog Hex File window. The path for the stk500.ebn for a normal Atmel Studio installation is C:Program Files (x86)AtmelAVR Studio 6.0toolsSTK500STK500.ebn.
  7. Push the Program button in the Avr Prog Flash window. A progress bar will now appear while showing additional information messages. Wait until the verify operation is finished.
  8. Close the Avr Prog program
  9. Power off and on the STK500 PCB. The STK500 is now ready to be used with the new firmware.
 

Testing apple push notifications on iOS simulator

You can not send / receive apple push notifications on iOS simulator as Push notifications are not available in the simulator. They require a provisioning profile from iTunes Connect, and thus are required to be installed on a device.

In order to test your app’s response to a push notification you either have to use a real device or you may use a library called SimulatorRemoteNotifications.

SimulatorRemoteNotifications is a library to send mock remote notifications to the iOS simulator.

It’s pretty easy to send push via terminal:

echo -n '{"message":"message"}' | nc -4u -w1 localhost 9930
echo -n '{"aps":{"alert" : "message","badge" : 99,"sound" : "default"}, "myField" : 54758}'

The library extends UIApplication by embedding a mini server that listen for UDP packets containing JSON-formated payload, and a service to send notifications to the mini server. It also includes the iOS Simulator Notifications MacOSX app to help you send the mock notifications.

Note that SimulatorRemoteNotifications does not send notification through Apple’s Push Service.

More details at https://github.com/acoomans/SimulatorRemoteNotifications

 

 

uElastix for Raspberry Pi (.img included)

Elastix, the open source software for unified communications, has been ported to a number of ARM boards including the Raspberry Pi, the Asiri and the Pico-SAM9G45.

This flavour, called uElastix, is a trimmed down version and differs significantly from the original Elastix.

uElastix gives you a trusted and tested asterisk based Elastix PBX on your Pi. But what makes it interesting is that it also gives you an alternative to the RasPBX. So, if you wanted a PBX on your Pi, you now have a choice.

A big let down for anyone wanting to try uElastix on their Raspberry Pi is that there is no readymade image file. There’s just a ‘How to Install’ page which (a lot of people who tried it would agree) isn’t very straightforward.

So, I decided to share this image I created. The image file requires a 8GB microSD card.

Download

The image file is ~7GB, I am uploading a winRAR compressed version . Use a suitable application to un-compress it after download. This will work with RapberryPi B+ and is not tested on Pi2 and Pi3

Pay 22.5 USD  (this will support our work)




The installation’s IP is 192.168.1.251/24. The root password is “palosanto” and the initial web interface credentials are: user “admin” and password “palosanto”.

FURTHER  RESOURCES:

Directions to write the image to SD card

 

 

Energy Monitor Shield — Monitoring System with Nokia LCD Screen

Do you want to make your home  smart? Energy Monitor Shield is the beginning for your IoT application with Arduino.

Energy Monitor Shield6

Energy Monitor Shield is an Arduino-compatible expansion card designed for building energy monitoring system with LCD screen and an interface for connecting the wireless transceiver nRF24L01 +.

Features
  • Connect up to three sensors AC (30-100A).
  • Support for LCD Screen Nokia LCD5110
  • Turn off the LCD backlight with a jumper
  • Two buttons to control (operate one analog pin)
  • Interface to connect the transceiver to 2.4G nRF24L01 +
  • GROVE-compatible connector: I2C
  • Fully compatible with Ethernet Shield

Energy Monitor Shield — Monitoring System with Nokia LCD Screen

 

Proteus and MikroC Tutorial [Video]

screenshot

Proteus as we already discussed earlier in post regarding COMPIM ,is a great tool for embedded Engineers, so here is a  very simple and easy to get started with Proteus and MikroC tutorial through flash demonstrations.These tutorials are hosted on http://smainj.free.fr (These are no more available) but i would embed them one by one in my posts so that they are accessed easily and can be viewed online. you can download them from the link given  and you can view them online here by clicking the link below.

Tutorail1: In this tutorial you would learn

  • Design A schematic  in Proteus using ISIS
  • Using mikroC to write a program
  • Simulate program and circuit
  • Convert Schematic from ISIS to PCB in ARES
Proteus Tutorial, simulating code in VSM & PCB… by dostmhd
CLICK HERE to view This as a flash video in a player with pause/play and seek bar….

 

 

 

strip non-ASCII characters from a string using RegEx (Regular expressions)

In case you have a string data which has some non ASCII characters and want to strip off all those non-ASCII characters the following regular expression will help you.

[^u0000-u007F]+

Explanation

  • [^u0000-u007F]+ match a single character not present in the list below
    Quantifier: + Between one and unlimited times, as many times as possible
  • u0000-u007F a single character in the range between the following two characters
    • u0000 the literal character u0000 (case sensitive)
    • u007F the literal character u007F (case sensitive)

^ is the not operator. It tells the regex to find everything that doesn’t match, instead of everything that does match.

The u####-u#### says which characters match.u0000-u007F is the equivilent of the first 255 characters in utf-8 or unicode, which are always the ASCII characters. So you match every non ASCII character (because of the not)

… 

 

3.3V and 5V on a single board

I started designing a new board for Alarm security system today, It would be having components that would be running on 3.3V and some at 5V. Although I can power micro-controller by 3.3V, but still I would require it to run at higher frequency, and Max485 wont work on something very close to 3.3V, not even at 3.9V. So I browsed some forums to check what are the best approaches and came across this document called 3V Tips ‘n Tricks by Microchip. Its so useful that I wished to share it here.

Cheers

DOWNLOAD  LINK:
http://www.microchip.com/stellent/groups/techpub_sg/documents/devicedoc/en026368.pdf

3V TIPS  AND TRICKS (mirror on dms)

The Complete Book:
ww1.microchip.com/downloads/en/DeviceDoc/01146B.pdf 

Mirror

 

upload/downlaod file from FTP using AT commands (Sim900 + arduino)

In the previous post I explained how to make a connection and send data via TCP connection on SIM900 and similar modems. This post is going to be about FTP connection. FTP stands for “file transfer protocol.” FTP powers one of the fundamental Internet functions and is the prescribed method for the transfer of files between computers. It is also the easiest and most secure way to exchange files over the Internet.

Without going into much details I would show the related AT commands and brief description. Later I would include sample code for FTP upload/download using arduino and SIM900

AT command Response Description
AT+SAPBR OK Configures GPRS profile.
AT+FTPCID=1 OK Selects profile 1 for FTP.
AT+FTPSERV=”****” OK Sets FTP server domain name or IP address. **** is the domain name or the IP.
AT+FTPPORT=*** OK Sets FTP server port. *** is the port.
AT+FTPUN=”***” OK Sets user name for FTP server access. *** is the user name.
AT+FTPPW=”***” OK Sets password for FTP server access. *** is the password.
AT+FTPPUTNAME=”****” OK Sets destiny name for the file.*** is the name of the file.
AT+FTPPUTPATH=”****” OK Sets destiny file path. *** is the path of the file.
AT+FTPPUT OK Use to put a file into the FTP server.
AT+FTPGETNAME=”****” OK Sets origin name for the file.*** is the name of the file.
AT+FTPGETPATH=”****” OK Sets origin file path. *** is the path of the file.
AT+FTPGET Use to get a file into the FTP server.

Make sure you have a server and note the ftp port, we would consider using the default port 21. Switch on your modem and make sure pin code is disabled or properly entered and that GPRS connection is available.

  1. Configure GPRS by sending AT+SAPBR=3,1,”Contype”,”GPRS”r  .
  2. Set APN by sending   AT+SAPBR=3,1,”APN”,”your apn”r  .replace your apn with APN for your network.
  3. Now set the username and password for the apn (replace username and password with correct values )
    AT+SAPBR=3,1,”USER”,”username”r  .
    AT+SAPBR=3,1,”PASS”,”password”r
  4. Connect to GPRS connection by sending AT+SAPBR=1,1r, when connected Modem will respond with OK
  5. Now select profile 1 for FTP by sending AT+FTPCID=1r
  6. Now set FTP server domain or ip using the command AT+FTPSERV=ftp.yourserver.comr
  7. Set FTP port by AT+FTPPORT=21r
  8. Now send FTP credentials using AT+FTPUN=user_namer and AT+FTPPW=”password”r
  9. To get a file from FTP send AT+FTPGETNAME=file_namer
  10.  Now set the path of the file AT+FTPGETPATH=/path/r
  11. Now send AT+FTPGET=1r and wait for response from server, which starts with +FTPGET:1,1
  12. To upload a file to FTP server send AT+FTPPUTNAME=file_namer
  13. Now set path AT+FTPPUTPATH=/pathr
  14. Now send AT+FTPPUT=1 and wait for +FTPPUT:1,1 after which you need to send the content of file to be uploaded.

int8_t answer;
int onModulePin = 2;
char aux_str[30];

char incoming_data[120];

char test_str[ ]= "0000000011111111222222223333333344444444555555556666666677777777000000001111111122222222333333334444";

int data_size, aux;


void setup(){

    pinMode(onModulePin, OUTPUT);
    Serial.begin(115200);


    Serial.println("Starting...");
    power_on();

    delay(5000);

    Serial.println("Connecting to the network...");

    while( (sendATcommand("AT+CREG?", "+CREG: 0,1", 500)
            || sendATcommand("AT+CREG?", "+CREG: 0,5", 500)) == 0 );

    configure_FTP();

    uploadFTP();

    downloadFTP();

    Serial.print("Incoming data: ");
    Serial.println(incoming_data);
}


void loop(){

}


void configure_FTP(){

    sendATcommand("AT+SAPBR=3,1,"Contype","GPRS"", "OK", 2000);
    sendATcommand("AT+SAPBR=3,1,"APN","APN"", "OK", 2000);
    sendATcommand("AT+SAPBR=3,1,"USER","user_name"", "OK", 2000);
    sendATcommand("AT+SAPBR=3,1,"PWD","password"", "OK", 2000);

    while (sendATcommand("AT+SAPBR=1,1", "OK", 20000) != 1);
    sendATcommand("AT+FTPCID=1", "OK", 2000);
    sendATcommand("AT+FTPSERV="ftp.yourserver.com"", "OK", 2000);
    sendATcommand("AT+FTPPORT=21", "OK", 2000);
    sendATcommand("AT+FTPUN="user_name"", "OK", 2000);
    sendATcommand("AT+FTPPW="password"", "OK", 2000);

}


void uploadFTP(){

    sendATcommand("AT+FTPPUTNAME="file_name"", "OK", 2000);
    sendATcommand("AT+FTPPUTPATH="/path"", "OK", 2000);
    if (sendATcommand("AT+FTPPUT=1", "+FTPPUT:1,1,", 30000) == 1)
    {
        data_size = 0;
        while(Serial.available()==0);
        aux = Serial.read();
        do{
            data_size *= 10;
            data_size += (aux-0x30);
            while(Serial.available()==0);
            aux = Serial.read();
        }
        while(aux != 0x0D);

        if (data_size >= 100)
        {
            if (sendATcommand("AT+FTPPUT=2,100", "+FTPPUT:2,100", 30000) == 1)
            {
                Serial.println(sendATcommand(test_str, "+FTPPUT:1,1", 30000), DEC);
                Serial.println(sendATcommand("AT+FTPPUT=2,0", "+FTPPUT:1,0", 30000), DEC);
                Serial.println("Upload done!!");
            }
            else
            {
                sendATcommand("AT+FTPPUT=2,0", "OK", 30000);
            }
        }
        else
        {
            sendATcommand("AT+FTPPUT=2,0", "OK", 30000);
        }
    }
    else
    {
        Serial.println("Error openning the FTP session");
    }
}

void downloadFTP(){

    int x = 0;

    sendATcommand("AT+FTPGETNAME="file_name"", "OK", 2000);
    sendATcommand("AT+FTPGETPATH="/path"", "OK", 2000);
    if (sendATcommand("AT+FTPGET=1 ", "+FTPGET:1,1", 30000) == 1)
    {
        do{
            if (sendATcommand2("AT+FTPGET=2,50", "+FTPGET:2,", "+FTPGET:1,", 30000) == 1)
            {
                data_size = 0;
                while(Serial.available()==0);
                aux = Serial.read();
                do{
                    data_size *= 10;
                    data_size += (aux-0x30);
                    while(Serial.available()==0);
                    aux = Serial.read();
                }while(aux != 0x0D);

                Serial.print("Data received: ");
                Serial.println(data_size);

                if (data_size > 0)
                {
                    while(Serial.available() < data_size);
                    Serial.read();

                    for (int y = 0; y < data_size; y++)
                    {
                        incoming_data[x] = Serial.read();
                        x++;
                    }
                    incoming_data[x] = '';
                }
                else
                {
                    Serial.println("Download finished");
                }
            }
            else if (answer == 2)
            {
                Serial.println("Error from FTP");
            }
            else
            {
                Serial.println("Error getting the file");
                data_size = 0;
            }
        }while (data_size > 0);
    }
    else
    {
        Serial.println("Error openning the FTP session");
    }
}




void power_on(){

    uint8_t answer=0;

    // checks if the module is started
    answer = sendATcommand("AT", "OK", 2000);
    if (answer == 0)
    {
        digitalWrite(onModulePin,HIGH);
        delay(3000);
        digitalWrite(onModulePin,LOW);

        while(answer == 0){     // Send AT every two seconds and wait for the answer
            answer = sendATcommand("AT", "OK", 2000);
        }
    }
}


int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout){

    uint8_t x=0,  answer=0;
    char response[100];
    unsigned long previous;

    memset(response, '', 100);    // Initialize the string

    delay(100);

    while( Serial.available() > 0) Serial.read();    // Clean the input buffer

    Serial.println(ATcommand);    // Send the AT command


        x = 0;
    previous = millis();

    // this loop waits for the answer
    do{
        if(Serial.available() != 0){
            // if there are data in the UART input buffer, reads it and checks for the asnwer
            response[x] = Serial.read();
            //Serial.print(response[x]);
            x++;
            // check if the desired answer  is in the response of the module
            if (strstr(response, expected_answer) != NULL)
            {
                answer = 1;
            }
        }
    }
    // Waits for the asnwer with time out
    while((answer == 0) && ((millis() - previous) < timeout));

        return answer;
}

int8_t sendATcommand2(char* ATcommand, char* expected_answer1,
            char* expected_answer2, unsigned int timeout){

    uint8_t x=0,  answer=0;
    char response[100];
    unsigned long previous;

    memset(response, '', 100);    // Initialize the string

    delay(100);

    while( Serial.available() > 0) Serial.read();    // Clean the input buffer

    Serial.println(ATcommand);    // Send the AT command


        x = 0;
    previous = millis();

    // this loop waits for the answer
    do{
        // if there are data in the UART input buffer, reads it and checks for the asnwer
        if(Serial.available() != 0){
            response[x] = Serial.read();
            x++;
            // check if the desired answer 1 is in the response of the module
            if (strstr(response, expected_answer1) != NULL)
            {
                answer = 1;
            }
            // check if the desired answer 2 is in the response of the module
            if (strstr(response, expected_answer2) != NULL)
            {
                answer = 2;
            }
        }
        // Waits for the asnwer with time out
    }while((answer == 0) && ((millis() - previous) < timeout));

        return answer;
}