Posts Tagged ‘Coding Projects’
Building a touch-screen laboratory monitor with PyGTK
So I’m building this application to use in our lab at Clemson to keep tabs on all the sensors around the equipment. I’m not going to copy over the whole post here but for anybody who has an interest in following my coding endeavors can check out my post at http://ionsurfing.wordpress.com/2009/12/30/mockupsunusable-alpha-screenshots-for-tactile/. I’ve got some nice screenshots and explanations of where I’m going with the program. I think the biggest challenge will be finding a good way to deal with human interaction using an old-style touchscreen. Any and all suggestions on libraries to look into or thoughts on UI challenges are welcome. :)
By the way, thanks to Mairin for her Inkscape mockup class at FUDCon… I actually used it!
Tea & Tidbits
I’ve recently ventured off to visit two tea rooms around Clemson. Last weekend, Karen and Sarah and I headed to The Victoria Tea Room in Anderson. Pretty awesome place. You can see pictures of the excursion on Facebook, if you’re friends with myself or Sarah or Karen.
Aside. Click the links. They’re relevant, really! Well, half of them are.
The Victoria had over 80 different teas (which you’d know if you clicked that link up there)! I went ahead and ordered a full cream tea. The scones were excellent.
I ended up buying two ounces of a chinese white peony to bring home with me. Overall, the trip was an epic success.
This week – Tuesday, in fact – Mark and I ventured down to Greenville to visit the O-Cha Tea Bar. We didn’t get a chance to stay for the full experience because we had trouble finding it and Mark had to get back for his French class, but we brought back an ounce of cream earl grey and and ounce of lapsang tea. Both are… interesting. I’m not going to buy either again, myself, but they aren’t bad and I’m glad to have tried them.
The cream earl grey is actually earl grey with some vanilla flavors. It’s meant to be a dessert tea; I’m not a fan of dessert teas, but it was okay, especially when we diluted the vanilla with some of our own earl grey. And the lapsang was good, but it’s an extremely smoky tea, and we couldn’t get the smoky flavor out of my tea pot until today. The weird thing is that it tastes like barbeque when you smell the leaves, and it isn’t a subtle hint of odor, either. It’s like someone stuffed barbeque up your nose.
I’m harsh, but they were both good teas. Don’t take it the wrong way.
That was the tea; now for the tidbits:
- FUDCon’s coming up and I still need to ask Mel about the class I’m doing. She already replied to my email, but I never followed up.
- Somebody needs to help me understand the tagging mechanism CVS uses. My xinha package is done but I can’t put it in more than on repository (I already put it in rawhide) because I don’t know how to use different tags for each branch… I guess.
- Still need to email Dr. Tipnis to follow up on that medical physics paper.
- Anastasia and Lauren are coming up to Clemson tonight!
- Next semester in Sosolik’s lab, we’re going to be building/coding a touch screen interface to monitor the entire ion beam assembly. I’m looking forward to that a lot, and I’m starting to brush up on writing daemons in C (to monitor data logging all day on all our sensors).
And I think that’ll about do it.
Oh, in other news, happy Riemann Hypothesis 150th Anniversary month. I’m starting to think that Abstruse Goose has it about right. *despair*
Communicating with SPCI
Background Story/Flavor Text
So I’m working on getting this ammeter to interface with Linux system for the lab, and it turns out that this thing supports the Standard Commands for Programmable Instruments (SCPI). A few hours, Google searches, and Perl scripts after I started, I’d done what I would call a reasonable job of communicating with this device and pulling data from it.
So what is SPCI, and how does it work?
Connecting the Interface
SPCI is just a standard set of commands, not a defined interface. But it turns out that when you’re communicating with electronics SPCI is often used over serial connections like GPIB or RS-232. In my case, I was forced to use RS-232 because of hardware limitations.
Now, you can just read and write directly with the device handle. In my case using RS-232, I ended up discovering that
/dev/ttyS0
was right for me.
Commands
The entire set of commands is found in this documentation from the IVI foundation site. The commands are organized in a directory like structure. If I want to execute the command to ask how many errors messages are sitting in the buffer, for example, I’ll execute this:
:SYST:ERR:COUNT?
What this effectively seems to do is…
- Go to the “root” directory [:]
- Look in the SYST(em) folder [SYST]
- Look in the ERR(or) folder [:ERR]
- Execute the COUNT command [COUNT]
- Note that this is a query; i.e. returned data is expected [?]
Each command has as:
:SYSTEM:ERROR:COUNT? :System:Err:Count? Syst:ERROR:COUNT?
Note that you can vary capitalization without consequence, you can choose to ignore that prefixed colon, and you can even mix around when you use long and short forms.
Example
I used SCPI to communicate with a Keithley 6485 Picoammeter. I doubt seriously that many people reading this will ever need to repeat this task, but it’s all I have to present some examples.
To turn off the zero check on the picoammeter and take the current reading, we could execute these commands:
Syst:ZCh 0 Read?
Note that I could have used “OFF” in place of “0″; either is a legitimate boolean value for “false”. Meanwhile, a script running in the background that looks something like this:
#!/bin/bash cat /dev/ttyS0 >> datafile
Will magically receive a line of data from the machine that we can interpret with a simple Perl script.
Seasons of Code
When I joined the Fedora Project last year, it was a pretty big deal to me. A college freshman, I’d used Linux for a few years and enjoyed it but never really contributed anything back upstream except for the occasional automated bug report.
A year later, I’m very glad I got involved in open source. But I know plenty of very smart people about my age – oftentimes people I think would be even better at this stuff than I am – who don’t join projects or contribute back upstream for no reason other than that it’s not easily accessible for them.
I’ve been sort of monitoring a student from my old high school as he works on his senior thesis. The project is improving security for Sesame. Some of the first questions he started asking his thesis mentor made it pretty clear that he wasn’t sure where to start or how contact project members. Moreover, I’m not entirely sure that he was clear on how open source development even progresses (c’est á dire, he had never been outside of the Cathedral).
I remembered my own thesis project which involved a new type of spam detection that I built as a plugin of sorts to SpamAssassin. I remembered how confused I was about open source projects too, and now I’m wondering: if someone makes a conscious effort to open up opportunities in the open source world to students, especially high schoolers and younger college students, could we make:
- A significant boost in the number of people interested in computers who manifest that hobby in the open source world (in other words, can we increase our contributer numbers?), or
- For those that don’t necessarily become contributers, can we at least get them to try Linux? Consequently, since that’s one of the strongest demographics in terms of driving the computing market (a statement I’m completely hypothesizing with no hard numbers), can we make a dent in the consumer world where more developers support OSS or, at the very least, Linux releases?
When I thought of this, the first thing that came to mind was Google’s Summer of Code. But this is a summer thing and it usually targets pretty complex tasks. It also costs money. What if there was a web community where hackers could post jobs of various difficulty or depth with the intent of having students pick them up? There would (probably) be no payment involved, but I have a feeling that lots of students who need projects for school or who are sort of curious but have no obvious point of entry to the open source community would be happy to pick up small tasks if they’re spoon fed to them (at least in the beginning). Course instructors/professors could even use these postings as projects for their classes which have a real effect in the world – that’s perhaps the best case scenario that I could think of.
Maybe.
Maybe not.
Just an idea.
OS X niceties in Linux: a second look
Being both a Linux and OS X user, I’m often left in one operating system wishing I had access to $convenient_feature in the other system. Two big OS X features that I miss in Fedora are Automator and Growl.
Yes, I know; a unified notification system has been implemented in GNOME (I think; I know it is in Ubuntu/Mint, but since I usually use Fedora and I usually use barebones Fluxbox, I can’t really say if it’s in Fedora yet). I’ll go ahead and complain, though, that it isn’t as extensive as Growl is. All I’ve seen it do is brightness and volume. I’ve read a tutorial on how to easily implement notifications in applications though, so perhaps it’ll just take a bit of time for applications to jump on the bandwagon.
The other feature, Automator, is something that, as far as I know, certainly is far off. There is a tool called GNU Xnee which has X11 macro recording capabilities, but the capacities are nowhere close to what’s available in OS X’s Automator, because it can’t harness specific application functions or easily pipe I/O. In my opinion, this is more than another centralization issue; the most popular OS X apps are from Apple, so they all have great Automator support… but non-Apple applications like Growl, Quicksilver, Fetch, and the Microsoft Office 2008 suite also have hooks in Automator, so I imagine Apple has made it easy to interface with.
Do I really need Automator in Linux? Not really, no. I have this much better thing called the command line. But as I rewrite the Fedora Desktop Guide (more on that later) I think more and more about new users who have little experience with scripting. There are GUI programming tools to teach concepts to newcomers, but I think something that actually has practical purpose would be more useful for a beginner who wants to harness the power of Linux. Besides, in the age of the graphical desktop, I think being able to pipe I/O between applications should be nearly as easy in a graphical fashion as it is on the command line… if slightly less powerful.
Enough ranting. Just finished a Perl script to run 300ish Monte Carlo simulations for me while I’m asleep. Time for bed.
PS: This post is a “second look” because I already discussed Automator-ish functionality in the comments of a previous post.
Nevhma: Sugar activity for math4
Nevhma is a Sugar activity my friend Rob and I are working on to cover a math curriculum item for the Math4 Project.
We’re tackling requirement 4.G.6, which deals with teaching kids about the rectangular coordinate system. Our immediate idea that we’re working with right now is a Tron like game, where you race your opponent to various coordinates to gain points. Right now, it’s pretty simple; you’re just racing around to goal points before your opponent gets there. Plans for future development include the volatile tail (like in a traditional tron game), networking support, and maybe some cool powerups (earned by solving math problems, of course) or other game enhancements. Perhaps later down the road we could even introduce some different coordinate systems… just for kicks.
I did a little video cast you can get here: http://danielsmw.fedorapeople.org/Nevhma.ogv. I’ll put this on YouTube soon so Fedora doesn’t have to handle the load, but for some reason YouTube’s upload page isn’t working for me at the moment. Note that the video is mirror-imaged because of my webcam. EDIT: The video can now be found on Youtube. Please use this if you can, but if you don’t have Flash, you can still use the Ogg file above.
Also, as far as I know, there aren’t any Tron games already out there for Sugar, so maybe we can make the educational options optional and kill two birds with one stone with Tron/Achtung, die Kurve! game.
EDIT: I forgot the most important link (to the source): fedorahosted.org/nevhma.
Life Update (or “Lupdate”)
This is the kind of thing I should use Twitter for, but I’m just too verbose. For the few onlookers interested in an update on the life of Matthew, though, here it is.
- I’m interning at MUSC, doing medical physics research on dosimetry. Really, it’s just me dissecting some software from a Brazilian research lab and processing numbers, but it makes me feel like I’m at least doing something productive.
- I’m working at Masters Studios over the summer as well. I actually kinda ran the studio this past week because Master Phil was out. Next week I’m back to just one or two evening classes to teach a week. Over and over I’ve volunteered to redo the crappy website for them, and I keep hearing for the past one or two years that someone’s been working on it already. I think at this point the site would already have to be re-updated to keep up with the times.
- I got out of Fedora stuff for a while as I adjusted to summer, but I’m kinda trying to get back into it. I’m not sure that I want to keep doing all docs stuff, so I’ll pull back on that once I can find someone to hand off the user guide to and then I’ll get into packaging. I’ve been reading up on the packaging guidelines tonight.
- I’d like to reconnect with some friends over the summer. There are a few people I’ve been independently talking to about getting together, so hopefully that’ll all fall into place. I was going to do something with Araba too, but I have a feeling she’s already gone back to Cambridge without saying bye… (*frown*)
- I’ve been blogging more frequently!
- Rob and I are working on Nevhma, a Sugar activity for the XO-1 for the math4 project. It’s a little Tron-like game where you run around a coordinate plane to hit benchmark points.
- Sherwin and I are still working on our project which has about 6 different names now. He’s actually done way more effective work than me since I started worrying about MUSC stuff, but hopefully I’ll be able to get my part done by the end of the summer and we can release Beta 1.
That’s all I can think of right now. Hopefully I’ll find another Csifa soon, and take a photo if I can.
Goodnight, Moon.
Lessons learned: prototype.js
My friend and I are building this site, and one thing I really wanted to do was use prototype.js, what with all the hype about it. Turns out that it was well worth my trouble, and it’s a fantastic framework for doing dynamic web pages and such. But there’s a few things I wish I could have found more quickly and more clearly instead of learning them the hard way.
1. If you’re about to call a class method using ‘this’ from an event observer, read the documentation for the ‘bind’ and ‘bindAsEventListener’ functions first. (Otherwise you might have browser-crashing infinite loops, or something else not intentional).
2. Make sure you understand CSS, and make it your intention to format the entire page via CSS.
3. Don’t forget that functions are variables, and when you refer to them outside the context of calling them you should do so without parentheses. Example: this.onClickFunc.bind(this) instead of this.onClickFunc().bind(this).
That’s all I can think of at 12:13 AM EST, but I’m sure there’ll be plenty more before this site is finished. Stay tuned.
Seesaw: An Idea for [math4]
I’ve been trying to come up with an idea for an application to write for the math4 program. I’ve mentioned this program before, and you can find more information at their wiki page: http://wiki.sugarlabs.org/go/Math4Team.
My idea is inspired by a leaning game we used to play in elementary school in 4th and 5th grade. We had these devices reminiscent of balance scales and we had to put different weights on one end to balance the weights on the other. The trick, of course, is that while the left side of the balance may have had a 10 gram weight, we could only balance it with a discrete number of non-10 gram weights on the other end. Mathematically, you might think of it like this:
10 = X1 + X2 + … + Xi
Where each X was some weight. The first idea of my Sugar activity was just to emulate this behavior with some basic drag-and-drop. I think that’s a good start, but then I wondered: can this be expanded to include variables?
I think the answer is that it can. Consider the polynomial (6X + 13). If we need to balance this on the right side of our scale, then we need two types of weights: weights of the form nX and weights of the form n. There’s really no way around this. This can be explained formally with linear algebra and vector spaces, but that would be beyond the scope of our 4th grade curriculum. On the other hand, grasping that concept in a more a priori way is something that I feel can be important to grasping the bigger idea of variables and equations.
That’s not that hard then. We can simply have a new class of weights which take the form nX. In fact, it could be easily expanded to include weights of the form nY, nZ, et cetera; once the kid gets the concept, they should be able to balance a polynomial of any order.
From there, we can probably do even more, but I don’t have any solid ideas yet. I just think that the framework of using a seesaw format like this has lots of applications for understand equality.
As I wrote that last sentence, I realized that we could have a dynamically changing equality sign that demonstrates how the equation is currently balanced (a >, <, or =). With that in mind, I’m off to start coding!
First Impressions: Adobe Flex
My friend and I are in the process of building a website, and we’ve been looking around and all kinds of interesting platforms for delivering web content. We’re probably doing most of it in Google’s Web Toolkit with a mix of Perl and Python on the backend, but one very neat thing we’re looking at for delivering a web chat interface is Adobe Flex.
Flex is a technology from Adobe that allows developers to write Flash applications. People have been doing this for a while, but (from what I understand) it’s kind of been clunky, because most applications used for doing this were focusing specifically on delivering multimedia content. But Flex is made for use specifically by developers, and so far it seems to deliver very clean, very pretty, and very easy-to-code Flash.
Besides Adobe’s provided Flickr client tutorial, I’ve been working on a chat program. The code is in MXML/ActionScript, so it’s pretty flexible and tends to do what you tell it in the same sense that Perl does.
If you need to quickly code up a quick web application, I’d suggest Flex. I think, but am not totally sure, that you can download the Flex developer kit for free. The awesome Eclipse-based editor, however, is somewhere in the magnitude of $200 USD.
Would I really pay that much for it? No. I got it for free with a student ID. :-)
You can also try a 30-day trial, I think. It looks like it’s much more advanced than I can comprehend right now. Since I’ve never done any Flash coding before, I think that’s understandable. My next task is reading up on how to do direct socket communication, which looks pretty easy via the SocketXML class.





