Zibb
Subscribe to Control Engineering
FirstLight
Ask Charlie   


Recent Posts

Recent Comments

Most Commented On

Archives

Blog

Link This | Email this | Blog This | Comments (0)


Can I practice programming microprocessors in assembly language by myself on a PC?
September 10, 2007

This question comes to us from Ahmad Saeed, an engineer with the General Electricity Company of Libya (GECOL), who is interested in embedded control systems applied to electric power generation and distribution. He will receive an “Engineer, and Proud of It!” pocket protector with our thanks.

Yes, you can program microprocessors in assembly language, but I don’t recommend it. There are so many tools available to simplify programming embedded microprocessors using higher languages that fiddling with Assembler isn’t worth the trouble, even if you already know the language.

You are correct that the way to develop an embedded microcomputer system is to create all of your software on a PC-class computer, then deploy it to your embedded microcomputer. It’s a two-step process.

Developing an embedded control system proceeds in two stages: write and debug the code on a PC with the target system simulated in software, then download it to the microcontroller connected to the real target system.

First, you have to develop on your PC the software that will run on your microcontroller. To test the software, however, you will need a separate program that will simulate the target system. In this case, whatever electric power generation and / or distribution equipment you wish to control automatically. This simulation system exists only as software.

Think of the simulated system as a black box to which you send the control variables that your control software sets, and from which you get response variables that mimic what you should get from your target-system sensors. The simulated system likely has its own “control panel” that you can use to manually simulate faults, changes in environmental conditions, and so forth. Remember, all you are doing is changing values of variables shared by the two programs, which run simultaneously on your PC.

Once you have written and thoroughly tested your control software, you are ready to deploy it to the microcontroller, which your hardware folks have built and connected to a pilot version of your target system. Obviously, you don’t want to be debugging your control system on your country’s actual power grid! You won’t make the live connection until you’re absolutely sure it will work right.

As you can see, this is a complex process requiring you to create and integrate a lot of separate components. To do it successfully, you need all the help you can get.

Start with the company that makes the microcontroller you plan to use. All major semiconductor fabricators provide development kits to help you get through the process with as little angst as possible. Three that jump to mind are Rabbit Semiconductor, Freescale Semiconductor, and Advanced Micro Devices (AMD).

You should plan to write your application program in at least a third-generation language like C. Third-generation languages are robust, general-purpose languages that are easy for humans to understand and write. Assembler is a second-generation language that works at a low level and changes with the target processor. When writing in an assembly language, you have to keep track of all the registers, memory locations, etc., yourself. Third generation languages take care of all that. They allow you to deal with variable names and mathematical operations, instead of thinking about which bit goes where. There is still a fair amount of detail to deal with, however.

Fourth generation languages—sometimes called “frameworks”—step up one level in abstraction. National Instruments’ LabView, for example, provides objects (called “virtual instruments” or “VIs”) that collect all of the lower-level code modules needed to communicate with, for example, a data acquisition board, or a motor drive. For a power-generation system, you might create VIs to control entire gas-fired generators from sub-VIs that read sensors and operate relays.

When dealing with third and fourth generation languages, you communicate with the actual hardware you are controlling through software “drivers.” Drivers are code modules written in second-generation languages by the companies that manufacture the computer-controllable hardware components (such as drives for electric motors) that you need to make anything happen in the real world.

If you program with third-generation language, you simply include the appropriate driver library and use the high-level commands the hardware manufacturer provides. With fourth-generation language, it gets even simpler.

Find related products and software in the Control Engineering Buyer’s Guide.

Posted by Charlie Masi on September 10, 2007 | Comments (0)



POST A COMMENT
Display Name or Registered Users Login Here.

Before submitting this form, please type the characters displayed above:


Advertisement



Advertisements



About Us   |   Advertising Info   |   Site Map   |   Contact Us   |   Useful Sites   |   FREE Subscription   |   RSS
© 2008 Reed Business Information, a division of Reed Elsevier Inc. All rights reserved.
Use of this Web site is subject to its Terms of Use | Privacy Policy
Please visit these other Reed Business sites