Looking for some input for school related work

First off, a little introduction. I'm currently enrolled in Grade 12, and will be starting my next set of classes in 3 weeks times. I've convinced my school's administration to let me essentially "create my own class". There's a program called Independent Directed Studies (IDS for short), which allows you to pursue a topic beyond that which a current class teaches. I've completed every tech-related class at my school (obtained 99% in ICTS12), but am just looking for a bit more.

Anyways, I've pretty much told them that I plan on taking Electrical Engineering next year, so I'd like to prepare for it a bit. I've done some fairly basic stuff with my Arduino, so I'd like to base the class off of programming this.

So far I have interfaced LEDs, a Character LCD, and a Graphical LCD. That is about the extent of my experience; I have no prior experience with DIY electronics of any type.

I would appreciate some suggestions for possible assignments to do in this class. I have a meeting date set on the first day of the next term at our school with the teacher who will be "running this class", so I've got 3 weeks to get some ideas. I already plan on re-doing everything I've done, just as it's easy marks, and it'll make the class more linear (at least in my mind).

I will be placing orders at both Sparkfun and Futurlec within the next week or two, so any suggested hardware would be cool! I'm open to pretty much any ideas; I'd just like to have useful assignments with practical applications, to keep things fun. Please mind I have very little money, so I can't be spending a whole lot :slight_smile:

Thanks,

  • Jesse

A friend of mine had to create an analog circuit to solve a mathematical equation for one of his circuits classes. His was solving a first order differential equation, but you could probably start off with something simpler. i.e. given an input voltage representing the height of a dropped object, determine its impact velocity as an output voltage or frequency, and measure it on a scope or multimeter. It should be pretty cheap too, since it would probably be mostly simple components.

For me, the analog parts of circuits always gives me a lot more headache than the digital parts.

"Smart" night light. Turns on dimly when it's dark. Gets gradually brighter if motion is detected.

Simple desktop rover robot:

  1. Arduino
  2. Two continuous rotation servos
  3. Two 4-cell AA battery holders (one for the Arduino, the other for the servos)
  4. Ping Pong ball (caster "wheel" for body)
  5. One or Two Sharp IR sensors
  6. Foam Core board (for body, wheels, etc)
  7. Double stick tape and/or Hot glue
  8. Various hookup wire

I think you can see how this would be put together; it would make an interesting educational kit (cheap, too) for such a class. There would be a bit of mechanical engineering involved (building the robot itself, figuring out where to mount the sensors, etc), electronics (hooking everything up properly to the Arduino), plus tons of programming (simple moving, to "turtle graphics" by mounting a pen on it and drawing on butcher paper, to solving problems like a simple maze - and if you had enough of them built by a full class, you could try complex swarm-based systems and such).

If only i could have done that when i was at school!
Being a electronics engineer with HW and SW background, here are a couple of small but very Academic points to remember first:-
Major mark winners at degree level anyway!

  • Always lay your code out properly, use the format function in the IDE. this will aid everyone to be able to read it easily!
  • Always comment your code!!! Biggest bug bare of mine!!! Picking up someone elses code and not knowing what it means, if your mum can understand what your trying to do then your at about the right level! Remember comments are never complied so the more the better!
    • Implement some sort of code versioning, again, very useful for coding very easy to do and it shows that you are coding this with some thought behind it! - For example at the top of the file in a comment area call it V0.1 and with that make a small comment like first draft, then when you change to V0.2 when you have made a change, state what you have changed and how.
  • Do flowcharts and diagrams for all the basic build blocks for your software/hardware, again if someone has no idea about c/C++ they should be able to follow a flowchart. Again this should show your teacher that you can communicate your ideas well and also implement them! keep them updated as well, you can then show how your design process has evolved. Another mark winner!

Ok all the points are a little detailed and mean you are not coding, but they are all good mark winners!!! Espically when you look at degrees!

As far as projects go, it depends on how far you want to go!
I'm currently working on a remote temperature sensor, which uses a website to display the information as a graph. This uses the ethernet sheild and code, PHP script on the webserver and Flot a JQuery library to plot the info. That could show some diveristy and the ability to make a fully functioning system. All you would need is a ethernet shield and a PC running Apache with PHP installed.

You could simplify that by doing the sensor but and using the serial port and something like processing to store and graph the results, again i have alot of script that could point you in the right direction!

If your interested in electrical engineering you could loop at Control Systems, like PID Controllers, these are used alot in the electrical controls side. Again very easy to do as there are libraries already created, you could build a Fan speed controller using a opto couple a mosfet and the PWM pin on the ardunio, but you'd have to make sure your fan has a tacho output, most new PC fans do now. If your really being clever you could attached a temperature sensor and have the fan control the air temperature, this would need to PID loops but again a very cool little project!

How about looking at charging and discharging of a Li-Polymer battery? Sparkfun of a charging board, you could use a ADC pin and a 3.3v regulator to monitor voltage discharge. Just watchout on your choice of regulator, some will always produce the output voltage even if the supply in is lower, and some will follow the supply voltage and just regulate it down, both have good and bad points!

I've got some sketches that could help you with some of this if your interested!
Good Luck!

From milneandfletch:

Always comment your code!!! Biggest bugbear of mine!!! Picking up someone elses code and not knowing what it means, if your mum can understand what you're trying to do then you're at about the right level! Remember comments are never compiled so the more the better!

Comments are valuable. But there are two rules about comments that make for effective comments.

  • comment the purpose or intent or strategy of a bit of code, instead of explaining what each statement does to variables

  • write the comments first in simple english sentences, and then write the code that implements the intended behavior afterwards

For example, I liked the "smart night light" idea above.

/* a "smart" night light */

/* at first boot, set up the pins used for sensors and lights */
void setup() {
    // prepare to read the motion sensor
    // prepare to read the ambient light sensor
    // prepare to output a desired light level
}

/* forever more, decide the appropriate light levels */
void loop() {
    // assume we need no light
    // we want some light when it's dark
    // we want more light when there's motion
    // ensure the new light level won't be too different from the old one
    // adjust the actual lighting level accordingly
}

Once you've written your pseudocode in English, it will be that much easier and more organized for you to write the actual code in C/C++. It will also be easier for people to follow the code. pinMode(SONIC, INPUT); makes sense in a literal machine-oriented way, but when combined with // prepare to read the motion sensor, it's a slam dunk. If you just comment the parameters of the pinMode() function, you're duplicating the documentation already written for it, and giving no extra insight as to why you chose pinMode() in the first place.

Thanks a lot for all the suggestions up to this point in time!

milneandfletch, thanks a lot for all the pointers for writing code. I'm proud to say I've already made a few of those habits of mine, but I will be sure to incorporate the remainders.

I like your idea of a fan controller with a temperature sensor; I was planning on making a fan controller for my arduino already, so implementing the temperature sensor wouldn't be too much harder! I think I'll definitely use this idea for one of my projects.

halley, thanks again for the tips for writing code, it's much appreciated, and I"ll work to implement what you've suggested.

cr0sh, I love your idea, but I'd like to hold off on this project and maybe do something similar in my own time. I pitched this class as mainly programming, so I'm not sure how happy the admin would be if I spend a bunch of time building something first. I have always been interested in robotics however, and do eventually plan on making one myself.

Thanks again to everybody,

  • Jesse

Alright, well I've thrown a few things into my shopping cart over on Sparkfun, so I'll just update you guys as to what I have planned.

Essentially what I have is the following:

12-Button KeyPad, a PS/2 Breakout-Board w/ Connector (for a keyboard), an LM335A Temperature Sensor, and a 5v 50mm DC Fan. Just some random things that I feel I can make some decent projects with.

For my fan controller I was thinking of just going with a TIP110 from my Futurlec order or something. If anybody suggests anything otherwise that's cool.

So yeah, that's what I've got at this point in time. Still open to suggestions.

Thanks,

  • Jesse

Hi Jesse,
Thanks for letting us know what your purchasing! Its nice to see a project progressing!
Right a couple of thoughts,

  • The LM335A Temp Sensor seems to work like the TMP36 i purchased recently, Ruffly working out at 1 degree K/C per 10mV if you work out what your ADC is going to see, its only going to have 1-2 ADC steps per degree so if there is any fluctuation in temperature your sensor readings will be everywhere, even if you put some major smoothing in!!
    All is not lost! Try getting an OP AMP and some resistors with roughly a 1 to 4 ratio (I think - I have the calculations at work) something like a 1k and 4k for example, you can then build yourself a nice little gain amplifier and then each degree is more like 10-15 steps on your ADC giving you much more detail.
  • What sort of Fan have you purchased? Does it have a tacho output (normally a pin shorted to ground two to three times per rotation) and how much current does it pull? The TIP110 can only swtich 2 Amps as along as the fan is less than this you should be fine!
    You may need a opto coupler just to isolate the arduino supply with the fan supply, remembering that the arduino's regulator can only handle 0.8 Amps!
    Also as i mentioned orginally, for a full closed loop system, using the PID library you will need to know what speed your fan is running at, thus the tacho.
    Roughly speaking it will work something like this,
    You will control the fan using the PWM pin and a percentage value of modulation, this in turn will make the fan turn at a certain speed, you then find out how fast the fan is actually going and tweak the PWM signal to give you the fan speed you want to achieve thus closing the loop.
    Anyway good luck and let us know if we can help anymore!

Pete

  • The LM335A Temp Sensor seems to work like the TMP36 i purchased recently, Ruffly working out at 1 degree K/C per 10mV if you work out what your ADC is going to see, its only going to have 1-2 ADC steps per degree so if there is any fluctuation in temperature your sensor readings will be everywhere, even if you put some major smoothing in!!
    All is not lost! Try getting an OP AMP and some resistors with roughly a 1 to 4 ratio (I think - I have the calculations at work) something like a 1k and 4k for example, you can then build yourself a nice little gain amplifier and then each degree is more like 10-15 steps on your ADC giving you much more detail.

I have not actually purchased anything that I listed in that post; that is just what I was planning on purchasing. Will this sensor work fine, or would you suggest something else? Remember, has to be on SparkFun or Futurlec please :slight_smile:

  • What sort of Fan have you purchased? Does it have a tacho output (normally a pin shorted to ground two to three times per rotation) and how much current does it pull? The TIP110 can only swtich 2 Amps as along as the fan is less than this you should be fine!

Again, haven't purchased anything yet. I have a variety of 12v PC fans laying around, most of which are 3-wire. I was thinking of ordering a 5v fan from SparkFun however, which I just realized only has 2-wires, so scratch that :smiley:

Thank you very much for your input :slight_smile:

  • Jesse

You probably need to focus on your programming project first instead of buying general hardware. If your self study is to be programming orentated, the outside hardware needs to support the internal programming you are going to demonstrate.

Hi,
It looks like you have the fan thing under control! Get a three wire fan and everything should be able to be worked from there!
With regards to the Sensor, as zoomkat said, if your project is meant to be programming biased you really need to concentrate on that.
The LM335A and OP AMP approach will look cool if you can demonstrate the HW and how it works and all of its calculations, but if your not getting marked on it, its more woirk than really needed!

So the other option is to look for a 10k Ohm NTC this will give you 25 deg C at 10k ohms and using another 10k resister in a p.d. you get 2.5V at 25 degree's and its then a simple curve calc to give you your temperature.
Very simple HW but could be a little more difficuilt to calibrate, but it might do what you want it to do, and it is small enough to be fitted in front of the fan to get a good air temperature.

One other way, is to use a I2C Temp sensor, according to the spec's there very sensitive and pre calibrated, sparkfun do a TMP102 board.
Its about 15mm x 15mm so still quite small and could be positioned so that the fan pulls or blowns air over it. But you get a much more accruate reading.
IF your trying to be clever you could get the ntc, the LM335A and the TMP102 and do a project to calibrate the ntc and the LM335A against the TMP102. Fairly boring on HW but the software would be quite indepth espically if you try to write the code so that is dynamically calbrates the sensors!!! I've done some work on that if you want a hand!

Pete

milneandfletch, thanks again for the help. I do have a couple questions, however.

I understand pretty well how I should go about controlling the fans. One thing I'm unsure of however, is how I read the RPM. Is it as simple as connecting the proper wire to an input on my Arduino, or is there more required than that?

I'm gonna order up a couple 10k NTC's, as well as the LM335A and the TMP102, just for some variety.

Thanks again,

  • Jesse

Hi Jesse,
Its very simple, the tacko output from the fan is put to ground two to three times (depending on the fan) per rotation, so all you have to do is wire that directly into the Ardunio's I/O pin with a 10k ish resistor connected to + 5V (Pull up resistor) so that you get a square wave.
Then you use pulseIn to measure the time between pulses.
And from that you can calculate your RPM.

I would suggest you start of looking at the fan at 100% (Fully on) and work backwards, as you may not know if it is a 2 or 3 pulse per rotation fan.
For simplisty I would suggest you start of controlling the fan in a percentage manner, (this should make the control routes much more straight forward) then if you really want to know RPM calculate this from the percentage, or from the pulseIn routine.
Also bear in mind that the fan will only start at about 40% but may go down to 10-20% due to the produced emf needed to move the fan from standing or emf needed to keep the fan moving.
So you may need a start routine.

Good Luck.

Pete

Jesse, just to be controversial, I would recommend you avoid flowcharts.

If your code is so complex and opaque that flowcharts actually help, then go fix your code and make it easier to understand, rather than try to solve its opaqueness with a flowchart. After all, if the code doesn't match the flowchart, the flowchart hurts, and if the code is broken, the time and effort sent drawing a reasonable flowchart would IMHO be better spent fixing the code or making it easier to understand.

My other concern is some folks draw flowcharts which might look okay, but are awful to implement in code. IMHO, it's better to have clean, easy to read code than any flowcharts.

I agree strongly with using comments to add value which the code, with well chosen variable names, would lack.

Version control is well worth the effort. If you have to maintain a log book, it can be helpful for that too. Add your log book to the versioned files.

A VERY low-cost project if you have an Arduino is a LED which comes on when it's dark, and off when it's light. You aren't allowed to use any other sensors than the LED itself. This is a nice illustration of the physics of LEDs, they can emit photons or detect photons.

Hall effect sensors are pretty interesting, and low cost. You can use them to time movements (like something spinning) by gluing a magnet onto a moving part. So you could do speed estimation with any existing 'dumb' motorised object, which may earn you more kudos from your teachers.

Also, making a tacho with an LED and a phototransistor (or photodiode) would give you an approach for fan control, or for a robot to track its speed, and hence estimate position.

You could also make a wireless communication system with LEDs and phototransistors/diodes. You could use an analogue electronic system, or use two Arduino's for a digital system.

If you are happy soldering, and have access to a USB to serial lead, you might even make an Arduino (without the USB part) on some stripboard/veroboard. Then you could show a free-standing product (and have a second Arduino :-).

Having said all that, I'd echo the earlier sentiment - focus on what you want to have working at the end, and buy bits to support it.

HTH
GB-)