CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

step mode vs adc
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Fri Mar 02, 2012 10:10 am     Reply with quote

My technik is right ?
_________________
sahu
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Sun Mar 11, 2012 7:16 am     Reply with quote

Anybody guide me where I am wrong ??
_________________
sahu
jeremiah



Joined: 20 Jul 2010
Posts: 1426

View user's profile Send private message

PostPosted: Sun Mar 11, 2012 8:10 am     Reply with quote

You don't really say "how" it isn't working now. You just say power_level_1 and HIGH_VOLTAGE aren't working, but don't explain.


As far as form goes, I really don't like how you did your case statements. It might be on purpose, but you don't have break statements at the end of the cases. Is it your intent to move from case 1 to case 2 in the same call or is it meant to go to case 2 two on the next call? Tracing through I didn't catch any bugs there, but it makes it pretty hard to read, especially with how you didn't format your code to be readable (lines aren't aligned with similar indenting schemes.

I would have expected something like:
Code:

switch(value){
   case 1:
      if(blah){
         //stuff here
      }else if(blah){
         //stuff here
      }
      break;
   case 2:
      if(blah){
         //stuff here
      }else if(blah){
         //stuff here
      }
      break;
   default:
      //error situation here...should probably display something.
}


Your formatting is all over the place, so it is hard to read to check.

I don't mean that to be mean at all, I just want you to understand that it is tough to figure out. Also, can you post the whole program or is that too big now?
dezso



Joined: 04 Mar 2010
Posts: 102

View user's profile Send private message

PostPosted: Sun Mar 11, 2012 8:49 am     Reply with quote

Use this to upload you images..

http://imgur.com/
_________________
I'm could be wrong many time's, at least I know what I'm doing Smile
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Thu Mar 22, 2012 10:17 am     Reply with quote

dezso wrote:
Use this to upload you images..

http://imgur.com/

Due to net problem, I can't upload images.
By the way pin assignment are as
Code:
/*        16F676 Configuration   For 95volt to 290 volt dual I|P
          O = Output, I = Input RIGHT NOW AS DEMO
                    _________
              Vdd   | 1  14 |  Vss
  (I) SW1 --> RA5   | 2  13 |  AN0 <-- ADC_Value (I) For I_P feed bauck
  (I) SW2 --> RA4   | 3  12 |  AN1 <-- ADC_Value (I) For O\P feed bauck
             MCLR   | 4  11 |  RA2 --> I_P_RL1 (O)
  (O)  L1 <-- RC5   | 5  10 |  RC0 --> I_P_RL2 (O)
  (O)  L1 <-- RC4   | 6   9 |  RC1 --> O\P__FX_RL3 (O)
  (O) BZR <-- RC3   | 7   8 |  RC2 --> TDR_RL_4 (O)
                    ---------

now pl help me any body ...
now i use as .,,
Code:
int ProcessMains(void)
{
   ch_1 = getchreading(0);              // Extract volts (thousands of millivolts) from AN0
  {step_mode=div(a,5);
            switch (step_mode.rem)
          {
           case 0:
/********
 i\p dc volt (milivolt) = (ADC_value*5000)/1023
 so """""  ADC_value = [(milivolt) * 1023]/5000
********/

               if ((ch_1 >= 1) && (ch_1 <= 130)) //95 volt
          {          power_level_1();
                            }

          if ((ch_1 >= 137) && (ch_1 <= 167))  /  //115 v
          {          power_level_2();
                           }

          if (ch_1 > 167){a=a+1;}// goto step 2
            break;   // now leav case 0

     case 1: // for step chnge sencing
     if (ch_1 < 117)//(ch_1 < 640) //now  case 2 < 115v
                    {a=a-1;}
            if (ch_1 >= 117)  {a=a+1;}
                break;  // goto step 2   

     case 2:
     if (ch_1 <= 118)  { a=a-1;}         
                 
        if ((ch_1 >= 119) && (ch_1 <= 141)) //RL1=ON &  //RL3=OFF now  case 2 < 137v
          {          power_level_3();
                            }

       if ((ch_1 >= 143) && (ch_1 <= 178)) //RL1=ON &  RL3=ON  > 137v to 170 v       
          {    power_level_4();
                           }
       if (ch_1 > 178)    {a=a+1;}   break;

     case 3:
     
     if (ch_1 < 119)   {a=a-1;}

         if (ch_1 >= 119)   {a=a+1;}
         break;

      case 4:
     if (ch_1 < 120)   {a=a-1;}
                 

            if ((ch_1 >= 121) && (ch_1 <= 141)) //RL1=ON &  RL2=ON &RL3=OFF     
          {          power_level_5();
                            }

         if ((ch_1 >= 143) && (ch_1 <= 178)) //RL1=ON &  RL2=ON &RL3=OFF
          {          power_level_6();
                           } break;
          }}
     // High Voltage protection is done here
   if (ch_1>=204)
      return(HIGH_VOLTAGE);

   //We have got here, so voltage should be normal
   return(NORMAL_VOLTAGE);
}

It is work on Real Pic Simulator[ very well as i want, but not work real card. pls help me.......
_________________
sahu
Ttelmah



Joined: 11 Mar 2010
Posts: 20161

View user's profile Send private message

PostPosted: Thu Mar 22, 2012 10:48 am     Reply with quote

Nobody is going to be able to help you, because most important things are missing:
Variable declarations.
Code for 'getchreading'.

etc. etc...

Then, the actual layout of the code is completely illogical. Makes it almost impossible to understand.

If I was marking this, the student would be failed immediately, even if the code worked...

Most likely thing (guessing), is that your code to take the readings, does not allow Tacq for the ADC to acquire the voltage, which the simulator doesn't care about, but the real chip does.

Best Wishes
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

Make it easy for others to help you.
PostPosted: Thu Mar 22, 2012 12:17 pm     Reply with quote

Read the CCS forum guide.

(1) You do not tell us what is wrong.
(2) There is no clear explanation of what your current version of the code is supposed to do.
(3) A SHORT but complete, compilable code which shows the problem would assist.
(4) ...................
(5) ..................

Mike
temtronic



Joined: 01 Jul 2010
Posts: 9658
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Mar 22, 2012 3:13 pm     Reply with quote

Yeah I love the 'works on real PIC simulator'...but NOT in the real world..

Gee, I wonder why !!

As others have said, post your code and WHAT doesn't work.
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Sun Sep 23, 2012 9:55 am     Reply with quote

sahu77 wrote:
dezso wrote:
Use this to upload you images..

http://imgur.com/

Due to net problem, I can't upload images.
By the way pin assignment are as
Code:
/*        16F676 Configuration   For 95volt to 290 volt dual I|P
          O = Output, I = Input RIGHT NOW AS DEMO
                    _________
              Vdd   | 1  14 |  Vss
  (I) SW1 --> RA5   | 2  13 |  AN0 <-- ADC_Value (I) For I_P feed bauck
  (I) SW2 --> RA4   | 3  12 |  AN1 <-- ADC_Value (I) For O\P feed bauck
             MCLR   | 4  11 |  RA2 --> I_P_RL1 (O)
  (O)  L1 <-- RC5   | 5  10 |  RC0 --> I_P_RL2 (O)
  (O)  L1 <-- RC4   | 6   9 |  RC1 --> O\P__FX_RL3 (O)
  (O) BZR <-- RC3   | 7   8 |  RC2 --> TDR_RL_4 (O)
                    ---------

now pl help me any body ...
now i use as .,,
Code:
int ProcessMains(void)
{
   ch_1 = getchreading(0);              // Extract volts (thousands of millivolts) from AN0
  {step_mode=div(a,5);
            switch (step_mode.rem)
          {
           case 0:
/********
 i\p dc volt (milivolt) = (ADC_value*5000)/1023
 so """""  ADC_value = [(milivolt) * 1023]/5000
********/

               if ((ch_1 >= 1) && (ch_1 <= 130)) //95 volt
          {          power_level_1();
                            }

          if ((ch_1 >= 137) && (ch_1 <= 167))  /  //115 v
          {          power_level_2();
                           }

          if (ch_1 > 167){a=a+1;}// goto step 2
            break;   // now leav case 0

     case 1: // for step chnge sencing
     if (ch_1 < 117)//(ch_1 < 640) //now  case 2 < 115v
                    {a=a-1;}
            if (ch_1 >= 117)  {a=a+1;}
                break;  // goto step 2   

     case 2:
     if (ch_1 <= 118)  { a=a-1;}         
                 
        if ((ch_1 >= 119) && (ch_1 <= 141)) //RL1=ON &  //RL3=OFF now  case 2 < 137v
          {          power_level_3();
                            }

       if ((ch_1 >= 143) && (ch_1 <= 178)) //RL1=ON &  RL3=ON  > 137v to 170 v       
          {    power_level_4();
                           }
       if (ch_1 > 178)    {a=a+1;}   break;

     case 3:
     
     if (ch_1 < 119)   {a=a-1;}

         if (ch_1 >= 119)   {a=a+1;}
         break;

      case 4:
     if (ch_1 < 120)   {a=a-1;}
                 

            if ((ch_1 >= 121) && (ch_1 <= 141)) //RL1=ON &  RL2=ON &RL3=OFF     
          {          power_level_5();
                            }

         if ((ch_1 >= 143) && (ch_1 <= 178)) //RL1=ON &  RL2=ON &RL3=OFF
          {          power_level_6();
                           } break;
          }}
     // High Voltage protection is done here
   if (ch_1>=204)
      return(HIGH_VOLTAGE);

   //We have got here, so voltage should be normal
   return(NORMAL_VOLTAGE);
}

It is work on Real Pic Simulator[ very well as i want, but not work real card. pls help me.......


why it not work
{a=a-1;}
{a=a+1;}

on real stabilizer card.
_________________
sahu
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Wed Sep 26, 2012 10:27 am     Reply with quote

if i'm joking here pl tell me !
_________________
sahu
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Sat Sep 29, 2012 4:24 am     Reply with quote

Quote:
if i'm joking here pl tell me !
You've certainly got me totally confused as to where this thread is at.

I think I'm not the only one.

This thread has been going a long time, and lots of things have changed.

We need a clear, concise description of:-

1) What you are trying to do.
2) Your current hardware setup.
3) Short but complete compilable code which illustrates your problem.
4) Detail of what works and doesn't.
5) Testing you've done.

Mike

EDIT I don't mean to be harsh, but you're making it difficult to help you. I'm aware of the language isssue, and can deal with that.
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Sun Sep 30, 2012 7:15 am     Reply with quote

Here the function of my stabilizer.
Code:

            ////////////////////////////////////////////////             
            //                                            //
            //     working fx of my stb controller crad . //
            //                                            // 
            ////////////////////////////////////////////////



Only one L.T. is required. its wiring as per my diagram.
******************************************************
*    ITS stb wiring diagram  for 90 Volt to 290 Volt *
******************************************************

************************************************************************************************
1-  When we connect 95V input from variac the output should be 200V on output relay-4 on com point(POLE) .Now increase input and check output. When output reaches between 240 - 245V, we move preset wiper till
   relay-3 goes ON and 
   relay-1 ,relay-2 are off

output will reach near about to 205V.now input near about 115volt.
     THIS STEP WE CAN SAY STEP_0 .
************************************************************************************************

2- now input near about 115volt. Again increase input and check output. When output reaches between 240 - 245V, now input near about 137volt.
  relay-1 goes ON and now
  relay-3 goes off .
  relay-2 are off

   output will reach near about to 205V, now input near about 167volt.
     THIS STEP WE CAN SAY STEP_1 .
************************************************************************************************

3- now input near about 167volt. Again increase input and check output.When output reaches between 240 - 245V.now input near about 200volt.
 relay-1 all ready on in STEP_1 .
 relay-3 goes on .
 relay-2 are off

output will reach near about to 205V.now input near about 200volt.
     THIS STEP WE CAN SAY STEP_2 .
************************************************************************************************

4- now input near about 200volt. Again increase input and check output.When output reaches between 240 - 245V.now input near about 240volt.
 relay-1 all ready on in STEP_1 & STEP_2.
 relay-2 goes on and now
 relay-3 goes off .&

output will reach near about to 205V.now input near about 240volt.
     THIS STEP WE CAN SAY STEP_3 .
*************************************************************************************************

5- now input near about 240volt. Again increase input and check output.When output reaches between 240 - 245V.
 relay-1 all ready on in STEP_1 , STEP_2 & STEP_3 And also
 relay-2 all ready on in STEP_3 .. & now
 relay-3 goes on  .&

 output will reach near about to 205V.now input near about 240volt.
     THIS STEP WE CAN SAY STEP_4 .
************************************************************************************************


/////////////////////////////////////////////////////////////////////////////////////////


relay-4 for hi\low volt  cut & time delay 




here the function details of my stabilizer controller card .
[QUOTE] Only one L.T. is required. its wiring as per my diagram.
******************************************************
*    ITS stb wiring diagram  for 90 Volt to 290 Volt *
******************************************************

************************************************************************************************
1-  When we connect 95V input from variac the output should be 200V on output relay-4 on com point(POLE). Now increase input and check output.When output reaches between 240 - 245V, we move preset wiper till
   relay-3 goes ON and 
   relay-1 ,relay-2 are off

output will reach near about to 205V. now input near about 115volt.
     THIS STEP WE CAN SAY STEP_0 .
************************************************************************************************

2- now input near about 115volt. Again increase input and check output.When output reaches between 240 - 245V. now input near about 137volt.
  relay-1 goes ON and now
  relay-3 goes off .
  relay-2 are off

   output will reach near about to 205V.now input near about 167volt.
     THIS STEP WE CAN SAY STEP_1 .
************************************************************************************************

3- now input near about 167volt. Again increase input and check output.When output reaches between 240 - 245V. now input near about 200volt.
 relay-1 all ready on in STEP_1 .
 relay-3 goes on .
 relay-2 are off

output will reach near about to 205V.now input near about 200volt.
     THIS STEP WE CAN SAY STEP_2 .
************************************************************************************************

4- now input near about 200volt. Again increase input and check output. When output reaches between 240 - 245V. now input near about 240volt.
 relay-1 all ready on in STEP_1 & STEP_2.
 relay-2 goes on and now
 relay-3 goes off .&

output will reach near about to 205V.now input near about 240volt.
     THIS STEP WE CAN SAY STEP_3 .
*************************************************************************************************

5- now input near about 240volt. Again increase input and check output. When output reaches between 240 - 245V.
 relay-1 all ready on in STEP_1 , STEP_2 & STEP_3 And also
 relay-2 all ready on in STEP_3 .. & now
 relay-3 goes on  .&

 output will reach near about to 205V.now input near about 240volt.
     THIS STEP WE CAN SAY STEP_4 .
************************************************************************************************


/////////////////////////////////////////////////////////////////////////////////////////


relay-4 for hi\low volt  cut & time delay 


wiring diagram of relay connection & sch is here.
[url]<a href="http://imgur.com/A2mlp"><img src="http://i.imgur.com/A2mlp.png"

title="Hosted by imgur.com" alt="" /></a>[/url]
_________________
sahu
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group