Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

pls help me with this frnds

Status
Not open for further replies.

rti

Newbie level 6
Joined
Mar 21, 2013
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,374
am doing my project based on pic16f877a to generate 21 level using cascaded h bridge multilevel inverter...my problem is am trying to do in proteus ...i have my program in hand, ,,but there is a error like undefined identifier portb ...i ll post my program here ....pls anyone help me out..plssssssss........

Code:
#INCLUDE <16F877A.H>
#FUSES HS,WDT,NOPROTECT
#USE DELAY(CLOCK=20000000)
   VOID main()
   {
   
   TRISB = 0X00;
   TRISD = 0X00;
   PORTB = 0X00;
   PORTD = 0X00;

   WHILE (1)
   {
      PORTB.F0 = 0;
      PORTB.F1 = 0;
      PORTB.F2 = 0;
      PORTB.F3 = 0;

      //////////
      PORTB.F4 = 0;
      PORTB.F5 = 0;
      PORTB.F6 = 0;
      PORTB.F7 = 0;

      //////////
      PORTD.F0 = 0;
      PORTD.F1 = 0;
      PORTD.F2 = 0;
      PORTD.F3 = 0;

      //////////
      PORTD.F4 = 0;
      PORTD.F5 = 0;
      PORTD.F6 = 0;
      PORTD.F7 = 0;

      //////////
      delay_ms (750);
}

   WHILE (1)
   {
      PORTB.F0 = 0;
      PORTB.F1 = 0;
      PORTB.F2 = 1;
      PORTB.F3 = 1;

      //////////
      PORTB.F4 = 1;
      PORTB.F5 = 1;
      PORTB.F6 = 1;
      PORTB.F7 = 1;

      //////////
      PORTD.F0 = 1;
      PORTD.F1 = 1;
      PORTD.F2 = 1;
      PORTD.F3 = 1;

      //////////
      PORTD.F4 = 1;
      PORTD.F5 = 1;
      PORTD.F6 = 1;
      PORTD.F7 = 1;

      //////////
      delay_ms (750);
   }

   WHILE (1)
   {
      PORTB.F0 = 1;
      PORTB.F1 = 1;
      PORTB.F2 = 1;
      PORTB.F3 = 1;

      //////////
      PORTB.F4 = 0;
      PORTB.F5 = 0;
      PORTB.F6 = 1;
      PORTB.F7 = 1;

      //////////
      PORTD.F0 = 1;
      PORTD.F1 = 1;
      PORTD.F2 = 1;
      PORTD.F3 = 1;

      //////////
      PORTD.F4 = 1;
      PORTD.F5 = 1;
      PORTD.F6 = 1;
      PORTD.F7 = 1;

      //////////
      delay_ms (750);
   }

   WHILE (1)
   {
      PORTB.F0 = 1;
      PORTB.F1 = 1;
      PORTB.F2 = 1;
      PORTB.F3 = 1;

      //////////
      PORTB.F4 = 1;
      PORTB.F5 = 1;
      PORTB.F6 = 1;
      PORTB.F7 = 1;

      //////////
      PORTD.F0 = 0;
      PORTD.F1 = 0;
      PORTD.F2 = 1;
      PORTD.F3 = 1;

      //////////
      PORTD.F4 = 1;
      PORTD.F5 = 1;
      PORTD.F6 = 1;
      PORTD.F7 = 1;

      //////////
      delay_ms (750);
   }

   WHILE (1)
   {
      PORTB.F0 = 1;
      PORTB.F1 = 1;
      PORTB.F2 = 1;
      PORTB.F3 = 1;

      //////////
      PORTB.F4 = 1;
      PORTB.F5 = 1;
      PORTB.F6 = 1;
      PORTB.F7 = 1;

      //////////
      PORTD.F0 = 1;
      PORTD.F1 = 1;
      PORTD.F2 = 1;
      PORTD.F3 = 1;

      //////////
      PORTD.F4 = 0;
      PORTD.F5 = 0;
      PORTD.F6 = 1;
      PORTD.F7 = 1;

      //////////
      delay_ms (750);
   }

   WHILE (1)
   {
      PORTB.F0 = 0;
      PORTB.F1 = 0;
      PORTB.F2 = 1;
      PORTB.F3 = 1;

      //////////
      PORTB.F4 = 1;
      PORTB.F5 = 1;
      PORTB.F6 = 1;
      PORTB.F7 = 1;

      //////////
      PORTD.F0 = 1;
      PORTD.F1 = 1;
      PORTD.F2 = 1;
      PORTD.F3 = 1;

      //////////
      PORTD.F4 = 0;
      PORTD.F5 = 0;
      PORTD.F6 = 1;
      PORTD.F7 = 1;

      //////////
      delay_ms (750);
   }

   WHILE (1)
   {
      PORTB.F0 = 1;
      PORTB.F1 = 1;
      PORTB.F2 = 1;
      PORTB.F3 = 1;

      //////////
      PORTB.F4 = 0;
      PORTB.F5 = 0;
      PORTB.F6 = 1;
      PORTB.F7 = 1;

      //////////
      PORTD.F0 = 1;
      PORTD.F1 = 1;
      PORTD.F2 = 1;
      PORTD.F3 = 1;

      //////////
      PORTD.F4 = 0;
      PORTD.F5 = 0;
      PORTD.F6 = 1;
      PORTD.F7 = 1;

      //////////
      delay_ms (750);
   }

   WHILE (1)
   {
      PORTB.F0 = 1;
      PORTB.F1 = 1;
      PORTB.F2 = 1;
      PORTB.F3 = 1;

      //////////
      PORTB.F4 = 1;
      PORTB.F5 = 1;
      PORTB.F6 = 1;
      PORTB.F7 = 1;

      //////////
      PORTD.F0 = 0;
      PORTD.F1 = 0;
      PORTD.F2 = 1;
      PORTD.F3 = 1;

      //////////
      PORTD.F4 = 0;
      PORTD.F5 = 0;
      PORTD.F6 = 1;
      PORTD.F7 = 1;

      //////////
      delay_ms (750);
   }

   WHILE (1)
   {
      PORTB.F0 = 0;
      PORTB.F1 = 0;
      PORTB.F2 = 1;
      PORTB.F3 = 1;

      //////////
      PORTB.F4 = 1;
      PORTB.F5 = 1;
      PORTB.F6 = 1;
      PORTB.F7 = 1;

      //////////
      PORTD.F0 = 0;
      PORTD.F1 = 0;
      PORTD.F2 = 1;
      PORTD.F3 = 1;

      //////////
      PORTD.F4 = 0;
      PORTD.F5 = 0;
      PORTD.F6 = 1;
      PORTD.F7 = 1;

      //////////
      delay_ms (750);
   }

   WHILE (1)
   {
      PORTB.F0 = 1;
      PORTB.F1 = 1;
      PORTB.F2 = 1;
      PORTB.F3 = 1;

      //////////
      PORTB.F4 = 0;
      PORTB.F5 = 0;
      PORTB.F6 = 1;
      PORTB.F7 = 1;

      //////////
      PORTD.F0 = 0;
      PORTD.F1 = 0;
      PORTD.F2 = 1;
      PORTD.F3 = 1;

      //////////
      PORTD.F4 = 0;
      PORTD.F5 = 0;
      PORTD.F6 = 1;
      PORTD.F7 = 1;

      //////////
      delay_ms (750);
   }

   WHILE (1)
   {
      PORTB.F0 = 0;
      PORTB.F1 = 0;
      PORTB.F2 = 1;
      PORTB.F3 = 1;

      //////////
      PORTB.F4 = 0;
      PORTB.F5 = 0;
      PORTB.F6 = 1;
      PORTB.F7 = 1;

      //////////
      PORTD.F0 = 0;
      PORTD.F1 = 0;
      PORTD.F2 = 1;
      PORTD.F3 = 1;

      //////////
      PORTD.F4 = 0;
      PORTD.F5 = 0;
      PORTD.F6 = 1;
      PORTD.F7 = 1;

      //////////
      delay_ms (750);
   }

   WHILE (1)
   {
      PORTB.F0 = 1;
      PORTB.F1 = 1;
      PORTB.F2 = 1;
      PORTB.F3 = 1;

      //////////
      PORTB.F4 = 0;
      PORTB.F5 = 0;
      PORTB.F6 = 1;
      PORTB.F7 = 1;

      //////////
      PORTD.F0 = 0;
      PORTD.F1 = 0;
      PORTD.F2 = 1;
      PORTD.F3 = 1;

      //////////
      PORTD.F4 = 0;
      PORTD.F5 = 0;
      PORTD.F6 = 1;
      PORTD.F7 = 1;

      //////////
      delay_ms (750);
   }

   WHILE (1)
   {
      PORTB.F0 = 0;
      PORTB.F1 = 0;
      PORTB.F2 = 1;
      PORTB.F3 = 1;

      //////////
      PORTB.F4 = 1;
      PORTB.F5 = 1;
      PORTB.F6 = 1;
      PORTB.F7 = 1;

      //////////
      PORTD.F0 = 0;
      PORTD.F1 = 0;
      PORTD.F2 = 1;
      PORTD.F3 = 1;

      //////////
      PORTD.F4 = 0;
      PORTD.F5 = 0;
      PORTD.F6 = 1;
      PORTD.F7 = 1;

      //////////
      delay_ms (750);
   }

   WHILE (1)
   {
      PORTB.F0 = 1;
      PORTB.F1 = 1;
      PORTB.F2 = 1;
      PORTB.F3 = 1;

      //////////
      PORTB.F4 = 1;
      PORTB.F5 = 1;
      PORTB.F6 = 1;
      PORTB.F7 = 1;

      //////////
      PORTD.F0 = 0;
      PORTD.F1 = 0;
      PORTD.F2 = 1;
      PORTD.F3 = 1;

      //////////
      PORTD.F4 = 0;
      PORTD.F5 = 0;
      PORTD.F6 = 1;
      PORTD.F7 = 1;

      //////////
      delay_ms (750);
   }

   WHILE (1)
   {
      PORTB.F0 = 1;
      PORTB.F1 = 1;
      PORTB.F2 = 1;
      PORTB.F3 = 1;

      //////////
      PORTB.F4 = 0;
      PORTB.F5 = 0;
      PORTB.F6 = 1;
      PORTB.F7 = 1;

      //////////
      PORTD.F0 = 1;
      PORTD.F1 = 1;
      PORTD.F2 = 1;
      PORTD.F3 = 1;

      //////////
      PORTD.F4 = 0;
      PORTD.F5 = 0;
      PORTD.F6 = 1;
      PORTD.F7 = 1;

      //////////
      delay_ms (750);
   }

   WHILE (1)
   {
      PORTB.F0 = 0;
      PORTB.F1 = 0;
      PORTB.F2 = 1;
      PORTB.F3 = 1;

      //////////
      PORTB.F4 = 1;
      PORTB.F5 = 1;
      PORTB.F6 = 1;
      PORTB.F7 = 1;

      //////////
      PORTD.F0 = 1;
      PORTD.F1 = 1;
      PORTD.F2 = 1;
      PORTD.F3 = 1;

      //////////
      PORTD.F4 = 0;
      PORTD.F5 = 0;
      PORTD.F6 = 1;
      PORTD.F7 = 1;

      //////////
      delay_ms (750);
   }

   WHILE (1)
   {
      PORTB.F0 = 1;
      PORTB.F1 = 1;
      PORTB.F2 = 1;
      PORTB.F3 = 1;

      //////////
      PORTB.F4 = 1;
      PORTB.F5 = 1;
      PORTB.F6 = 1;
      PORTB.F7 = 1;

      //////////
      PORTD.F0 = 1;
      PORTD.F1 = 1;
      PORTD.F2 = 1;
      PORTD.F3 = 1;

      //////////
      PORTD.F4 = 0;
      PORTD.F5 = 0;
      PORTD.F6 = 1;
      PORTD.F7 = 1;

      //////////
      delay_ms (750);
   }

   WHILE (1)
   {
      PORTB.F0 = 1;
      PORTB.F1 = 1;
      PORTB.F2 = 1;
      PORTB.F3 = 1;

      //////////
      PORTB.F4 = 1;
      PORTB.F5 = 1;
      PORTB.F6 = 1;
      PORTB.F7 = 1;

      //////////
      PORTD.F0 = 0;
      PORTD.F1 = 0;
      PORTD.F2 = 1;
      PORTD.F3 = 1;

      //////////
      PORTD.F4 = 1;
      PORTD.F5 = 1;
      PORTD.F6 = 1;
      PORTD.F7 = 1;

      //////////
      delay_ms (750);
   }

   WHILE (1)
   {
      PORTB.F0 = 1;
      PORTB.F1 = 1;
      PORTB.F2 = 1;
      PORTB.F3 = 1;

      //////////
      PORTB.F4 = 0;
      PORTB.F5 = 0;
      PORTB.F6 = 1;
      PORTB.F7 = 1;

      //////////
      PORTD.F0 = 1;
      PORTD.F1 = 1;
      PORTD.F2 = 1;
      PORTD.F3 = 1;

      //////////
      PORTD.F4 = 1;
      PORTD.F5 = 1;
      PORTD.F6 = 1;
      PORTD.F7 = 1;

      //////////
      delay_ms (750);
   }

   WHILE (1)
   {
      PORTB.F0 = 0;
      PORTB.F1 = 0;
      PORTB.F2 = 1;
      PORTB.F3 = 1;

      //////////
      PORTB.F4 = 1;
      PORTB.F5 = 1;
      PORTB.F6 = 1;
      PORTB.F7 = 1;

      //////////
      PORTD.F0 = 1;
      PORTD.F1 = 1;
      PORTD.F2 = 1;
      PORTD.F3 = 1;

      //////////
      PORTD.F4 = 1;
      PORTD.F5 = 1;
      PORTD.F6 = 1;
      PORTD.F7 = 1;

      //////////
      delay_ms (750);
   }

   WHILE (1)
   {
      PORTB.F0 = 0;
      PORTB.F1 = 0;
      PORTB.F2 = 0;
      PORTB.F3 = 0;

      //////////
      PORTB.F4 = 0;
      PORTB.F5 = 0;
      PORTB.F6 = 0;
      PORTB.F7 = 0;

      //////////
      PORTD.F0 = 0;
      PORTD.F1 = 0;
      PORTD.F2 = 0;
      PORTD.F3 = 0;

      //////////
      PORTD.F4 = 0;
      PORTD.F5 = 0;
      PORTD.F6 = 0;
      PORTD.F7 = 0;

      //////////
      delay_ms (750);
   }
   }
 
Last edited by a moderator:

You have mixed CCS C code and mikroC code. There is no PORTx.Fx in CCS C. You have to use output_high() and output_low() functions if you are using CCS C Compiler. PORTx.Fx is mikroC code.
 

can you pls rewrite this program for me...coz i did this program by referring some previous programs and i don't have knowledge about embedded c
 

There are tomm many while(1) loops and there are no breaks to exit while(1) loops, so, your program execution will be looping in the first while(1) loop which it encounters. Nobody can help unless you mention which PIC you are using, what is your crystal frequency, which compiler, etc... I don't use CCS C but I can give you the mikroC code if you mention the details.
 

am using pic16f877a...compiler is ccs c

- - - Updated - - -

am using pic16f877a...compiler is ccs c
and crystal frequency is 16mhz

- - - Updated - - -

am using pic16f877a and compiler is ccs c and crystal frequency is 16mhz
 

I don't use CCS C Compiler. I used it once. It is the worst Compiler I have used.

If you use CCS C then you have to remove all PORTx.Fx codes. Use only one while(1) loop.

In main function use the tris codes given below.

Code C - [expand]
1
2
set_tris_b(0x00);
set_tris_d(0x00);


these tris settings will make the PORTB and PORTD as output ports.

To make pin high and low use the below codes.


Code C - [expand]
1
2
output_high(PIN_B0);  //makes RB0 high equ to mikroC PORTB.F0 = 1
output_low(PIN_B0);  //makes RB0 low equ to mikroC PORTB.F0 = 0

 

no need to mention portb=0 and portd=0
??
 
Last edited:

Initially you have to make port values 0 if you want but I don't know how to make a whole port low or high in CCS C.

Ok. I got it.

You can use

Code C - [expand]
1
2
OUTPUT_B(0b00001111);  // pins 0,1,2,3 of portb is high
OUTPUT_B(0b00000000);  // all pins of portb is low

 
  • Like
Reactions: rti

    rti

    Points: 2
    Helpful Answer Positive Rating
just a min i ll show some things in my project take a look and suggest some new things
GENERATION OF NEAREST SINUSOIDAL WAVEFORM USING ASYMMETRIC CASCADED H-BRIDGE MULTILEVEL INVERTER
OVERVIEW OF THE PROJECT:

LEVElS1 S2 S3 S4 S5 S6 S7 S8 S9 S10 S11 S12 S13 S14 S15 S16 O/P V
1 0 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1 0V
2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3V
3 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 6V
4 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 9V
5 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 12V
6 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 15V
7 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 18V
8 0 0 0 0 0 0 0 0 1 1 0 0 1 1 0 0 21V
9 1 1 0 0 0 0 0 0 1 1 0 0 1 1 0 0 24V
10 0 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 27V
11 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 30V
12 0 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 27V
13 1 1 0 0 0 0 0 0 1 1 0 0 1 1 0 0 24V
14 0 0 0 0 0 0 0 0 1 1 0 0 1 1 0 0 21V
15 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 18V
16 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 15V
17 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 12V
18 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 9V
19 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 6V
20 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3V
21 0 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1 0V

this is base of the program i have to write it in ccs c compiler and have to run

- - - Updated - - -

just a min i ll show some things in my project take a look and suggest some new things
GENERATION OF NEAREST SINUSOIDAL WAVEFORM USING ASYMMETRIC CASCADED H-BRIDGE MULTILEVEL INVERTER
OVERVIEW OF THE PROJECT:
LEVEL S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 S11 S12 S13 S14 S15 S16 O/P V
1 0 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1 0V
2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3V
3 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 6V
4 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 9V
5 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 12V
6 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 15V
7 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 18V
8 0 0 0 0 0 0 0 0 1 1 0 0 1 1 0 0 21V
9 1 1 0 0 0 0 0 0 1 1 0 0 1 1 0 0 24V
10 0 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 27V
11 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 30V
12 0 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 27V
13 1 1 0 0 0 0 0 0 1 1 0 0 1 1 0 0 24V
14 0 0 0 0 0 0 0 0 1 1 0 0 1 1 0 0 21V
15 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 18V
16 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 15V
17 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 12V
18 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 9V
19 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 6V
20 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3V
21 0 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1 0V

this is base of the program i have to write it in ccs c compiler and have to run
 

Are you trying to generate digital equivalent of sine wave which when given to DAC will give 0V, 3V, 6V, 9V,... (sine wave)? Post your circuit. You are using PORTB and PORTD. Are you giving 16 bit data from these ports to DAC? Why don't you choose some PIC which have 16 pins for a PORT?
 

ya am using 4 different supply to generate the sin wave

- - - Updated - - -

here i post

- - - Updated - - -

here is the output to get
 

Attachments

  • Drawing2.pdf
    369.7 KB · Views: 77
  • output wave.pdf
    16.5 KB · Views: 81

intially the 3 volt h bridge should ON..by pic we giving signal through optocoupler and make s1 s2 to conduct,,,next 6 v should on likewise we should ON the mosfet switches simultaneously to get the sign output like i showed u before

- - - Updated - - -

just show how to change the code for that tabulation
 

When 6V is given S5 and S6 conduct? Have you simulated the circuit in Proteus? See how you circuit works using Proteus.

In this data 1 [0 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1] 0V which is RB0 and which is RD0 bits. I need to know the bits.
 

thats the problem bcoz for proteus i need a program to download in it....
 

am using oly 16 so in port d and port b for output...through those ports am giving high or low signal to optocoupler inorder to conduct the mosfet

- - - Updated - - -

am 0ly giving the digital signal 0's and 1's

- - - Updated - - -

the bits in the order rb0 to rb7 and rd0 to rd7
 

0 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1
rb0 rb1 rb2 rb3 rb4 rb5 rb6 rb7 rd0 rd1 rd2 rd3 rd4 rd5 rd6 rd7

in this 0 all represent correspond mosfet is on conducting...in this first two 0's represent s1 and s2 is conducting..next 0's represent s7 and s8 of 6 volt is conducting and next represent s11 and s12 s conductin and next s13 and s14 is conductin bcoz of conduction we will get 0v...+3and-6 and -9 and +12 make 0 volt
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top