CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Measure the length on a subject moving?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








Measure the length on a subject moving?
PostPosted: Thu Dec 11, 2008 3:21 pm     Reply with quote

Hi

I working on a add on project to a pre build machine where I want to measure the length on a subject moving 4m/s.
There are some fotosensors and an encoder in the machine I can use for my project.

I will use 2 of the fotosensors and the encoder to measure the subject.
I want to measure the length of the subject 2 times one at foto_1 and one at foto_2 if there are maybe 10 encoder pulses in difference the subject is bad!

The problem is that the machine pickup and feed the subject at 8000 pcs/h. The subject is in constant movement.

If I use a timer as counter and compare the result of the count, the rollover to 0 can be a problem. If one read if 0xfff2 and the next is 0x20 I get wrong result?

Another problem is handling the incoming subject, will I need a fifo?

Any comments:-)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Dec 11, 2008 3:29 pm     Reply with quote

Quote:
If one read if 0xfff2 and the next is 0x20 I get wrong result?

Test it. Many questions like this can be answered by making a test
program. Try this code. What do you get ?
Code:
#include <16F877.h>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//=========================================
void main (void)
{
int16 a, b, c;

a = 0xFFF2;
b = 0x0020;

c = b - a;

printf("Result = %LX \n\r", c);

while(1);
}

Note that in CCS, an 'int16' is an unsigned 16-bit integer.
Guest








PostPosted: Sat Dec 13, 2008 11:24 am     Reply with quote

Some reflections on the project.

If there 5 fotocensors(FC) and all subject are placed just before the FC. I face some problem to make proper detection. First idea was to “or” all sensors and put them to one ext int pin, if I get a int I can poll for which sensor. But if one sensor make the trigger int. and I process this, and in this processing another sensor get covered I will miss this int?

How to handle process flow with maybe 5 FC there are not in sync and must be handled just after they are covered. With not in sync I mean, maybe FC 1 is covered and in the middle of being handled. Then FC 2 get covered but I don't see it, because I am in the int. and when leaving this int the software clear my int.

Some help is needed.
Guest








PostPosted: Sun Dec 14, 2008 3:39 am     Reply with quote

Hi

Trying to rewrite this...


I want to measure on a moving subject 4m/s → 4mm/ms. I have 5 fotocensors(FC) end one syncron puls generator in the machine I can use for my project.

I want to measure my moving subject at every FC.

If there are 5 fotocensors(FC) and all subject are placed just before the FC. I face some problem to make proper detection. First idea was to “or” all sensors and put them to one extern interrupt pin. If I get a interrupt I can poll for which sensor. But if one sensor make the trigger int. (object detected) and the cpu is just processing from another FC, I will miss this int?

How to handle process flow with maybe 5 FC there are not in sync, and they must be handled just(near by) after they are covered. With not in sync I mean, maybe FC 1 is covered and in middle of being handled, then FC 2 get covered.

Another way to handle this can be by using the encoder. Setup as “ccp” for interrupting every 0,5 m/m(some puls tick). But if the speed is 4mm/ms, then 0,5mm will be about 125us. This will take near all my cpu time(clk 8mhz) because it also take some time to read my FC and enter and leave the interrupt.

I'am little confused how to handle this?

Some help is needed.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group