Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

chronometer didnot work in real prototype but simulation work (protues)

Status
Not open for further replies.

ahatmob

Newbie level 5
Newbie level 5
Joined
Sep 15, 2014
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
egypt- cairo
Visit site
Activity points
54
hi i design a chronometer but didnot work in real prototype although it works in the protues simulation
there is the code work in simulation but not in the real mikro controller design here is the code:




Code dot - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//Chronometer original
//////////////////////////////
////// Pin direction
////////////////////////
sbit LCD_RS_Direction at TRISd4_bit;
sbit LCD_EN_Direction at TRISd5_bit;
sbit LCD_D7_Direction at TRISd3_bit;
sbit LCD_D6_Direction at TRISd2_bit;
sbit LCD_D5_Direction at TRISd1_bit;
sbit LCD_D4_Direction at TRISd0_bit;
////////////////////////////////
///// Lcd pinout settings
///////////////////////////////////
sbit LCD_RS at Rd4_bit;
sbit LCD_EN at Rd5_bit;
sbit LCD_D7 at Rd3_bit;
sbit LCD_D6 at Rd2_bit;
sbit LCD_D5 at Rd1_bit;
sbit LCD_D4 at Rd0_bit;
/////////////////////
////parameters
///////////////////////
const a,b;
long  t;
double speed;
char v1[12];
int x=0x00;
int y=0;
////////////////////////
////interrupt fn
/////////////////////////
 
void interrupt(){
  if(intcon.f0){
  t++;
  
              }
  
  
  if(intcon.f1){
y=1;
x = portb;
INTCON.f0=0;
INTCON.F1=0;
               }
 
 
 
 
 
 
portc=t;
 
 
          
 
                    }
 
////////////////////////////////////
// main fn
///////////////////////////////
void main() {
 
 
Lcd_Init();
b:
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1, "bullet speed m/s");
trisc =0x00;
trisb =0xff;
portc =0;
portb=0;
 
 
 
 
 
 
option_reg =0x90;
INTCON =0x98;
 if(y==1){
 speed=100000/t;
FloatToStr(speed,v1) ;
Lcd_Out(2,2, v1);
 
 
 
delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1, "take next shoot");
delay_ms(1000);
Lcd_Out(1,1, "bullet speed m/s");
delay_ms(1000);
t=0;
portc=0;
y=0;
/*INTCON =0x98;*/ }
 
 
goto b;
 
 
 
                }

 
Last edited by a moderator:

First you need to put ±10K resitor to MCLR pin in microcontroller to VCC!!! Its is called PULLUP Resistor!!! Many do not put this resistor and it does not work well in the real hardware!!!

See example:

File.jpg

Send source code and and real hardware schematic, and schematic proteus!!!
 
Last edited:

i use lm324 opamp instead of the buttons to make the interrupt and 2 potentiometer to adjust the threshold that will trigger the counter to estimate the time

- - - Updated - - -

this is the lm324 op/amp cct drow url:
 

port c show the interrupt counting each overflow of the timer in progress and the final result is displayed in the lcd as speed m/s
 
Last edited:

Sorry have no time to redraw the circuit in Proteus and create a new mikroC project just to compile and test the working. If possible Zip and post the complete mikroC project files and Proteus file.
 

As shown on your schematic the load capacitors for the crystal C1=1nF and C2=1nF are too high. They should be between 15 pF and 27 pF.
 

in the real design i change them with 30 pf cap andalso, the simulation run very good the problem in the real design on the bread board

- - - Updated - - -

i am trying to measure the speed of air gun pellet it is around 1 cm long and 220m/s speed that means need 0.01/220 seconds to sense it ie 45 micro second i use the lm324 op amp is this op amp speed enough to measure my interrupt signal pls help
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top