# Semester Project Disucssion

This page serves to start the discussion about the semester project. The first and most important question, of course, is whether we do or do not plan the semester project. I’d appreciate your comments, anonymous if you wish. Thanks!

(Early comments removed (a) to protect your e-mail from spambots and (b) to keep the discussion tidy)

## 49 thoughts on “Semester Project Disucssion”

1. I would like to know if it would be possible to randomize the group selection process. My fear, as was thoroughly articulated by others today in class, is that there will be several all-ME groups. Also would it be beneficial if we were to provide you with our preferred group size (ie. 4-7 members), and you can pair us in like minded groups.

2. We had a brief after-class discussion with several students about this question. I think that you might be overestimating the importance of having an EE student on each team, because the actual controller electronics are comparatively simple. A purely analog solution would need two operational amplifiers, a power transistor, and a few resistors and capacitors.

I think that the knowledge you gained in Circuits plus the materials we will cover in the course of this class should prepare you to build the necessary control elements.

I do not think that random team assignments are a good idea, because I assume that several of you work together in other classes anyway. However, if there are a good number among you who like the idea, please submit your names and I will form teams by random selection.

3. Dr. Haidekker,

Our group is ready to get a move on as far as beginning fabricating our levitation device. Would it be best to talk to you after class to discuss potential parts for our device? We are looking for a proper optical sensor as well as attempting to determine whether we want to go the analog or digital route. Have digital teams in the past gone the Arduino route or are there cheaper less complex micro-controllers that you would recommend for this project? As far as the sensor goes, we are hoping to find a sensor that can detect the height at which our object is levitating in regards to our setpoint height as opposed to just delivering on on/off signal when the sensor is covered/uncovered. We believe that adjusting the magnetism based off of distance from our set hover point would be the best way to go about this and get smooth levitation, but also think that a rapid on off signal with a cheaper sensor could potentially accomplish the same thing. Any suggestions? Also, if we do not go the digital route, what other electronics/devices will be needed to create this system via an analog solution. We certainly know we need an electromagnet, some sort of power source and converter, and wiring – but we are not sure what/how to build our feedback control loop mathematics into. If there is an easy resource we can look through that covers all this please don’t hesitate to direct us there.
Thanks

4. Sure, we can talk after class. To answer some of your questions:

* Everybody who went the digital route so far has used Arduinos. I am a bit skeptical, because the Arduino is comparatively slow. It can be done (it has been done), but stability is more of an issue, because the time-discrete nature of the signal really plays a role (viz. z-transform). Personally, for the demo I showed you I used a Microchip PIC18F, hardcore-programmed in assembly. My controller runs at a 10kHz sampling rate. This is quasi-continuous.

* You CANNOT use a pure on-off control. This leads straight to two-point controls, and this won’t get the system stable.

* There are several sensor types that are linear, optical and magnetic. Or at least monotonic. You definitely want a balance between a good monotonic range and a curve that is not too flat so you get enough gain from the sensor. If the sensor’s monotonic range is ~5mm, great. Smaller is OK, too, but you may miss out on awards.

* We will cover control electronics with op-amps. I wouldn’t worry about that yet. However, consider universal PWM controllers, such as the TL494. It has some pretty charming advantages (I used it myself with success)

5. I seem to perceive some angst that the semester project might get overly complicated. For your info, let me present to you a circuit that I took from a 1996 edition of Popular Electronics — more than 20 years old! Look at the circuit diagram: Is it really that complicated? Sure, we will discuss why the individual elements are needed and what they do. Also, I do not claim that this is the best solution. However, I do think this is well within Circuits knowledge.

6. Here is another one, this time with a Hall sensor, so you can see that the Hall sensor solution works, too. There are several sensor solutions (including inductive!).

Again a particularly simple and elegant solution; however, this one is extremely tricky to describe, because the big electromagnet, together with the Hall sensor and the first-order delay (R1, C1) forms an unstable controller to make the levitated object stable. Unstable in this context means, it acts as an oscillator that is modulated by the magnet-object distance. Highly interesting concept.

7. Hello Professor Haidekker,

Our team has a few questions in relation to the Inverted Pendulum (Upright Robot) project:

Are there any specific size requirements/restraints?
Do we need a complete assembly that consists of the robot body by this first due date?
Does the robot need to actively move?
Are there usable Arduinos currently in Driftmier or do we need to purchase our own?

We appreciate you taking the time to assist us.

8. Are there any specific size requirements/restraints? — No, pick a size that fits the components you can acquire.

Do we need a complete assembly that consists of the robot body by this first due date? — Yes. This is the idea that you can proceed to the next step. This step-by-step progress is necessary to reach the goal at the end of the semester.

Does the robot need to actively move? — No. I do not think you’ll achieve this, because it will topple immediately. However, it would be ideal if you had running motor(s).

Of course, if there are very specific reasons why you want to deviate from the given step-by-step outline, we can discuss this. For example, you could consider to focus on the sensor first. In that case, we’d switch two steps and you would get the sensor to operate, and then focus on the motion. However, I’d like to give approval in specific cases before you proceed.
Are there usable Arduinos currently in Driftmier or do we need to purchase our own?

9. Dr. Haidekker,

For the grading milestone number 2, what exactly needs to be done? We need to have the frame, the solenoid, the levitated object, but do we also need to have the sensor and the rest of the circuit built?

• As you wrote: the frame, the solenoid, the levitated object. Plus, show that the solenoid is strong enough to pull the object out of your hand from 1/4 to 1/2 inch distance.

Sensor and rest of circuit is several milestones down the road.

• Ok thanks. So on the report that is going to be turned in to eLC, we just need to show the equations that prove our solenoid is strong enough?

• Actually, please provide some evidence that this part works, such as photos of what you built.

10. For the equations needed to describe the mechanical system of the upright robot, there is a comment in the project handout that says these equations should perhaps be determined experimentally. I understand how to go about deriving the equations without data and purely using knowledge of statics and dynamics to establish the described relationships, but is your intent that we would acquire data from our built robot and use a program such as Excel or Matlab to find a “curve of best fit” equation that describes the data and therefore the relationships?

• At this stage this is probably somewhat impractical. A good start (for the upright robot) is the book’s chapter 14 where the equations are derived. For the levitators, the force can be measured, for example, with a letter scale. This would prove to be very helpful down the road. For the upright robot, you probably can do little more than use weight and shape to estimate the moment of inertia — and a crude estimate at that. For the upright robot, measuring the sensor functions becomes more important.

11. To respond to questions regarding the coil. I was asked about those 170 meters of wire length.

First of all, please consider as an alternative an electromagnet from ebay or Amazon. This could be an easy way to get a magnet, and it is already wound and has a suitable iron core. Hand-winding is not nearly as tight as those machine-manufactured ones.

However, I wound my own magnet, and I can assure you that it works. Here are a few tips. First, the magnetic force increases with the bolt cross-sectional area. Let’s for the sake of argument assume you use a 3/8″ bolt, and you have a bobbin so that the diameter of the inner turns is about 1/2″. Next question is that of wire diameter. If you use thicker wire, you get fewer turns but a higher current. The magnetic force increases with the square of the number of turns and with the square of the current. With a thin wire, you need a high voltage, and the coil will get warm. For a 10-minute demonstration, this is hardly a problem, but you should not exceed ~15 watts if you want to run it continuously.

Here is an example. Let’s say we use 22-ga wire (diameter approx. 0.65mm, cross-sectional area therefore 0.0032 sqcm. Copper has a specific resistance of 1.68e-8 ohms*meter. This translates into roughly 52 mOhms per meter or ~9 ohms for 170 meters. Also approximate is that you might get between 1000 and 1500 turns, depending on how tight you wind the wire.

The exact magnetic force depends strongly on the overall geometry. One way to determine it is to attach an iron bolt to a letter scale (hold it down with tape or putty). Weigh the bolt. Hold the magnet at a small distance above it — the air gap could be anywhere between 1/4 and 1/2 inch. Run a current through the magnet and weigh again. The difference in weight allows you to calculate the magnetic force.

• Oh, and one more thing. A battery-powered drill is a miracle instrument for winding the coil.

12. For the levitated object, are there any other options other than the iron bolt in the project description that would still work well? For example, would a small steel ball bearing suffice? Also how specific should the dimensions of the iron bolt be? You suggest 1/4 ” diameter with 3 ” length but how close to those dimensions does the iron bolt need to be?

13. SENSORS:

I promised I would write something about possible sensor solutions. This will also be covered in class. There are a number of sensor solutions of almost limitless sophistication, but the first and foremost question is: How fast is it? For example, if you have laser time-of-flight sensors or ultrasound distance sensors, how many readings per second do you get? And, if you get a discrete signal, how sensitive is it? It is pointless if you have a sensor that covers the 10cm to 100cm range but hardly changes its output in the sub-millimeter motion range of the levitator.

The same considerations apply for the upright robot, of course. “Upright” means a few degrees from the vertical position, everything larger means it’s not holding its position anyway. So… speed and sensitivity.

1. Optical

There are several options. Simple occlusion or reflectance, both either with a single sensor or a dual-sensor differential. Dual-sensor differential is particularly attractive for the upright robot, because it can swing in both directions. A combination of LED (infrared?) and phototransistor has a good chance of giving you a good signal.

2. Magnetic

Hall sensors are quite cheap, and they have a good dynamic range. Make sure you get linear Hall sensors, not the on-off type. Hall sensors can work pretty well for the inverted pendulum. For the levitator, you have to deal with the electromagnet. One suggestion is to subtract the field with dual Hall sensors. Provided that the sensor does not saturate, this will work. Alternatively, you can assume that the field is known (you can access the corrective action signal, after all), subtract that out. If you consider a relatively large object (a 4 inch world globe, for example), you can also mount the sensor underneath.

3. Inductive

I never tried this myself, but it could be one of the best solutions for the levitator, albeit with more extensive electronics. A transformer underneath the main magnet will change its coupling ratio when the object is in close proximity (viz. LVDT). Transformer in this context means simply two air coils. One gets excited with a signal of a few tens of kHz, and the other rectified and amplified — ideally in resonance, which gives you some *real* sensitivity. Even simpler, if you use PWM, the main magnet can serve as excitation. A single sensor coil is sufficient in that case. The dual transformer principle (LVDT) can also be used for the inverted pendulum.

4. Gyroscope-Accelerometer combo

For the upright robot, using a gyroscope-accelerometer combo may be the most viable solution. There are complete chip sets available in Driftmier (as far as I know). The major advantage is that they deliver $\dot{\Theta}$ directly, and you do not need an analog or digital differentiator to compute it from $\Theta$.

• Yes, correct. One submission per team, and this submission is automatically applied to all team members.

14. Where is the link to the page that tells what topics we will be talking about in class? For some reason I can’t find it.

• Good point. There was none. I have now provided a link right before the general syllabus/course outline.

15. I’m a little confused on how to go about linearizing the transfer function of the process. Could you maybe give a hint/some guidance?
Thanks

16. At the core of the levitator transfer function is the equation for the magnetic force,

$$F_M(t) = k_M \frac{I(t)^2}{d(t)^2}$$

So there are two variables that influence the force: $I(t)$ and $d(t)$. This means that you need to superimpose the two components after linearization. Specifically, the linear approximation is

$$F_M (t) \approx \alpha I(t) + \beta d(t)$$

where $\alpha$ and $\beta$ combine $k_M$ and the partial derivatives in the operating point. Note that $\partial F_M / \partial d$ has a negative sign.

Next, you know that the levitated object is accelerated by $F_M$, and accelerated upward, meaning $d$ decreases. So you also have

$$m \ddot{d}(t) = -F_M(t)$$

Put these together and you get the differential equation.

NOTE: The transfer function poles are real-valued, and your denominator polynomial should be of the form $s^2 – a$. Check your signs, especially the directions of force and motion if your result differs.

17. Dr.Haidekker,
My group is very confused on how we should go about getting measurements for the inverted robot sensor characteristic curve. Would we get these measurements through arduino code? or is there another method.

thanks for the help

• You are using the accelerometer-gyroscope combo? The gyroscope is difficult, because it is dynamic. Therefore I think that the accelerometer is sufficient.

Yes, you’d use the microcontroller to read the digital data for the accelerometer. Ideally, you’d use two axes and obtain the angle from the rotation matrix. Then let the microcontroller (a) output a proportional PWM signal or (b) send serial or USB data, or (c) display it on a LCD. Tilting it should then show you the angle.

• Dr.Haidekker,
We are using the L3GD20H gyroscope, and after many different Arduino codes, we think our sensor is broken. The codes gives us inaccurate measurements for a second and then they flatline. Is this supposed to be normal? It seems like when we implement all of the Arduino codes separately ( that are supposed to do the same thing) ends in giving inaccurate measurements.( Also none plot the output of the gyroscope)

We put this in the amended report along with an explanation of the process, and ordered a new sensor.

• I think this is completely acceptable with respect to the report. You are, after all, reporting your observations. However, this does not fix the sensor problem. It is certainly possible that a sensor is broken, and you’ll see that after you got the replacement. Where did you get the initial one from? Driftmier? Please let me know.

18. Our group is considering using hall effect sensors for our magnetic levitator. We have explored ideas of sensor systems to use and have seen options using one hall effect sensor and options that use two hall effect sensors to cancel out one another. Is there an option that you would recommend to us? Using one sensor is probably easier from a circuitry standpoint, so what is the benefit of using 2?

19. Two things about the Hall sensor. First, it should be obvious that it will only work when there is an auxiliary magnet on the levitated object (this is allowed, of course, although the nonlinear behavior gets even worse).

Second, you have to deal with the variable magnetic field of the solenoid. This certainly bears the risk of saturating the Hall sensor, especially if the sensor is placed close to the coil core (distance squared!). To actually measure the object distance, the effect of the solenoid has to be eliminated or at least strongly reduced. Since you know the current (= controller output), it could be subtracted. Alternatively, you place a second Hall sensor atop the solenoid, where it receives the solenoid’s field only. The difference to the lower Hall sensor is therefore the influence of the auxiliary magnet.

The best way to figure out what is needed is the experiment. Place two Hall sensors and monitor them with an oscilloscope. Multitrace oscilloscopes often provide a difference function. Run a strong current through the solenoid and verify that it does not saturate. Place the levitated object nearby (hold on to it so it does not crash into the magnet) and monitor the difference signal. Plot difference signal over distance.

20. I don’t see a grade for team nomination in elc. is it safe to assume that it is not included?

• The team nomination is a chicken-and-egg problem. I need the teams for team grades, but the teams have to be nominated first. For this reason, team nomination is not graded based on teams. Instead, the 3 points are awarded individually and are reflected in your grade sheets.

21. Dr. Haidekker

Is there anytime you’ll be in your office tomorrow to discuss our sensor issues for the inverted pendulum robot?

• Another topic tat I am pursuing. I have contemplated a poster-type presentation, but I have not made a decision. “Classical” 10-minute presentations are pretty much out of the question, because it would simply take too long.

Ideas from your side would be appreciated, of course.

22. I was wondering if Milestone 6 could be due on April 6th instead of April 4th since quiz 7 is longer than usual?

I get repeated questions about sensors, and I’d like to point out two fundamental characteristics that you need to pay attention to. I mentioned this before (see threads above), but this is important enough to get repeated.

1) GAIN — The sensor needs to be sensitive enough to pick up minute changes of the controlled variable. For the levitator, this means that you need to get a clear signal change if the levitated object moved a fraction of a mm. For the upright robot, this means changes of less than a degree. If this is not the case, you will not be able to stabilize the system.

2) TIME — The sensor should be able to read the value instantaneously or almost-instantaneously. If the point-to-point time is more than a few milliseconds, the delay is too long and you again risk stability.

There are a number of fancy sensors out there that might be tempting. I am thinking, for example, about ultrasound distance sensors. SOME (but not all) measure distance up to several feet — these won’t be sensitive enough. Some also can deliver only 10 or so samples per second. This is not fast enough.

One test (for the levitators, at least) is the following: Take a regular 80mm or better 120mm computer fan. It has a curved blade. Point your sensor at the curved section of the fan and run it slowly. You should be able to see the curve of the blade very clearly in your signal. If you can’t discern the curvature, your sensor is not sensitive enough.

Then spin the fan up to maybe 600 rpm — you should still be able to see the fan blades and their curvature. If this is not the case, the sensor is not fast enough.

24. I wanted to follow up on the sensor and the fan blade test. The oscilloscope screenshot below shows the output signal of a reflective sensor measuring hte distance to a point on a 120mm fan blade:

The sensor shows a higher voltage with greater distance. I labeled some points in this curve, and you can see the undefined potential in the gaps between blades. Also, you see that the signal takes a fraction of a ms to drop when the fan blade enters the field of view. After that, the curvature of the fan blade is nicely visible (the fan blows air away from the sensor). The fan runs with roughly 1800 rpm. With its seven blades, the time between blades is slightly less than 5ms.

This analog signal could be easily converted by an ADC — or directly used in a PD controller (see Figure 3.5D of my book). It is sensitive enough, because 1/10mm is easily above the “noise floor”. It is fast enough, because its step response settles under 1 ms.

This is not the sensor I used in my own levitator demo — it is a reflective sensor, similar in its arrangement to time-of-flight and ultrasound sensors. This example is intended to show you how you can test if your sensor shows an acceptable dynamic behavior.

25. For the motor transfer function, is there a simple way to determine a value for J and Rf? In the textbook example, the values were assumed. If assuming, how do we estimate viable values for these two constants?
Thanks

• In principle, there is a way. If the motor has an encoder, you could watch it spin up (step response), which gives you the time constant. The motor efficiency then emerges from a torque disturbance.

I think measuring the motor is impractical. And I really think that it is not necessary. You will determine the controller coefficients experimentally anyway. If you look at the stability criteria (Eq. 14.37) you see that the integral component plays a minor role. This is further highlighted in Figure 14.23 and accompanying text. In practice, you’d start with PD control and get as close to stable behavior as you can. Then you add the integral component — small — and readjust kp and kD to get it stable.

26. For both upright robot and levitator teams:

In regards to the comment right above, I want to highlight again that the most practical method to experimentally determine the controller coefficients is to use analog potentiometers. Those teams who use analog controls will do so anyway, because it emerges logically from the circuit.

But digital controls benefit, too. Connect the two ends of a potentiometer to 0V and +5V, and the wiper to an analog input channel. Now you have a digital value (the ADC read value) that you can vary on-the-fly. Using this for the setpoint is logical, and it needs no rescaling. Note that this is VERY useful for upright robots, too, as the centroid of the mass is most likely slightly off-axis. By allowing for a very small angular deviation, you can “trim” the centroid.

In addition, use separate potentiometers for kp and kD. The values need to be reasonably rescaled, though. Example for what I mean:

Upright robots — let’s assume a sensor that maps the angle from -90 degrees to +90 degrees to the value range from 0 to 1023. In that case, the ideal upright position would be 512. it is possible that an off-axis centroid causes a small angular deviation, perhaps at most 3 degrees in either direction. This is 1/30 of the full-scale value of the sensor. If you do this in floating-point arithmetic, use this for the control deviation:

epsilon_k = (float)Theta_k - (float)A / 30.0;