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 1, 2, 3  Next
 
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

step mode vs adc
PostPosted: Mon Sep 26, 2011 12:06 pm     Reply with quote

i am facing some problem about scening adc in step mode ... adc sens tabol as below ...
Code:
/**********************************************************************************
     O\P        ADC      RELAY POSITION ( 0=OFF  1=ON )
                            RL1 RL2 RL3       step_mode
********************************************************************************
   200 - 240   565 - 722     0   0   0   --   Step 0
   200 - 240   731 - 877     0   0   1   --   Step 1
**********************************************************************************
   200 - 240   596 - 720     1   0   0   --   Step 2
   200 - 240   731 - 877     1   0   1   --   Step 3
**********************************************************************************
   200 - 240   586 - 720     1   1   0   --   Step 4
   200 - 240   724 - 877     1   1   1   --   Step 5
***********************************************************************************/

and ccs c as below...
Code:
 switch (step_mode)
    {
      // Step 0 -- ADC 565 - 722
        case 0:
          // Low Voltage protection is done here
            if ((ch<565) && ((input(SW2)==0) || (QuickStart_flag == 1)))
               return(LOW_VOLTAGE); 
   
         
             if (ch < 722)//95 volt
             {
               output_low(RL1);
               output_low(RL2);
               output_low(RL3);
                break;
              }
             if (ch >= 722)  //115 v
             {
            step_mode = 1;  // goto step 1
              break;
             }
       
      // Step 1 -- ADC 731 - 877 
        case 1:
           if (ch < 731) //now  case 2 < 115v
             {
               step_mode = 0;  // Callback to step 0
                break;               
             }
         
         if (ch < 877)  //  < 137v
             {
            output_low(RL1);
            output_low(RL2);
            output_high(RL3);
             break;
            }

             if (ch >= 877)    // > 137v to 170 v
             {
            // Switch to Step 2
            output_high(RL1);
            output_low(RL2);
            output_low(RL3);
            break; 
             }
           if (ch >= 720)  //115 v
             {
            step_mode = 2;  // goto step 1
                 break;           
             }

      // Step 2 -- ADC 596 - 720
        case 2:
           if (ch < 596) //now  case 2 < 115v
             {
               step_mode = 1;  // Callback to step 1
            break;
             }
         if (ch >= 720)
             {
            // Switch to Step 3
            output_high(RL1);
            output_low(RL2);
            output_high(RL3);
                   break;
             }
               if (ch >= 877)  //115 v
             {
            step_mode = 3;  // goto step 1
                 break;           
             }           
   
      // Step 3 -- ADC 731 - 877
      case 3:
         if (ch < 731)
         {
            step_mode = 2;
            break;
         }
         if (ch >= 877)
         {
            // Switch to Step 4
            output_high(RL1);
            output_high(RL2);
            output_low(RL3);
            break;
         }
            if (ch >= 722)  //115 v
             {
            step_mode = 4;  // goto step 1
                break;           
             }

      // Step 4 -- ADC 586 - 720
      case 4:
         if (ch < 586)
         {
            step_mode = 3;
            break;
         }
         if (ch >= 720)
         {
            // Switch to Step 5
            output_high(RL3);
            output_high(RL2);
            output_high(RL1);
            break;
         }
              if (ch >= 877)  //115 v
             {
            step_mode = 5;  // goto step 1
                 break;           
             }       

      // Step 5 -- ADC 724 - 877
      case 5:
         if (ch < 724)
         {
            step_mode = 4;
            break;
         }
         if (ch >= 877)
         {
            // High Voltage protection is done here
               return(HIGH_VOLTAGE);
         }

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

_________________
sahu
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Mon Sep 26, 2011 12:10 pm     Reply with quote

there is just not enough to go on here about what you are trying to do
or what your actual problem IS .

try to be more clear and tell MUCH more about
what is supposed to be going on in your program
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Mon Sep 26, 2011 12:15 pm     Reply with quote

asmboy wrote:
there is just not enough to go on here about what you are trying to do
or what your actual problem IS .

try to be more clear and tell MUCH more about
what is supposed to be going on in your program

Actually I am trying to make mcu based stabilizer controlled card. It is based on 16f676.
I do not use linear adc i/p, because do some problem. So I decide I use step mode.
Sorry for my bad English.
_________________
sahu
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Mon Sep 26, 2011 12:41 pm     Reply with quote

JUST FOR A START:

1- you don't say where var ch is loaded or how ( from ADC read??)

2- if you are using physical relays to change excitation and then measure
have you TIMED how long the relay contact open and close actually TAKE to happen - and allowed settling time for it all ?? ( hint open and close are usually NOT the same timing )

3- what do you MEAN precisely by step mode ADC?

you are still far from disclosing enough to get the help you want.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Mon Sep 26, 2011 12:46 pm     Reply with quote

I have been working with microcontrollers and robotics for nearly 30 years and I for one have no idea what "step mode" is. Is this a AC voltage stabilizer like a tapped transformer, or a mechanical part like an aircraft stabilizer?

What does your code do that it should not do, or not do that it should do?
_________________
The search for better is endless. Instead simply find very good and get the job done.
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Mon Sep 26, 2011 12:58 pm     Reply with quote

SherpaDoug wrote:
I have been working with microcontrollers and robotics for nearly 30 years and I for one have no idea what "step mode" is. Is this a AC voltage stabilizer like a tapped transformer, or a mechanical part like an aircraft stabilizer?

What does your code do that it should not do, or not do that it should do?

"step mode" use for my understanding.
as you say ...AC voltage stabilizer like a tapped transformer I use for this.
For tapping changing I use relay.
I want post here my stabilizer + relay wiring schematic but can't understand how do it.
pls help me
_________________
sahu
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Mon Sep 26, 2011 1:50 pm     Reply with quote

I will note ONE thing:

You are changing the value of step_mode within the switch function being driven by step_mode.
----------------
I have always entertained a certain paranoia about that sort of thing, even though the BREAK statement should protect you.

I would choose to assign my new step_mode value to some temporary var and then OUTSIDE the switch construct - assign that TEMP value back to switch_var.

OR
Drive the switch argument with a copied VAR fo step_var.

It may not be required now but I got myself into trouble long ago by doing just the sort of thing you do here inside your switch statement.
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Mon Sep 26, 2011 1:56 pm     Reply with quote

asmboy wrote:
i will note ONE thing:

you are changing the value of step_mode within the switch function being driven by step_mode
----------------
i have always entertained a certain paranoia about that sort of thing, even tho the BREAK stmt should protect you

i would choose to assign my new step_mode value to some temporary var and then OUTSIDE the switch construct - assign that TEMP value back to switch_var

OR
drive the switch argument with a copied VAR fo step_var

it may not be required now but i got myself into trouble long ago by doing just the sort of thing you do here inside your switch statement


Where I post my stabilizer sch + wiring diagram ? Then everything is clear, what I am saying to everybody. Right now I am facing some language problem because my English is very bad.
_________________
sahu
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Tue Sep 27, 2011 7:38 am     Reply with quote

Before worrying about the wiring I think we first need to know how your code is currently behaving. What does your code do that it should not do, or not do that it should do?
_________________
The search for better is endless. Instead simply find very good and get the job done.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Sep 27, 2011 8:10 am     Reply with quote

i can tell one thing for sure:

if these state changes apply to physical relays - this
and all your other relays state changes - is a BIG TROUBLE SPOT.


Code:

// Switch to Step 3
            output_high(RL1);
            output_low(RL2);
            output_high(RL3);

in my experience:
relays take more time to CLOSE than to OPEN.

so you could be having some short duration nasty , unintended
connections being made in "mains voltage land" by NOT considering
overlap timing of relay contacts.
temtronic



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

View user's profile Send private message

PostPosted: Tue Sep 27, 2011 8:39 am     Reply with quote

Not to mention the EMI noise and transients caused by switching even moderate levels of power !
You could minimize it by using SSRs( triacs) with zero crossing but switching AC power of say a few watts spells a LOT of headaches !!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 27, 2011 12:53 pm     Reply with quote

Quote:
Where I post my stabilizer sch + wiring diagram ?

Use a free image hosting website, such as http://www.imageshack.com
and then post a link to it here.
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Thu Sep 29, 2011 2:15 pm     Reply with quote

PCM programmer wrote:
Quote:
Where I post my stabilizer sch + wiring diagram ?

Use a free image hosting website, such as http://www.imageshack.com
and then post a link to it here.

this link not work here (India).
_________________
sahu
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

stabilizer sch + wiring diagram
PostPosted: Sun Oct 16, 2011 2:11 am     Reply with quote

stabilizer sch + wiring diagram here
http://imageshack.us/photo/my-images/705/stb02.png/
http://imageshack.us/photo/my-images/705/90v300vstbwiring.png/
pl help me / / /
_________________
sahu
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sun Oct 16, 2011 2:49 am     Reply with quote

asmboy wrote:

in my experience:
relays take more time to CLOSE than to OPEN.


The [spam] is equally true. It often takes longer for a relay to open (as a result of the relay coil being de-energized) than for the contacts to close (when the relay coil is energized). There are lots of factors that contribute to this behaviour however one key consideration is the back EMF protection diode feeding current back into the relay coil as the relay's magnetic field collapses thereby prolonging the relay holding time.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
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 1, 2, 3  Next
Page 1 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