View Full Version : Help on memory and sensors

02-25-2005, 11:43 AM
Hello. I'm a newbie to all this STAMP stuff... I am interested in using the BS2 for a sensor in this compressed air engine I am making.

I need to measure the rotational speed of the flywheel on the engine. So what kind of tachometer could I build with BS2? I figure I could build a simple optical tachometer using an optical incremental encoder (HEDS-9100) and a codewheel (HEDS-5120) on the flywheel. I dont think parallax sells these, so anyone have any suggestions on where to get these components or other types of tachometers I could build for the BS2?

Also, could someone shed a light on the memory of the BS2? So if I write a program, it will be stored in the EEPROM (meaning the program will stay there even without power)? And if I wanted to store values, would it be stored in the RAM? How big is the RAM? What I wanted to do was attach the sensor to the engine and store the measured RPMs, which could then be displayed on a computer via a terminal program. Is this possible with the BS2?



Ken Gracey
02-26-2005, 11:43 AM

I also do machining. If you are looking for a clean solution, embed a couple of magnets on opposite sides of the flywheel. Then, you only need a hall-effect sensor and it could literally be hidden - almost non-intrusive. See my RPM display here:

Even slicker would be to use one magnet on the hub of the flywheel. Then, the Melexis sensor would count the change in magnet poles. Very cool.

As for optical encoders, I think they involve more hardware than is necessary for this application. You could use the optical sensors in our encoder kit for the Boe-Bot, but I'm not certain they can handle higher RPMs (x 1 or 2 per revolution).

BS2 has 2K EEPROM and is fine for your project. The EEPROM is non-volatile, so your program is retained even if power is loss (same for any data you have stored in EEPROM). You could store data in RAM (26 bytes) or you can use the EEPROM (holds lots more - up to 2K depending on the size of your PBASIC program).

Everything you want to do is entirely possible, easy, fun, and the code is written (at least for the Hall-effect sensor example above). If you want to display on a PC, you can use Hyperterminal or even StampDAQ or StampPlot Lite. Both of these programs are free and work really well for graphing, logging, display, etc.

Show us some pictures of the engine.


Ken Gracey
Parallax, Inc.

02-26-2005, 01:03 PM

Thanks for the feedback. Sounds really interesting. Gotta do some research into this now. Will post pics of the engine once my group gets a prototype out.


03-03-2005, 04:18 AM
I had another question...

So to sum things up, what I am trying to do is build a sensor system to measure:

1. RPM of the engine
2. Pressure of the air tank
3. Temperature of the air tank

So I kind of have an idea of how I can measure the RPM now, but how about for the pressure and temp?

I was thinking of using this: http://www.parallax.com/detail.asp?product_id=800-00027
instead of this: http://www.parallax.com/detail.asp?product_id=604-00002
because I want the STAMP circuit OUTSIDE of the tank. But in order to use the probe, what other parts do I need? A/D converter?
OR... since I may need the pressure sensor in the tank as well, i could just place the temp sensor and pressure sensor on a seperate bread board inside the tank and run wires out to the stamp cicruit... is that recommended?

Two methods:
1. I was thinking of using the Motorola MPX4115 barometer and the Maxim MAX187 analogue-to-digital converter.
2. Use gas laws PV=nRT to calculate pressure from the temp and volume of the air tank. Major drawback would be it probably wont be too accurate because things won't be "ideal"

Other Questions
It might be easier to do temp and pressure measurements using hardware, but I thought it might be cool to do it with STAMP as well because I need for the RPM anyway.

Which STAMP is recommended for all this? I was looking at the BS2p and the pe in case I end up using a 1-wire device.

Which STAMP board is recommended? I felt that NX-1000 24/40 Board is a good deal since it includes LCD and power supply and other extras (but doesnt have 1-wire it seems) at $125. But if 1-wire is necessary, the only choice would be the BS2p24/40 Demo Board?

Finally, would I need a seperate, dedicated EEPROM to store all these data values to run calculations?

Thanks in advance.


Post Edited (Evan) : 3/2/2005 9:31:27 PM GMT

03-03-2005, 05:17 AM

One quick question about your code to measure RPM...

In MAIN, you have:

COUNT SpeedIn, 1000, Pulses
RPM = Pulses * 60

So COUNT SpeedIn,1000,Pulses is saying "Count how many times the Melexis is outputting high every 1ms for 1 second and put this value into Pulses, which is just a measurement of RPS"

so the max RPS (rev per sec) it can detect is 1000 = 60,000rpm?

also, how big/strong of a magnet would i need? guess it depends on how far the melexis is from the magnet...


Post Edited (Evan) : 3/2/2005 10:20:20 PM GMT

Jon Williams
03-03-2005, 05:23 AM
I helped Ken with that program so I'll chime in... on the BS2 the detection window timing is in milliseconds, so that command monitors the input for one second (1000 ms). Since the sensor outputs one pulse per revolution, the value in pulses is now in revolutions per second. Mutliplying by 60 gives us RPM. Technically, the max RPS detectable would be 65535 because that's all a Word can hold. Obviously, we would have an overflow error if the value every went above 1092, but with Ken's machine we knew that the max RPM was 7500. By using the 1000 ms sample window for COUNT, we got the best resolution and the display updates nicely every second.

What would one do with greater speeds?· Shorten the sampling window and adjust your math accordingly.· For example, if Ken wanted his mill speedo to update four times per second we would do this:

COUNT SpeedIn, 250, pulses ' count for 1/4 second
rpm = pulses * 240 ' convert to RPM (pulses * 4 * 60)

Make sense?

Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA

Post Edited (Jon Williams) : 3/3/2005 3:37:19 PM GMT

03-03-2005, 07:47 AM
yes, that makes sense.

thank you for clarifying.


04-06-2005, 10:26 AM

Could you tell me what magnet you used for your rpm sensor? The melexis website says that for their kit, they use a Neodymium 35 magnet... is that what you used for your system as well? Could you recommend a place where I could get a magnet that will be compatible with the MLX90217? Thank you very much!


Ken Gracey
04-06-2005, 07:30 PM
Hi Evan,

I visited the local Ace hardware store and they had some small, high-strength round magnets. These were easy to embed in a part turned on a lathe because they were perfectly round. It doesn't require any special magnet, but I'm pretty sure that stronger magnets work better in this application. They also allow more distance from the sensor. There are many places on the web to buy them as well.