How to read multiple pings' value for basic stamp 2 at the same time
PeterJiang
Posts: 9
Hello everyone! Here's a question about basic stamp 2 , hope someone can help >.<
I have 12 hall sensor,and i have to check all these sensor's output value at the same time and then send the output to matlab.
I tried to use the function "debug" to check every pings
The code is like below
Main:
DO
DEBUG BIN IN15,BIN IN14,BIN IN13,BIN IN12 ,BIN IN11 ,BIN IN10,BIN IN9,BIN IN8,BIN IN7,BIN IN6,BIN IN5,BIN IN4,BIN IN3,CR
LOOP
END
But it seems that every pings' value will show one by one,I want that all the pings' value can be read and then shown at the same time
Could everyone provide me some functionsto use or code?
Thanks,
Peter
I have 12 hall sensor,and i have to check all these sensor's output value at the same time and then send the output to matlab.
I tried to use the function "debug" to check every pings
The code is like below
Main:
DO
DEBUG BIN IN15,BIN IN14,BIN IN13,BIN IN12 ,BIN IN11 ,BIN IN10,BIN IN9,BIN IN8,BIN IN7,BIN IN6,BIN IN5,BIN IN4,BIN IN3,CR
LOOP
END
But it seems that every pings' value will show one by one,I want that all the pings' value can be read and then shown at the same time
Could everyone provide me some functionsto use or code?
Thanks,
Peter
Comments
The Stamps are single threaded microprocessors. They do only one thing at a time. The PING is designed to be controlled using the PULSIN statement of the Stamp. This causes the Stamp to wait until the rising edge of an input pulse on a single I/O pin, then wait until the falling edge occurs while measuring the time between the rising and falling edges of the pulse. The time is returned by the PULSIN statement by storing it in a specified variable.
The PING has to be triggered with a short output pulse and the input pulse begins quickly after the trigger pulse. You can read a single PING at a time, one after another, and store the results in a series of variables, then output the variables to MATLAB one after another with a single or multiple DEBUG statements.
The purpose for asking this question is that I want to test 12 hall sensors and observe their high-low voltage value
for your comment above,I have to wait a cycle,spending 1/4 second,then I can read the value of the same PING again ,is that right ? But waiting 1/4 second for my hall sensor experiment is a little long time
The changing of flux may be disappear within 1/4 second.
So the only way to solve my question is extending the time for changing of flux?
Welcome to the forums! I am a little confused about what you're trying to read...are you trying to read multiple PING))) Ultrasonic Range Finders and Hall-Effect Sensors? Or are you just referring to the Hall-Effect Sensors when you say ping?
I want to read the high-low voltage value for hall sensor,as the code above,high will represent"1" and low will represent"0",that is what i want to read.
And here is the website for datasheet of the hall sensor
http://www.feeling-tech.com.tw/km-master/ezcatfiles/cust/img/img/26/fs41g1-a_v12.pdf
thanks for ur replying!
If you connect the Hall-effect sensors to I/O pins 0-11 of a Stamp, you can easily read the state of all 12 sensors at the same time by using the expression "INS & $FFF" (without the quotes).
INS is a 16-bit register that contains all 16 I/O pins of the Stamp represented as a single 16-bit value with I/O pin 0 as the least significant bit and I/O pin 15 as the most significant bit. Since you're using only 12 I/O pins, you only need the corresponding bits, so you mask the other 4 I/O pins off using "& $FFF". You can send this as 12 binary digits by using "DEBUG BIN12 INS". The "BIN12" will send only the least significant 12 bits which is what you want.
Remember that your Hall-effect sensor has an open collector output. You'll need a pullup resistor on each Hall-effect output. A 4.7K to 10K resistor connected to Vdd (+5V) will do.
A few years ago, someone posed a question about PING when they actually meant PINK and there was a similar flurry of miscommunication for several replies. What a difference a letter makes!
Using:DEBUG BIN12 INS is what I want.
It shows around 12x40 data in the debug screen.
So it's the maximum speed that basic stamp can show the data for my hall sensor experiment?
A "pin" typically refers to a particular BS2 input/output (I/O) connection, of which the BS2 has 16. The BS2 has other pins used for power, ground, reset, and communication.
A "ping" in and around Parallax typically refers to an unltrasonic sensor:
http://www.parallax.com/Store/Sensors/ObjectDetection/tabid/176/CategoryID/51/List/0/SortField/0/Level/a/ProductID/92/Default.aspx