Circuit Negma

C++, C, VB.NET, PCB, Electronics, Circuit Design

Archive for April, 2010

Microchip MPLAB :: Error – could not find file ‘c018i.o’.

Posted by Circuit Negma on April 26, 2010


Created By: Hussein Nosair

Symptoms:

The MPLAB IDE shows the following error message when trying to compile a project:

“ Error – could not find file ‘c018i.o’. “

Solutions:

1. Sol.: 1

Sometimes the workspace file gets corrupted. To solve this problem:

1. Close your project if necessary

2. Go to the project directory.

3. Delete the workspace file that ends with mcw :: YourProject.mcw

4. Open your project again. MPLAB IDE will take care of rebuilding and creating a new workspace file for your project.

6. Try to compile your project.

2. Sol.:2

Sometimes a one forget to include the appropriate/required linker file of used Microchip Microcontroller (uC) in the Project. To solve this problem:

1. Open your project in the MPLAB if necessary.

2. Determine the uC is being used for the project in hand. Click on Configure > Select Device…

 

Select Device Window will open, showing the chosen Device (uC) for the project.

4. In the Project Window on the left:

Right Mouse Click on Linker Script > Add Files…

And Browse to the MPASM folder to locate the chosen uC linker file

4. Try to compile the project again.

3. Sol.:3 (Preferred Method)

I use the solution 3 for all of my projects. Before we begin, I should state that the following example is based on the use of MPLAB C18 compiler. However, the example can be transferable to other mplab configurations. To solve this problem:

1. Open your project in the MPLAB if it is not already open.

2. Click on Project > Build Options… > Project

 

3. Click on Directories tab > From the Show directories for: Drop list select “output Director”

4. Click the “New” Button

5. Type in: Output – Hex Files, and then Hit ENTER

6. From the Show Directories for Drop list select “Intermediary Directory”

7. Click the “New” Button

8. Type in: Object – Linking Files

9. From the Show Directories for Drop list select “Include Search Path”

10. Click the “New” Button

11. We are going to include the compiler’s header files folder (*.h) which you use to compile and build your project. In my case I am using MPLAB C18 compiler for my current projects. The header files are located in “h” folder at “C:\MCC18\h”. Either you type in the location of the compiler’s herder files or you click on the “ … “ Button to locate the header files folder.

12. Click the “New” Button

13. We are going to include the current opened project folder, incase of the project folder houses a custom built header files. Refer to the picture above.

14. Click the “New” Button

15. Type in: .

NOTE: The order of items in the list. The compiler will first look for files in the project folder if it cannot find the required files then the compiler will move on to the next item in the list which would be in this case “C:\MCC18\h”. Refer to the above picture for reference.

16. From the Show Directories for Drop list select “Library Search Path”

17. Click the “New” Button

18. We are going to include the compiler’s library files, by clicking on the “ … “ Button. Refer to the picture above.

19. From the Show Directories for Drop list select “Linker-Script Search Path”

20. Click the “New” Button

21. We are going to include the Microcontroller’s Linker files, by clicking on the “ … “ Button. Refer to the picture above.

NOTE: I prefer to use the linker-script files that came in with the compiler. However, if your compiler does not come with a Linker-Script files then you need to browse to the following folder location:

Vista 64-bit users: C:\Program Files (x86)\Microchip\MPASM Suite\LKR

Windows XP and Vista 32-bit users: C:\Program Files\Microchip\MPASM Suite\LKR

DONE.

Posted in Microchip PIC | 10 Comments »

NOTES :: Timer 0 (TMR0) Equation

Posted by Circuit Negma on April 13, 2010


Create By: Hussein Nosair

We need  to convert the desired delay time from seconds to HEX:

D = ( Td * Fosc ) / ( 4 * PS )    ………………………………….. eq. 1

Td = Delay time in sec
Fosc = Oscillator Frequency (Instruction cycle or Instruction time)
PS = Prescaler assignment value
D = Delay time in HEX (software level)

Load D into TMR0 register:

(TMR0 + 2) = (2^16) – 1 – D

Note that I have added a 2 to TMR0 value. This is a small fix to TMR0 register behavior. When TMR0 register is written to it, the first increment of TMR0 will happen after 2 instruction cycles.

TMR0 = 65535 – D – 2

TMR0  = 65533 – D

TMR0H = upper 2 bytes of TMR0

TMR0L = Lower 2 bytes of TMR0

Ex:

Td = 1sec
Fosc = 40MHz
PS = 256

D = (1sec x 40MHz) / (4×256)
D = 39062

TMR0 = 65533 – 39062
TMR0 = 26471
TMR0 = 0x6767

TMR0H = 0x67
TMR0L = 0x67

 

/**********************************************************************
* Create By: Hussein Nosair
* Date     : 09/10/2008
* Processor: PIC18F4520
* Compiler : MPLAB C18 V3.21
* Language : C
* Description:
*            This code domenstrate the use of TMR0 as counter
*            and as a timer.
***********************************************************************/

#include <p18cxxx.h>

#define ClrWdt()                asm(“CLRWDT”);

unsigned char dwInternalTicks;            // Used as a counter

#pragma interruptlow LowISR
void LowISR(void)
{
    if(INTCONbits.TMR0IF)
    {
        // Increment internal high tick counter
        if (dwInternalTicks)              // Check if counter is 0
        {
            dwInternalTicks–;            // Decrement counter by 1
        }         
        // Reset Interrupt flag
        INTCONbits.TMR0IF = 0;
        // Note the order of TMR0H and TMR0L
        TMR0H = 0x67;            //1.67sec
        TMR0L = 0x67;
    }
}

#pragma code lowVector=0x18
void LowVector(void){_asm goto LowISR _endasm}
#pragma code                     // Return to default code section

void init(void)
{
    // Set up the timer interrupt
    INTCON2bits.TMR0IP = 0;        // Low priority
    INTCONbits.TMR0IF = 0;
    INTCONbits.TMR0IE = 1;         // Enable interrupt
    // Timer0 on, 16-bit, internal timer, 1:256 prescalar
    T0CON = 0x87;

    // Digital Pins
    ADCON0 = 0x00;
    ADCON1 = 0x0F;
    CMCON = 0xCF;

    //Enable Interrupts
    RCONbits.IPEN = 1;            // Enable interrupt priorities
    INTCONbits.GIEH = 1;
    INTCONbits.GIEL = 1;       
}

void main(void)
{
    init();          // Initialize PIC hardware

    while(1)         // Enter Infinit loop to prevent the PIC from reseting
    {
        //…. DO STUFF HERE
        // NOTE order of TMR0H and TMR0L
        TMR0H = 0xF0;     
        TMR0L = 0x00;
        T0IF = 0
        while(!T0IF);

        //… DO STUFF HERE

        dwInternalTicks = 12;
        while(!dwInternalTicks)
        {
            //…… DO STUFF HERE
        }

        //…. DO STUFF HERE

        //ClrWdt();  <————- Uncomment if WDT is turned on
    }
}

Posted in C Programming, Microchip PIC | Leave a Comment »

How to Translate PDF & Word Documents with Google Translation

Posted by Circuit Negma on April 13, 2010


Original By: Amit Agarwal

Created By: Hussein Nosair

The following blog explains the use of online tools to translate your documents into foreign languages.

The link is ::

How to Translate PDF & Word Documents with Google Translation

The process start first by uploading your document to Zoho or SlideShare. Then plug-in the document created link into Google translation to translate the document to what ever language you desire.

Posted in Links | Leave a Comment »

FUN

Posted by Circuit Negma on April 10, 2010


Created By: Hussein Nosair

I am trying to build a power base converter that would convert any power based number to a decimal (10 base) number.

However, I am not completely done. This is what I have so far. By the way I am using Matlab.

   1: %-------------------------------------------------------------------------

   2: % Created By: Hussein Nosair

   3: % Date      : 4/10/2010

   4: % Description:

   5: %   The following algorithm convert any power base number to a 10 base

   6: %   system, keeping in mind that this module accepts only numbers and not

   7: %   alphabets. Trying to keep this code as simple as possible, however, a

   8: %   future work will includes the use of alphabets.

   9: %

  10: %   Result = nth_digit * base^index + (n-1)_digit * base^(index-1) + ....

  11: %

  12: % Example:

  13: %   32564 base 8

  14: %   n = 5 digits

  15: %   base = 8

  16: %   index = nth digit position with in the number to be converted

  17: %   Result = 15029

  18: %   32654 base 8 ---> 15029 base 10

  19: %-------------------------------------------------------------------------

  20:  

  21: function y = base_n(input, base)

  22:  

  23: % Clear Window

  24: clc

  25:  

  26: % Define and Initialize variables

  27: x = input;

  28: i = 0;

  29: n = 10;

  30: y = 0;

  31:  

  32: % Prepare

  33: fprintf(' ___________________________________________________________________\n');

  34: fprintf('|                                                                   |\n');

  35: fprintf('| base: %d                                                           |\n', base);

  36: fprintf('| Number: %d                                                     |\n', input);

  37: fprintf('|-------------------------------------------------------------------|\n');

  38: fprintf('| index      digit         nth digit         New x            Result|\n');

  39: fprintf('|-------------------------------------------------------------------|\n');

  40:  

  41: % Power Conversion Algorithm

  42: while 1

  43:     % Determine the n digit from the given number:

  44:     z = mod(x,n);

  45:     r = (z * 10)/n;

  46:     

  47:     % Calculate a number for the next nth digit extraction

  48:     x = x - z;

  49:     

  50:     % Perform the conversion

  51:     y = y + (r * base^i);

  52:     

  53:     % Print out the result on screen

  54:     fprintf('| %3.5d      %3.5d          %3.5d            %3.5d            %3.5d |\n', i, z, r, x, y);

  55:  

  56:     % Check if conversion is over

  57:     if x == 0

  58:         % Display the final results.

  59:         fprintf('|-------------------------------------------------------------------|\n');

  60:         fprintf('| Number: %d                                                     |\n', input);

  61:         fprintf('| base: %d                                                           |\n', base);

  62:         fprintf('| n: %d                                                              |\n', i+1);

  63:         fprintf('| Result: %d                                                     |\n', y);

  64:         fprintf('|___________________________________________________________________|\n');

  65:         break;

  66:     end

  67:     

  68:     fprintf('|-------------------------------------------------------------------|\n');

  69:     i = i + 1;

  70:     n = n * 10;   

  71: end

  72: fprintf('\n');

Posted in C Programming | Leave a Comment »

MentorGraphics PADS Layout :: How to extract an IPC-356 netlist from PADS

Posted by Circuit Negma on April 7, 2010


Partum Per : Hussein Nosair

Symptoms

Quam ut extraho an IPC netlist ex PADS Layout

Quam ut output an netlist ex PADS

Quam ut extraho an IPC netlist

Solution

PADS : 9.0 quod newer

Beginning : per PADS 9.0 illic est paternus IPC netlist extraho capability. Peto Lima Patefacio quod change " lima of Typus " ex ASCII Lima (*.asc) ut IPC 356 Lima (*.ipc). Secundum clicking servo vos ero validus sumo inter IPC D -356 vel IPC D netlist output.

PADS2007.4 quod senior :

senior versions of PADS operor non have paternus IPC netlist extraho. Vero , vos can download a VB scriptor ut has been written per a 3rd secui Vendolius procul CapeCAD.com ( nota , VB scriptor has non been exertus per Mentor Graphics quod nos vindicatum haud officium pro it’s sagaciter ).

 

 

Powered by WordTran/NeuroTran (R)

Posted in PCB | Leave a Comment »

Meus nomen est CircuitNegma

Posted by Circuit Negma on April 7, 2010


Posted in Uncategorized | Leave a Comment »