EmbeddedMan

Embedded Man

Adventures in Embedded Design.
  • Home
  • About
  • Books
  • Magazines
Rss feed Subscribe

State Machine Design Articles

Jan.16, 2010 in Articles, C/C++, Embedded Leave a Comment

I’ve always been fond of state machines.  I don’t know why but perhaps it has to do with the fact that they have a visual representation that makes it easy to understand the sequence of operations.  Granted, I’m talking about well thought out state machines.  I have seen people abuse the state chart tool to get spaghetti code from an ugly state diagram.

For programmable logic design they are great but I don’t get to use them that often in software.  Most of the software projects I work on are already designed by the time they get to my hands and I can’t make architecture changes.  Still, I like to read about them and one good article I found some time ago is here.

In it the author describes designing UML State Machines.  He starts out by describing some errors that were found in a simple Visual Basic calculator program.  Errors that could be prevented by using state machines instead of relying on the traditional method of using if statements.  Not that there’s anything bad about using if conditions but we’ve all seen nested code that was almost impossible to read because it was so convoluted.

So, yes, state machines have more overhead and they are probably not the solution to all problems but they make nice alternatives to lengthy, nested conditionals.  Food for thought.

Tags: Articles, State Machines

Last Post of 2009

Dec.31, 2009 in Just Because Leave a Comment

So here it is, the last day of the decade and I’m nursing a cold.  What a way to go out.  Oh well, maybe it’s a sign that next year will be better.  I hope you all have a great and safe New Year celebration!  See you next year.  Keep coding!

Hp 48 iPhone Apps

Dec.19, 2009 in Career, Cool Stuff, Just Because Leave a Comment

My first year in college I was faced with one of those career-altering decisions:  TI or Hp?  I had managed to get through high school with an older model TI programmable calculator but the final in my circuits course required doing complex matrices.  I tried to program the algorithm into my calculator but it just couldn’t handle it.  Of course that gave me all the excuse I needed to upgrade my calculator but which one?

The engineering student population was divided in two groups:  the TI’ers and the Hp’ers.  Like some old 50’s style gang they would snarl at each other and trade evil looks in the hallways.  One particularly bad semester things got out of hand when a group of TI’ers cornered one of the Hp’ers and forced him to use THEIR calculator on his Linear Algebra homework.  The Hp’ers found out and retaliated by replacing the batteries in all the TI calculators with those cheap dollar store brand batteries.  Right before a major exam.  That lead to an all out gang war and the National Guard had to be called in.

But I digress.  I eventually settled on an HP because I noticed that, while TI made several calculators with varying degrees of functionality, all of HP’s calculators had the same functionality but with different memory capacities.  I opted to buy an HP48G and I wound up using it for pretty much everything.  Even after finishing college I still used it as my alarm clock.  The RPN took some getting used to but all the bells and whistles more than made up for the inconvenience of learning new entry methods.

Since buying my iPhone I have been looking for a scientific calculator app so I wouldn’t have to worry about carrying my HP48G around in case I need to perform some operation on Hex or Binary numbers.  Well last week I discovered some really cool HP48 emulator apps and the best part is that they were all FREE.

They are m48 and GraphiX48.  The first is GraphiX48 which is an app that looks just like the HP48G complete with color schemes and key graphics (I wonder if HP knows).

img001_320x480

This I thought was really cool because the developer went all out in recreating the calculator experience.  The one problem I have with this app is that it’s really hard to press the buttons.  I tried using it several times but I kept having to retype keys and that slows you down.  Old timer note–I remember using both thumbs on the HP48G back before everyone did the same for texting.

The next app is m48 and it takes my vote for best HP48G emulator.

img002_320x480

Yes, the colors take some getting used to but the response is great.  The app allows other skin selections (it even has a skin for the real HP48G) but this is best-looking one (and easiest to use) in my opinion.  As I mentioned previously, I can actually use both thumbs on this app because of the larger buttons.  I haven’t take the time to put either of these apps through more stringent testing but for the occasional quick calculation they are more than adequate.

If you have a favorite calculator app by all means leave a comment and I’ll do a review on it.

Keep coding!

Videos for C++ Newbies

Jul.04, 2009 in C/C++, Career, Programming Leave a Comment

If you can’t make it to a lecture on C++, these videos will at least help you get a feel for what you’re getting into.  Even though C was for many years the defacto language for embedded systems, C++ is commonly used so you should get intimate with it.

Tags: C/C++, Programming

Videos on Using Threads in C++

Jul.04, 2009 in C/C++, Programming Leave a Comment

Tags: C/C++, Programming

Resolving “branch out of range” Errors When Using Older MIPS Compilers

Jun.25, 2009 in C/C++, Embedded, Linux, Programming 2 Comments

In embedded software design it is common to want to have the code footprint as small as possible.  Therefore, it is fairly common when using the GNU C++ compiler to use the -O2 option which includes the -O optimization flags plus a whole slew of others.  You would think that the best optimization is always what you want when compiling embedded systems code.  Not so, my young apprentice, at least that’s what I found out the hard way.

I was building some code using a compiler created for MIPS and I began getting a long list of messages from standard input that looked like this:

Warning: AT used after ".set noat" or macro used after ".set nomacro"

These were followed by a long list errors that looked like this:

Error: Branch out of range

Needless to say, I wasn’t sure what was going on.  Well after a little bit of research a senior developer pointed out that the code had been assembled in such a way that a jump was being attempted that was more than 32K instructions away, thus causing the error.  And how did we fix this problem?  By removing the -O2 option from the compilation command.

You wouldn’t normally run into these kinds of issues with modern compilers but it turns out we were forced to use an older compiler (3.3.1) with an older version of the standard C++ library (2.2.5).  So there you have it.  A small tip when using older compilers.

Tags: C/C++, Embedded, Programming

Conference Attendance Down - Sign of The Times

Jun.23, 2009 in Uncategorized Leave a Comment

Last week I attended the TI Tech Days conference in Dallas and it was a stark reminder of the state of the economy.  Last year TI had two major conferences, the TI Developer Conference and the Advanced Technical Conference.  This year they bundled both into one and shortened it from 4 days to 2.  The venue was still a nice place but you could tell that corners were being cut where possible.  I happened to notice that many of the rooms we were in had a large power supply sitting on the floor as if the main 220 box had been pulled from the wall and they had no place to put but on the floor leaning agains the wall.  It’s hard to describe and I should have taken a picture to show just how odd it seemed.

In TI’s defense, they’ve had to make changes to stay afloat (who hasn’t) and they even had the CEO, Rich Templeton, give the keynote address.  Now I don’t know how many gozillian-dollar companies have their CEO speak to the troops but it sure made me feel special, no lie.  What’s amazing is that the guy is not that old, he couldn’t be more than 45 (at least that’s my guess).

While Mr. Templeton is a good speaker he couldn’t disguise the fact that there were much fewer attendees this year than last.  No surprise given the state of things but it’s kind of sad because large conferences are cool.  You get to meet people from all over and you get to see a lot of cool innovations.

Hopefully, next year will be better.  Keep coding!

Open Source iPhone Woes

Jun.10, 2009 in Uncategorized Leave a Comment

You may have been wondering where I’ve been for the past few weeks.  Well, besides from working some insane hours, I’ve been trying to created programs for my iPhone using the open source toolchain.  Now I’m all about open source but I have to admit this is a lot harder than I anticipated.  I tried to use Linux but I couldn’t get the decrypting tools to work.  Ironically, I was able to get the dmg decrypting tools to work in Windows of all things so I went with Cygwin.  I was able to build the HelloWorld app which was way cool but I’m running into roadblocks getting the other examples to work.  Oh well.

Hackers Hold Data for Ransom

May.14, 2009 in Just Because Leave a Comment

Sounds like a bad tabloid headline but, according to this article, some mean people hacked the Virginia Prescription Monitoring Program and stole some patient and prescription data and are now demanding $10 M to return the data.  This story was picked up by the AP whom reported that the state of Virginia refuses to pay the ransom.

This is a disturbing story for two reasons:  1) you would think that with all the cool things you can do with technology, why would people still insist on doing bad things?, 2) will this become a trend?

I don’t know if you know this but kidnapping has become a common thing in countries like Mexico.  It’s become so common in fact that now it’s starting to take place in border towns–on the US side.  Someone is kidnapped on the state side and quickly whisked away to the Mexico side where the law is less likely to find them before the ransom can be paid.

So what does Mexico have to do with this story?  Well if one person can hold data for ransom, who’s to stop this from becoming more and more prevalent.  I guess the first thing we should take from this is the importance of security and backups.  The other thing is that crime is crime whether its physical or cybernetic and when a crime is committed we all lose.

Old School Programming Techniques

May.12, 2009 in Just Because, Programming Leave a Comment

This is an interesting article I found via Clive Maxfield (Engineer Extraordinaire) about programming skills that were once mandatory.  One interesting bit was Hungarian notation.  I use Camel Case but I still prefix pointers with a lower case “p” so I guess I’m still a little old school.  Punch cards are thankfully no more but I remember hearing other engineers talk about using them.  I remember taking a programming class where the instructor mentioned the “goto” statement and just simply saying “don’t use it!”  Can you think of any that are not on this list?  If so, just add them in a comment and we’ll keep out own list.

Tags: C/C++, Careers, Programming
« previous entries  
  • Sign up for out mailing list!

    E-mail:admin@embeddedman.com

    Subscribe
    Unsubscribe

    Get this Wordpress newsletter widget
    for newsletter software
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org

© 2007 Embedded Man - SafiTech Theme

Full RSS - Comments RSS