Sample LHFSD
 
 
Introductory Chapters


LEARN HARDWARE FIRMWARE AND SOFTWARE DESIGN


Back to LHFSD main page


Return to LHFSD main page

 
 
 Introductory Chapters LEARN HARDWARE FIRMWARE AND SOFTWARE DESIGN

*********************************************************************
Special fragment reprinting permission has been given to COROLLARY THEOREMS by O G POPA
Few special characters were lost while copying and pasting into the HTML page
*********************************************************************


LEARN HARDWARE FIRMWARE AND SOFTWARE DESIGN ISBN 9780978160449 © O G POPA
Covers and graphic design by O G POPA.

COPYRIGHT ENFORCEMENT
No parts of this book may be reproduced in print or electronic format without written permission from O G POPA.
No copies of this book in print or electronic format are allowed without prior written consent from O G POPA.
No translations of this book are allowed without prior written consent from O G POPA.
This book may be distributed only through sellers and resellers authorized by Corollary Theorems Ltd.
All firmware and software programs, or fragments of programs, presented in this book are for educational purpose only, and they must not be included in any commercial product.
Electrical schematics presented in this book may not be used for production of more than one PCB board per rightful buyer. The "rightful buyer" is the person who has paid the price required for this book to Corollary Theorems, or to other authorized resellers.
The accompanying Source-Code on CD is an integral part of Edition 4, ISBN 9780978160449; therefore, it is protected by International Copyright Legislation as it is explained above.

COPYRIGHT AND TRADEMARK ACKNOWLEDGEMENT
We made all efforts to mark registered names in this book by capitalization, and by inserting the registered mark (®), or trademark (TM) symbols on the first occurrence; however, we cannot attest to the accuracy of the information. This book should not be regarded as misinformation or as an attempt to the validity of any registered mark, trademark, or service mark. Should there be any unintentional omission on our part, we will introduce corrections upon notice if that is reasonably possible. This book is compliant with all copyright and trademark legislations. To our knowledge, no copyrighted materials from external sources were inserted in this book.

WARNING AND DISCLAIMER
All information in this book is for educational purpose, only. The author, O G POPA, and the publisher, Corollary Theorems Ltd., worked hard together to make this book complete, accurate, and suitable for study; however, that does not imply any warranty or responsibility on their side. Due to special character hardware, firmware, and software design work have, accidents could happen. Under no circumstances should the author or Corollary Theorems Ltd. be held liable for any possible loss connected to the information presented in this book.


FOR LIBRARY USE
This book may not leave the library, and it will not be lent in any way or form.
This book shall not be copied in any form.

EDITIONS
Edition 4 ISBN 9780978160449 © O G POPA, first published on August 15, 2007
Edition 3 ISBN 9780978160418 © O G POPA, first published on January 27, 2007
Edition 2 ISBN 0973567856 © O G POPA, first published on June 15, 2005
Edition 1 ISBN 0973567872 © O G POPA, first published on April 08, 2005

PUBLISHED AND DISTRIBUTED BY
COROLLARY THEOREMS LTD.

http://www.corollarytheorems.com/
#304 10420 148th Street
Surrey, BC, V3R 3X4, Canada
1 604 581 9214



REQUIREMENTS


My recommendation is, you should first read this book as a relaxed lecture. There are no additional requirements to understand it, excepting a little bit of logic--naturally. If you are an advanced hardware, firmware, and software designer, you do not necessarily need to experiment: just use this book as reference in your future design work. However, if it is your intention to learn from ground up and to experiment with all schematics and programs presented here, then you do need to prepare first. Please be aware that hardware, firmware, and software design work could be a bit expensive to deal with, and you should expect to invest something into acquiring the knowledge.

NOTES
LHFSD is not just another technical book: it presents in details a set of working hardware, firmware, and software projects. In order to do that, LHFSD makes references to complex Data Sheets, to professional compilers, and to specific hardware, firmware and software tools. Working with LHFSD is not easy: it requires determination, efforts and, most important, logic. Intelligent people are anywhere in society. Many doctors, teachers, artists, trades people and unqualified technicians have discovered they are in fact genii in programming. LHFSD can help you find your way.


LEARN HARDWARE FIRMWARE AND SOFTWARE DESIGN - FRONT COVER
This book deals with Microchip controllers, because they are still the cheapest and simplest technology available to start professional hardware and firmware design. For software design, Visual Basic 6 compiler is also one of the cheapest and most efficient software tools available. Of course, we are limited to the Windows® environment, but that is over 90% of all existing PCs! Any commercial program is written for Windows OS first, and before anything else. On the other hand, particular OS limitations refer only to the tools and technologies we use, because designing skills you will learn here work on all Operating Systems, and on other microcontroller brands as well. Now, after a first, relaxed lecture, it should be perfectly clear to you what to do next. If you decide to build yourself LHFSD-HCK, to test and learn the "how-to", then you need to procure few electronic components, and then the software compilers. Let's see what it takes to bring into factual reality all designs in this book.

For Hardware Design, you need, first of all, a "Schematic and PCB Editor", and there are many interesting options for that. If you already have one, then use the one you are most familiar with; if you do not have any, then you should go on the Internet and start with a search for "free PCB software". Have no fears, my friend, you will find your tool. The good thing is, PCB-CAD software design tools are greatly needed these days, and there are many companies striving to offer their products. Note this please: while some Schematic and PCB Editor software tools are priced in the range of 500 to 10000 USD, others are totally free! Well, not quite totally free, as you will discover--good things are never free--but they are a very cheap alternative. I dare say, in the near future the price of the PCB-CAD tools is going to drop dramatically. Even more, if any of the readers would feel "the call" for Visual Basic software development, I do encourage them to try developing a Schematic and PCB-CAD Editor--again, that is not very difficult.

Now, one way or the other you will get your software tools for hardware design, but the tragedy comes when building LHFSD-HCK. Although your board will work just fine, it is going to be rather expensive for a learning aid. We will calculate its approximate costs when we study BOM (Bill of Materials). Fact is, LHFSD-HCK is mandatory to implement all firmware and software programs in this book. Sure, as mentioned, if you do have some experience or a very sharp logic, you do not necessarily need to experiment with the firmware and software programs presented--in that case you will understand them logically, just by studying the accompanying source-code files. However, little hands-on experience is crucial when working with microcontrollers, so ... You see, microcontroller technology is somehow "custom", specific to each microcontroller brand, and even to each microcontroller family. Each hardware/firmware development environment has particularities, and there are specific "tricks" you need to know, in order to do the job properly. If you learn to control a particular family of microcontrollers, and if that particular family is a powerful one--as is Microchip's Digital Signal Controllers--then you have an enormous range of benefic applications ahead of you.

In order to help you reduce development costs, I will try contracting LHFSD-HCK with a local manufacturer; that should cut its price in half, or less, not to mention time saving. Please visit http://www.corollarytheorems.com/ where I will build few pages dedicated to LHFSD book. You should find there software updates for all source code in this book, and information regarding the future, possible, LHFSD-HCK kit. Now, even if you are going to buy your LHFSD-HCK from Corollary Theorems, you still need to study Hardware Design part very well, because hardware and firmware are strongly interdependent.

Firmware Design requires that you buy MPLAB ICD2 from Microchip. ICD2 is a very good investment, because you will have a Debugger and a Programmer in a single tool, for a wide range of Flash microcontrollers. Please buy the complete kit, with RS232 and USB cables, and with the AC/DC power adaptor included, because we need them all.

Microchip offers their MPLAB IDE (Integrated Development Editor) for free download, and that is quite a treat. Please be aware that MPLAB IDE is a complex editor, and you have to study it thoroughly before experimenting with the source code in this book. My advice is, before doing anything, just go to Microchip website and download MPLAB IDE--it is free, and you can download it as many times you want. The next step is, study MPLAB "Help" and its accompanying documentation for few days.

NOTES
It happened we had few clients asking for Customer Support related to using MPLAB IDE. We are sorry, but we cannot help you with that. First, MPLAB IDE has very good Help documentation and, secondly, it is Microchip's product.

Spline LHFSD

In order to work with the firmware source-code files accompanying this book, you need Microchip® C30 ANSI C compiler, and it is not cheap. You have to decide yourself if you will buy C30 or not. The good news is, Microchip allows for 60 days free trial period of a fully functional C30 compiler--a student version. You should download your C30 copy only when you feel you are ready, and you do have the necessary time. All firmware programs in this book have been developed during the 60 days trial period--together with many other tasks--and that means, it is possible. On the other hand, the firmware programs presented in this book may be easily ported on any other C compiler that handles Microchip dsPIC family of controllers, because they were written in ANSI C. All you need is, translate the header file and the ISR definitions to the new environment. As a note, C30 compiler is the last and most powerful firmware tool offered by Microchip. At the time of the 4th Edition, C30 V3.00 range of applications is: 24 dsPIC30F family controllers, each working at maximum 120 MHz and 5V; 37 dsPIC33F family controllers, each working at maximum 160 MHz and 3.3V; and finally 35 PIC24 family controllers, each working at maximum 160 MHz and 3.3V. Altogether, C30 covers 96, 16 bits microcontrollers--this is a lot!

NOTES
The 4th Edition of this book was written specifically to address the changes in MPLAB, C30, Visual Basic 6, and Windows XP/Vista. Therefore, the source code accompanying previous editions in not compatible with the present one, although it is greatly similar. The 4th Edition presents the source code developed with:

1. MPLAB 7.60 tested on Windows XP and Vista
2. C30 V3.00 tested on Windows XP and Vista
3. Visual Basic 6 with SP 6 tested on Windows XP and Vista

We try posting few major source code changes from previous Editions in our website, though not all of them. You need this book for complete, accurate information.

LEARN HARDWARE FIRMWARE AND SOFTWARE DESIGN - BACK COVER

Software Design is implemented using Visual Basic 6 compiler, and you do need this excellent software tool. Although modestly expensive, Visual Basic 6 is one of the cheapest compilers available of the professional type. Used efficiently, it can help you write beneficial, commercial products. For example, the first four SDx (Software Development; "x" is the number assigned) applications in part 3, Software Design, are everything you need to know in order to start developing a commercial product similar to the HyperTerminal one--even way better! Now, I let it to your appreciation if you want to work in part 3 with Visual Basic 5/6/.Net/2003/2005. The best alternative is Visual Basic 6, since it is well supported on both Windows XP and Vista. Further, a (technical) program developed with Visual Basic 6 is perfectly portable to Visual Basic .Net/2003/2005 with minor modifications. Note that Visual Basic .Net and 2003 are not (yet) supported by Windows Vista. If some readers already have Visual Basic 5, I encourage them to try implementing SDx applications using the code in this book as guidance. It should work, if you have the ActiveX controls I used; otherwise, try finding similar controls. LHFSD.exe has been tested on Windows 95/98/2000/ME/XP/Vista: it works perfectly well on any of them. Again, the most important is to understand the design method presented, because practical implementations could be easily changed to work on any Windows platform, and even on other Operating Systems.


NOTES
Microsoft has vowed to preserve Visual Basic 6 functionality throughout the Vista period estimated at five years, plus five more years, for a total of ten years starting in 2007. Please check this page: http://msdn2.microsoft.com/en-us/vbrun/ms788708.aspx about Microsoft support of Visual Basic 6 lifetime.

Even when Microsoft will cease upgrading/supporting actively Visual Basic 6, it will still remain functional for at least ten more years. However, if things will change, LHFSD will also be timely upgraded for future, new firmware/software environments. In addition, at Corollary Theorems website there is posted information about major source code changes from previous Editions.

Note again that the only working alternative to Visual Basic 6 supported by Vista is Visual Basic 2005--I tested it. For the 4th Edition, I preferred using Visual Basic 6, because it has more useful features than Visual Basic 2005 has, and it is far simpler to understand and work with. Additional reasons in favor of using Visual Basic 6 are presented in Software Design, part 3 in this book. Besides, you can upgrade Visual Basic 6 to 2005 or 2007 at any time.

You should use a second PC, if you want to work with ICD2 Debugger and Visual Basic in the same time. However, you could try a little harder and use both tools alternatively, on a single PC. An important issue is, you need both DB9 and USB ports on your PC machine. The best case scenario is to use one PC having RS232 serial interface--a DB9 connector--for Visual Basic and HyperTerminal, and a second one having one USB port for MPLAB ICD2.

Please be aware that, lately, commercial PCs do not have DB9 connectors: they work only with USB ports. If that is your case, you need to buy an "USB-to-Serial" cable adapter. The one I use is built by Sabrent® (M501-1022), and it is very cheap at 12 USD-it works perfectly well with USB V1.1 protocol. There are very many USB-to-Serial cable adaptors, and all of them are very good. After installing the firmware driver, you should restart your computer to register the driver with Windows [except for Vista]. Next, you will have a virtual serial COMx port on your PC/Notebook/Tablet PC working over USB, and you could start developing a lot of useful applications. I inserted the USB-to-Serial cable adaptor picture for your reference.

USB-to-Serial cable adaptor
Fig R1: USB to Serial cable adaptor

Some readers may shy away thinking RS232 serial communications interface is outdated and they do not need to learn it anymore. Not so, dear readers. The RS232 application presented in this book is a very good learning lesson if you want to understand the basics of serial communications. In my next book of the hardware, firmware, and software design series, I will build a USB interface to control hardware, but you will see that there is a lot less to understand from it, in terms of serial communications. USB is handled by Windows, and by the built-in factory firmware drivers. On the other hand, there are still millions of serial applications developed for RS422, RS485, RS488, CAN, OBD, etc., and all work similar to the RS232 examples presented in this book. All industrial and professional grade PCs use the RS232 interface, and they will continue to use it for a long time. The USB-to-Serial cable adaptor will install a COMx port working over USB, and that will help you control hardware and firmware in many great applications. No matter how we take it, the RS232 interface is a mandatory lesson.

Now, lets summarize the steps needed to start from ground up with hardware, firmware, and software design:

STEP 1
Navigate to http://www.microchip.com and download last version of MPLAB IDE then install it on your PC. Take a day or two and study it, but do not get scared with its complexity. You are going to master it in no time, and you need to work with only a fraction of its (very advanced) features.

STEP 2
Buy your MPLAB ICD2 from the most convenient supplier. Please buy ICD2 with the power supply adaptor, and with RS232 serial cable included. In Microchip website you will discover a list with all ICD2 suppliers.

STEP 3
If you have only USB connectors on your PC, you need to buy an USB/RS232 cable adaptor from anywhere you discover the cheapest price. Install your driver according to manufacturer specifications: that will add a COMx serial port on your PC working over USB. Download LHFSD.exe from http://www.corollarytheorems.com and install it on your PC, just to see how it works for you. Please be aware that you will build LHFSD.exe application exactly as it is presented, therefore you will know how to modify everything inside, including the way it looks. For now, just study its (partial) functionality in order to understand what you are going to learn in part 3, Software Design.

STEP 4
Buy this book, Learn Hardware Firmware and Software Design. If you decide to use LHFSD-HCK companion kit already built, you could get a fair price at Corollary Theorems. If you want to build the companion kit yourself, then use this book as guidance. Please be aware that building the kit by yourself is not easy: it takes a lot of time, and it is going to be way more expensive.

STEP 5
Buy your version of Visual Basic 6 from wherever you find the cheapest price. Visual Basic 6 is better, easier to work with, and way more powerful than Visual Basic 2005 is. Besides, you could upgrade Visual Basic 6 later.

STEP 6
Read this book first, and use LHFSD-HCK, MPLAB, and Visual Basic 6 only visually, at first, to understand the topics presented.

STEP 7
Download your free trial period C30, student version compiler from http://www.microchip.com. Make sure you do have the necessary time (60 days) to work intensively with C30.

STEP 8
Start working with each firmware and software application presented in this book. Try to implement the suggested tasks exercises until you feel confident you can modify and control each firmware program the way you want.

STEP 9
After working with all programs presented in this book, you will master all Microchip dsPIC controllers. Think of whatever applications you need/want to implement, then buy C30 compiler: now, you have everything you need to start designing your own commercial products. Use this book as guidance in your future design work.


At http://www.corollarytheorems.com we have a directory named "TOOLS": it contains many links to the products listed above. Again, do not be scared with the complexity of this learning process, and rest assured you will learn everything you need after working with LHFSD book and LHFSD-HCK kit. We monitor the book and the kit permanently for compliance with the latest developments in Windows, MPLAB, C30, and Visual Basic. This Requirements chapter is posted on the web at Corollary Theorems, and it will be modified to include future developments.

Lastly, regarding your personal skills, you should know something about the basic notions of electronics, and you should have at least some idea about C and Visual Basic programming. It is advisable to keep few good C and Visual Basic programming reference books close to your hand, if necessary, while working with this book.

NOTES
The LHFSD-HCK we are going to build together in this book is in fact a custom-built, little PLC (Programmable Logic Controller). Therefore, those readers who know something about PLCs are going to assimilate the knowledge presented here very fast. Note that LHFSD-HCK is way cheaper than a standard PLC system, a lot easier to design, and far easier to maintain/troubleshoot/modify. In addition, a custom-built PLC is a proprietary, unique solution, therefore it protects intellectual property, and it may also prevent most attempts of reverse-engineering.


As for the future, you do not have to worry. If you do understand and like what you read in this book, you will learn advanced electronics, ANSI C, and Visual Basic programming by yourself, in no time.

***
 


Back to LHFSD main page


Return to LHFSD main page

Send your comments regarding this page using support@corollarytheorems.com 
Page last updated on:
January 01, 2008
© Corollary Theorems Ltd. All rights reserved.
 

Valid HTML 4.01!


Page valid according to W3C