Another useful Python script. Divides text of bits into 8 bits at a time, so you can see everything byte by byte.
Python Code:
>>> string = raw_input('String = ')
String = 1 1 1 0 0 1 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>>> " ".join(string[i:i+16] for i in range(0,len(string),16))
'1 1 1 0 0 1 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'
Thanks Keith and #python IRC
Main Site
Friday, October 2, 2009
Reverse Text in Python
I've been doing a lot of work lately dealing with bits, and many times I've had to reverse the bit text in order to actually see what was being submitted ( most significant bits are first not last). I used to do it by hand, but I now use a handy one line python script.
The raw data from my microcontroller:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1
The one line Python script :
print raw_input("Enter String to Reverse: ")[::-1]
Open up terminal and go into python. Type in that script and press enter.
Python 2.5.1 (r251:54863, Feb 6 2009, 19:02:12)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print raw_input("Enter String to Reverse: ")[::-1]
Enter String to Reverse:0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1
1 1 1 0 0 1 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
The reversed code:
1 1 1 0 0 1 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Special thanks to Keith!
The raw data from my microcontroller:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1
The one line Python script :
print raw_input("Enter String to Reverse: ")[::-1]
Open up terminal and go into python. Type in that script and press enter.
Python 2.5.1 (r251:54863, Feb 6 2009, 19:02:12)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print raw_input("Enter String to Reverse: ")[::-1]
Enter String to Reverse:0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1
1 1 1 0 0 1 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
The reversed code:
1 1 1 0 0 1 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Special thanks to Keith!
Wednesday, September 30, 2009
The truth about leaving light bulbs on
A common piece of urban folklore: Its better to leave a light on than to turn it off and turn it on a half hour later. The theory is that the bulb takes more energy on startup than it takes while in regular operation.
Time to debunk this foolish folklore with some math and specifications.( for incandescent bulbs)
Cold resistance of a tungsten incandescent bulb is usually around 1/10 or 1/15 the hot resistance of the bulb.( depending on the bulb). The startup time for the bulb to get from cold resistance to hot resistance is at maximum 1/5 of a second.
So when the bulb is starting up and turning on , it has cold resistance. After the the bulb is all turned on, it now has the higher resistance.
And we all know that with great power comes great current squared times resistance, or power = current* resistance. So Power = Current^2 * Resistance.
Lets take a common incandescent bulb with the following specs:
100W power consumption
120 volt source
Hot Resistance of 150 ohms
Cold resistance of 10 ohms
Startup Time(cold to hot) of .20 seconds
So that means that during that startup time , you will spend 3.16 amps(100 = i^2 * 10) for .2 seconds . Whereas with the hot resistance you will spend 0.81 amps(100 = i^2 * 150).
So lets see: upon startup you are spending around 4 times(3.16/.81=3.9) as much energy as you would spend , but only for 1/5 of a second.
Lets solve to see how many seconds of hot current draw equals cold current draw.
3.16 amps * .2 seconds = .81 amps * X seconds
X seconds = .78 seconds
Conclusion:
It takes less than one second to compensate for that startup current "surge"! Urban myth is busted!
Time to debunk this foolish folklore with some math and specifications.( for incandescent bulbs)
Cold resistance of a tungsten incandescent bulb is usually around 1/10 or 1/15 the hot resistance of the bulb.( depending on the bulb). The startup time for the bulb to get from cold resistance to hot resistance is at maximum 1/5 of a second.
So when the bulb is starting up and turning on , it has cold resistance. After the the bulb is all turned on, it now has the higher resistance.
And we all know that with great power comes great current squared times resistance, or power = current* resistance. So Power = Current^2 * Resistance.
Lets take a common incandescent bulb with the following specs:
100W power consumption
120 volt source
Hot Resistance of 150 ohms
Cold resistance of 10 ohms
Startup Time(cold to hot) of .20 seconds
So that means that during that startup time , you will spend 3.16 amps(100 = i^2 * 10) for .2 seconds . Whereas with the hot resistance you will spend 0.81 amps(100 = i^2 * 150).
So lets see: upon startup you are spending around 4 times(3.16/.81=3.9) as much energy as you would spend , but only for 1/5 of a second.
Lets solve to see how many seconds of hot current draw equals cold current draw.
3.16 amps * .2 seconds = .81 amps * X seconds
X seconds = .78 seconds
Conclusion:
It takes less than one second to compensate for that startup current "surge"! Urban myth is busted!
Friday, August 28, 2009
Working at BugLabs
I've been working at BugLabs - buglabs.net for the past few weeks. Its been lots of fun and I got to play with a lot of cool stuff.
RFID Module I made: http://bugcommunity.com/wiki/index.php/VonHippel_RFID_Reader
I also took my bipedal robot and mounted a BugBase onto it. BugBase talks to my custom Serial Servo Controller.
RFID Module I made: http://bugcommunity.com/wiki/index.php/VonHippel_RFID_Reader
I also took my bipedal robot and mounted a BugBase onto it. BugBase talks to my custom Serial Servo Controller.
Friday, July 10, 2009
CMUcam Line Follower Tutorial
I built a vision line follower robot a couple of months ago and haven't got a chance to document it. Anyways, I wrote up some documentation today - http://www.narobo.com/robots/line_vision/line_vision.html
I have more than a dozen projects and robots to document , so expect a lot more documentation to be upload this week and next week. Also, I'll be uploading a ton of videos to youtube, most of them old stuff I've never gotten around to uploading.
Heres my Youtube Channel : http://www.youtube.com/user/Erobots
Monday, June 8, 2009
Linear Actuator Demo Video
I've been playing with linear actuator solenoids lately. They're a lot of fun and have tons of applications. Here's a quick video:
Omniwheel Robot Driving Around
I added on some L298 Motor Controllers and wired up everything. The robot is wicked fast! Have a look at this video of it driving
Subscribe to:
Posts (Atom)