Translate

Showing posts with label rpm. Show all posts
Showing posts with label rpm. Show all posts

Sunday, March 2, 2014

Quality time with my daughter

My daughter this year choose to do something different from the usual "biology" science fair project.
She choose to build an electric motor and do some tests to see how is possible to improve the conversion of electricity into kinetic energy.
So it was natural my direct involvement in this.

The science fair project had some specific guidelines and "things to do", but from a more practical point of view, the first thing to do was  to build a basic electric motor.
We found  a lot of suggestions on the net about how to do so. In the end the choice depended about the availability of material and simplicity of building.
Here a brief video showing the motor running.


Oh ... she won the Third place for her category at school :)
She also participated to the regional science fair. Unfortunately the motor broke down during the presentation (see notes "Problems" at the end of this article)

Third place for the category

Building a motor

There are many ways to build an electric motor and there are many types of electric motors.
There are AC motors and DC motors.
The object of the experiment was to show how some components of the motor could affect it's performance, when changed.
So we picked up one of the basic-simple type of electric motor, a DC static magnet rotor motor.
The type of motor we wanted to build, had fixed magnet on the moving part (rotor) and an electromagnet on the base (stator).
Many commercial motors have the electromagnet on the rotor and the fixed magnets in the stator, or both electromagnets for rotor and stator, but they are more complex since it must exists a way to bring the electricity on the rotor, a moving part.

Principle


The type of electric motor we choose to build  is extremely simple.
The idea is to have two or more magnets on the rotor. The magnets need to be "paired", i.e. they need to be aligned to themselves.
This simple schematic can help to understand the principle.
When a magnet is close to the Reed switch (a switch activated by a magnetic field) it powers the electromagnet.
The electromagnet generates a magnetic filed with the same polarity of the magnet glued to the rotor, "kicking" it and thus forcing the rotor to spin.
As soon the rotor starts to spin the magnet close to the Reed switch is going away, thus the electromagnets cease to work.
The rotor however continues to rotate for mechanical inertia until the sequence restart, i.e. magnet close to reed switch, electromagnet activated, kick to the other magnet, and so on.

There are some constrains :
  • the magnets need to be glued on the rotor facing with the same pole
  • the position of the Reed switch must be as much as possible aligned with the position of the electromagnet
  • the distance between the Reed switch and the magnet on the rotor is critical. If too far the Reed switch is not activating.
  • the distance between the electromagnet and the rotor is critical too. If too close the magnet on the rotor "attach" to the electromagnet when it is disabled.


Rotor

The rotor is the part of the motor that "rotates" and, for the experiment, is the part we decided to change in order to evaluate the performance of the motor.
The rotors were  built using an empty thread spool, magnets and office pins.
Two or more magnets (always in pair) were  glued on the spools and two pins were glued on the spool central hole to form the axe.



Gluing the magnets on the spool

The spools with the inserted pins to form the axe

We chose to orient the static magnets on the rotor with the South pole facing out, mainly because the RPM meter sensor works on the South pole of a magnet.
We used a simple app for a smartphone to determine the magnet polarity.

Stator

The stator is, for our purposes, everything around the rotor.
We used a wooden base and wooden blocks to build the support for the rotor, the electromagnet, the Reed switch and accessories (main switch, RPM meter, ecc.)

The basic components of the stator, a wooden base and wooden blocks

The electromagnet was connected to a battery and a Reed switch.
The Reed switch is necessary because we need to turn on and off the electromagnet in order to generate a magnetic field only when a rotor's magnet is close by.

Electromagnet

We needed something metal and an insulated electric wire in order to build a coil around the metal part.
Since we used  using small voltage for the project (up to 4.5 Volt) we needed a lot of wire.
We used a nail as metal core of the electromagnet, with the wire coiled directly around it.
We used a drill to facilitate the winding of the wire around the nail

Electromagnet, Reed switch and wooden blocks

Prototypes

Two prototypes were built.
The first one was built mainly to prove the concepts and experiment positioning the components.
The second prototype was the one used to actually perform the test and it was built differently, since we learned from the first one what NOT to do.

First prototype


The first prototype was built positioning the electromagnet on the top of the rotor and the Reed switch fixed at the base.
The idea was to have the Reed switch easily glued at the base and position the electromagnet on the top, it was easier to adjust the distance between the electromagnet and the rotor.

The first prototype
The first prototype was working however it had many problems, like :
  • the electromagnet was moving, required more strong holding
  • the distance between the rotor and the Reed switch was fixed
  • it was difficult to change the rotor
  • the rotor was not strongly hold on the wooden blocks
  • the electromagnet was too weak
  • the voltage used was too high
In the end we realized it was better to rebuild it with different principles.

Second prototype

The second prototype was built with  the idea to be able to easily change the rotor and position the electromagnet/Reed switch more easily.
The second prototype layout

A new electromagnet was built, using a 3 inches nail and almost 250 feet of wire, held by a wooden block carved to the shape of  the electromagnet.

The electromagnet holder, a wooden block carved to the electromagnet shape

The new layout included also a better support for the rotor and the attachment of an RPM meter.


The second prototype used for the test. The RPM meter is shown on the  lower right corner

The RPM meter


In order to evaluate the motor performance, we decided to use the speed of the rotor.
To measure the rotor RPM we needed a tool, an RPM meter or 'tachometer'.
So I built an easy tachometer using one of the boards I had around.

The experiment

At this point we had everything ready for the experiment.
We had a motor base, capable to support a rotor and an RPM meter.
We built 5 different rotors, changing the type of the magnets and the number of the magnets.

  • Rotor 1
    Two ceramic 0.5 inch magnets - Weight : 12.5 g 
  • Rotor 2
    Two Neodymium 0.5 inch magnets - Weight : 20.9 g 
  • Rotor 3
    Two Neodymium 0.2 inch magnets - Weight : 12.7 g 
  • Rotor 4
    Four ceramic 0.5 inch magnets - Weight : 16.4 g 
  • Rotor 5
    Four Neodymium 0.2 inch magnets - Weight : 14.4 g
We decided to proceed in this way :

For each rotor, we choose to perform the test 4 times.
During each test, we set up the RPM meter, let the rotor run for about a minute to "stabilize" the system and then start a 2 minutes timer.
Every 10 seconds we took a reading from the RPM meter.
In this way we ended up with 5 different set of data, one for each rotor.

Capturing the data

Setting the RPM meter

Reading the RPM meter every 10 seconds
From the readings we created 5 graphs to better compare the performance using different rotors.
Here they are :






All the graphs were built using the same scale, so it was possible to compare them directly.
Looking at them resulted that indeed changing the type of the magnet and the number of magnets, the motor had different performances.

Problems

We also experienced a problem.
After building the second prototype we started to collect data for the experiment.
However some rotors had problems. They were spinning at very low RPM and often they were not spinning at all.
We checked the motor and apparently everything was OK .. only apparently.
In the end we discovered that the Reed switch was defective or damaged somehow and it was not always capable to react to the magnet on the rotor.
We decided to substitute the defective Reed switch with a new one, and all the rotors were behaving as expected.

The same problem happened later, during the regional science fair.
The Reed switch broke down again.  The very probably cause of the broke down is the spike of voltage generated by the electromagnet when the Reed switch opens.
Hooking up an oscilloscope we saw spikes up to 250V. On the long run, spikes like that can warm up the metal of the contacts, bending them and leaving the Reed switch unable to operate correctly.
i.e. on the long run the Reed switch mechanical characteristics are compromised by the sparks generated by the electromagnet generated spikes.

The spike in full view - each vertical block is 50 V

A detail of the spike

The poster


Here a couple of pictures of the poster my daughter prepared for the presentation.



Saturday, December 21, 2013

Build fast a simple tachometer

The goal : measure the RPM of an home-made electric motor for a school experiment.

Requirements


The kind of motor built for the experiment is slow by definition, so the RPM meter (also called tachometer - http://en.wikipedia.org/wiki/Tachometer) must be capable to measure and display low revolutions per minute.
The other goal is to build the tool easily and in short time, possibly spending the less possible.

Acquiring Methods


The first problem to solve is how to acquire the rotor revolutions, i.e. how to translate a movement in an electric signal.
Usually there are two methods :
  • magnetic
  • optical 

Magnetic

Since the rotor has already magnets glued on it, it is relatively easy to add a magnetic sensor capable to generate a pulse every time a magnet pass close to it.
The sensor can be a reed switch or, typically, a Hall sensor. The Hall sensor is better than the Reed switch because is not mechanical, so is not generating false signals and is faster.
If an Hall sensor is used, it must be unipolar.
There are two kind of Hall sensors, unipolar and bypolar.
The bypolar requires to "see" a change pole. i.e. a change from South pole to North pole and viceversa. Every change, triggers the change of the electric signal.
The unipolar sensor change the state of the electric signal every time a South pole is close to the sensor.
Here a graph to show the two kind of Hall sensors :


The upper part shows a bipolar Hall sensor.
When the South pole is close to the sensor, the output signal goes down. Only when the North pole is close to the sensor, the output signal goes back high.
The lower part of the graph shows a unipolar Hall sensor.
When the South pole is close to the sensor, the output goes down and it goes up as soon as the South pole is going away from the sensor.

Optical

The other common way to acquire the revolution, is optical.
Typically on the rotor is glued a reflective surface in a spot. A Infrared ray is sent toward the rotor and a circuit can detect the reflection of the infrared ray when bounced back from the reflective surface.
As alternative is possible to attach a disc with holes to the rotor and have a light beam (or infrared beam) interrupted by such disc.
A third optical alternative is to attach to the rotor a "black and white" pattern and illuminate it with a stroboscopic light.
Changing the frequency of the light until the pattern is "stable" (or visible as it would be stopped) will give the RPM.

Measurement


We have a series of pulses generated by the sensor.
Let assume we are using the magnetic acquiring method, with a unipolar Hall sensor.

Depending how many magnets we have on the rotor we can have "n" pulses for every revolution.
i.e if we have two magnets on the rotor, we'll have two pulse every revolution. 4 magnets will generate 4 pulses and so on.

The "intuitive algorithm is quite easy. We need to count the number of pulses in a minute, then divide the number for the number of magnets and the result will be our RPM.

Unfortunately this method has a drawback. We need to wait a minute before to see the result and after that, we need to wait another minute before to see changes.
So we need to reduce the acquiring time and then estimate the RPM from the minor number of readings.
For example we can count the pulses for 1 second, then divide the number of pulses by the number of magnets. The number will represent the number of revolution for second. If we multiply that number for 60, will have the number of revolution per minute (1 minute = 60 seconds).

This can work well assuming the motor rotates at a constant rate and that rate is not too slow.
For very slow rotations, it is necessary to increase the counting time, maybe to two or three seconds (and then multiply accordingly)

The problem with that is the "visualization" of the measurement. More time to count the pulses means more time between the visualization of the result.

Building


It is possible to build the tachometer in many different ways.
Of course today is more simple to use a microcontroller rather than use more "traditional" ways, like using counters, decoders and LED display.
Any microntroller family is more than suitable for this application, especially because the measurements to do are not critical.
A microcontroller is also better than "traditional logic" because it require less components and only changing the software is possible to change the type of measurement.

Mostly because is something I already have around, the idea is to use the Texas Instrument MSP430 family of microcontroller, specifically a board with already the MSP430F169 and a Philips LCD display.


This board has everything we need to build a tachometer and we can easily change the parameters, like the number of magnet on the rotor and the acquisition time.

The software will be build using the GNU Msp430 Gcc compiler.

Note ! It is possible to use the software on different boards with few modifications.
For example the MSP430 Launchpad board is more than enough for this project.
Only two reasons did let me decide for the Olimex board :
  1. I already had this board around picking up dust
  2. This board has already a joystick and LCD display on it

Tools


In order to develop the RPM meter (or tachometer) some tools are necessary.
The software will be build under a Linux machine, using Code::Blocks as editor/IDE.
The compiler used is the open source version of the GNU Gcc for the MSP430 .
The debug system is based on the msp430-gdbserver.
An oscilloscope will be used to check the input signal from the Hall sensor.
The PC used to develop the code must have a traditional parallel port since the only GDB tool is parallel.
For the schematics, the FidoCad and Eagle programs will be used.
FidoCad allows to draw very simple schematics, Eagle is more sophisticate and can be used to produce a PCB (not necessary for this particular project though)

Hardware


As introduced before, the main hardware is the Olimex board based on the MSP430F169.
What is needed is the Hall sensor. I choose a Honeywell SS400 series Unipolar Hall sensor (SS441A ).

The sensor will be connected to an I/O pins of the board,  one capable to read the output signal from the sensor.
Since the board has plenty of available I/O Pins is not a problem.

Specifically will be used the Pin1.1 to read the signal from the Hall Sensor.


The P1.1 is capable to generate interrupts and it can be also connected to an internal timer in case a different measure approach is needed.
The sensor needs to be powered with a Vcc starting from 3.8 V. The Olimex board is operating at 3.3.V so an external regulator is needed and a 5V one is used. Because the MSP430F169 I/O pin are NOT 5V tolerant a resistor limiting the current is needed to avoid damage to the microcontroller.
The capacitors are the standard ones for the 78L05 regulators.

Here is possible to find the schematic of the Olimex board. 

Software

First draft


The software is a first simple draft to prove the concept and verify the hardware.
It is based on the original demo code coming with the board, modified for the specific needs.
The Hall sensor signal will be connected to an interrupt capable I/O in order to don't miss any "firing" of the signal.
One or more timers will be used for the time counting. The visualization will be placed in the main loop.

The algorithm is quite simple and based on two interrupts.
One interrupt is related to the I/O pin connected to the Hall sensor. Normally the signal is pulled up, so the interrupt is set to fire on the descending slope of the signal.
The interrupt function increment a counter every time the signal goes down.

The other interrupt is a timer.
A generic timer "fires" every "n" seconds (default is 1).
When the timer fires, the the counter is copied in a variable and the counter is set to zero.
A flag is set to one indicating the need to display the content.
In the main loop, the visualization loop check the variable updated by the visualization timer to show the result.

I/O Settings


Some I/O are "forced" by the nature of the board.
Here the main ones used other than the ones pre-wired on the board :


P1.1 Hall sensor input
Pulled up, the pin goes to zero when a South Pole magnetic field is close to the sensor
P2.1 Status LED - toggle at every Hal sensor signal
The LED is toggled at every sensor magnetic event
P2.2 Status clock
The pin is toggled at every timer firing. If the timer is set for 1 second, the signal will have 2 second period.
2 seconds timer will generate a 4 seconds period on the pin and so on.
P2.3 Debug pin
Generic debug pin


Clock settings


The Olimex MSP430F169 LCD board has two crystal sources.
A 32Khz crystal and a 8 Mhz crystal.
For this application one of them should be OK since the low time involved.
The minimum period needed is about 1 second, so also the slower but precise 32Khz source should be OK as clock.

In order to minimize the timer interrupts generated, the 32 Khz crystal is used in order to generate a 1 second timer used for the measurement, the rest of the board continue to use the DCO as main source of the clock.

To set the 32Khz crystal :
DOCTL = 0x60
modulation off, DCOx and RSELx ~800kHz
BCSCTL1 = 0xB7
XT2OFF = 1 - XTS = 0 - DIVAx = 3 - RSELx = 7
BCSCTL2 = 0x00
SELMx = 0 - DIVMx = 0 - SELS = 0 - DIVSx = 0 = DCOR = 0
BCSCTL3 = 0x0C
XT2Sx = 0 - LFXT1Sx = 0 - XCAPx = 12.5pF - XT2Of = 0 - LFXT1OF = 0

With this setting the ACLK is of 4096 Hz, the MCLCK/SMCLK of ~800kHz
Note : using the 32Khz for the main clock (MCLK) the display is not working properly.

Timer setting


A generic timer is handling some sub-timers used to count the Hall sensor pulse and display the value.
The timer_A 0 will be used in the up mode.
The clock source for the timer will be ACLK, i.e. 4096 Hz.
The Timer_A will be set with a /8 so that the value 512 placed in the TACCR0 will generate an interrupt every 1 second.

TACTL = TASSEL_1 + ID_3 + MC_1; /* Uses ACLK, divide by 8, count in up mode */
TACCTL0 = CCIE; /* Use TACCR0 to generate interrupt */
TACCR0 = TMRVALUE; /* 1s */

Menu

When the code starts, a menu appears.
Two choices are available :

  • Set
  • Measure

The Set allows to set up some parameters, like the number of seconds for the counter/display value or the number of magnets
The Measure starts the measurement.



Update


After few small modifications and settings, the tachometer was installed on the home-made experiment motor.
The sensor is placed on the top of the rotor using a wooden pole, so to be perfectly aligned with the rotor's magnets.





If somebody is interested to have the source code just contact me