element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Business of Engineering
  • Technologies
  • More
Business of Engineering
Forum If I Had a Hammer
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Business of Engineering to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 34 replies
  • Subscribers 242 subscribers
  • Views 4666 views
  • Users 0 members are here
Related

If I Had a Hammer

jack.chaney56
jack.chaney56 over 8 years ago

I used this as a clever draw to get more readers.  The actual intent is to start a discussion and get input from people for software.  Most of the discussions I have seen on the site are about inventing hardware solutions to popular problems.  I guess I am getting overloaded with how many ways there are to turn on an LED.  A significant amount of computer work is actually in the realm of information technology,  Too often what is lacking are skilled individuals that bring an array of tools to the task. The expression "If the only tool you have is a hammer, all your problems look like nails" is a problem I deal with in my professional life. I am constantly faced with vendors who provide the one pony circus (a million ways to make a state machine).

 

Embedded programming is a discipline that requires the developer to be expert at OS scheduling, database management, hardware interfacing, design architecture, and structured objects, as well as proper coding style, and best solution language. It is a constant process of sharpening the tool set to get the best solution. I have taken to putting some tools into retirement as well. Archiving example code and hint/help files is done periodically so I don't have to keep my COBOL skills current, but, by archiving properly, it is possible with a bit of effort, to blow the dust off a few brain cells, and get back in step with my Fortran lines starting in column 7. (...how old is this guy?)

 

Getting back to where I started with this, I wanted to put a call out to all you embedded PROGRAMMERS for tips and techniques and tricks learned that can become the foundation for tool boxes.

 

Tips like:

  • Thinking like a computer
  • Faster graphics and ray tracing
  • Integer only formulas
  • Weight loss (or wait loss) compression
  • T...I...M...I...N...G...

 

Again, some of these are done with hardware these days, but not all solutions have bottomless bank accounts. Sometimes a one chip 8-bit piece of hardware needs to run an 8 cylinder diesel fueling operation.

  • Sign in to reply
  • Cancel

Top Replies

  • jack.chaney56
    jack.chaney56 over 8 years ago in reply to ntewinkel +4
    ntewinkel , Precisely what I was referring to. Fixed point for calculations saves tons and tons of calculation overhead and saves boatloads of memory. Time for my first contribution to the tools. Fixed…
  • DAB
    DAB over 8 years ago +3
    Hi Jack, I can sympathize. Using high level programming languages hide a lot of detail you need to learn when going into embedded programming. Luckily I learned assembly language programming on an old…
  • rsc
    rsc over 8 years ago +3
    The most important tip I can think of is to document what you do, both hardware and software. When you get to the point you're writing code in several languages on several compilers for different projects…
  • DAB
    DAB over 8 years ago

    Hi Jack,

     

    I can sympathize.

    Using high level programming languages hide a lot of detail you need to learn when going into embedded programming.

    Luckily I learned assembly language programming on an old PDP-11 minicomputer.

    That experience put me in a great position to dive into all of the microprocessors that came out after.

     

    I think you will find most work today is done in C, which in my opinion was a slight step above assembly language, but is reasonable simple to learn and use.

    Depending upon the vender you choose, most have extensive support libraries to implement both simple and complex applications on their products.

    Embedded operating systems get interesting.  In my day, yes I am probably older than you, we made simple control systems when we could and used more exotic OS products when the situation warranted it.

    I have built some very complex systems without needing an OS, but at the time, I had a great understanding of how the processors worked and how to exploit interrupts.

     

    Timing analysis was my forte, and I did some amazing things just by understanding how to fit functions together using interrupt timers and sometimes hardware additions.

     

    Everyone likes inexpensive tools and there are a host of those available free today.

    Arduino, Texas Instruments, Raspberry Pi, MBED, Pickit, and others have excellent free support tools.

     

    Take a good look at Energia, the Russians are making excellent progress with that tool to keep embedded software simple.

    They provide very useful examples and have very useful debugging tools.  I wish this type of support had been around in my day.  I used to chase things with an Oscope and logic analyzer.  Both very expensive at the time.

     

    There are also a number of free Operating Systems that you can pick up and learn.  Just be aware, it takes a while to get really proficient with each one.  My biggest problem with them is that you need to learn is what each OS does TO you.  Each OS has interesting implementations to efficiently facilitate your application.  Each can do interesting thing to your embedded software design, especially timing.

     

     

    So feel free to set up a list of questions, pick a vendor to focus on, and get started.

    I like TI, because they have a copious amount of documentation, a good of small to complex devices, all of which you can program with or without an OS using Energia or Code Composer Studio (CCS).

    Luckily, there is plenty of support on the web for most of the processor lines, it just depends on what you want to do and how complex you want to get.

     

    DAB

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Cancel
  • balearicdynamics
    balearicdynamics over 8 years ago in reply to DAB

    Woth similar background, I totally agree with you!

     

    Enrico

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • niteowl12
    niteowl12 over 8 years ago

    Jack,

     

    Unfortunately, good programmers are something that can't be developed. You can share the tools and examples but the ones that truly understand machine logic are the ones that will shine. There is something to be said for a hardware solution though. There are benefits, and limitations, to having a piece of hardware that has the same function as a set of software. I fully agree that there should be an array of tools and multiple options for completing the same task whether it be cleverly written code, an ASIC, FPGA, or a well designed feedback circuit etc.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • jack.chaney56
    jack.chaney56 over 8 years ago

    Hi,

    Thanks for all the feedback. I was hoping to spend most of my day today responding and entering discussions with a bunch of you, but sadly I still need to generate a paycheck, and some excrement has just contacted the rotary impeller, and I must attend to it.

     

    to quote... "talk amongst yourselves"

     

    Jack

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • shabaz
    shabaz over 8 years ago

    Hi Jack,

     

    Interesting discussion : ) I never studied Fortran (although friends did who were studying subjects like chemical engineering I think) but I still had to try to decipher it a while back, because some code I wanted to use was written in that language.

    I archive off bits of code that I write, to save effort or at least be able to inspect it and improve on it the next time around.

     

    Also, another tip could be to be prepared to get a book on a topic of interest (or even do a course) - many computing books get old quickly, but the knowledge at the right time is valuable and can save days/weeks of effort so it pays for itself.

     

    Sometimes it is really instructive to think like a computer as you say, and along with that goes becoming comfortable occasionally inspecting compiled output, examining library files, etc. Also another nice tool (occasionally!) is being semi-aware (but not spend too much time on it) of the instruction set and what the compiler is doing, so that when it comes to the (rare) low-level troubleshooting, you have a rough idea of how to follow the content in memory.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • jack.chaney56
    jack.chaney56 over 8 years ago in reply to shabaz

    shabaz

     

    I have this condition that a good friend remarked about. I always code in assembly, but think in objects.  No matter what language I am coding in I tend to analyze the instructions as to how they compile. Carry over from my old 360 system days when the compile was a job that had to be accounted as well as the runtime. It has saved me countless times knowing what the computer is capable of doing from a bare metal level, before applying high level axioms to the problem.

     

    I have noticed that more and more, the candidates for positions we are getting in (new graduates), are less and less familiar with the concepts of compiler design. I guess optimization is something best left to the experts at Microsoft image.  I feel myself slipping into old man dinosaur mode, thinking, "I remember when I was starting out..."

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Instructorman
    Instructorman over 8 years ago

    Seems like you have touched a nerve among the more seasoned members.

     

    A couple of your bullet point tips come right out of my teaching philosophy developed over a 25 year career of trying to get novice technologists to develop good coding habits.

    Specifically, "Thinking like a computer" and "Integer only formulas".  I have based many embedded systems programming lectures and labs on those concepts.

     

    I have spent many hours single stepping classes of young technologists through a block of code, getting them to process each instruction as if they were the CPU, predicting register values, asserting outputs, and following conditional branch instructions.

    The "integer only formulas" approach was especially useful when using an 8-bit microcontroller and a non-floating point capable compiler to do things like Fahrenheit to Celsius temperature conversion.

     

    Overall, I think the pedantic tedium I inflicted on my classes produced a net beneficial understanding of how computational hardware works in concert with code to accomplish useful things.

     

    Ah, the good old days.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • ntewinkel
    ntewinkel over 8 years ago in reply to Instructorman

    >"Integer only formulas"

     

    I noticed even fairly recently (within the last year I think) the difference floating point math makes for firmware. I'm pretty sure it was an Arduino app for an ATTiny I was working on, and as soon as I introduced some floating point math the package size bloated to use up far too much space (we're talking magnitude difference). And the kicker was that it wasn't even something requiring floating point - with just minor tweaks I brought the app size down immensely.

     

    I wish I could remember the exact example, but I'm sure it would be easy to replicate.

     

    -Nico

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • jack.chaney56
    jack.chaney56 over 8 years ago in reply to ntewinkel

    ntewinkel,

     

    Precisely what I was referring to. Fixed point for calculations saves tons and tons of calculation overhead and saves boatloads of memory. Time for my first contribution to the tools.

     

    Fixed point elements, the 16 bit solution

    All data elements have like conversions, and a single set of units. All conversions are done externally to the device, or at the UI level.

    Values are all maintained as integers types are:

    • Temperature -> absolute degrees K * 100 (0 degrees C stored as 27315)
    • Angle in binary radians 360 degrees converts to 32768
    • Ratios are all fixed point * 1024 or 100% == 1024
    • Pressure is stored in kPa * 100 absolute (1 atm stored as 10129)

     

    Limits of accuracy for equations are imposed based on 16 bit values

    • angles (error +/- 0.0109 degrees)
    • ratios < 6399.90% for unsigned or 3199.90% for signed (error +/- 0.049%)
    • temperature < 655.35 degrees K or 382.20 degrees C (error +/- 0.005 degree C)
    • pressure < 655.35 kPa or 6.47 atm (error +/- 50Pa)

     

    Additional limitations based on sensor measurement could be greater

    History: [JAC] Original creation when the earth was cooling, Copyright(c) 2016 Chaney Firmware...  Use it as much as you like, as long as I get credit

     

    Jack

    • Cancel
    • Vote Up +4 Vote Down
    • Sign in to reply
    • Cancel
  • Workshopshed
    Workshopshed over 8 years ago

    Back when I was doing karate, the students who had got to the top of their game went off and looked at other martial arts such as judo and taekwando. When they returned to karate their karate technique was better.

     

    This also works with software and hence it can be useful to look at other languages and areas to improve your own area. I've seen this myself bringing better code segregation and testing to VBA after a period with C#. I'm now doing all my hobby projects in NodeJS to see what that can bring.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube