AL Saint Jerome

From BenningtonWiki
Jump to: navigation, search


The tech team needs to keep in mind the power requirements of whatever it's putting together. I've started notating the current consumption of the various pieces of tech we might use. If you add items to the list you should take the time to read the tech docs and post the power, size, etc. specs.

Power consumption is measured in milliamps (mA). Power sources are measured in milliamp/hours (mAh), meaning that it can provide that many milliamps in one hour (before running out). For example, a 700mAh power source can power something that consumes 100mA for seven hours, or it can power something that consumes 700mA for an hour.

Some power sources will be rated in milliwatt/hours. Watts are simply amps times volts. Or in other words, to figure out the mAh, divide the mWh by the voltage of the power source.

When we get enough pieces together we'll be able to start doing a "power audit" to determine the total power consumption of the device we want to build. Then we can see what power sources will work and how long the device will run on a charge.

Wireless BlueSMiRF

  • Cost: 10-99: $58.46 each
  • Power: 4.5V - 5.5V, 120mA transmit, 40mA receive, 2mA idle
  • Size: 1.7" x 0.6" x ?
  • Host interface: TTL serial, AT command set
  • Wireless protocol: Bluetooth
  • Range: XBee™ ZigBee OEM RF Module

  • Cost: $19
  • Power: 2.1V - 3.6V, 35mA transmit, 38mA receive, 1uA power-down
  • Size: 1.087" x 0.96" x 0.32"
  • Weight:
  • Host interface: 3.3V serial, AT command set, up to 1 Mbps
  • Wireless protocol: proprietary, 250 Kbps
  • Range: 100ft

Cameras CMOS Camera Module

  • Cost: 10-99: $17.96 each
  • Resolution: 640x480 color
  • Power:
  • Dimensions: small
  • There isn't any official documentation, but the forum (linked from this page) has a lot of info. Miniature Lightweight Camera 50mW

  • Cost: 10-99: $44.96 each
  • Resolution:
  • Power:
  • Dimensions:

Power Sources Canon NB-4L Battery Pack

  • Cost: $35 (there are cheaper generics, $17, $5!)
  • Power: 3.7V, 900mAh (3330 mWh)
  • Dimensions: 1.5" x 1.25" x 0.25" (40 x 35 x 5mm)
  • Weight: Canon CB-2LV Battery Charger

  • Cost: $38 (there are cheaper generics, $15)
  • Power: 120VAC
  • Dimensions:
  • Weight:
  • Charge time:

Plain ol' 9V alkaline

  • Cost:
  • Power: 9V, 595mAh (5355 mWh)
  • Dimensions:
  • Weight:

Plain ol' 9V rechargeable (NiCd or NiMh)

  • Cost:
  • Power: 9V, 150mAh (1350 mWh)
  • Dimensions:
  • Weight:

Microcontrollers Arduino Mini

  • Cost: 10-99: $34.16 each
  • Power: 5Vreg or 9V (or presumably anything in between?)
  • Note: The ATmega168 can be powered with 1.8V - 5.5V. From looking at the Arduino Mini schematics I see no reason why it can't be powered with less than 5V.
  • ATmega168 power consumption: 3.5mA active/1.5mA idle at 3V/4MHz. 12mA active/5.5mA idle at 5V/8MHz.

Smart LEDs

  • Prototypes. Uses hardware PWM to drive the three color LEDs. The ATmega8 has three PWD outputs; the ATmega168 has 6. Which is sort of cool -- what could we do with TWO RGB LEDs? Got to investigate the power requirements. What do the LEDs draw? The Arduino? The LEDs will draw different amounts depending on their brightness.
  • More prototypes from the same guy.

  • BlinkM, the thing they're productizing. It comes with a drum machine-like sequencer.



Tasks of Saint Jerome #1 - FizzBuzz

October 11, 2007 — Joe:

Hey all, you asked for a Saint Jerome task and so here's your first. I want you to write FizzBuzz, the first (cheap) version. Here's the description:

Write a program that prints the numbers from 1 to 100. But if a number is divisible by three print “Fizz” instead of the number, and if a number is divisible by seven print “Buzz”. For numbers which are divisible by both three and seven print “FizzBuzz”.

Since you're still in the nascent stage, this is not only algorithm and coding practice but it's also to get you comfortable with running ruby programs, starting ruby programs from scratch, picking and using a program editor, etc. Also, experiment in irb.

  • Run ruby programs on the command line with "ruby program.rb".
  • Give your programs the extension ".rb".
  • Sometimes you can copy and paste an old program into the new to get started. Other times it's easiest just to start with a blank file. There's no template or boilerplate text necessary for Ruby. The first line of the file can be the start of your program.
  • I use BBEdit as my program editor. It's on all the computers in the Pod. I've heard good things about TextMate. You'll get tired of TextEdit real fast.
  • Here's a page of Ruby notes from when I taught Ruby in Code Critique last year.

Let's use this wiki page as a blog of sorts. For now we can post our experiments and insights. So put your FizzBuzz programs here.

P.S. The tricky thing about FizzBuzz is the part about printing "FizzBuzz" if it's divisible by both 3 and 7. It makes the conditional interesting.

October 12, 2007 — Joe:

By the way, the best thing you can do to learn Ruby, now that you have an idea of how it all works, is to read read read memorize practice using the methods provided by the classes. You should read this and hold it against your fluttering heart like a love letter: Ruby Class and Library Reference. In particular, read up on Array, Hash and String. Also, Time is fun.

Codes – Hannah, David and Rebecca

H & D started it out, R joined in and together they FizzBuzzed the night away!

<source lang="ruby"> (1..100).each do |x|

if x % 3 == 0 and x % 7 == 0 print "FizzBuzz" elsif x % 3 == 0 print "Fizz" elsif x % 7 == 0 print "Buzz" else print x end print "\n"

end </source>

October 15 — Joe:

Excellent! The formatting's a little weird -- you should put the expressions for the "if"s on the same line as the "if". And I'd put the print "\n" at the bottom of the loop after all the if/elses instead of at the top. That way, logically, you print fizz, buzz, whatever and then end it with the newline (it should also be indented). [changed!]

Okay, Obstruction Challenge: rewrite the code above but you can use the % operator only twice. Not four times like you have. There are only two %'s in the Ruby closet and that's all you're allowed to wear. Go for it.

Rebecca sez: I'm sitting in my room with my non-mac laptop, but this is my assumption for how to do it (well, one way, at least). Can't test it right now, though.

<source lang="ruby"> (1..100).each do |x|

seven = x % 7 three = x % 3

if seven == 0 and three == 0 print "FizzBuzz" elsif three == 0 print "Fizz" elsif seven == 0 print "Buzz" else print x end

print "\n"

end </source>

October 16 — Joe:

Good jorb, Rebecca. That's what I had in mind. Division, and by association modulo, are expensive operations. So strive to optimize code by doing fewer of them. In this case, doing modulo once for the mod 7 and mod 3 and then using the results (the remainders) in the conditionals.

I'm going to touch up the formatting a bit on the two codes above. The entire contents of the do block should be indented to the same level. Indenting shows the innards of things. The innards of the do block, the innards of conditionals, etc. The conditionals are good except that the final else's block should be on its own line. Finally, I use blank lines to separate logically distinct parts of the code: blank lines before and after the innards of a block (if the innards are more than a few lines), and blank lines between logical chunks (eg, the mods, the ifs, the print).

2nd Obstruction: rewrite the code to use only two =='s. (Hint: you'll still have just as many if/elsif's.)