Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Recording speed of an Action

Status
Not open for further replies.

atuldey

New Member
Hi Guys;
My very first query was messed up, so I am posting my query again.
My project has two objects, one stationary and other mobile.
When the mobile object touches(at a slow speed) the stationary object, a LED should light up....this is the easy part. Next, when the same mobile object is moved very fast towards the stationary object, another LED should light up and it should Flash! indicating that the action has been very rapid as against a lethargic movement...This is the Important part of my project.
Please help me with this problem!!
 
Time stamp the starting point (when you set the object in motion)
Time stamp the ending point (when the object hits the obstical)
Subtract the two and you have a difference. The small of the two differences is going to be the faster object.
 
what is your problem?

is it mathematics?

what sensors are going to use to detect the start and stop time?

i propose 1 IR led sender, and 2 receivers, with this sensor placed infront of the moving object, any stupid uController can perform the tast of calculating the speed of the moving object, by comparing the time at which the 2 sensors were trigered.
 
Hi;
No, the problem is not maths!
In fact the Subject heading is diverting you guys to wrong solution. I am not looking for recording the speed of the action
My problem or rather I am looking for this solution:
When the mobile object touches(at a slow speed) the stationary object, a LED should light up....this is the easy part. Next, when the same mobile object is moved very fast towards the stationary object, another LED should light up and it should Flash! indicating that the action has been very rapid as against a slower movement...This is the Important part of my project.

Let me explain with a simple example:
It is like pressing on your Gas-Paddle while driving a car. When you press the Gas-Paddle ( I presume slowly) a LED should light up. Now, imagine you press the Gas - Paddle all the way down, the action of your foot ( or the Paddle) is very swift. The circuit should acknowledge this change of motion of the paddle ( the swiftness) and light up another LED ( may be different color or just flash). Here, the Gas-Paddle is a moving object and the floor of the car is a stationary object.
I hope I have been able to explain the problem!!

Thanks!
 
atuldey said:
.
I hope I have been able to explain the problem!!

No you have not.

You started by talking of one object hitting another, then the analogy of moving the accelerator pedal of a car is used.
I am totally confused.

WHAT DO YOU WANT TO MEASURE???

An impact between two objects?

The speed of an object?

The acceleration of an object?

What are the object involved? If we dont know what it is, how can we suggest ways of measuring it?

Define the problem clearly and you may get some meaningfull replies.

JimB
 
ok, I'll take a stab at it. He wants to determine when the mobile object moves above a certain velocity. I assume that the indicator is on the stationary object. This requires determining the distance of the object at specific periods and computing the speed.

If that is correct, you need a distance sensor in the stationary object that can track the mobile object. The uC would read the distance at periodic intervals and compute the speed. when the speed is above the threshold, the hi speed led gets lit.

seems like a wierd school assignment
 
Dear Philba:
You are very close to what I am looking for in my project:
"The uC would read the distance at periodic intervals and compute the speed. when the speed is above the threshold, the hi speed led gets lit."
Any idea, which UC I can use or if have come accross a circuit I can use!!
 
If you use a PIC micro, you could either use a potentiometer and connect it to the mechanical movement of the lever/object that you are monitoring speed. Then do the following in your program;

* Create a time interval routine
* Every 1/100th of a second (or less), make a new reading from the pot
* If last value is more than new value by a certain amount (i.e. - its accelerated to fast) then turn on LED2, but if the acceleration is within limits then turn on LED1

This would work if your problem consists of a mechanical movement such as the 'gas pedal' as you described earlier.

If the mechanical device is moving extremely quickly all the time, a potentiometer will probably be subject to mechanical failure..

Perhaps there's other better mechanical 'voltage dividers' out there instead of pot's
 
atuldey said:
Any idea, which UC I can use or if have come accross a circuit I can use!!

No we have not. You do not even tell us what the oblject is, or how its speed is being measured, so how do you expect anyone to make a sensible suggestion as to which hardware to use?

JimB
 
I posted earlier and thought I'd better explain what I meant a bit more.

I threw something together really fast, it can definitely be refined, I used a a lot of variables to try and help you follow the code, its written in Proton+

This is untested, but just my view of a solution for your problem.

PHP:
Device 16F876A
Declare XTAL 4

'_______________________________________________________
' ADC compiler settings / declares

DECLARE ADIN_RES 10 		' 10-bit result required 
DECLARE ADIN_TAD 8_FOSC	   ' RC OSC chosen 
DECLARE ADIN_STIME 50 		' Allow 50us sample time 

'_______________________________________________________
' Define program variables

Dim ADC_Result As Float
Dim ADC_Total As Float
Dim ADC_Channel as Byte
Dim ADC_Loops as Byte
Dim Temp as Byte
	
Dim First_Result As Word
Dim Second_Result As Word	
Dim Difference As Word
Dim Last_Difference As Word

Symbol Max_Deviation = 10 		' Set the max deviation (i.e. acceleration)
Symbol mS_Time_Sample = 50	   ' Set the interval for sampling (mS)	
Symbol LED1_Control = PORTB.0	' Assign the outputs for the LED's
Symbol LED2_Control = PORTB.1	'

'_______________________________________________________
' TMR0 Settings

Dim uS as Word
Dim mS as Word
Symbol GIE = INTCON.7	
Symbol TMR0_uS = 512		  ' Set time interval of TMR0 with 4Mhz Osc
Symbol TMR0_Enable = INTCON.5
Symbol TMR0_Overflow = INTCON.2

'_______________________________________________________
' Start of program

ON_INTERRUPT Goto Interrupt_Sub

Goto Initialize
	
Initialize:

	INTCON = %00100000			' Config the Interrupt Register
   	OPTION_REG = %00000000 		' Config the OPTION_REG
		
	TRISA = %11111111			' Set porta/b pins		
	TRISB = %00000000
	PORTB = %00000000
	
	ADC_Loops = 100 			' This controls the accurracy 
	 	 	 	 	 	        '   of the ADC routine	
 	ADC_Channel = 1
 
	ADCON1 = %10000000 			' Set analogue input, Vref is Vdd
	
Main:

	 ' Grab a 10-Bit value (0-1023) of what the voltage is on PORTA.0
	 Gosub ADC_Average
	 
	 ' Store the value
	 First_Result = ADC_Result
	 
	 ' Zero the timer settings
	 uS = 0
	 mS = 0
	 TMR0 = 0
	 GIE = 1
	 
	 ' Loop until the specified time is reached
	 Repeat
	 
	 Until mS = mS_Time_Sample
	 
	 GIE = 0
	 
	 ' Check what the new value of PORTA.0 is 
	 Gosub ADC_Average
	 
	 ' Store it
	 Second_Result = ADC_Result
	 
	 ' Check which direction it has moved, 
	 '  then calculate its amount of movement
	 If First_Result > Second_Result Then
	 	Difference = First_Result - Second_Result
	 Else
 	 	Difference = Second_Result - First_Result
	 Endif
	 
	 ' Check which direction it has moved, 
	 '  and determine if its to fast
	 If Difference > Last_Difference Then
	 	If Difference - Last_Difference >= Max_Deviation Then
		   LED1_Control = 0		
		   LED2_Control = 1
		Else
		   LED1_Control = 0		
		   LED2_Control = 1
		Endif
	 Else
	 	If Last_Difference - Difference >= Max_Deviation Then
		   LED1_Control = 0		
		   LED2_Control = 1
		Else
		   LED1_Control = 0		
		   LED2_Control = 1
		Endif	 	
	 Endif 

	 ' Store the last difference to compare with next time
	 Last_Difference = Difference
	 
	 Goto Main
	 
ADC_Average:  	' Grab an average of the ADC value, increases
				'  accuracy greatly
	ADC_Total = 0
	For Temp = 1 To ADC_Loops
		ADC_Result = ADIN ADC_Channel
		ADC_Total = ADC_Total + ADC_Result
	Next Temp
	
	ADC_Result = ADC_Total / ADC_Loops
	
	Return 
	
Interrupt_Sub:

	Context Save

	If TMR0_Overflow = 1 And TMR0_Enable = 1 Then
	   TMR0_Overflow = 0
	   uS = uS + TMR0_uS
	   If uS >= 1000 Then
	   	  uS = uS - 1000
	  	  mS = mS + 1
	   EndIf
	EndIf
			  
	GIE = 1
	
	CONTEXT RESTORE

It compiles to 946 Words of code, and you must use a device such as the 16F876A with ADC
 
Last edited:
gramo, I think the mobile and stationary units are not connected.

atuldey, you can use any uC. your biggest challenge is to figure out how to do ranging (distance measurement). there are several approaches: ultrasonic, IR and true radar. all 3 require that you track the object since the beam is highly directional. so, you will need tracking as well as ranging. I think true radar is out of the question. get googling.
 
Hi Gramo and Philba;
No measurement please!!
Even after acknowledging earlier that Philba, you got me right...I am trying to figure out how I can make the second LED light up once the moving object (the Paddle) moves at a faster speed ( like instantly pressing the Gas-Paddle)as against routine or normal pressure on the gas paddle ( first LED lights up).

Gramo...You are close, but could you please suggest me with my explainations above...
 
Hi,
I could finally upload my project. I hope you guys can now help put this project together.
Thanks..
 

Attachments

  • Project.JPG
    Project.JPG
    50.2 KB · Views: 136
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top