tag:blogger.com,1999:blog-58674002009-07-03T22:14:06.355+10:00Journeys EndWe walk many paths, many roads<br> Till death halts our steps.<br> Every day a new adventure,<br> A new journey of self discovery.<br> <br>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.comBlogger421125tag:blogger.com,1999:blog-5867400.post-60446418077981558942009-06-07T15:22:00.005+10:002009-06-07T15:31:22.983+10:00Dealing with rkhunter warnings<p>rkhunter often warns on file property changes after upgrade and such, and sometimes you just aren't sure whether it is due to recent upgrades, or because you really were compromised. The following script was written to compare the checksum of all files rkhunter warns about against the originals in a debian repository.</p> <p>Naturally you should run this on a machine which is working off the same repository, and is at the same versions. Alternatively, separate the script into 2 parts: first part dumps the require aptitude arguments, second part does the checking. Run the first on the suspect machine, second on a machine known to be good.</p> <pre class="brush:bash"> #!/bin/bash desc=" This script will verify whether files for which rkhunter has logged a warning for is still valid. It does this by finding which debian package it came out of, and downloads them, unpacks them, then checks the checksums. Run it by supplying a rkhunter log file as first argument " # this script should not be ran on a suspect machine, but on a machine # running the same distribution IFS=" " function find_suspect_files { grep -1 Warning "$1"| grep File | awk '{print $2}' } function find_packages { for suspect_file in $1 do package=$(dpkg -S $suspect_file|awk '{print $1}'|sed 's/.$//') echo $package done } function make_aptitude_args { for package in $1 do version=$(dpkg -p $package | grep Version | awk '{print $2}') echo $package=$version done } function cleanup { popd rm -rf tmp } function setup { rm -rf tmp mkdir tmp pushd tmp } if [ $# -ne 1 ]; then echo "$desc" exit 1 fi suspect_files=$(find_suspect_files "$1") packages=$(find_packages "$suspect_files" | sort | uniq) aptitude_args=$(make_aptitude_args "$packages") setup aptitude download $aptitude_args for deb_file in *.deb do ar -x $deb_file tar zxf data.tar.gz rm -rf data.tar.gz control.tar.gz done for suspect_file in $suspect_files do suspect_sum=$(sha256sum $suspect_file | awk '{print $1}') clean_sum=$(sha256sum ".$suspect_file" | awk '{print $1}') if [ $suspect_sum == $clean_sum ]; then echo "$suspect_file: OK" else echo "***WARNING****" echo "Checksum mistmatch for $suspect_file!!!" echo "Should be: $clean_sum" echo "Is: $suspect_sum" fi done cleanup </pre> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-6044641807798155894?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.com0tag:blogger.com,1999:blog-5867400.post-40828847278039014622009-06-04T00:20:00.007+10:002009-06-04T00:55:07.707+10:00microbric viper review<p>The microbric viper is neat. Good quality parts and unique idea. Makes a decent robotics platform if you get the wheel add-on. However, you gotta have small fingers to get some of the parts in place. Despite this, the hardware is solid, I like it. The one thing I would ask for however is more short-nuts and a printed manual, not a CDROM with a PDF. Take a leaf from LEGO and their construction manuals.</p> <p>While the hardware is decent, the microbric viper is sadly let down by the software.</p> <p>The microbric viper uses the basicAtom (by basicmicro), a PIC 16F87{6,7} with a custom bootloader. Now there is nothing wrong with this - arduino uses a custom bootloader too. However the custom bootloader uses a proprietary programming protocol. This is pretty fail, but what really fails is the programming software only runs under windows (or wine under ubuntu, but only for now).</p> <p>IMHO the basic-esque language used by basicAtom is no better than what picaxe offers. I am completely at a lost as to why companies would use the basicmicro's products and lock themselves to a single supplier. Think about it: if basicmicro goes bust, your products using the basicAtom will not longer have a supported development environment.</p> <p>Robotics companies need to seriously consider how their selection of controller will affect their customers - specifically those customers who aren't going to be running windows and staying with in the limits of whatever custom language designed by the controller vendors.</p> <p>Arduino would be the best choice IMHO. Open hardware, open software. You don't have to pay premiums for the bootloader, and the number of people who will consider your product increases to include people like me.</p> <p>I bought the microbric viper because it was on sale: reduced to $29 from $199. If I had known I could only program it under windows or that it used such a closed platform, I won't have bought it, even for that price.</p> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-4082884727803901462?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.com0tag:blogger.com,1999:blog-5867400.post-54132879605667950082009-05-29T22:27:00.002+10:002009-05-29T22:29:33.532+10:00New addition to the work bench<div style="float:left; margin-right: 10px; margin-bottom: 10px;"><a href="http://www.flickr.com/photos/sentientintelligence/3575882456/" title="photo sharing"><img src="http://farm4.static.flickr.com/3311/3575882456_b5ed4642d4_m.jpg" alt="" style="border: solid 2px #000000;" /></a></div>Thanks to Anthony from <a href="http://area.net.au/">Area I.T. & T</a>, I am now a happy owner of a dual channel 40Mhz oscilloscope.<br /><br />I am happier than a pig in mud!<br /><br />Cheers,<br />Steve<br clear="all" /><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-5413287960566795008?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.com3tag:blogger.com,1999:blog-5867400.post-31071023317724732862009-05-18T01:17:00.003+10:002009-05-18T01:27:48.999+10:00Sketch to calibrate SEN-08663<p>Got my hands on a ADJD-S371 on a breakout board from Sparkfun. The code below can be used to calibrate it. The most up-to-date version of the code can be found at <a href="http://git.pictorii.com/?p=sketches.git;a=tree">my git repository under colour_sensor_calibration</a>.</p> <pre class="brush:cpp"> #include &lt;Wire.h&gt; /* Calibrates the sensor to get white balance. Pin 2 should be connected * to LED on the breakout board's LED pin. Calibration is done by placing the * breakout board inside a pin pong ball, and using the built-in LED for * illumination. * * Amount of light is measured by charging N capacitors for time X then * reading off the voltage. (Conjecture) * * N is controlled by CAP_XXX * T is controlled by INT_XXX * * Calibration is done by adjusting the integration time. No real reason. */ int _slave_id = 0x74; int _LED_pin = 2; uint8_t read_register(uint8_t addr) { i2c_send(_slave_id, &addr, 1); return i2c_read(_slave_id); } void write_register_int(uint8_t addr, int data) { write_register_multibyte(addr, (uint8_t*)&data, 2); } /* write data[i] = register+i */ void write_register_multibyte(uint8_t addr, uint8_t* data, uint8_t bytes) { for (int i = 0; i < bytes; ++i) { write_register(addr+i, data[i]); } } void write_register(uint8_t addr, uint8_t data) { uint8_t bytes[] = {addr, data}; i2c_send(_slave_id, bytes, 2); } uint8_t i2c_read(uint8_t id) { Wire.requestFrom(_slave_id, 1); for(int i = 0; i<10 && !Wire.available(); ++i, delay(10)); if (!Wire.available()) { return 11; } return Wire.receive(); } void i2c_send(uint8_t id, uint8_t * data, uint8_t len) { Wire.beginTransmission(id); for(int i = 0; i < len; ++i) { Wire.send(data[i]); } Wire.endTransmission(); } #define CTRL 0x00 #define CONFIG 0x01 #define CAP_RED 0x06 #define CAP_GREEN 0x07 #define CAP_BLUE 0x08 #define INT_RED_LO 0x0A #define INT_RED_HI 0x0B #define INT_GREEN_LO 0x0C #define INT_GREEN_HI 0x0D #define INT_BLUE_LO 0x0E #define INT_BLUE_HI 0x0F #define DATA_RED_LO 0x40 #define DATA_RED_HI 0x41 #define DATA_GREEN_LO 0x42 #define DATA_GREEN_HI 0x43 #define DATA_BLUE_LO 0x44 #define DATA_BLUE_HI 0x45 int read_colour(uint8_t low_addr) { int lo = read_register(low_addr); int hi = read_register(low_addr+1); return lo|(hi<<8); } int red_integration_time = 2048; int green_integration_time = 2048; int blue_integration_time = 2048; void set_integration_times(int red, int green, int blue) { write_register_int(INT_RED_LO, red); write_register_int(INT_GREEN_LO, green); write_register_int(INT_BLUE_LO, blue); } void setup() { pinMode(_LED_pin, OUTPUT); digitalWrite(_LED_pin, HIGH); Serial.begin(57600); Wire.begin(); // join i2c bus (address optional for master) Serial.println("Setting up..."); // datasheet says, wait 10us for hardware reset, so lets wait 1000 delay(1); // gain setup write_register(CAP_RED, 0x08); write_register(CAP_GREEN, 0x08); write_register(CAP_BLUE, 0x08); set_integration_times( red_integration_time, green_integration_time, blue_integration_time ); // ask for colour data and offset write_register(CTRL, 0x01); } void loop() { if (read_register(CTRL)) { return; } int red, green, blue; red = read_colour(DATA_RED_LO); green = read_colour(DATA_GREEN_LO); blue = read_colour(DATA_BLUE_LO); Serial.println("--------------"); Serial.print("red: ");Serial.println(red); Serial.print("green: ");Serial.println(green); Serial.print("blue: ");Serial.println(blue); Serial.print("red_int: ");Serial.println(red_integration_time); Serial.print("green_int: ");Serial.println(green_integration_time); Serial.print("blue_int: ");Serial.println(blue_integration_time); // have to calibrate against blue, because LED has a blue bias otherwise // it would look like blue has high gain than it does float P = 1; int reference = blue; red_integration_time += (reference - red)*P; green_integration_time += (reference - green)*P; blue_integration_time += (reference - blue)*P; // set the new integration times set_integration_times( red_integration_time, green_integration_time, blue_integration_time ); // ask for colour data again write_register(CTRL, 0x01); }</pre> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-3107102331772473286?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.com0tag:blogger.com,1999:blog-5867400.post-40171545573203741502009-05-08T16:03:00.007+10:002009-05-18T01:20:48.043+10:00Facebook python authentication gateway<p><strong>Edit:</strong> it occurred to me what I have below is the basics of a thin facebook api wrapper. I might make it into one at some point in the future.</p> <p>If you don't know what this does, you don't need it. Hope this helps some one. Written because pyfacebook is broken, always returns error 100.</p> <pre class="brush:py"> def get_session(auth_token): params={ "api_key":FB_API_KEY, "v":"1.0", "auth_token":auth_token, "generate_session_secret":1, "method":"auth.getSession", } sorted = params.items() sorted.sort(key=lambda x:x[0]) str_to_hash = ''.join(["%s=%s"%(x[0], x[1]) for x in sorted]) str_to_hash += FB_API_SECRET md5 = hashlib.md5() md5.update(str_to_hash) sig = md5.hexdigest() params["sig"] = sig encoded_params = urllib.urlencode(params) headers = { "Content-type":"application/x-www-form-urlencoded", } conn = httplib.HTTPConnection(FB_API_HOST) conn.request("POST", FB_API_PATH, encoded_params, headers) response = conn.getresponse() print response.status, response.reason return response.read() </pre> <p>This Works For Me when I use it with iphone facebook-connect client:</p> <pre> [FBSession sessionForApplication:myApiKey getSessionProxy:myURL delegate:self]; </pre> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-4017154557320374150?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.com0tag:blogger.com,1999:blog-5867400.post-5132474050159777832009-04-29T00:41:00.003+10:002009-04-29T00:51:54.167+10:00Stripping trailing whitespace from XCode<div style="float:right"> <img src="http://shuningbian.net/files/xcode_strip_trailing_whitespace_regex.jpg"/> </div> <p>Firstly, my usual approach of <code>s/\s+$//g</code> doesn't work since it eats up the newline too. <code>s/\s+$/\n/g</code> doesn't work either because the Replace: field in the find dialogue doesn't escape the <code>\n</code>.</p> <p>Final solution is as shown: <code>s/[ \t]+$//g</code></p> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-513247405015977783?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.com0tag:blogger.com,1999:blog-5867400.post-4182534929371327222009-04-06T12:21:00.009+10:002009-04-07T00:57:21.833+10:00Family Planning<h3>YLDE comic: half as funny half as often.</h3> <br/>because imitation is the best form of flattery. <a href="http://shuningbian.net/files/familyplanning-600.png"> <img src="http://shuningbian.net/files/familyplanning-400.png" title="and the product of their age will be my private key"/> </a> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-418253492937132722?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.com0tag:blogger.com,1999:blog-5867400.post-39017236157503732152009-04-02T21:11:00.004+11:002009-04-02T21:14:45.005+11:00Finally<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://farm4.static.flickr.com/3655/3406014833_b84cd321e9.jpg?v=0"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 500px; height: 375px;" src="http://farm4.static.flickr.com/3655/3406014833_b84cd321e9.jpg?v=0" border="0" alt="" /></a> <p>I <a href="http://peter.stillhq.com/jasmine/rubikscubesolution.html">cheated thought</a>.</p> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-3901723615750373215?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.com1tag:blogger.com,1999:blog-5867400.post-46289485432184169162009-02-16T18:04:00.002+11:002009-02-16T18:07:08.084+11:00Futurlec Ultrasonic Sensor Note<p>Part number <strong>US1440</strong>, these sensors are <em>not</em> dual use, which means the transmitter and receiver is not exchangeable. They also look identical from the outside, so if you build my <A href="http://www.shuningbian.net/2009/02/arduino-ultrasound-ranger.php">arduino ultrasound ranger</a> with these (as I did) and find you can't see echoes, try swapping your transmitter and receiver around! It cost me no small amount of headach this morning.</p> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-4628948543218416916?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.comtag:blogger.com,1999:blog-5867400.post-58066538029133023122009-02-16T00:52:00.014+11:002009-06-01T12:38:01.212+10:00Arduino ultrasound ranger<a href="http://www.shuningbian.net/uploaded_images/ultrasound_ranger-732633.gif"><img style="float:right;margin:1em; border: thin solid black;" src="http://www.shuningbian.net/uploaded_images/ultrasound_ranger-732630.gif" border="0" alt="" /></a> <p>Code to drive it is <a href="http://git.pictorii.com/?p=sketches.git;a=blob;f=ultra_sound_range_finder_test/ultra_sound_range_finder_test.pde;h=22392b358bea3d379c6c78d486838acb6e1872b0;hb=HEAD">avaliable under GPL.</a></p> <p>An updated version of the <a href="http://git.pictorii.com/?p=schematics.git;a=blob;f=ultrasound_ranger.sch;h=fb0796dcbd27b4d9862ca65c013d9403912eed56;hb=HEAD">schematic as a .sch file</a> is available also.</p> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-5806653802913302312?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.comtag:blogger.com,1999:blog-5867400.post-71498121960665368012009-02-13T22:47:00.002+11:002009-02-13T22:54:39.062+11:00The libertarian argument against vaccination<p>Goes like this:</p> <blockquote>I have a right to decide what happens to my children!</blockquote> <p>To that I say, we have the right to not be a victim of your stupidity. Further, laws represent social contracts that all members of society enter into for everyone's benefit. Getting vaccinated is one such contract which serves to prevent epidemics of infectious diseases.</p> <p>If you <em>really</em> don't want to vaccinate your child, then please ensure your child never comes into physical contact with the rest of society for our sake. I would not welcome them without vaccinations.</p> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-7149812196066536801?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.comtag:blogger.com,1999:blog-5867400.post-33737336387844592312009-02-06T16:56:00.002+11:002009-02-06T20:11:12.921+11:00MATHS FAIL<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.shuningbian.net/uploaded_images/128783732919015373-703519.jpg"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 308px; height: 249px;" src="http://www.shuningbian.net/uploaded_images/128783732919015373-703515.jpg" border="0" alt="" /></a> <p>What is the period if you want to generate a 40KHz signal? It certainly isn't 250E-6 seconds. The same calculator returns 2500E-3 for 1/4 which is 2.5, not 0.25.</p> <p>The calculator is <a href="http://www.apple.com/downloads/dashboard/calculate_convert/pemdas.html">PEMDAS</a>.</p> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-3373733638784459231?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.comtag:blogger.com,1999:blog-5867400.post-66681127617486173122009-01-25T00:10:00.003+11:002009-02-09T15:36:25.245+11:00Auto leveller<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/3D5gqDwatH4&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/3D5gqDwatH4&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object> <p>A simple 2 DoF setup with an accelerometer (LIS302DL) attached to the effector. The seeeduino attempts to drive the servos so the Z and Y axis measure zero acceleration. The sketch is available at <a href="http://git.pictorii.com/?p=sketches.git;a=summary">the usual place</a>. <p>The algorithm employed is a simple PD controller with pseduo-gradient stepping to determine how to control each servo without any knowledge of how the servos are arranged. To deal with sensor noise from the accelerometer, a schmitt trigger mechanism is employed along with a moving average.</p> <p>The code also allows the system to be calibrated to deal with accelerometer miscalibration.</p> <p>It is cute, but that is about it :-) Coupled with a tripod and better construction ut might be useful for some DIY surveying or construction work.</p> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-6668112761748617312?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.comtag:blogger.com,1999:blog-5867400.post-36009971251707571372009-01-13T21:02:00.005+11:002009-01-13T22:02:36.505+11:00Turn a servo into 1-wire-control bi-directional motor<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/XPctfYBw9-A&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/XPctfYBw9-A&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object> <p>It is often a pain building H-bridges or getting a motor shield just because you want to control a few motors. This is where servos come in: they are cheap(ish), have motor and gearbox, and they are controlled ysing only a single wire.</p> <p>The only problem is of course, servos aren't designed for continuous motion. Servos are designed to respond to PWM pulses which encode the desired position for the servo to be in, not a desired speed or direction. So some modification is required.</p> <p>Now there are many articles on the intertubes on how to do this, but they mostly concern themselves with making the servo into little more than a normal motor with a gearbox - you still need a H-bridge to control the direction. This modification is a little different: it leaves you with a servo that behaves like a bi-directional motor where the direction is controlled by a single wire.</p> <p>Due to the variety of servos out there, I will present only the general idea, which applies to servos which use a potentiometer to determine position.</p> <p>Firstly, a quick explanation of how these servos work. The principle behind these servos is that the potentiometer is connected to the output gear such that the voltage of the sweeper (connected to the middle pin usually) depends on the angular position of the output gear. The onboard controller converts the input PWM signal into a target voltage, then it powers the motor so it turns the output gear until the voltage of the sweeper matches the target voltage. This is kind of control action is relatively easy to achieve using an operational amplifier.</p> <p>The basis of the modification is essentially this: if we fix the sweeper voltage, then any input asking the servo to move away from the sweeper voltage will result in the onboard controller continuously attempt to match sweeper voltage to target voltage. By making the target voltage higher or lower than the sweeper voltage, we get directional control.</p> <p>To fix the sweeper voltage, the potentiometer will need to be disconnected and replaced with a voltage divider. I assume that when the output gear is in centre position, sweeper voltage is half the supplied power because the potentiometer will be in its centre position. Since I wanted 0 degree rotation to map to stop, I fixed the sweeper voltage at this value by using 2x1.5K resistors in series. This is all you need to do electronically. There should be enough room to fit in 2 extra resistors, even in small 8g servos (what I had).</p> <p>The last thing to do is to remove any physical obstructions which prevent the output gear from completing a full revolution.</p> <p>Once the electronic and physical modifications are complete, you should have a servo which can turn in either direction continuously and controlled via single wire. Two of these would be perfect for say powering a small rover...</p> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-3600997125170757137?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.comtag:blogger.com,1999:blog-5867400.post-49425463064303558112009-01-04T17:00:00.006+11:002009-01-04T17:49:34.552+11:00Tips for interfacing a electret mic with an arduino<ol> <li>The arduino ADC is 10bit, which means the range is 0-1023 and this is mapped to 0-5V most of the time, unless you do funky things to AREF.</li> <li>Most amplifier circuits on the net (using op-amps or LM386s) will have a DC bias of 2.5V, this is to allow the output to swing both ways. So on the arduino side even with complete silence you will read a value ~512 or so.</li> <li>The resistor connecting the electret mic and power also adjust the sensitivity of the microphone in addition to providing power to the mic (which includes an internal pre-amp, by the way). This resistor is very important - if you find your microphone isn't responsive enough, then adjust this resistor first before debugging your amplifier circuit. For me this "fixed" my microphone's responsiveness. It is best of this was a variable resistor which makes adjustment trivial.</li> <li>I was making a simple volume meter, and I did the following: clamp upper values to about 600, then using map map this to a range between 0-7 (since I had 8 LEDs). This was because I found the value never went above 600 very often, so the upper few LEDs were essentially going to waste sitting around. YMMV.</li> </ol> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-4942546306430355811?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.comtag:blogger.com,1999:blog-5867400.post-62840126405743558242008-12-26T00:24:00.009+11:002008-12-26T00:50:39.682+11:00DIY digital spirit level<br/><div style="float: right; margin-left: 10px; margin-bottom: 10px;"><a href="http://www.flickr.com/photos/sentientintelligence/3134648563/" title="photo sharing"><img src="http://farm4.static.flickr.com/3258/3134648563_abe5960890_m.jpg" alt="" style="border: solid 2px #000000;" /></a><br /><span style="font-size: 0.9em; margin-top: 0px;"><a href="http://www.flickr.com/photos/sentientintelligence/3134648563/">DIY digital spirit level</a><br />Originally uploaded by <a href="http://www.flickr.com/people/sentientintelligence/">sentientintelligence</a></span></div>A simply digital spirit level using a LIS302DL accelerometer from <a href="http://www.nkcelectronics.com">nkcelectronics</a> coupled with a seeeduino for processing and a 2x16 character LCD display for output.<br /> <p><a href="http://shuningbian.net/files/LIS302DL_test.pde">Sketch is available</a> for your convenience. Note the Sketch includes an extra feature: PWM backlight on pin3.</p> <br/> Cheers,<br/> Steve <br clear="all" /><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-6284012640574355824?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.com0tag:blogger.com,1999:blog-5867400.post-75980213039219228322008-12-20T14:51:00.003+11:002008-12-20T15:26:04.138+11:00RIP DSE, Greetings Futurlec<p>Dicksmith Electronics is dead to me now. Dead as a door nail, dead just like Tandy.</p> <p>When I was growing up, Tandy and DSE were the two places I went to get my electronic parts and information. The Engineer's Mini Notebook series and Getting Started in Electronics sold at Tandy were treasure troves of tips, tricks, and insights. The best thing was of course I could buy nearly any component mention in the book at either DSE or Tandy.</p> <p>Those days are no longer. Tandy degenerated into a specialised consumer electronics retailer long ago, and now DSE has suffered the same fate. Take for example my wasted journey to Burwood DSE: I had searched on DSE's website for some pin headers, and was inform Burwood store had them in stock. 30 minutes later I was there, and lo and behold: they no longer have an electronics section. Only a few years ago I would frequent Burwood DSE because they were the only component retailer I could reach with relative easy by public transport. Now there is nothing but the shiny and vacuous desert of electronic bling.</p> <p>How the mighty have fallen.</p> <p>Currently <a href="http://www.futurlec.com/index.shtml">Futurlec</a> is my supplier of choice. Not only do they have reasonable prices, they also have a <em>fantastic</em> range of components, boards and hardware, a better range than <a href="http://www.jaycar.com.au">Jaycar</a> with a easier to use website too.</p> <p>I am torn to use Futurlec - Jaycar has been an excellent business in encouraging the next generation to get into electronics, and I really want to support them. But their website leaves much to be desired, and their range in recent years has been slowly been invaded by consumer electronic bling. Will Jaycar fall like Tandy and DSE before it? Maybe if they stayed out of the hands of the Woolworths...</p> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-7598021303921922832?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.comtag:blogger.com,1999:blog-5867400.post-89418017701887872502008-12-12T23:47:00.003+11:002008-12-13T00:10:06.654+11:002x16 character LCD displays<p>2x16 character LCD displays can be tricky beasts. I got mine working today with my seeeduino (an arduino compatible board with more awesome), and really wished I had known that:</p> <ol> <li>The contrast pin needs to be in the same power network as the power and ground pins. The contrast pin at 0v provides highest contrast, which means you can probably just ground it normally.</li> <li>The timing between LCD driver power up and commencement of device programming appears to be important. I had the LCD power independently, and this gave me garbage on screen. When the LCD shared the same power supply as the seeeduino everything worked perfectly.</li> </ol> <p> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-8941801770188787250?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.comtag:blogger.com,1999:blog-5867400.post-46291422975543179562008-10-21T19:11:00.002+11:002008-10-21T19:15:22.661+11:00Safety fail<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://shuningbian.net/files/mb_safety_fail.jpg"><img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 320px;" src="http://shuningbian.net/files/mb_safety_fail.jpg" border="0" alt="" /></a> <p>Apparently only the hosts need safety screens</p> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-4629142297554317956?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.comtag:blogger.com,1999:blog-5867400.post-62931478516387087692008-10-15T19:45:00.004+11:002008-10-15T19:55:34.025+11:00Dear Steve Conroy,<p><br></p> <p><i>You can’t be serious.</i></p> <p><br></p> <p>You wants to filter <i>all</i> Internet connections now, without the option of opting out?! You want <i>every</i> Australian to be on a list so you can see who is “naughty” and who isn’t?!</p> <p><br></p> <p><i>You can’t be serious.</i></p> <p><br></p> <p>You wants to filter all <i>illegal</i> material on the Internet?!</p> <p><br></p> <p><i>You can’t be serious.</i></p> <p><br></p> <p>How on <i>earth</i> do you propose to classify the contents of more than <b>181,000,000</b> websites (Sept. 2008, Netcraft)!? Assuming a government worker can classify a site as illegal or legal in 1 minute, that person will have to work non-stop every day for <b>344</b> years to classify 181,000,000 websites.</p> <p><br></p> <p><i>You can’t be serious.</i></p> <p><br></p> <p>How on <i>earth</i> do you propose to even filter that many sites without rendering the Internet useless?! <span class="Apple-converted-space"> </span></p> <p><br></p> <p><i>You can’t be serious.</i></p> <p><br></p> <p>How can we be sure the site blocked really <i>is</i> illegal, when we can’t access it!? How do you stop the system from abused? How do you correct the system’s mistakes? Why isn’t any of these described in detail?!</p> <p><br></p> <p><i>You can’t be serious.</i></p> <p><br></p> <p>How on <i>earth</i> are you planning on preventing people from circumventing your flitters using encryption?! <p><br></p> <p><i>You can’t be serious.</i></p> <p><br></p> <p>Get a fucking clue Steve Conroy. The Internet doesn’t work like that. You have a background in the broadcast industry, and the Internet is nothing like it. You should leave technical decisions to people who know what they are talking about and stop pissing off every Internet literate Australian.</p> <p> DIAF,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-6293147851638708769?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.comtag:blogger.com,1999:blog-5867400.post-65231417654224482672008-10-11T17:12:00.003+11:002008-10-11T17:26:37.409+11:00For shame Dr Hearnden<blockquote>"...Why should small business take a hit for a public health measure?" -- Dr Hearnden</blockquote> <p>I am amazed a doctor of all people would utter such capitalistic remark.How can a doctor question whether or not it is in the business' interest to improve public health?</p> <p>Businesses derive their income from the public, and a healthy public is more capable of providing income to businesses. The only businesses which benefit from an ailing public are medical clinics. This leads to me to think Dr Hearnden belongs to a special class of doctors who prefers to <em>make money from treatments rather than from cures</em>. In other words, putting profit before his patients.</p> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-6523141765422448267?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.comtag:blogger.com,1999:blog-5867400.post-57310018063752178242008-10-09T23:36:00.004+11:002008-10-09T23:39:43.030+11:00Some people are going to hate me for this<p>But you can get the current function's name by using:</p> <code> sys._getframe().f_code.co_name </code> <p>Seems to work alright for debugging purposes. See the link embedded in the title for the origins and 3 other methods.</p> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-5731001806375217824?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.comtag:blogger.com,1999:blog-5867400.post-83903274757168776862008-10-06T18:30:00.002+11:002008-10-06T18:34:12.157+11:00Electronics, it gets the heart pumping<div style="float: right; margin-left: 10px; margin-bottom: 10px;"><a href="http://www.flickr.com/photos/sentientintelligence/2917367153/" title="photo sharing"><img src="http://farm4.static.flickr.com/3088/2917367153_e047f6e58e_m.jpg" alt="" style="border: solid 2px #000000;" /></a></div> <p>There is it, the new current limited H-bridge for my team's <a href="http://www.sumo-usyd.org/about-sumo/">SUMO</a> entry. Put it together this afternoon, and will be mounted on a piece of perspex (which I forgot to bring home) and then mounted on the robot. </p> <p>Statistics: <ul> <li>Numbered of times chickened out of short circuit test: 4</li> <li>BPM while testing: 100 (estimate)</li> <li>Short circuit current: 8A</li> </ul></p> <p>This is basically 2 <a href="http://www.cadvision.com/blanchas/hexfet/np-s.htm">MOSFET H-bridge</a> each powered by a <a href="http://www.jaycar.com.au/images_uploaded/LM138.PDF">LM138/LM338K</a> rigged with 150/150K for R1 and R2 respectively, providing ~13.5V. </p> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-8390327475716877686?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.com0tag:blogger.com,1999:blog-5867400.post-26660697339392416362008-09-28T21:36:00.002+10:002008-09-28T21:39:59.790+10:00Congrats to aday AND pseudonym<p>Live long and prosper!</p> <p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-2666069733939241636?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.comtag:blogger.com,1999:blog-5867400.post-7830013086544599712008-09-20T23:07:00.004+10:002008-09-22T01:13:57.989+10:00A relatively pain free Linux/OS X VNC setup<p>Ever since I got my 2nd monitor, I been using VNC to work on my laptop. Leopard's inbuilt VNC server isn't really VNC compliant, and has many issues when used with a normal VNC client. I have found <a href="http://sourceforge.net/projects/osxvnc/">Vine server</a> to be an excellent replacement. The client side is a little interesting. RealVNC didn't work too well for me, in that often the screen would stop responding, or it would not receive key events. The best setup I have found is to use <a href="http://www.tightvnc.com/">tightvnc</a> with the following Vine server settings: <ul> <li>Devices</li> <ul> <li>Keyboard Layout: US </li> <li>Keyboard Events: User Session Events </li> </ul> </ul> <p>The client and server will happily share the clipboard if you enable it. Settings are accessed via F8 in the client, and via Preferences in the server. The client is smart enough to synchronise clipboards only when it loses focus - which would be you switching away to say, paste a url into firefox. All in all it is a fairly painless experience.</p> Cheers,<br/> Steve</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5867400-783001308654459971?l=www.shuningbian.net%2Findex.php'/></div>stevehttp://www.blogger.com/profile/08905624839178001596noreply@blogger.com