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

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 forgot to mention..you can go through a nice tutorial from John about RTC interfacing in the following link...
http://www.matrixmultimedia.com/mmforum ... =29&t=8607
He has described how the program works and how to interface the chip all these issues and step-by-step procedure of programming the clock chip. I have added two code in the bottom of the thread you can see..one is for RTC with keypad time set and another is for RTC with 3 push switch time setting. Second one is feasible for your application. You can directly start working on my last post in the mentioned thread..If you stuck any place post here I will help.
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. I am interested to add clock facility in my design.
When the user want to see the Input or Output Voltage, he just has to press a switch,
other than that time, the LCD should run as Clock.
Please guide.
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 »

Thanks Mr Enamul,
I have download your 3 Push button Clock code and studying the thread.
Yes, The article is very very helpful, Thanks
I have to study and convert for 16F72, then only, i will test and report.
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 »

When the user want to see the Input or Output Voltage, he just has to press a switch,
other than that time, the LCD should run as Clock.
I will add AVR code in the RTC code..also add the switch to swap between time and voltages as you mentioned.
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 »

Hi SKS,
I think I should tell you couple of issue regarding PIC16f72..it's memory is only 2K so you can't fit my current RTC code in it. I am removing time setting option from code and I think in that case you will be able to use that code in 16f72 IC..But 16f72 doesn't have EEPROM or I2C master..so we can use I2C software..I have done so already..without EEPROM it's a problem to put time set indicator. The only solution comes in my mind is to use a push switch in the circuit which the customer will not have access but manufacturer will have access..when you push that sw, program will load one time and date setting in the system and coin battery will maintain that in power cut.
Hope you understand what I am trying to mean.
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 »

Hi SKS,
I have manged to accommodate clock code in pic16f72 IC, but 69% memory is occupied. so you main code i.e, AVR code need to check whether it accommodated in it or not. But you can test this RTC program as you will become familiar with this which will help you later on.
Attachments
RTC_SET_16f72.fcf
(45.57 KiB) Downloaded 381 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 a lot for helping me in such a way. I don't have words to express my feelings.
Sorry, i was busy for designing PCB of 1st model, that is just with a LCD meter.
I just check the thread and found 3 reply from you with the Clock code and lot of information.
Thanks. I did not understand fully
" when you push that sw, program will load one time and date setting in the system and coin battery will maintain that in power cut." ?
Do you mean to say, in our end we have to set the clock (Date and Time with the coin battery on board). customer cant set the date and time.
If i am right, that is not a big issue for a low price model.
But for future model, i have to decide for a better chip. OK, let me test the RTC code.
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 »

Do you mean to say, in our end we have to set the clock (Date and Time with the coin battery on board). customer cant set the date and time.
Yes, customer can't set time and date in this version..it will be factory set.
If i am right, that is not a big issue for a low price model.
But for future model, i have to decide for a better chip. OK, let me test the RTC code.
Yes this is due to PIC16f72 limitations..if you move to pic16f876 or 877a you can have all features. You can try in local market PIC16f876 and PIC16f877a both should be available.
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.
I cant compile the RTC code in my Home/Student Version of Flowcode.
I have to wait till i upgrade my software.
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 can post hex for you..Active low switch is connected in RB0 which pulled up via 4.7K
Attachments
RTC_SET_16f72.hex
(7.63 KiB) Downloaded 328 times
RTC_SET_16f72.fcf
(45.57 KiB) Downloaded 344 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 the Hex file.
You have config the code for 20mhz crystal but i am using 4mhz in my Stabilizer code as well as in my hardware.
shall i change the crystal to 20mhz in my hardware and config my code to 20mhz ?
I have never done a clock using any micro so i don't know Where to connect SQW pin ?
Right now i am testing the sent hex file in 16f72 board after burning the chip.
The clock is there, showing time and date.
Please answer the above question.
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 »

Yes, you can change your crystal to 20MHz if you have otherwise I will change that to 4MHz. SQW will be NC (No connection) or open. I think I have mentioned about SDA and SCL. If the clock is running..then everything is fine.
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.
Sorry, i don't have 20mhz crystal with me right now, So please convert the RTC code for 4mhz crystal and send hex file to me.
Please guide how to set time and date with the push button switch.
The date is showing correct, but the shown time is not correct right now in my hardware.
Yes SDA and SCL is correctly connected and SQW is NC in my hardware.
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 SKS,
No problem. I am changing that to 4MHz. One small issue regarding time is you can set time what is mentioned in the program in FIRSTTIME macro. As you can't compile the program so you can't change that in the code..so what I want to do..I will put time at least 4/5 hours ahead and date is today's date. so you might download the hex late but hope that still before 4/5 hour..so whenever you run the code and press the button you will see clock is running ahead then normal. But you can simply restart your system and press the sw when it comes to the right time.
I guess you understand what I want to mean.
Attachments
RTC_SET_16f72.hex
Time:20:00:00&Date:18/10/12
(7.46 KiB) Downloaded 215 times
RTC_SET_16f72.fcf
(45.57 KiB) Downloaded 250 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 you due to my net down. Modem was offline for more than a day.
I had tested the clock code, its working. Thanks for suggesting to solve the problem.
But it will not be convenient for both of us, so let me upgrade my software, then only i will add clock in my Stabilizer design.
I have placed order for PCB, it will take 2 weeks max as here in India PUJA is going on, you must be knowing as you are from Bangladesh.
I will contact you after assembling and testing the stabilizer, as per my knowledge it will be a good product.
Thanks Flowcode and specially YOU for development of my product.

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 »

No problem..Take your time and I will suggest you to run the AVR with load for long time before supplying to customer. When you get your copy of professional V5?
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,

The demo model is in testing stage more than a week now, Working all right with full load. Thanks for your help.
I have sent the schematic for developing the 2Layer PCB to a firm in Bangalore, they have promised me to deliver next week.
Before final assembly, i will send you the details if you want to see.

Right now i have written a code for a Device called Power Guard. It is a small device by which no LOW or HIGH voltage will pass to your equipment,
When the set voltage range will be there, your equipment will be Power to your equipment. Bellow set Voltage and above set voltage the internal Relay will be at OFF state and a LED
will Blink, when the correct voltage will be there at INPUT, the Relay will ON, and the Blink of the LED will OFF as well as the LED.

For making the relay OFF if i write ".USE_AN0 <= 158 && .USE_AN0 >= 250" and "PORTB bit-0 = 0" the Relay i s not responding.
and i am not able Blink the LED, i am using a macro, it is not working. Once the blinker starts, it wont stop. Please guide or correct the code.

Thanks
With best regards
sks
Attachments
PowerGuard_Model_01.fcf
(15.52 KiB) Downloaded 268 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 »

Before final assembly, i will send you the details if you want to see.
I will love to see your final version of model 1.
Right now i have written a code for a Device called Power Guard.
Thanks for the description of power guard even though I have developed those devices in my early days of PIC..I am very much familiar with it.
I am having a look in your code and in your requirement and will post after correction.
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 »

Here is your desired program..if you feel LED is blinking fast please let me know. I can make it slow.
Attachments
PowerGuard_Model_01.fcf
(17 KiB) Downloaded 228 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 the code and help.
It is working but not as per my requirement.
The Blinking LED should start when the the INPUT voltage is bellow 158v and above 250v. Stops between 160v to 248v.
Please help.

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 »

When the set voltage range will be there, your equipment will be Power to your equipment. Bellow set Voltage and above set voltage the internal Relay will be at OFF state and a LED will Blink, when the correct voltage will be there at INPUT, the Relay will ON, and the Blink of the LED will OFF as well as the LED.
I have followed the above instruction as you have mentioned here..Above 250v or below 158v, you said RELAY should be OFF and LED will blink. But when voltage is at correct level which is 160 to 248v, the RELAY will be ON whereas LED is turned OFF.

I think in the last posted program only RELAY was switching in opposite order..LED was working OK. I have corrected relay switching as well..Please let me know how it is working.
Attachments
PowerGuard_Model_01.fcf
(17 KiB) Downloaded 225 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. It is working as per my requirement. I will test in the hardware and inform tomorrow.
Is FLIP is Complement of a Bit of a Port?
Please educate me about Macro. I just don't want to disturb you every time, you must be a busy man.
A new task has arrived. Its a 3Phase AC Induction Motor Control design. Can it be done using PIC 16F877A or i should go for 18F series?
Little bit of financial problem is there so upgrading of my Software is getting late. By next month 1st week i will upgrade.

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 »

Is FLIP is Complement of a Bit of a Port?
Actually FLIP is just a variable but NOT is flipping bit. You will see that in the code.
Its a 3Phase AC Induction Motor Control design. Can it be done using PIC 16F877A or i should go for 18F series?
PIC16f877a is enough for that purpose as this chip is a nice one and have nice features. Please post some details of that project so that I can guide you for that.
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 Help and Support.
Please correct me where i am wrong.
It is a VFD going to be used in a Printing press. I have thought to use 6Nos IGBT to drive the 3Phase Induction Motor.
All 3Phase load current has to be display in a multi line LCD Display along with the % of the Frequency to know the speed percent.
There should be 7 Control Inputs.
1. START Switch (Press Button Switch) with Soft start facility
2. STOP Switch (Press Button Switch)
3. RUN Switch (Press Button Switch) Slow rise facility
4. INCH Forward (Press Button Switch)
5. INCH Reverse (Press Button Switch)
6. Analog (Dial Control) Pot meter to Control the Running speed.
7. Analog (Dial Control) Pot meter to Control the Inching speed whether inching is forward or reverse.

Please see the attached file.

Thanks
With best Regards
sks
Attachments
motorctrl idea.jpg
motorctrl idea.jpg (48.46 KiB) Viewed 11885 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 SKS,
It looks like a nice project to deal with..Bit more challenging R&D. I haven't made one for me but I have studied 3/4 years back and hoping that will be a great experience.
Enamul
University of Nottingham
enamul4mm@gmail.com

Post Reply