Hello,
I'd like to calculate the speed of rotation from a conveyor band with a photoelectric sensor (switching frequency=500Hz, response time=1ms).
This sensor is connected to C167 pin 3.6 (T3IN). The wheel from the band has 8 black colour and 8 white colours and we will get HIGH/LOW through a change from the colours.
First, I'd like to count HIGH-Signal in a certain time and then calculate the rotation speed.
Here is my code, the number always increases, although the band is off. What did I do wrong?
How should I write the code for the calculating?
WORD T3IMAGE; void main(){ T3CON = 0x0401; T3 = 0; T3IE = 1; T3IC = 0x61; T2CON = 0x000D; T2 = 0; T2IC = 0x44; T2R = T3R =1; IEN = 1; while(1){ TIMAGE = T2; set_cursor(20,5); printf("Counter = %5u", T2); } T3IE = 0; IEN = 0; T3R = 0; T2R = 0; }
Thank you very much and sorry for the miserable language
Best regards, Ciek