I can't do it all at the same time!!!

Thread Starter

raidermanz

Joined Aug 14, 2007
32
I am working on an automation project. I need to sense the position of an object as it passes under a dispenser, delay a period of time which will depend upon the speed of the conveyor, then open the dispenser. In some instances this will all occur within 10-20 ms. The speed of the conveyor will be measured by an additional sensor. I can do this currently, however, as I have it now, in certain conditions, it will "miss" the object. I am trying to do this and a few other "bell and whistle" type things using a Pic16F877a, and I thought I had it. The problem seems to occur because at certain speeds, the dispenser is in an open sequence at the same time that the next object is interrupting. Should I use a 555 to time the dispenser opening so that the pic isn't trying to perform more than the one action at a time. Forgive me for not being as technical as some, I am a newbie, only versed in my compiler commands and the pic operations. I would appreciate any help I can get. Thanks.
 

RiJoRI

Joined Aug 15, 2007
536
I think that until you have the basic operation working well, the bells & whistles should not be used. Once you can fill the container, then add the B&W one at a time, in case they are causing the trouble.

I would have the software do something like:
On ExtInt:
....Stop Dispenser (Just In Case)
....Stop Timer2 (Just In Case)
....Load and Start Timer 1 (the delay to begin dispensing)

On Timer1:
....Start Dispenser
....Load and Start Timer 2 (how long to dispense)

On Timer2:
....Stop Dispenser

If you do not have two separate timers, use a state indicator:
On Timer:
....IF State == 1
........Start Dispenser
........Load and Start Timer (how long to dispense)
........State = 2
....ENDIF
....IF State == 1
........Stop Dispenser
........State = 1
....ENDIF

The dots are there to show indenting.

HTH,
--Rich
 

Thread Starter

raidermanz

Joined Aug 14, 2007
32
Thanks for the advice, that helps a lot. I have one problem with the total operation. There is a chance, under a high-speed condition, that the dispenser should open, and during the timed event, the sensor may trigger another external interrupt. I think I need the action of the dispenser to be completely separate from the processor control. I think of it as I am simply trying to create a square wave signal from the processor, which is variable in it's frequency, and even if the first wave hasn't reached the dispenser relay yet, the interrupt may still trigger the second wave. This may not make much sense, as I may not be explaining it correctly, so I appreciate all the efforts to help.
 

RiJoRI

Joined Aug 15, 2007
536
OK, I am picturing this as jars running on a conveyor belt, being filled with something.

You have a sensor, S, that trips when a jar "comes into range." Some time (T1) later, the dispensing starts. And some additional time (T2) after that, the dispensing stops. T1 and T2 are dependent upon the conveyor speed: the higher the speed, the smaller the times. (And, unless the dispenser's pressure is controlled by the conveyor's speed, the less full the containers will be.) If T2 can still be running when S trips, then the "Just In Case" lines can be removed.

OK, I just checked your PIC's data sheet: why not use the PWM output to drive the dispenser??

--Rich
 

Thread Starter

raidermanz

Joined Aug 14, 2007
32
Thanks, great suggestion. As soon as I read up on how to use the PWM, I will know more about how to answer your question...:). You have been a great help. Thanks, I will post again when I try this solution. Thanks again.
 

beenthere

Joined Apr 20, 2004
15,819
If you are in charge, then you might exert some control over the conveyor speed to insure enough time to fill the cirent container.

Also, since you seem to be dealing with interrupts, lock out further interrupts until the current one has been completed. The PIC can only do one thing at a time, although it can poll conditions to see what is about to happen.
 

Thread Starter

raidermanz

Joined Aug 14, 2007
32
The PIC can only do one thing at a time, although it can poll conditions to see what is about to happen.
That has been my problem. I cannot have the interrupt and the dispenser action "stepping" on each other. I do not have control over the conveyor, and speed will vary which could occasionally cause an interrupt during a call to activate the dispenser. I think the PWM might be a good solution, I just need to figure it out.

Thanks for the help.
 
Top