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:
Code:
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:
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.
Bookmarks