Pages: 1 [2] 3   Go Down
Author Topic: serious guidance required for a motion sensor (sort of) device  (Read 3090 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
God Member
*****
Karma: 7
Posts: 647
"In this house, we obey the Laws of Thermodynamics" Homer J. Simpson
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If counter < 3600 you are going to be flashing pin 7 on and off.
As soon as counter gets to 3600 you set it to 0 so it will, more or less instantly start flashing pin 7 on and off.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Since I am not the best to explain stuff, so i draw the flow chart


the system is kind of a motion sensor, it will monitor movement using a vibration switch (very very sensitive), and taking data probably every 1 second and give feedback with Green LED and red led at the same time, Green mean yes there is movement, Red mean no. After an hour it will give an overall feedback. e.g. lets say there were 3600 data in an hour, and if the number of YES(s) are 1800 or more it will turn LED off and repeat the program over again. otherwise red led will flash for few times and repeat the program

in the flowchart the digitalread(0) should be digitalread(2)>0
« Last Edit: December 10, 2011, 07:54:16 pm by whitepanda » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

any one got any idea?
Logged

Offline Offline
God Member
*****
Karma: 7
Posts: 647
"In this house, we obey the Laws of Thermodynamics" Homer J. Simpson
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Flowcharts are a good idea. Look at the bottom of yours, counter will almost always be less than 3600 so the program will almost always be going up the right hand side and flashing the red LED. When counter get to 3600 it will go up the left hand side once and zero counter, then start going up the right hand side again. It is always going to look like the red LED is flashing.
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 67
Posts: 3702
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The design seems odd - what is the delay(3600-counter) for? Also, it seems as though if you're not watching the device very closely,  you will miss the hourly led flashing report. Would it make sense to have another led to indicate whether there was activity detected on more than half the sensor reads in the hour? Or in other words - what is this device supposed to be used for?
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 98
Posts: 4808
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

With all those delays your system is mostly ignoring the vibration switch. Is that your goal?

If your goal is to detect vibration then you need to re-think your flowchart.

Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Offline Offline
God Member
*****
Karma: 7
Posts: 647
"In this house, we obey the Laws of Thermodynamics" Homer J. Simpson
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe if you thought along these lines things would start to become clearer.
Use three counters
  • Count the total number of times you go round the loop
  • Count the number of times you go down the green leg
  • Count the number of times you go down the red leg

At the bottom of your program have some logic that does things based on total number of times you have been round the loop.
I agree with WildBill that you probably want to use more LEDs otherwise you will miss what happens when the total times round the loop is 3600 or 1800. GoForSmoke is also correct that you are hardly ever reading you switch.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have changed the delay much 10 - 20 so i will not miss any events.
loop should go around forever, and give feedback every hour ( in this testing case, scale down to 1 min)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the device is used for detecting leg movement (due to cost and component available, i was only given a vibration switch which will only have simple on and off) and if there wasn't enough movement over an hour, it will warn the user
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 98
Posts: 4808
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You might want to live-test your switch on a leg as fast as it can run just to see what you get. You can then say definite things about the switch and leg setup.

Like for all of loop() {
  if the switch is on, turn off the red led and light the green led, else turn green off and light red
}

Then see what you get when you don't move your leg on purpose. Maybe you get flashing lights always and need to modify your setup. It's best to find that through unadjusted data.

From your goal I get the idea you want to track non-movement. Don't make any delays longer than half of what you can afford to miss catching a change.

Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Offline Offline
God Member
*****
Karma: 7
Posts: 647
"In this house, we obey the Laws of Thermodynamics" Homer J. Simpson
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
the device is used for detecting leg movement (due to cost and component available, i was only given a vibration switch which will only have simple on and off) and if there wasn't enough movement over an hour, it will warn the user
Quote
it will monitor movement using a vibration switch (very very sensitive)

You should be able to do what you want with the components you have available, but it might be worth taking a step back and clearly stating your objectives.

You are trying to warn somebody that they have not moved their leg sufficiently is that correct?
Is the purpose to ensure they maintain circulation to the limb?

How long  can the person leave their leg without circulation, I would suggest 10min max.
Therefore there is no point in warning the person after an hour, that is way too long.
Also you describe the vibration sensor as "very very sensitive", will it react to levels of movement less than that required for circulation in the leg i.e. general upper body movement/vibration such as breathing (this should be easy to test just strap it your leg, keep your leg still but breath, move your arms etc.). If the sensor reacts to movement other than just the leg then you will need to be smart in how you use it to ensure circulation is being maintained.

This might be going off at a tangent but have you considered applying appropriate, safe, voltage to the leg muscles to make them contract/relax.

Yet another silly though, I don't suppose the sensor is sensitive enough to detect a pulse
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 67
Posts: 3702
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So from a user's perspective, what do they care about the red and green led as they are set up now? Useful to you in debugging, but doesn't tell them anything. How about having red yellow & green and light them to indicate whether the user has too little movement, some movement & enough. Check the sensor every time round loop and see if movement is detected in the last second. Keep count of elapsed seconds and the count for those in which movement was detected. Do a little math & light the leds accordingly. No need to use delay at all.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You are trying to warn somebody that they have not moved their leg sufficiently is that correct? Yes, it is used to reduce the risk of deep vein thrombosis. 10 mins seems too short as most people can sit and not move i would say at most 1 hour and a bit more without problem. so we choose 1 hour. in the prototype the sensor will be placed on the socks around the calf.

windbill: this was something we had in mind, but we want it to give overall feedback every hour, as well as instant feedback.
instant feedback like every 1 or few sec. it light up red or green to tell you no movement or there is movement.
and overall feedback based on not enough movement over an hour. as we wanted to make sure the program does work first (where the most mark will be given on working prototype) the value of accuracy may not be in play, as we need to present it in a trade show, which i don't think lecturer will be interesting to watch us playing with it and wait for an hour to see if it work or not.
Logged

Offline Offline
God Member
*****
Karma: 7
Posts: 647
"In this house, we obey the Laws of Thermodynamics" Homer J. Simpson
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
most people can sit and not move i would say at most 1 hour and a bit more without problem
I know pandas are sedentary but an hour is  a long time smiley-grin

I thought you might have had in mind somebody who had lost feeling in their legs and the device was to warn them to move.
If the problem is deep vein thrombosis then maybe you should try to see if the sensor can be used to detect a pulse in the ankle.

 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i don't exactly mean actual NOT moving like panda just chew bamboo, at least very very limted movement for about an hour... even our lecturer give us lecture from 2pm till 5pm with no break in between, and just sit n listening  smiley-sad-blue
Logged

Pages: 1 [2] 3   Go Up
Jump to: