Easy Basic Stamp Question... I HOPE..
str4t3gy
Posts: 2
Hey everyone.. i am doing a parallax project for school and i am using a bs2 to run a conveyer belt system and i have completed all of the programming except i need to find a way to use a timer in my program.· The idea is to have an infrared sensor to distinguish between a big block and a small block based on certain time that the sensor is broke from the block passing through.· If it is broke for a long time i want to signal a pump to push the block off the track as it goes down the track so far, and if the block is small and only breaks the signal for a short time i want it to continue down the conveyer.· any ideas would be extremely helpful?! Thank you ·
Comments
You set up a simple reflective encoder wheel to count pulses per revolution. Say the encoder has 10 pulses per revolution and is 2 inched in diameter.
2 * 3.14159 = 6.283 and divide by 10 you have a counter pulse for each .62 inches of travel.
Waiting for the block ir sensor to change state, you would save the state of the conveyer sensor and then monitor the conveyer sensor and the block sensor.
Counting the conveyer pulses you calculate the length when your block sensor changes state.
Depending on the resolution you need (block size difference needed to be measured) you increase your encoder wheel to what you need.
If for ecxample you set it up for 1/4 inch per pulse the minimum count would be 3 for a 1 inch block if both sensors were exactly lined up as you would have a pulse (state change) at 1/4 then 1/2 then 3/4.
It could be a count of 4 if it was not lined up exactly and a box size of over 1.25 would be necessary to give a 5 count.
Using 100 pulses per revolution you could measure much smaller differences in box sizes.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
mike green- im not quite sure how u would use this pause 1 in a (??wait loop??) as a timer to trigger a pump to push over a block if it counts for too long, or to have it not activate the pump if it is a short block.. would u be able to show me just an example of a code that you would use to accomplish this task??
metron9- im sorry i am not really any good with parallax yet, i have been reading and am going to keep on experimenting with different codes and try to get a good grasp with all that basic stamps can accomplish. But right now i am kind of puzzled on how you code in these pulses ect. to work properly. The diameter of this track wheel is 1 inch, so that would be 3.14/10 which would be .314 inches of travel, and the blocks that need to be distinguished are 1.5 inches for the long blocks that i want a pump to push off the track later on, and the small ones are 1 inch that i want the pump to ignore and let go through down further on the track.. if you could give some type of mock example code for this situation i would really appreciate it!!
Lets use pin 1 to monitor the block on the belt and pin 2 to monitor the pulse from the belt wheel
1.5 inches / 0.314 = 4.77 signals per block maximum
1.0 inch block / .314 = 3.18 signals per block maximum
Since we can't measure the decimal part we end up with 4 signals for 1.5 inch and 3 signals for a 1 inch block.
What is the minimum signals
If the block sensor and the wheel sensor both changed states at the same time (leading edge of the block is in sync with the leading edge of the encoder wheel)
We would read both pin 1 and pin 2 signals and count transitions on pin 2 (the wheel) while pin 1 was still high (assuming we set up the block sensor to read high when a block is sensed)
Now the transitions counted would be at .314 - .628· - .942 - 1.256 and then pin 1 would change to low as the trailing edge of the 1.5 inch block went past the sensor.
That would be 4 counts
If the block entered a bit earlier we may have a count of 5 since the first transition on the encoder wheel would trigger
So we know a count of 4 or 5 is a 1.5 inch block
However we have a problem. If a 1 inch block entered just a bit before the encoder we might indeed get 4 counts as well
So we need to double the encoder to 20. now we go through the same thing but using .157 steps per encoder.
1.5 / .157 = 9.55
1 / .157 = 6.3
So we can deduce that if the count is greater then 7 it must be a 1.5 inch block
Lets do the code
·Remember, you may have to stop the conveyer belt depending on how close the blocks are to each other or you may miss a block.
·Not sure why code is not formatted with cut and paste so I have attached it as well.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
Have fun
microwaveteach@hotmail.com
Jaime Ibarra (Mexico)
Just use 2 sensors to read the block. Put the sensors 1.25 inches apart. When a 1.5 inch block blocks both sensors you know you have a larger than 1.25 inch block.
Code something like this
waitforblock:
if in1 + in2·<> 2 then waitforblock
process bigblock
goto waitforblock
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!