View previous topic :: View next topic |
Author |
Message |
sahu77
Joined: 08 Sep 2011 Posts: 202
|
step mode vs adc |
Posted: Mon Sep 26, 2011 12:06 pm |
|
|
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
|
|
Posted: Mon Sep 26, 2011 12:10 pm |
|
|
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
|
|
Posted: Mon Sep 26, 2011 12:15 pm |
|
|
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
|
|
Posted: Mon Sep 26, 2011 12:41 pm |
|
|
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
|
|
Posted: Mon Sep 26, 2011 12:46 pm |
|
|
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
|
|
Posted: Mon Sep 26, 2011 12:58 pm |
|
|
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
|
|
Posted: Mon Sep 26, 2011 1:50 pm |
|
|
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
|
|
Posted: Mon Sep 26, 2011 1:56 pm |
|
|
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
|
|
Posted: Tue Sep 27, 2011 7:38 am |
|
|
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
|
|
Posted: Tue Sep 27, 2011 8:10 am |
|
|
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
|
|
Posted: Tue Sep 27, 2011 8:39 am |
|
|
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
|
|
Posted: Tue Sep 27, 2011 12:53 pm |
|
|
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
|
|
Posted: Thu Sep 29, 2011 2:15 pm |
|
|
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
|
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
|
Posted: Sun Oct 16, 2011 2:49 am |
|
|
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!! |
|
|
|