Automatic Voltage Regulator (AVR) using PIC16f72

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

s.k.sahoo
Posts: 147
Joined: Sun Sep 16, 2012 3:02 am
Has thanked: 144 times
Been thanked: 7 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by s.k.sahoo »

Dear Mr Enamul,

I just saw your post. yes you are right, there are hysteresis problem in Relay-4 switching sequences.
All the Relays are switching at 5v hysteresis except Relay-4.
I will test the latest sent code and post result within a hour.

Thanks
With best regards
sks

s.k.sahoo
Posts: 147
Joined: Sun Sep 16, 2012 3:02 am
Has thanked: 144 times
Been thanked: 7 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by s.k.sahoo »

Dear Mr Enamul,

Good evening.
I just test the code, the result is, hysteresis problem still persists.
Sorry to say, i am not able to find errors in the code. It must be the hardware problem
I am giving you some information of the hardware, pl help me to solve the problem.

At 61vAC input, AN0 pin voltage is 1.19 RL-4 is ON
At 58vAC input, AN0 pin voltage is 1.11 RL-4 is OFF

At 167vAC input, AN0 pin voltage is 3.89 RL-4 is ON, (it should be ON at 200vAC input}
At 163vAC input, AN0 pin voltage is 3.82 RL-4 is OFF, (it should be OFF at 195vAC input}

I am giving this data for clue, if it helps you to solve the issue.

Thanks
With best regards
sks

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by Enamul »

Hi
Can you please post ac voltage and adc input voltage and adc value of pic for each of the voltages that we used in the code ? It will help me in debugging the code?
Enamul
University of Nottingham
enamul4mm@gmail.com

s.k.sahoo
Posts: 147
Joined: Sun Sep 16, 2012 3:02 am
Has thanked: 144 times
Been thanked: 7 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by s.k.sahoo »

Dear Mr Enamul,

Thanks for the reply. Ok i will post the ADC voltage, the value given in our code and the AC input voltage after measuring.

Thanks
With best regards
sks

s.k.sahoo
Posts: 147
Joined: Sun Sep 16, 2012 3:02 am
Has thanked: 144 times
Been thanked: 7 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by s.k.sahoo »

Dear Mr Enamul,

Here is the measured details attached.
RL-4 chatters at 167v, i have corrected 89 to 86, because 91-5v hysteresis =86, it was wrongly entered.
Please see the table and help.
I will be out of station for few days,i am at home up to 1PM, i will contact you after 2 days.

Thanks
With best regards
sks
Attachments
RelayLogicTable_2.jpg
RelayLogicTable_2.jpg (105.73 KiB) Viewed 12218 times

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by Enamul »

Hi,
Your ADC seems non-linear..that's not a very good thing in this design. You have to adjust in hardware to make it linear..I will advice you how to do that..for voltage sense and better switching of relay voltage sense should be approximately linear. Can you please post ac sense circuit schematic upto ADC pin..so that I can find which make it non-linear..

Thanks,
Enamul
University of Nottingham
enamul4mm@gmail.com

s.k.sahoo
Posts: 147
Joined: Sun Sep 16, 2012 3:02 am
Has thanked: 144 times
Been thanked: 7 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by s.k.sahoo »

Dear Mr Enamul,

Thanks for the reply. The Sensing input schematic is attached, please see and guide.

Thanks
With best regards
sks
Attachments
sensing input .jpg
sensing input .jpg (70.15 KiB) Viewed 12204 times

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by Enamul »

Hi Mr SKS
Your sense section seems nice. But I wonder why it's not behaving linear! You have posted in earlier thread "Using ADC & 5 Relays" in page 3 at the bottom where the ADC read was linear..I am posting here what you posted that time to help you in recall in your mind..
Can you remember how get that nice linearity? Is it possible to have same linearity here as well?
Attachments
SpreadSheet.jpg
SpreadSheet.jpg (47.07 KiB) Viewed 12198 times
Enamul
University of Nottingham
enamul4mm@gmail.com

s.k.sahoo
Posts: 147
Joined: Sun Sep 16, 2012 3:02 am
Has thanked: 144 times
Been thanked: 7 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by s.k.sahoo »

Dear Mr Enamul,

Sorry, i couldn't reply as i am out of my home for few days.
I know, i had posted this Table. It is for my 1st design 96V model. The Transformer of this model is having
96,115,138,165 and 200 Volt tapping using a plain simple Relay switching logic.
But now, i am facing for a different model. This model is a 50V model having 50,75,111,165 and 200 Volt tappings.
The Relay switching is different than the 1st one, we call it Cross logic switching.
I have checked the assembled PCB, it is Ok. I don't know whats wrong with this design.
I have even Checked with the previous design board with new programmed chip. There is still error.

I can give you more data if required after reaching home may be after 10 days.

Thanks
With best regards
sks

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by Enamul »

Hi Mr SKS

Actually I don't feel it depends on your relay numbers or tapping voltage rather it is dependent on the input voltage and the input signal processing circuit which leads to the adc input of PIC. Can you please check the difference between the input voltage step down, ac-dc, filtering and voltage dividing circuit for both of your model? There must be some kind of difference. It's better if you could post schematic of input section for both the model.

Thanks,
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by Enamul »

Can you please check the difference between the input voltage step down, ac-dc, filtering and voltage dividing circuit for both of your model? There must be some kind of difference. It's better if you could post schematic of input section for both the model.
Can you please check that before any change in the code...as it seems to me in your first model you have used opto-coupler for voltage sense...but not in 2nd version. I might be wrong but it could cause some issue.
Enamul
University of Nottingham
enamul4mm@gmail.com

s.k.sahoo
Posts: 147
Joined: Sun Sep 16, 2012 3:02 am
Has thanked: 144 times
Been thanked: 7 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by s.k.sahoo »

Dear Mr Enamul,

Sorry, as out of station, we are late in finishing this model.
Actually i am not using any Opto Coupler in either models.
I am attaching the Schematics here for your verification and correction if any,
I am using this Schematic/Circuit and PCB for both the models, in my 1st model i am not using LCD meter.
You have quoted " Can you please check the difference between the input voltage step down, ac-dc, filtering and voltage dividing circuit for both of your model? "
All the components are same and no faulty components even.

Thanks
With best regards
sks

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by Enamul »

I am attaching the Schematics here for your verification and correction if any,
Did you miss it or post later..
Enamul
University of Nottingham
enamul4mm@gmail.com

s.k.sahoo
Posts: 147
Joined: Sun Sep 16, 2012 3:02 am
Has thanked: 144 times
Been thanked: 7 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by s.k.sahoo »

Sorry Dear,
I missed the Schematic. Here it is.

Thanks
With best regards
sks
Attachments
PIC16F72_StabilizerDesign_New.PDF
(116.86 KiB) Downloaded 443 times

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by Enamul »

No problem. I can't see anything wrong in the circuit. I think we have to adjust ADC input voltage and output and try to link the ADC input with AC by linear relationship.
Enamul
University of Nottingham
enamul4mm@gmail.com

s.k.sahoo
Posts: 147
Joined: Sun Sep 16, 2012 3:02 am
Has thanked: 144 times
Been thanked: 7 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by s.k.sahoo »

Dear Mr Enamul,

Thanks for the reply.
" we have to adjust ADC input voltage and output and try to link the ADC input with AC by linear relationship."
Have you seen the input voltage tables for both models?
Where is the mistake, i don't understand.

Thanks
With best regards
sks

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by Enamul »

Hi,

I think I got the issue...If you look carefully in the table I have attached from your previous post..you can see ADC behavior becomes more non-linear at higher ADC input voltage and I have seen this kind of issue earlier. It's good to use lower portion of the ADC range as that is more linear. That's why I will suggest you to post the latest code so that I can modify that and suggest you to take some reading and post in the forum and hopefully the issue will be sorted.
Attachments
RelayLogicTable_2.jpg
RelayLogicTable_2.jpg (75.17 KiB) Viewed 11877 times
Enamul
University of Nottingham
enamul4mm@gmail.com

s.k.sahoo
Posts: 147
Joined: Sun Sep 16, 2012 3:02 am
Has thanked: 144 times
Been thanked: 7 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by s.k.sahoo »

Dear Mr Enamul,

Thanks for your study and found the error. ( i think your doubt is correct )
I am attaching 2codes with little additions, pl correct if any thing wrong.

Thanks
With best regards
sks
Attachments
6-RELAY_CROSS_LOGIC_V1.02_2.fcf
(28.44 KiB) Downloaded 245 times
6-RELAY_CROSS_LOGIC_V1.02.fcf
(28.44 KiB) Downloaded 233 times

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by Enamul »

Hi

Can you please tell me what is the difference between the two version? I have done that long ago and can't remember..if you can tell me bit more..that will be helpful
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by Enamul »

If you use ADC value directly for voltage sense you will be limited to 255 as ADC can be maximum 255 and it seems there are some non-linearlity for high adc value; so if you use USE_AN0 =READ_AN0*2 that will change help you to read AC voltage easily 300V plus. Like if READ_AN0=255, USE_AN0=510; that means your range become double. But in reality you will be using 50 to 260 Vac may be; which means you are using 25 to 130 ADC value and that part of ADC is vary linear.
Now you need to do only one thing..you have to adjust the input of ADC in that way so that when the ac volt is 250, ADC value in LCD should be 125.
Here is a table..before testing the AVR..can you please test the table and put the analog voltage in the ADC pin so that I can check whether it is now linear or not. But before doing that remember to adjust 250V as 125 ADC value. If you want I can post a simple program just to check and fill-up the table.
Attachments
needed_addc.png
(19.83 KiB) Downloaded 6081 times
6-RELAY_CROSS_LOGIC_V1.03.fcf
(28.46 KiB) Downloaded 232 times
Enamul
University of Nottingham
enamul4mm@gmail.com

s.k.sahoo
Posts: 147
Joined: Sun Sep 16, 2012 3:02 am
Has thanked: 144 times
Been thanked: 7 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by s.k.sahoo »

Dear Mr Enamul,

Thanks for describing about ADC. Sorry i have not implemented LCD Display in my code yet.
I am posting the measured ADC Voltage value in different AC Input. Please tell me what to do next.
Shall i add the LCD Display in the code?
I don't know why its so difficult to finalize this 2nd project, is it due to the wrong chip?
Waiting for your reply.

Thanks
With best regards
sks
Attachments
Result_addc.jpg
Result_addc.jpg (86.88 KiB) Viewed 11856 times

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by Enamul »

Sorry i have not implemented LCD Display in my code yet.
In that case how will you know what is ADC value for AC voltage?
Shall i add the LCD Display in the code?
Yes you need LCD in the code to check linearity.
I don't know why its so difficult to finalize this 2nd project, is it due to the wrong chip?
What do you mean by wrong chip? Is that 16f72 you mean..that's not wrong just has less ADC resolution.
Enamul
University of Nottingham
enamul4mm@gmail.com

s.k.sahoo
Posts: 147
Joined: Sun Sep 16, 2012 3:02 am
Has thanked: 144 times
Been thanked: 7 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by s.k.sahoo »

Thanks Mr Enamul for a quick reply. OK,
I will add LCD and post, I mean is it due to 8-bit ADC?

Thanks
With best regards
sks

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by Enamul »

I will add LCD and post, I mean is it due to 8-bit ADC?
Data in the table is showing that this is not because of ADC rather your sensing circuit is some how non-linear. It could be the capacitor you are using. You can try with changing capacitor connected in series to 10K resistor.
Enamul
University of Nottingham
enamul4mm@gmail.com

s.k.sahoo
Posts: 147
Joined: Sun Sep 16, 2012 3:02 am
Has thanked: 144 times
Been thanked: 7 times
Contact:

Re: Automatic Voltage Regulator (AVR) using PIC16f72

Post by s.k.sahoo »

Dear Mr Enamul,

I have tested the hardware removing the 3.3uf cap after the 10k series resistor and adding a 1uf can at AN0, no improvement
found. just now i have added the LCD display in the code, yet to test in the hardware.
The code is attached, pl see. I will post the result tomorrow.

Thanks
With best regards
sks
Attachments
6-RELAY_CROSS_LOGIC_V1.03.fcf
(32.02 KiB) Downloaded 253 times

Post Reply