Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Advise on how to use a PIC. To Control a Calender Dial

Status
Not open for further replies.
Hi markelectro,
Ok, there you are the most simple circuit i can suggest, keeping in mind its reliability.
In contrast of what it said previously, i took the freedom to modify the circuit of the calendar to simplify the electronic part.
Pulsing the inductor by the negative, the microcontroller can exciting this by a simple NPN (BC337).
The diode D1 is very important to short the high voltage produced when the swich turns off.
All other pulse switches existing must have one diode also. If not, the high voltage, can produce interferences on our PIC.

Ok, about software i will try to have some time to think a little time to design the flowcharts in first place.

In a first sight we need the follow routines / functions:

timer_interrupt: to handle timings for key, led and pulses IN/OUT.
key_handle: to handle the states of the key like CLICK, LONG KEY DOWN, etc.
led_handle: to handle led states like blink when key pressed, flash n times, etc.
config: to set day/month from the key states and save this parameters in the internal eeprom.

For all this i suggest the use of machine states that is the most reliability way to maintain the things under control.
Don't be afraid, when you see, you find out that is very easy and your programming style never more it will be the same.

To acomplish your request, in the next post i will explain how this hardware works.

Regards,
jolino
 

Attachments

  • daysw_2.jpg
    daysw_2.jpg
    57.2 KB · Views: 112
Last edited:
Jolino

Wow thanks very much for this.It would be very difficult for me to get my head around this on my own. As you know this is my first project and I'm sure when this is finished I will have learned lots of usful tips.

Again many thanks for this and I look forwards to your replies.

Regards Mark

jolino said:
Hi markelectro,
Ok, there you are the most simple circuit i can suggest, keeping in mind its reliability.
In contrast of what it said previously, i took the freedom to modify the circuit of the calendar to simplify the electronic part.
Pulsing the inductor by the negative, the microcontroller can exciting this by a simple NPN (BC337).
The diode D1 is very important to short the high voltage produced when the swich turns off.
All other pulse switches existing must have one diode also. If not, the high voltage, can produce interferences on our PIC.

Ok, about software i will try to have some time to think a little time to design the flowcharts in first place.

In a first sight we need the follow routines / functions:

timer_interrupt: to handle timings for key, led and pulses IN/OUT.
key_handle: to handle the states of the key like CLICK, LONG KEY DOWN, etc.
led_handle: to handle led states like blink when key pressed, flash n times, etc.
config: to set day/month from the key states and save this parameters in the internal eeprom.

For all this i suggest the use of machine states that is the most reliability way to maintain the things under control.
Don't be afraid, when you see, you find out that is very easy and your programming style never more it will be the same.

To acomplish your request, in the next post i will explain how this hardware works.

Regards,
jolino
 
Hi marelectro,

Continuing from last post...

1. PULSE CATCH
The idea is, when the calendar inductor is powered by the electromechanic switch, the optocoupler put 0V (LOW) in the GP0 (PIN 7) of PIC.
So, the PIC read and count pulses.

2. SWITCH BY-PASS
When the calendar change from 30 to 31 in one 30 days month, the Q1 generate an additional pulse, as required.
But now the software knows that this pulse is "fake" and in fact it assume day 1 of next month.
For the Feb(28/9 days), it requires 3 or 2 additional pulses.
So, it would be funny if software knew to deal with the leap years. Anyway, this may be seen as one future ability.

3. SET MONTH AND DAY
To configure the PIC with one simple key, for two parameters, i use to do this:
a) Press and maintain the key down until Led flash twice.
b) Release the key and click n times according to the callendar day number.
For each click, the Led will blink one time to show valid CLICK.
c) When done, wait for timeout lets say 5 secs. When timeout is finished,
the Led will flash three times. This tell us that the system waits for month
setting.
d) Click the number of times acording to the number of month, JAN=1, FEB=2..
e) Forget the key and wait for the Led flash... 4 times.
f) After that, the software will save this settings inside of the internal eeprom and jumps to the RUN state.

4. SUPPLY SECTION
As you can see we have a 5V 78L05 (case=TO92), from the 12V main supply included in your clock/calendar system.This is required to supply the electronic section.

5. EXISTING CALENDAR CIRCUIT
Like i said in the last post, i don't know if the circuit is connected as i suggested or not, but if you do thus, our electronic circuit it becomes more simple.

The next post will be about software.

Note:
It would be interesting that you continued your learning. Also it's very important to know the PIC architecture as well the instruction set. Certainly much people can answer to your doubts.
The ideal would be that you start to plan the skeleton of software and later putting your hands on work. It's not so hard as you think.

That's all for now.

Regards,
Jolino
 
Last edited:
jolino
Thank you very much indeed for this breakdown it really does make it a lot easier for me to understand where I am. I suppose when I get down to making this up it will make even more sense. I think a parts list would be a good idea.
Would it be of use if I were to take photos of the parts involved for you to see?

Regards Mark
 
Jolino

I think it may be best if I point you to a couple of websites with the equipment just so you get a more technical description.

For the type of clock to be used to power the programmer from the clocks 30 sec output,mine is fig 3 mk 5 & 6 clock

**broken link removed**
Please see opperation 2 in the description for half minute pulses,this will drive the programmer.


for the programmer please use this link-
**broken link removed**



For the Callender slave-But mine has a 31 toothed wheel not 120 like in the photo.This will recieve a impulse from the programmer 1 in 24 hrs.
Of course the electronics will go between them.

**broken link removed**

If you can see any issues in what I have show you please let me know.

Regards Mark
 
Last edited:
Hi markelectro,
Very beautifull mechanic pieces.

What i can see about callendar is just a collection of photos.
I can't find any coil current specifications. I suppose that at least 1A is enough?
If this is true, then BC337 must be replaced by one more powerfull.
The darlington BDX33C (case=TO220) is more than enough.

About software:
As you may know, "c" can vary from one compiler to another.
So, can you to put here the C Compiler Reference Manual or tell its name?
This is relevant to adapt the code that i have for your compiler.

Regards,
Jolino
 
jolino said:
Hi markelectro,
Very beautifull mechanic pieces.

Hello Jolino and Many thanks,just want to try and make them even better!!


jolino said:
About software:
As you may know, "c" can vary from one compiler to another.
So, can you to put here the C Compiler Reference Manual or tell its name?
This is relevant to adapt the code that i have for your compiler.


The compiler the course uses PICCLITE
https://www.htsoft.com/products/compilers/PICClite.php

Hope this helps !!!

Regards Mark
 
Hi markelectro,
Sorry, i have been very busy in the last days.
Using the advantage to have in hands a similar application to yours, i inform you that the software is almost ready.
The next stage, consists of adapting it for HITECH compiler.
Please, wait a few more days.

Regards,
jolino
 
Jolino
No problem at all.I realise I have to wait I'm just happy that you a willing to help.
At the moment I am working through your circuit drawing and re-drawing it in livewire.I am doing this just to get to know the components that are used.When I have done this I will upload a copy of what I think is right for you to scan through.If all is of I will then purchase the parts and start to build.

One question I have is which would be easier to use C or ASM. code?

Again many thanks Mark




jolino said:
Hi markelectro,
Sorry, i have been very busy in the last days.
Using the advantage to have in hands a similar application to yours, i inform you that the software is almost ready.
The next stage, consists of adapting it for HITECH compiler.
Please, wait a few more days.

Regards,
jolino
 
Hi again markelectro,
Original markelectro:
One question I have is which would be easier to use C or ASM. code?
I use c all the time and the same is true for this "app".
At least for me c is, let me say... more straight forward.
Occasionally and when justified, i use assembly.

However, i realize that for PIC learning, ASM is essential.

Regards,
jolino
 
Hi! Jolino

Just wanted to ask if you had any progress with the programme?

I do ealise you are very busy so when you have time this is ok.

As you will know I am very much looking forwards to get this going and I thank you for the help that you have given me.

Regards Mark
 
Status
Not open for further replies.

Latest threads

Back
Top