Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

[SOLVED] conveyor object counting

Status
Not open for further replies.

cyanpraveen

Junior Member level 3
Joined
Mar 31, 2011
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,527
in this below mentioned code the count gets keep on increasing wen led is turned off. but i need to increase the counter only once wen led turned off till it get turned on

if(LED1 == 0)
{
value++;
Count = value;


UserMessageStorage[4]= Count/100;
Count=(Count-(UserMessageStorage[4]*100));
UserMessageStorage[4]+=0x30;

UserMessageStorage[5]= Count/10;
Count=(Count-(UserMessageStorage[5]*10));
UserMessageStorage[5]+=0x30;

UserMessageStorage[6]= Count%10;
UserMessageStorage[6]+=0x30;

TotalCount[0] = UserMessageStorage[4];
TotalCount[1] = UserMessageStorage[5];
TotalCount[2] = UserMessageStorage[6];


SerTx(TotalCount[0]);
SerTx(TotalCount[1]);
SerTx(TotalCount[2]);
LED1 = 1;
}
Please help me .. thanks for ur information . i
 

eklikeroomys

Full Member level 3
Joined
Oct 11, 2010
Messages
151
Helped
40
Reputation
80
Reaction score
38
Trophy points
1,308
Location
South Africa
Activity points
2,144
Are you using a PIC? FPGA? You need to provide more information. Like what programming language this is etc.
 

cyanpraveen

Junior Member level 3
Joined
Mar 31, 2011
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,527
Well i am using p89v51rd2 microcontroller. i am using keil IDE.

if(LED1 == 0)
{
value++;
Count = value;


UserMessageStorage[4]= Count/100;
Count=(Count-(UserMessageStorage[4]*100));
UserMessageStorage[4]+=0x30;

UserMessageStorage[5]= Count/10;
Count=(Count-(UserMessageStorage[5]*10));
UserMessageStorage[5]+=0x30;

UserMessageStorage[6]= Count%10;
UserMessageStorage[6]+=0x30;

TotalCount[0] = UserMessageStorage[4];
TotalCount[1] = UserMessageStorage[5];
TotalCount[2] = UserMessageStorage[6];


// SerTx(TotalCount[0]);
// SerTx(TotalCount[1]);
// SerTx(TotalCount[2]);
// LED1 = 1;
}

ArrayBasePtr="TOTAL OBJECTS= ";
DisplayLCD(1,0,ArrayBasePtr);
ArrayBasePtr=&TotalCount[0];
DisplayLCD(2,0,ArrayBasePtr);

ArrayBasePtr="Objects ";
DisplayLCD(2,3,ArrayBasePtr);
TimeDelay(850);
LCD_CLEAR();

}
this is the updated code.. now i just want to increment the counter only once wen the light turned off. but for me its keep on incrementing wen led is turned off.. so pls help
 

eklikeroomys

Full Member level 3
Joined
Oct 11, 2010
Messages
151
Helped
40
Reputation
80
Reaction score
38
Trophy points
1,308
Location
South Africa
Activity points
2,144
I think you will need to implement an interrupt. The problem is that the value keeps on incrementing for as long as LED1 is 0 due to the if statement. An interrupt will cause the value to increment only once at the moment when LED1 goes low.
 

cyanpraveen

Junior Member level 3
Joined
Mar 31, 2011
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,527
Well thanks for the reply
@nandhu015 : i have tried your idea but its not working.. still the problem persist
@eklikeroomys : this my first program. this might be silly but i had no other way
can you help to write interrupt.. can u give me any sample program using interrupt like which interrupt is need to be used.. how to write ISR and how to call the interrupt from main etc..

thanks
 

andre_teprom

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,221
Helped
1,147
Reputation
2,313
Reaction score
1,123
Trophy points
1,403
Location
Brazil
Activity points
53,677
cyanpraveen,


Despite don´t know the scope in where your couter is indeed, I can point some info.
Generally, in industry conveyor counter we take some cares :
> Use of rottary Encoder to measure lengh of object.
> Measured in pulses domain, may validate the object counting, applying width filters ( min/max size )

+++
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top