PDA

View Full Version : Counter pic16f84



miro245
- 12th April 2009, 21:14
Hello all !!!
I am new in programming,but in this moment I need help.I want make interface with pic16f84 for 8 electro mechanical counters.In main,I needs send decimal number with rs232 to PIC,and in one of them out pin,electromechanical counter must count impulses in value of sending of my PC.(for examples,I sent decimal value 10,and one counters must count 10 impulses).Is it possible and I need help.
Yhank you for all
Miro245

mister_e
- 13th April 2009, 00:21
What kind of mechanical counter are we talking about here?

miro245
- 13th April 2009, 05:36
HI !!!
I use electromechanical counter,and he works with 12V DC.Also I use IC driver ULN2804.Eny pinout and counter works diferents than other (If first count 10 impulses,second or ... count another number of impulses.I need help with this problem.
Best regards
Miro245

mister_e
- 13th April 2009, 06:13
I meant the part # of, this could help to find the datasheet...

HYETİK
- 13th April 2009, 11:33
more information we need pls. add more explanation,

I think pulsein command acn help you, try it or explain it completely

miro245
- 14th April 2009, 05:38
HII !!!
Look,my friend.I need make next :
I must have interface with PIC16F84,and also he must connect with my PC.With any terminal program,I need to send decimal number,like 10 or 15 etc. to interface.With interface,I need 8 electrome chanical counters (he works with 12 V DC).For Examples:If I send A10 or another number,PIC must count with first counter 10 impulses.Or If I sent H10, eight counter must count 10 impulses.The A...,B...,C...,D...,E...,F...,G... anh H... is name of counter or his address.
That is my problems and I must find solution for this interface.
Thank you for any help
Best reguards
Miro245

HYETİK
- 14th April 2009, 09:29
first you need to know how to communicate with pc using serial port, I have a laptop pc and it has no serial port so I dont know how to use serial port.

but you can search on this foorum,there are lots of examples about it.

you can send A10 or C10 to the pic with serial port, and the pic will select the counter according to the info that you send.

And to understand when the counter finish count, you should find a solution.
Does it informs you when it finish counting?

Melanie
- 14th April 2009, 09:33
Well here's 75% of your project complete...

http://www.picbasic.co.uk/forum/showthread.php?t=573

The other 25% is down to you...

miro245
- 14th April 2009, 15:49
Yes,I have NOTEBOOK and adapter USB to RS232.You are rihgt.But,First or other counter port out work diferents than another.Any counter received yours decimal number and work counting.In second solution,if I (examples) send to first counter A10 and he started counting,and in next moment I send second A20,he must make sum nad continue counts to finish.Other works like first..
Thank tou for yours help
Miro245

miro245
- 15th April 2009, 05:53
Thank you for you help.But,I have one question for you.If you send that one led blinks (examples) 15 second.He started,and in moment you send 10 plus.Is led blink countinius blinking 25 second???Is programs make sum like 15+10 seconds.???
Thank you once gain
Miro245

aratti
- 15th April 2009, 09:02
Miro245, for activating your electro-mechanical device (counter) you will need to put the pic pin connected to it high for few milliseconds than low again, in doing so you will obtain one count. So the sub routine for activating counter A could be as follow:


Label_A:
For A0=1 to ValueReceived
HIGH Pin_x
Pause 100
LOW Pin_x
Pause 100
Next A0
return


Now let's assume you will send via RS232 a command A10 pic will receive the command and will decode it. It will read address "A", it will load 10 in the variable "ValueReceived" and it will gosub "LabelA" (since address was "A").
Now the pic will make your electro-mechanical device counting up to ten, but since it is very slow pic will take two seconds to complete the job (100 millisecs + 100 millisecs x 10)
You have to understand that during this two seconds you cannot send anything to your 16F84 because otherwise it will be lost, since the pic is busy to make your electromechanical device counting.
One solution is that you wait for an answer from the pic telling you that the job has been completed and now it is still listening. To do that is pretty simple,
at the end of the count you will activate the following code:


SEROUT Pin_y,baudrate,["done"]

When your PC receive the word "done" you know that pic is available for receiving a new command, and you can send it. Now suppose you send A20
pic will do the same work already explained above, but it will count 20 and it will take twice the time (4 seconds). Your electro-mechanical counter was recording 10 (the previous command) so at the end of the second command it will record 30 (10 + 20 "additive capability of the device).

Pin_x and Pin_y are pic pins of your choise.

Hope this will help you in completing your project.

Al.

aratti
- 15th April 2009, 09:08
I use IC driver ULN2804.

I suggest you to use ULN2803 instead.

Al.

Melanie
- 15th April 2009, 09:35
Thank you for you help.But,I have one question for you.If you send that one led blinks (examples) 15 second.He started,and in moment you send 10 plus.Is led blink countinius blinking 25 second???Is programs make sum like 15+10 seconds.???
Thank you once gain
Miro245

The answers to all your questions are in the code...



'
' BLINK LED Command
' -----------------
If Command=3 then
For CounterA=1 to Yvariable
Gosub LEDsON
Pause 200
Gosub LEDsOFF
Pause 200
Next CounterA
endif