₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,095 members, 8,420,309 topics. Date: Thursday, 04 June 2026 at 04:05 PM

Toggle theme

Guassian's Posts

Nairaland ForumGuassian's ProfileGuassian's Posts

1 2 3 4 (of 4 pages)

Science/TechnologyRe: EMBEDDED SYSTEMS Tutorial For Beginners:#include <module4.h> Experiments 1 & 2 by guassian(op): 7:05am On Mar 27, 2015
More circuit and pictures...

Experiment 1 led flashing breadboard implementation.

Science/TechnologyEMBEDDED SYSTEMS Tutorial For Beginners:#include <module4.h> Experiments 1 & 2 by guassian(op):
MODULE 4: EXPERIMENTS 1-5

Welcome again to my tutorials for beginners. In this tutorials, we will be designing hardware on proteus and as well as writing simple programs. We will import the software to the hardware on proteus just to test and see how it works before we implement. And we are going further to implement it on breadboard. These experiments will get you started on the real thing; I can assure you that you will gain a lot. If you have any question, don’t hesitate to ask. We will be writing programs also but I cant start taking the basics of C programming language now but as I go on, I will try as much as possible to explain some things you need to know. It will help you a lot if you can pick up an ebook on embedded C programming and read, then you can as questions here if you don’t understand.
If you are just joining this tutorial and you are a beginner, please read from the introduction https://www.nairaland.com/2175195/embedded-systems-future-electronics-computer or join the previous tutorial https://www.nairaland.com/2195254/embedded-systems-tutorial-include-module3.h

We will be doing 5 experiments:

Experiment 1: Flashing led, buzzer and creating a square wave oscillator
Experiment 2: Power-up delay/ Power on alarm(aka Nepa buzzer)
Experiment 3: Multiple outputs/ led chaser/ RGB led
Experiment 4: Traffic light system
Experiment 5: Introduction to 7 segment display system

Due to the fact that i was blocked several times by Nairaland antispam bot and i am still trying to figure out what I am doing wrong, for the meantime the full text of this tutorial Expertiment 1 is in the doc file attached to this post proteus DSN file, CCS C souse code and Hex file is also attached to the RAR file. Sorry for the inconveniences

Experiment 2 will be posted soon on this thread. Watch out

ProgrammingRe: Embedded Systems: Future Of Electronics And Computer Engineering. by guassian(op): 10:42am On Mar 21, 2015
Ok...
Its good to start early and don't hesitate to ask questions when you are stuck.
Science/TechnologyRe: Embedded System Tutorial #include<module2.h> :what Is A Microcontroller? by guassian(op): 11:11am On Mar 20, 2015
Hi there, this is the link for the next tutorial MODULE 3 https://www.nairaland.com/2195254/embedded-systems-tutorial-include-module3.h
Science/TechnologyRe: Embedded System Tutorial #include<module2.h> :what Is A Microcontroller? by guassian(op): 11:10am On Mar 20, 2015
Hi there, this is the link for the next tutorial MODULE 3
Science/TechnologyRe: EMBEDDED SYSTEMS Tutorial:#include <module3.h>software And Hardware Tool Needed by guassian(op):
Mistake in the word document, the site to get basic electronics construction tutorial is www.electronicsclub.info
Science/TechnologyRe: EMBEDDED SYSTEMS Tutorial:#include <module3.h>software And Hardware Tool Needed by guassian(op): 10:40pm On Mar 17, 2015
@savotech and whole house, i am so sorry. I dont really know why NL keep deleting my post. i have tried several time to post the 2nd part which is the hardware tools but i am always banned and the post deleted. i am new in nairaland and i dont know what i am doing wrong.

But in the meantime I have attached the continuation as a word document at the bottom of this post.
ProgrammingRe: Embedded System Tutorial #include<module2.h> :what Is A Microcontroller? by guassian(op): 6:11pm On Mar 15, 2015
Science/TechnologyEMBEDDED SYSTEMS Tutorial:#include <module3.h>software And Hardware Tool Needed by guassian(op): 7:15am On Mar 14, 2015
MODULE 3: SOFTWARE AND HARDWARE TOOLS NEEDED

INTRODUCTION
Welcome again to my tutorials. Sorry for taking too long for me to post, it was due to some technical issues. Today I will be covering the basic hardware and software tools needed to start an embedded system project using a PIC microcontroller. Remember I said in the last tutorial that I will limit this tutorial to the use of PIC MCUs not because others are not good, but because it is popular here in Nigeria and its very easy to use.
I will be listing the tools needed and explaining the importance and why you actually need them. This is actually for beginners. Intermediate embedded developer and professional, I still have you in mind. Let me finish with the basic, and then we start discussing some complex embedded circuit and also sharing ideas.
If you are new to embedded systems and to this series of tutorial i will advice you read my previous tutorial on nairaland https://www.nairaland.com/2181302/embedded-system-tutorial-include-module2.h or start from the introduction https://www.nairaland.com/2175195/embedded-systems-future-electronics-computer.

I actually prepared images after each subtopics but i find it difficult to insert image along side with text. so you will see the images at the end of the post

SOFTWARE TOOLS

SCHEMATIC DESIGN TOOLS:

This is a circuit designing and simulating software environment. Actually, electronics design has gone beyond drawing schematics with your pencil and ruler or drawing with Microsoft word or AutoCAD or Corel draw. Though you might still need all these tools for further design of the mechanical structure of finished product or you might need a little graphics to prepare presentation for seminars or exhibition. Schematic design software helps you to easily create your circuit because it has many libraries of commonly used components standard symbols and has auto features which will aid you to connect all the components together neatly. Many of these schematic design tools now have simulation and animation features which enable you to virtually test your circuit and see how it works. As debuggers is to a programmer which allows them test their code gradually as the build and add lines and before finally exporting it as finished application, so a simulator is to an electronics designer and it is very helpful especially to a beginner. Practical Electronics is not really like programming that will give you syntax error, semantic error or any other type of error when not written properly; In electronics, if the circuit is designed and/or connected recklessly, can blow up components, cause fire thereby wasting money and putting lives and properties in danger.
Some professional schematic design and simulation software comes with many feature and has many tools like multimeters, signal generators, oscilloscope, test probe etc. this to a great extent helps a lot of circuit designers to easily model circuit and see how it works before implementation. There are many schematic design and simulator software that you can get easily online such as eagle, Orcad, proteus, tina, multisim, livewire etc. All these are expensive softwares which comes in trial versions but thanks to some hackers who create cracks for all these softwares and make an average hobbyist enjoy the full features of these softwares. Out of all these softwares, you might ask a question on which one is the best. Well, all are good to in their own capacity but personally the ones I like and have used is proteus, livewire and Tina.
These three has their own merits and demerits but some are just far above average on the scale of comparison. Comparing this three:

LIVEWIRE: this is a very good software which is not complex and it is very easy to use and flexible. It has many testing tools such as multimeters, oscilloscope etc. It is very easy to use such that u can figure things out yourself without the prior knowledge of schematic design. The IDE is easy to install and most livewire software you see online are portable software (they don’t need to install on your hard drive). The simulation animation is superb, plotting of graph is very easy, it has a function to see current as it moves in the circuit. The demerit of livewire is that it doesn’t have enough component library to cater for the growing needs of circuit designers. It cannot simulate embedded systems circuit so you will barely need it for the sake of this tutorial.

TINA: This also is a very powerful software that I respect and give kudos to them. This software is very good in the area of analog electronics and analysis such as AC analysis DC analysis, symbolic analysis which generate formulas for you to mathematically calculate voltages and other properties of in your circuit, Fourier analysis etc. As a student you need to get this software, it will be useful for you to solve complex electrical network and circuit theorems problems. I stand to be corrected, Tina too cannot be used to simulate microcontroller project.

PROTEUS: this is the best schematic software of all time. It has thousands of components and it is very professional in nature. It can be used to simulate microcontroller and microprocessor. It has inbuilt assemblers and it can be integrated with many compilers. It is the best embedded schematic and simulation tool I have ever seen. It has many functions more than you need to start embedded system. As we all know that no system ever created is 100% perfect, proteus too has many short comings and that is in the area of COMPONENT MODELS or libraries or supported devices. There are still so many devices you might want to use but wont get it on proteus, but I don’t actually blame them directly because thousands of components are created everyday and if they should include all of them in the model, it will be too cumbersome so they put the frequently used once and however, where that problem is actually solved is that you can create your own model and add it to the proteus DLL files but these models are not for beginners or intermediate or even masters, simple models are for professional while very complex ones are for emeritus.
This is the download link for proteus 8
http://dc263.4shared.com/download/o2QOjJ3Kba/proteus_8_full.rar?tsid=20150312-213840-cae30fea&lgfp=2000


SPICE: The full meaning is Simulation Program with Integrated Circuit Emphasis. It is mostly used to simulate analog circuit and it is ancient in nature and are not frequently used as the world of technology going digital. It is the “most worstest” (if there is any word like that) simulation tool a hobbyist or engineer can use in these modern day and unfortunately it is what most universities has been using since the 80s and are still using, they haven’t changed their curriculum. I stand to be corrected, spice is a piece of crap; it cannot be used to simulate even a very complex analog circuit. It cannot be used to simulate complex digital circuit, there is no multimeters, oscilloscope, it is not graphical based but a command line based (analogous to using command prompt in a computer to open a file instead of the click of a button). I can’t exhaust the demerits. Lets move on, I don’t want to bore you with this, you can search online for more information about it and see for yourself.
WHY SIMULATION
Many hobbyist do projects without simulation not that they don’t know that the software exist, they even use them just to design circuit but don’t see the need of simulation. Listed below are the reasons why you need simulation:
1. For easy development of circuits from the scratch.
2. It helps an engineer who has little practical knowledge to design and test his design without the intervention of a technician or having to buy expensive components.
3. It helps an engineer to easily determine the effect of variation of component values.
4. It reduces the risk of electric shock and fire caused by curious beginner hobbyist.
5. It makes circuit design easy, cheap and time efficient because you have ready-made multimeters, oscilloscope, signal generator and other tools.
6. It helps you to debug and test your embedded software in the virtual hardware on the simulation environment. This will make embedded system development easy because you might need to edit a complex code up to 100 times before you get it working perfectly.
7. It also aids teaching and lecturing.

How I wish many our university and polytechnic lecturers knows how to use simulation tool, circuit theory explanation and calculation would have been a piece of cake but its never too late. If you are still in an undergraduate and were not thought simulation, you can walk up to you lecturers or HODs and challenge them politely (or get you’re a*s kicked). But you as a student can take it as a challenge to learn it yourself, this will help you a lot especially if your area of interest is electronics.

WHERE SIMULATION WOULD NOT WORK
Simulation has its own limitations. One of the disadvantages is that is makes student lazy and it assumes an ideal environment. Take for example a resistor and capacitor which in real world has 5%- 10% tolerance due to its properties changing with temperature humidity and other factors, the simulation assumes a 0% tolerance. There is no Electromagnetic interference in simulation which is a major problem in the real world circuit.
A circuit can be assumed to be working perfectly on simulation because it assumes many ideal condition and use default values, but when such circuit is implemented and there is problem can go a long way to frustrate the beginners. So it is always a best practice that after a circuit is simulated, it should also be experimented on breadboard to see the real life working.
Simulation will also not work in some cases because the actual real world cannot be fully represented by a computer. In such case, an additional circuit or device can be added to the simulator via computer USB port or serial to get real world analog data. Take for example, in the design of a fire sensor which uses smoke, heat and flame sensing circuitry; you cannot virtually start a fire on the system except there is a model that does that. A solution to this is to physically build a fire sensing circuit and connect it via the USB or serial port or parallel port to the simulation software. Another example is a fingerprint related project, how on earth can you simulate that? It needs biodata(fingerprints) which will be difficult to model.

SOFTWARE DEVELOPMENT TOOLS
Software development tools are computer programs, and they usually run on personal computers, that allow the programmer (or system developer) to create, modify, and test applications programs. Some common software development tools are:

Text Editors
A text editor is used to create or edit software programs and text files. The Windows operating system comes with a text editor program called Notepad. Using Notepad, we can create a new program file, modify an existing file, or display or print the contents of a file. It is important to realize that programs used for word processing, such as Microsoft Word, cannot be used for this purpose, since they embed word formatting characters such as bold, italic, and underline within the text. Most assemblers and compilers come with built-in text editors, making it possible to create a program and then assemble or compile it without having to exit from the editor. These editors provide additional features as well, such as automatic keyword highlighting, syntax checking, parenthesis matching, and comment line identification. Different parts of a program can be shown in different colors to make the program more readable (e.g., comments in one color and keywords in another). Such features help to eliminate syntax errors during the programming stage, thus speeding up the development process.

Assemblers and Compilers
Assemblers generate executable code from assembly language programs which is a low level language, and that generated code can then be loaded into the flash program memory of a the microcontroller. Compilers generates executable code from high-level language programs by first of all converting the “English language” related code to low level language and later generate an executable code with the file extension ”.hex”. that means all compilers comes with an inbuilt assembler. Some compilers have the feature to allow developers write in both low level and high level on the same source code. The compilers used most often for PIC microcontrollers are BASIC, C, and PASCAL. So which one is good? Writing with assembly language or high level. I will leave this to some guru on this Nairaland who has done justice to that. That guy is something else… He is really like me, we have almost same thought on this issue and i agree with him totally.

he wrote and i quote


Microcontroller programming knowledge is best to start with assembly language, but for easy and quick knowledge, C is better. Reason is because with C,u don't have to controll the microcontroller directly with mnemonics but all u have to do is to write statements for the C compiler and it will generate the equivalent assembly language for the microcontroller.
So C its just a servant for u.
E.g creating a 1 secon delay in c is just:
Delay_ms(1000);
While in assembly, u will have to write at least 10 lines and do a lot of calculation before u can acieve that.

I stand to be challenged and corrected by all assembly language freeks out there. I coded in assembly for a year and I know what I am saying. So to those that says C is for lazy people, its not about lazyness but about knowing what you are doing and using the easy and fast method to achieve it. And the beauty of intelligent C compilers is that if there are registers u cannot access with C, u can write assembly code in line with C using #asm.

Even with C that is regarded as "code-servant" when using preinstalled functions, looping, iteration etc, u can develop an embedded application e.g password acces system for as long as a whole day, now imagine using assembly language that u are to do the whole job yourself. Show me what u can do in assembly language that I can't do in C apart from the ram optimisation and reduction of hex file.

If u are a newbie I will advice u use to learn assembly language just for a short period of time so that u won't be an illitrate in that aspect. But the koko is C language. And also use CCS compiler for PIC microcontroller. Its very easy, intelligent and has a lot of preinstalled peripheral and memory drivers.

So if u wanna learn microcontroller progamming, Start from how numbers are being represented in hex,bin,dec then how to set ports as input or output, then writing logic state to port, on a LED,then learn to use delay,flash a led, then how to create loops, while loop, do while loop, for loop, then how to create a christmas light led chaser, then how to read from input ports, then how to create traffic light with delays, then how to use 7 segment display and also to cascade to give u more digits, and how to multiplex, then how to write to lcd display and how to read from 4x4 keypay etc.

The ccs compiler has help file or manual which u can read to get all the syntax and functions availabe. And u can check example programs to guide u. Know that when u start, u will get a lot of errors and sometimes everything might look frustrating but continue and don't give up. The more u learn and practice syntax, the less error u get.

U also need to install a proteus simulation software that will enable u to design the circuit virtually and run your program on it to see how it works before u actually implement it physically. This will help you save a lot of time and component used when experimenting. Cos u don't need to buy anything. Unlike doing it physically and blowing up your components due to errors.

I hope this is useful information to atleast one person that needs it.
copied from https://www.nairaland.com/1550279/engineering-students-chatroom/6

To add to what he said, back in the dark ages of microprocessors, software development was done exclusively in the specific assembly language of the specific device. These assembly languages were character based ‘mnemonic’ substitutions for the numerical machine language codes. Instead of writing something like: 0x12 0x07 0xA4 0x8F to get the device to load a value into a memory location, you could write something like: MOV 22 MYBUFFER+7. The assembler would translate that statement into the machine language for you. I’ve written code in machine language (as a learning experiment) and believe me when I tell you that assembly language is a major step up in productivity. But a device’s assembly language is tied to the device and the way the device works. They are hard to master, and become obsolete for you the moment you change microcontroller families. They are specific purpose languages that work only on specific microprocessors. C is a general-purpose programming language that can work on any microprocessor that has a C compiler written for it. C abstracts the concepts of what a computer does and provides a text based logical and readable way to get computers to do what they do. Once you learn C, you can move easily between microcontroller families, write software much faster, and create code that is much easier to understand and maintain.
Assembly language is used very useful in applications where processing speed is critical, where each registers of the MCU must be controlled precisely and the microcontroller must respond to external and internal events in the shortest possible time. However assembly language programs are not easy to maintain but High-level languages like C C++ are on the other hand, are easier to learn, and complex programs can be developed and tested in a much shorter time. All experiments in this tutorial limited to the C language using CCS compiler. Many different C language compilers are available for developing PIC microcontroller-based programs. Some of the popular ones are:
1. CCS C (http://www.ccsinfo.com)
2. Hi-Tech C (http://htsoft.com)
3. C18 C (http://www.microchip.com)
4. mikroC C (http://www.mikroe.com)
5. Wiz-C C (http://www.fored.co.uk)
Although most C compilers are essentially the same, each one has its own additions or modifications to the standard language.


This is the download link for CCS C Compiler. you can also get others from www.4shared.com
http://dc535.4shared.com/download/jqtu4IBGba/ccs_pic_c_compiler_pcwdh_4114.rar?tsid=20150312-213902-153fcdab&lgfp=2000

Science/TechnologyRe: Embedded System Tutorial #include<module2.h> :what Is A Microcontroller? by guassian(op): 10:30am On Mar 06, 2015
GrAnDwEeZ:
I'm with u bro. following. Currently studying elect elect with no practical experience @ all. This is d kinda platform I ll need 2 kick me started. Got a laptop. No knowledge on programming @ all. It ll b nyc if u can com down 2 a beginners level as much as possible. Thanks
Kindly follow this tutorial from the beginning including comments and contribution. Links to some useful books is there where you can learn basics and i recommend this book for you "practical electronics for inventors". Just type the name on google search or copy and paste this link on your browser https://www.google.com/url?q=http://www1.appstate.edu/~curtincm/sculpture/suppliers/gizmos/Practical_Electronics_for_Inventors.pdf&sa=U&ei=PHP5VOytCMXgaqbxgcAH&ved=0CA8QFjAC&sig2=yiiMQdx1Rlqthj_99Lgp1Q&usg=AFQjCNH2L9FW0j2Xz8jrAGWtFUqfq2aoiw
ProgrammingRe: Embedded System Tutorial #include<module2.h> :what Is A Microcontroller? by guassian(op): 7:24am On Mar 06, 2015
Memories of the microcontroller.
Memory is a very important component of any computer. When we go to market to buy phones and PC the first thing we ask is the memory size. Memory in Embedded systems is very important just as human beings needs memory to store tasks and information. As we have discussed ealier, memory size in microcontrollers is very low compared to one in smartphones and personal computers because what a MCU needs to control or memorize is very small. A 256Mb of RAM in a PC world is very low and obsolete but in a MCU world, 512Kb of RAM has never existed (i stand to be corrected).
There are three major types of memory in embedded system. RAM(Random Access Memory), ROM(Read Only Memory) and EEPROM(Electrically Erasable Programmable Read Only Memory). All these have its major functions which cannot be used interchangeably.

RAM is used to store and read temporary data with high speed and does not have limit of the number of times it can be accessed. Its content is lost when power is lost and can never be retrieved again. Its content can be accessed at “Runtime” i.e time of use of the MCU in applications.
ROM is used to store data permanently and can only be changed at “program-time” i.e time of burning program into the MCU and its content can never be changed at runtime. The instructions ececuted by MCU and some temporary data are stored in the ROM. Ordinary ROM is OTP(one time programmable) i.e it can only be programmed once, just like your CD-ROM which information can only be written to it once. A special kind of ROM called Flash ROM is what a MCU use, this technology allows ROM to be reprogrammed up to 100,000 times. This flash technology allows us to re-write and read information from a ROM at program-time, and this makes MCU attractive for students and Hobbyist. However, the disadvantage of flash ROM is that it is costly, so companies go for OTP ROM MCU because they must have been sure of the content of what they want to program into the chip and do not have any need to reprogram.
EEPROM is a type of ROM that is used to store data permanently also but just that it can be electrically erased and reprogrammed i.e. its content can be modified at runtime and it will retain its data for more than a century. It is what is synonymous to floppy disk or Hard disk of a PC. The number of read and write times of EEPROM is limited; about 1,000,000 times and the write and read speed is quite low compared to a RAM. So an EEPROM cannot probably be used as a RAM in real practical situations.
I/O (Input/Output) PORTS is a gateway for the MCU to communicate with the outside world i.e. it is a physical connection port for the microcontroller to get data from transducers or other input device into the MCU and also gives processed data from the MCU to output transducers or peripheral. General purpose ports are used to get logical data(1 and 0, high and low ) from input device and also send logical data to output device. Some PIC microcontroller in addition to the general purpose function, has many special function ports ranging from USB port, UART port, SPI, I2C, ADC ports, PSP, PWM etc.

Resetting the Microcontroller
On every PIC microcontroller you will find a pin labeled as MCLR. This pin has two basic functions. Used to reset the microcontroller like a soft-boot and as well as to put the microcontroller into programming mode. A MCU can “hang” just like your smartphone and your PC used to hang and you probably need to restart it by switching it off or removing the battery. A MCU can hang when there is a power brownout (low voltage or fluctuation) or when the programmer writes the instruction such that he tells the microcontroller to access a memory location that does not exist and thereby makes the MCU practically lost in the program flow and could not find its way back to execute the next instruction, the MCU needs a reset to bring the program flow to the initial state.
The MCLR pin when connected to ground(0 volts or logic 0), will reset the microcontroller, and keep it in a reset state or OFF state, till the mclr pin is connected to 5v before the MCU restarts. After a reset, the microcontroller will have all its RAM reset, and program execution will begin, just like the system has been just powered on. A 10K “pull up resistor”(used to give an input pin a default logic 1) is usually connected with the mclr pin, to keep it high when reset switch is released.
The mclr pin will also work as program mode pin i.e it is used to tell the MCU to go into programming mode when a programming device wants to modify its ROM content. When new software is to be downloaded into a PIC MCU, about 13.5V is applied to the MCLR pin, by your programming device. This can be done right in your circuit called ICSP(In-Circuit Serial Programming), or by taking the IC out of circuit and putting it into the IC socket on your programmer. More about programming Device will be discussed in another module of this tutorial, probably when we do the first experiment.

Analog and Digital Data
Microcontrollers use digital data to represent everything. Even music, videos and images all are represented as digital data, which is a series of logical ‘0’ and ‘1’. However our real world data is not digital. It is rather analog. It is rightly said, “We live in an analog world, but process the data in digital world”. Real world data like light, temperature, pressure, heat, height, distance, speed, force etc. all are analog data. In order to utilize these data we have to acquire them with specific sensors or transducers and then convert into digital format for use within microcontroller’s digital world.
Many other microcontrollers require an external ADC(Analog to Digital Converter) chip to implement this, however this feature has been nicely built into PIC microcontrollers. The number of Analog channels varies among PIC MCU but typically they have about 5, and some PICs do not have this feature on-board. Pins labeled as AN0, AN1 etc are for analog data if required, however they can also function as normal digital pins to work with digital data.

PROGRAM OR FIRMWARE OF MICROCONTROLLER
A Program is nothing but a series of instructions, in a correct and logical manner to instruct the microcontroller to respond to various inputs and give specific output. By changing the program, the behavior of microcontroller will change. The MCU doesn’t come with a preloaded function from the manufacturer. Using an analogy of a music system, the manufacturer has not designed it to produce any particular sounds out of its speakers, yet it has all the necessary circuitry to do that. What music it will produce would depend upon the tape, or CD inserted. Thus you change the CD, and the same hardware is playing different thing. So we can say that the music system, is a programmable device, and the information stored on tape, or CD is the program, or instructions to help the music system make sounds.
Similarly microcontrollers are programmed to do a job. The job can be changing a TV channel to controlling complex movements of a robot, control all home lighting and electrical appliance etc. All these applications have a microcontroller doing its specific job. It can be astonishing to find the same microcontroller in the remote control, and the robot. In one place it is driving an infra-red LED and in other it is driving the motors. So the same hardware serving thousands of different jobs. You have to learn the instructions your particular microcontroller understands, and what those instructions order it to do. Then it’s your mind, and ideas how you play with these instructions to get your job done. Literally there are hundreds of methods to get the same job done. Just like in English, there many ways you can arrange the alphabets, to convey the same message.
Programming the microcontroller
Programming is a mechanism to transfer the compiled program into the microcontroller’s program memory. Like earlier said when talking about memories PIC microcontrollers have a separate area of memory called program memory or ROM. The size of this memory differs in various chips.
The source code is written which is called the program with either low-level language or high-level language. This program is assembled or compiled with an assembler or compiler respectively to generate an object code usually with a file extension of “.HEX”. It is otherwise known as “hex file”, analogous to a computer’s “.EXE”. This hex file is loaded or burnt into the PIC with a device called “Programmer”. As people from PC world are used to talking about megabytes and gigabytes, most of programs written, will not exceed few hundred bytes. This is because unlike the PC the microcontroller has less to do with videos, pictures, and music. These devices are not meant to run windows, but to control a specific device based upon certain input and logic.
In order to put your microcontroller into programming mode, the MCLR pin has to be driven up to 12-13.5V. This is referred as VPP. The VPP is generated by programmer. Once VPP is applied to MCLR pin, the processor stops functioning and accepts data from programmer on PGD and PGC pins, which are mostly RB7 and RB6 pins on microcontroller. The programmer first erases the old program memory and then writes new program and EEPROM data if required. After the program is transferred it is verified. After successful programming, the VPP must be taken down, so that the program may be started.
There various programming device in market. There is a universal programming device which can program all types of microcontroller but they are quite expensive. I recommend you use a PIC programmer which is very cheap and you can also build one for yourself. Someone has made the work easy by posting this link on Nairaland ( https://www.nairaland.com/2157202/simplest-reliable-pic-microcontroller-programmer ) I bet this circuit works like magic. The disadvantages it has is that it uses 15v power supply which make you look for mains electricity when u can power the rest of circuit with a 5v power bank, it uses serial port which most modern laptop doesn't have, old Dell D630 has serial port and some old HP laptop too. So you will need a USB programmer if you intend to use a modern laptop. If you need a cheap and reliable USB programmer, contact www.hub360.com.ng and make your request.

Conclusion
Forgive me if I am boring you with theories; these are summaries of some of important things you need to know and you will surely need them when I start showing you practical examples. Please read more online about the little you learnt in today's topic as this will give you broad knowledge and make widen your scope.
In the next tutorial, I will be exposing you to the various software and hardware tools you will need to start performing experiments and doing projects. I will be giving you links to where you will download very useful software free. I bet you will gain a lot. Remember, I will be posting the next tutorial with a new post. This will help to give room for continuous comments, contributions and questions on the topic of today and will avoid unnecessary long thread.

More information about today’s tutorial can be gotten from these links.
http://www.personal.rdg.ac.uk/~stsgrimb/teaching/programming_pic_microcontrollers.pdf
http://www4.hcmut.edu.vn/~bmthanh/ESD/Programming%208-bit%20PIC%20Microcontrollers%20in%20C%202008%20Martin%20PBates.pdf
ProgrammingEmbedded System Tutorial #include<module2.h> :what Is A Microcontroller? by guassian(op): 7:21am On Mar 06, 2015
#MODULE TWO: MICROCONTROLLERS AND MODERN DAY ELECTRONICS:

Welcome again to my Embedded systems tutorial, last time we learnt about embedded systems in general (https://www.nairaland.com/2175820/embedded-system-tutorial-beginners-include ) today we shall be learning in summary what a microcontroller is, memory types, oscillator, ports, programming the microcontroller etc. Remember that the aim of this tutorial is to give you a summary, basic things you need to know to arouse your interest, you still need to pick up an ebook and read in details if you want to have full knowledge. And don’t hesitate to ask questions if you don’t understand anything discussed in this topic and embedded systems in general. This tutorial is quit long but I bet you will gain a lot. Please Just Exercise patience and read through till the end.

INTRODUCTION
Looking back into the history of microcomputers, one would at first come across the development of microprocessor, but the stand alone microprocessor is not self-sufficient. It requires other components like memory to store data and I/O devices that serves as a gateway to receive and transmit data to and from the microprocessor, to form a workable system configuration. The device which contains a microprocessor and the above mentioned components in small scale on a single chip is a microcontroller. The introduction of microcontrollers drastically changed the microprocessor based system design. There are various type of micro controllers such as: AMR, Atmel AVR, Intel 8051, Infineon, ZILOG Z80, Motorola M68HC11 series, Microchip PIC etc.

Microcontrollers are integrated circuits, but they differ fundamentally from other ICs. They are a class in themselves, and the designers have not made them to do a particular job. As such when you buy them from the market, you can not specify what function it will do. In order to get some useful function, these ICs have to be configured or programmed. Thus a microcontroller can be configured to check the status of a button, and then turn a motor ON or OFF and lit an LED etc. While the same IC can be configured later, to read the status of an infra-red sensor, decode the signal and turn another device ON or OFF or send a number to a LCD screen etc. If these two types of circuitries mentioned above were to be made using conventional digital ICs, it would have required a large number of components. Moreover any change in the specification, like change of Infra-Red codes would result in total change in design, but using a configurable IC, no design has to be changed but just the program has to be edited.
Not only that the same IC can be configured to do different tasks, but a change in specifications can easily be implemented by just changing the device configuration some lines of programming codes. This greatly facilitates the engineers and hobbyists to rapidly develop new electronic devices, and continuously improve previous ones. Not only the hardware requirements decreased, but also design time, and time to market were decreased. Microcontrollers therefore took over the market. Large hardware designs were reduced, and most of the circuitry was replaced by the configuration scripts. Today we call this ability to configure a microcontroller “Programming”.
Someone might be thinking why are there so many types of microcontroller and which is best to use. No microcontroller is better than the other, each has both advantage and disadvantage, some are costly and others are cheap, some are of big sizes and others are small, some has many I/O ports and peripherals for easy interfacing while others does not have enough and so on. There are many microcontrollers available for developers to choose from. The microcontroller used mostly in Nigeria here are the PIC Microcontroller, ATMega, AVR but PIC and is what I will most likely be using for tutorials on this Nairaland because it is the one I am most familiar with, it is easy to use and has lots of inbuilt peripherals e.g internal oscillator, ADC, timers etc and also so many compilers supports it. Eg mikro C, CCS C compiler etc. Forgive me if you have already been learning other types of microcontroller, but I can tell you that they all do the same thing and the principles of operation are all the same, they just differs by architecture, inbuilt peripherals etc.

THE PIC MICROCONTROLLER
Although microcontrollers were being developed since early 1970’s real boom came in mid 1990’s. A company named Microchip® made its first simple microcontroller, which they called PIC. Originally this was developed as a supporting device for computers to control its peripheral devices, and therefore named as PIC, Peripheral Interface Controller. Thus all the chips developed by Microchip have been named as a class by themselves and called PIC. Microchip itself does not use this term anymore to describe their microcontrollers; however use PIC as part of product name. They call their products MCU’s.
A large number of microcontroller designs are available from microchip. Depending upon the architecture, memory layout, number of input and output ports and processing power. They have been classified as low range, mid range, high range and now digital signal processing microcontrollers. The beauty of these devices is their easy availability, low cost and easy programming and handling. This has made PIC microcontrollers as the apple of hobbyists and students eyes. We shall be using PIC12f683(8 pin), PIC16f88(18pins), PIC16f877A,PIC18f452 as in various experiment for this tutorial.
[pic pinout diagrams]

BASIC THINGS YOU NEED TO KNOW ABOUT PIC MICROCONTROLLERS

Power Supply to the Microcontroller

All electronics components or circuits needs power supply to work either high voltage AC or low voltage DC. Fortunately for us, the PIC microcontroller uses low voltage so we are safe and not at risk of electric shock except we are using the MCU(microcontroller) to switch high voltage. PIC microcontrollers use TTL logic, and therefore expect a well regulated 5V power supply. You can generate 5v by using a 7805 voltage regulator IC or better still use a USB cable to tap 5v from your laptop or desktop or power bank or from your USB charger.
The supply may however range from 3.5V to 5.5V but it’s typically 5V for most PIC MCU’s. MCU requires very small amount of current in order of mA for normal operation and uA in sleep mode. Indeed these devices have been labeled as nano-watt technology devices. The logical levels are also same, a signal from 0 to about 2V is considered as logical ‘0’ and a signal from 3.5V to 5.5V is considered as logical ‘1’. In order to communicate with devices using higher logical voltages, you will need a level converter such as a max232 IC or use a voltage divider circuit or a transistor or an opto-coupler. MCU’s can supply about 25mA to output peripherals or transducers but if higher current is needed, a transistor is used for amplification.

Oscillator of the microcontroller

Every microcontroller needs a kind of timing to work with. An oscillator is used to provide clock for the microcontroller and the clock frequency determines the speed of the microcontroller. There are four oscillator modes a PIC microcontroller can work with. These are the internal RC, external RC, external crystal oscillator/resonator and external oscillator source. You might be wondering which one is best, all of them has their advantages and disadvantages. We shall compare and contrast these various oscillator sources.

Using internal RC oscillator makes the design cheaper, lighter, more compact and less complex but the maximum oscillator speed can be about 8Mhz which is slow for some applications and the accuracy is above average.

Using an external RC however makes the circuit more complex and more costly and inaccurate (because of high resistor capacitor tolerance).

Using external oscillator source makes the circuit much more complex, bogus and expensive but in a case whereby so many MCU is used in a circuit, they all can tap from one oscillator source and the accuracy of these MCU will be determined by the accuracy of the oscillator source.

Using a crystal oscillator makes the circuit much more accurate and used when great precision is needed. Crystal oscillator can make the MCU run with maximum speed which is typically 20MHz, but the crystal oscillator is expensive and can add extra cost to production of cheap gadgets.
The faster is the oscillator, the faster is the processing speed. However fast processing also requires more current. The highest frequency that most PIC MCU can respond to is 20MHz. However PIC18F series have an internal mechanism to multiply the clock frequency by 4 and generate an internal frequency 4 times that of the crystal being used. The highest frequency for 18F452 and many others is 40MHz to 48MHz.

Science/TechnologyRe: Embedded System Tutorial For Beginners #include<module1.h> by guassian(op): 12:44am On Mar 06, 2015
Science/TechnologyRe: Embedded System Tutorial #include<module2.h> :what Is A Microcontroller? by guassian(op): 12:39am On Mar 06, 2015
Memories of the microcontroller.
Memory is a very important component of any computer. When we go to market to buy phones and PC the first thing we ask is the memory size. Memory in Embedded systems is very important just as human beings needs memory to store tasks and information. As we have discussed ealier, memory size in microcontrollers is very low compared to one in smartphones and personal computers because what a MCU needs to control or memorize is very small. A 256Mb of RAM in a PC world is very low and obsolete but in a MCU world, 512Kb of RAM has never existed (i stand to be corrected).
There are three major types of memory in embedded system. RAM(Random Access Memory), ROM(Read Only Memory) and EEPROM(Electrically Erasable Programmable Read Only Memory). All these have its major functions which cannot be used interchangeably.

RAM is used to store and read temporary data with high speed and does not have limit of the number of times it can be accessed. Its content is lost when power is lost and can never be retrieved again. Its content can be accessed at “Runtime” i.e time of use of the MCU in applications.
ROM is used to store data permanently and can only be changed at “program-time” i.e time of burning program into the MCU and its content can never be changed at runtime. The instructions ececuted by MCU and some temporary data are stored in the ROM. Ordinary ROM is OTP(one time programmable) i.e it can only be programmed once, just like your CD-ROM which information can only be written to it once. A special kind of ROM called Flash ROM is what a MCU use, this technology allows ROM to be reprogrammed up to 100,000 times. This flash technology allows us to re-write and read information from a ROM at program-time, and this makes MCU attractive for students and Hobbyist. However, the disadvantage of flash ROM is that it is costly, so companies go for OTP ROM MCU because they must have been sure of the content of what they want to program into the chip and do not have any need to reprogram.
EEPROM is a type of ROM that is used to store data permanently also but just that it can be electrically erased and reprogrammed i.e. its content can be modified at runtime and it will retain its data for more than a century. It is what is synonymous to floppy disk or Hard disk of a PC. The number of read and write times of EEPROM is limited; about 1,000,000 times and the write and read speed is quite low compared to a RAM. So an EEPROM cannot probably be used as a RAM in real practical situations.
I/O (Input/Output) PORTS is a gateway for the MCU to communicate with the outside world i.e. it is a physical connection port for the microcontroller to get data from transducers or other input device into the MCU and also gives processed data from the MCU to output transducers or peripheral. General purpose ports are used to get logical data(1 and 0, high and low ) from input device and also send logical data to output device. Some PIC microcontroller in addition to the general purpose function, has many special function ports ranging from USB port, UART port, SPI, I2C, ADC ports, PSP, PWM etc.

Resetting the Microcontroller

On every PIC microcontroller you will find a pin labeled as MCLR. This pin has two basic functions. Used to reset the microcontroller like a soft-boot and as well as to put the microcontroller into programming mode. A MCU can “hang” just like your smartphone and your PC used to hang and you probably need to restart it by switching it off or removing the battery. A MCU can hang when there is a power brownout (low voltage or fluctuation) or when the programmer writes the instruction such that he tells the microcontroller to access a memory location that does not exist and thereby makes the MCU practically lost in the program flow and could not find its way back to execute the next instruction, the MCU needs a reset to bring the program flow to the initial state.
The MCLR pin when connected to ground(0 volts or logic 0), will reset the microcontroller, and keep it in a reset state or OFF state, till the mclr pin is connected to 5v before the MCU restarts. After a reset, the microcontroller will have all its RAM reset, and program execution will begin, just like the system has been just powered on. A 10K “pull up resistor”(used to give an input pin a default logic 1) is usually connected with the mclr pin, to keep it high when reset switch is released.
The mclr pin will also work as program mode pin i.e it is used to tell the MCU to go into programming mode when a programming device wants to modify its ROM content. When new software is to be downloaded into a PIC MCU, about 13.5V is applied to the MCLR pin, by your programming device. This can be done right in your circuit called ICSP(In-Circuit Serial Programming), or by taking the IC out of circuit and putting it into the IC socket on your programmer. More about programming Device will be discussed in another module of this tutorial, probably when we do the first experiment.

Analog and Digital Data
Microcontrollers use digital data to represent everything. Even music, videos and images all are represented as digital data, which is a series of logical ‘0’ and ‘1’. However our real world data is not digital. It is rather analog. It is rightly said, “We live in an analog world, but process the data in digital world”. Real world data like light, temperature, pressure, heat, height, distance, speed, force etc. all are analog data. In order to utilize these data we have to acquire them with specific sensors or transducers and then convert into digital format for use within microcontroller’s digital world.
Many other microcontrollers require an external ADC(Analog to Digital Converter) chip to implement this, however this feature has been nicely built into PIC microcontrollers. The number of Analog channels varies among PIC MCU but typically they have about 5, and some PICs do not have this feature on-board. Pins labeled as AN0, AN1 etc are for analog data if required, however they can also function as normal digital pins to work with digital data.

PROGRAM OR FIRMWARE OF MICROCONTROLLER
A Program is nothing but a series of instructions, in a correct and logical manner to instruct the microcontroller to respond to various inputs and give specific output. By changing the program, the behavior of microcontroller will change. The MCU doesn’t come with a preloaded function from the manufacturer. Using an analogy of a music system, the manufacturer has not designed it to produce any particular sounds out of its speakers, yet it has all the necessary circuitry to do that. What music it will produce would depend upon the tape, or CD inserted. Thus you change the CD, and the same hardware is playing different thing. So we can say that the music system, is a programmable device, and the information stored on tape, or CD is the program, or instructions to help the music system make sounds.
Similarly microcontrollers are programmed to do a job. The job can be changing a TV channel to controlling complex movements of a robot, control all home lighting and electrical appliance etc. All these applications have a microcontroller doing its specific job. It can be astonishing to find the same microcontroller in the remote control, and the robot. In one place it is driving an infra-red LED and in other it is driving the motors. So the same hardware serving thousands of different jobs. You have to learn the instructions your particular microcontroller understands, and what those instructions order it to do. Then it’s your mind, and ideas how you play with these instructions to get your job done. Literally there are hundreds of methods to get the same job done. Just like in English, there many ways you can arrange the alphabets, to convey the same message.
Programming the microcontroller
Programming is a mechanism to transfer the compiled program into the microcontroller’s program memory. Like earlier said when talking about memories PIC microcontrollers have a separate area of memory called program memory or ROM. The size of this memory differs in various chips.
The source code is written which is called the program with either low-level language or high-level language. This program is assembled or compiled with an assembler or compiler respectively to generate an object code usually with a file extension of “.HEX”. It is otherwise known as “hex file”, analogous to a computer’s “.EXE”. This hex file is loaded or burnt into the PIC with a device called “Programmer”. As people from PC world are used to talking about megabytes and gigabytes, most of programs written, will not exceed few hundred bytes. This is because unlike the PC the microcontroller has less to do with videos, pictures, and music. These devices are not meant to run windows, but to control a specific device based upon certain input and logic.
In order to put your microcontroller into programming mode, the MCLR pin has to be driven up to 12-13.5V. This is referred as VPP. The VPP is generated by programmer. Once VPP is applied to MCLR pin, the processor stops functioning and accepts data from programmer on PGD and PGC pins, which are mostly RB7 and RB6 pins on microcontroller. The programmer first erases the old program memory and then writes new program and EEPROM data if required. After the program is transferred it is verified. After successful programming, the VPP must be taken down, so that the program may be started.
There various programming device in market. There is a universal programming device which can program all types of microcontroller but they are quite expensive. I recommend you use a PIC programmer which is very cheap and you can also build one for yourself. Someone has made the work easy by posting this link on Nairaland ( https://www.nairaland.com/2157202/simplest-reliable-pic-microcontroller-programmer ) I bet this circuit works like magic. The disadvantages it has is that it uses 15v power supply which make you look for mains electricity when u can power the rest of circuit with a 5v power bank, it uses serial port which most modern laptop doesn't have, old Dell D630 has serial port and some old HP laptop too. So you will need a USB programmer if you intend to use a modern laptop. If you need a cheap and reliable USB programmer, contact www.hub360.com.ng and make your request.

Conclusion
Forgive me if I am boring you with theories; these are summaries of some of important things you need to know and you will surely need them when I start showing you practical examples. Please read more online about the little you learnt in today's topic as this will give you broad knowledge and make widen your scope.
In the next tutorial, I will be exposing you to the various software and hardware tools you will need to start performing experiments and doing projects. I will be giving you links to where you will download very useful software free. I bet you will gain a lot. Remember, I will be posting the next tutorial with a new post. This will help to give room for continuous comments, contributions and questions on the topic of today and will avoid unnecessary long thread.

More information about today’s tutorial can be gotten from these links.
http://www.personal.rdg.ac.uk/~stsgrimb/teaching/programming_pic_microcontrollers.pdf
http://www4.hcmut.edu.vn/~bmthanh/ESD/Programming%208-bit%20PIC%20Microcontrollers%20in%20C%202008%20Martin%20PBates.pdf
Science/TechnologyEmbedded System Tutorial #include<module2.h> :what Is A Microcontroller? by guassian(op): 12:38am On Mar 06, 2015
#MODULE TWO: MICROCONTROLLERS AND MODERN DAY ELECTRONICS:

Welcome again to my Embedded systems tutorial, last time we learnt about embedded systems in general (https://www.nairaland.com/2175820/embedded-system-tutorial-beginners-include ) today we shall be learning in summary what a microcontroller is, memory types, oscillator, ports, programming the microcontroller etc. Remember that the aim of this tutorial is to give you a summary, basic things you need to know to arouse your interest, you still need to pick up an ebook and read in details if you want to have full knowledge. And don’t hesitate to ask questions if you don’t understand anything discussed in this topic and embedded systems in general. This tutorial is quit long but I bet you will gain a lot. Please Just Exercise patience and read through till the end.

INTRODUCTION
Looking back into the history of microcomputers, one would at first come across the development of microprocessor, but the stand alone microprocessor is not self-sufficient. It requires other components like memory to store data and I/O devices that serves as a gateway to receive and transmit data to and from the microprocessor, to form a workable system configuration. The device which contains a microprocessor and the above mentioned components in small scale on a single chip is a microcontroller. The introduction of microcontrollers drastically changed the microprocessor based system design. There are various type of micro controllers such as: AMR, Atmel AVR, Intel 8051, Infineon, ZILOG Z80, Motorola M68HC11 series, Microchip PIC etc.

Microcontrollers are integrated circuits, but they differ fundamentally from other ICs. They are a class in themselves, and the designers have not made them to do a particular job. As such when you buy them from the market, you can not specify what function it will do. In order to get some useful function, these ICs have to be configured or programmed. Thus a microcontroller can be configured to check the status of a button, and then turn a motor ON or OFF and lit an LED etc. While the same IC can be configured later, to read the status of an infra-red sensor, decode the signal and turn another device ON or OFF or send a number to a LCD screen etc. If these two types of circuitries mentioned above were to be made using conventional digital ICs, it would have required a large number of components. Moreover any change in the specification, like change of Infra-Red codes would result in total change in design, but using a configurable IC, no design has to be changed but just the program has to be edited.
Not only that the same IC can be configured to do different tasks, but a change in specifications can easily be implemented by just changing the device configuration some lines of programming codes. This greatly facilitates the engineers and hobbyists to rapidly develop new electronic devices, and continuously improve previous ones. Not only the hardware requirements decreased, but also design time, and time to market were decreased. Microcontrollers therefore took over the market. Large hardware designs were reduced, and most of the circuitry was replaced by the configuration scripts. Today we call this ability to configure a microcontroller “Programming”.
Someone might be thinking why are there so many types of microcontroller and which is best to use. No microcontroller is better than the other, each has both advantage and disadvantage, some are costly and others are cheap, some are of big sizes and others are small, some has many I/O ports and peripherals for easy interfacing while others does not have enough and so on. There are many microcontrollers available for developers to choose from. The microcontroller used mostly in Nigeria here are the PIC Microcontroller, ATMega, AVR but PIC and is what I will most likely be using for tutorials on this Nairaland because it is the one I am most familiar with, it is easy to use and has lots of inbuilt peripherals e.g internal oscillator, ADC, timers etc and also so many compilers supports it. Eg mikro C, CCS C compiler etc. Forgive me if you have already been learning other types of microcontroller, but I can tell you that they all do the same thing and the principles of operation are all the same, they just differs by architecture, inbuilt peripherals etc.

THE PIC MICROCONTROLLER
Although microcontrollers were being developed since early 1970’s real boom came in mid 1990’s. A company named Microchip® made its first simple microcontroller, which they called PIC. Originally this was developed as a supporting device for computers to control its peripheral devices, and therefore named as PIC, Peripheral Interface Controller. Thus all the chips developed by Microchip have been named as a class by themselves and called PIC. Microchip itself does not use this term anymore to describe their microcontrollers; however use PIC as part of product name. They call their products MCU’s.
A large number of microcontroller designs are available from microchip. Depending upon the architecture, memory layout, number of input and output ports and processing power. They have been classified as low range, mid range, high range and now digital signal processing microcontrollers. The beauty of these devices is their easy availability, low cost and easy programming and handling. This has made PIC microcontrollers as the apple of hobbyists and students eyes. We shall be using PIC12f683(8 pin), PIC16f88(18pins), PIC16f877A,PIC18f452 as in various experiment for this tutorial.
[pic pinout diagrams]

BASIC THINGS YOU NEED TO KNOW ABOUT PIC MICROCONTROLLERS

Power Supply to the Microcontroller

All electronics components or circuits needs power supply to work either high voltage AC or low voltage DC. Fortunately for us, the PIC microcontroller uses low voltage so we are safe and not at risk of electric shock except we are using the MCU(microcontroller) to switch high voltage. PIC microcontrollers use TTL logic, and therefore expect a well regulated 5V power supply. You can generate 5v by using a 7805 voltage regulator IC or better still use a USB cable to tap 5v from your laptop or desktop or power bank or from your USB charger.
The supply may however range from 3.5V to 5.5V but it’s typically 5V for most PIC MCU’s. MCU requires very small amount of current in order of mA for normal operation and uA in sleep mode. Indeed these devices have been labeled as nano-watt technology devices. The logical levels are also same, a signal from 0 to about 2V is considered as logical ‘0’ and a signal from 3.5V to 5.5V is considered as logical ‘1’. In order to communicate with devices using higher logical voltages, you will need a level converter such as a max232 IC or use a voltage divider circuit or a transistor or an opto-coupler. MCU’s can supply about 25mA to output peripherals or transducers but if higher current is needed, a transistor is used for amplification.

Oscillator of the microcontroller
Every microcontroller needs a kind of timing to work with. An oscillator is used to provide clock for the microcontroller and the clock frequency determines the speed of the microcontroller. There are four oscillator modes a PIC microcontroller can work with. These are the internal RC, external RC, external crystal oscillator/resonator and external oscillator source. You might be wondering which one is best, all of them has their advantages and disadvantages. We shall compare and contrast these various oscillator sources.

Using internal RC oscillator makes the design cheaper, lighter, more compact and less complex but the maximum oscillator speed can be about 8Mhz which is slow for some applications and the accuracy is above average.

Using an external RC however makes the circuit more complex and more costly and inaccurate (because of high resistor capacitor tolerance).

Using external oscillator source makes the circuit much more complex, bogus and expensive but in a case whereby so many MCU is used in a circuit, they all can tap from one oscillator source and the accuracy of these MCU will be determined by the accuracy of the oscillator source.

Using a crystal oscillator makes the circuit much more accurate and used when great precision is needed. Crystal oscillator can make the MCU run with maximum speed which is typically 20MHz, but the crystal oscillator is expensive and can add extra cost to production of cheap gadgets.
The faster is the oscillator, the faster is the processing speed. However fast processing also requires more current. The highest frequency that most PIC MCU can respond to is 20MHz. However PIC18F series have an internal mechanism to multiply the clock frequency by 4 and generate an internal frequency 4 times that of the crystal being used. The highest frequency for 18F452 and many others is 40MHz to 48MHz.

ProgrammingRe: Embedded Systems: Future Of Electronics And Computer Engineering. by guassian(op): 7:45pm On Mar 04, 2015
@spikes I now get u. going through basic electrical principles here will make this tutorial cumbersome. I said it in the proceeding tutorial ( https://www.nairaland.com/2175820/embedded-system-tutorial-beginners-include ) that i assume my audience has basic theoretical knowledge of electricity and computer.
But if not, this website will help a lot to learn circuit interpretation, circuit diagrams, resistors, capacitors, circuit symbols, etc. http://www.electronicsclub.info/
ProgrammingRe: Embedded Systems: Future Of Electronics And Computer Engineering. by guassian(op): 12:01am On Mar 04, 2015
spikesC:
Hub360 have quite a good collection but am still not impressed.
So boss, which aspect are you going to cover?
Microcontrollers, IC's, circuit boards and/or FPGA's?
If you need any help of any kind on any of them, just halla me cool
@fulaman198
Embedded systems is fun. It gives you a kind of joy and satisfaction that software programming lacks. Make out time for it, you'll never regret it cool
I will be covering microcontrollers which can replace any digital IC and will definately needs a circuit board to implement. i will also teach how to produce a PCB locally within a twinkle of an eye.

I stand to be corrected, FPGA is not really common here in nigeria and they dont have good market here. they are not easy to configure and uses HDL(hardware description language) which is nothing like assembly language or C. they are not mentioned at all in most universities and its not part of their curriculum. In my own point of view, we need to use a microcontroller to begin learning embedded systems because its what students are taught in and close to what everybody is familiar with(a microprocessor). then later anybody who is not satisfied with the functionality of microcontroller can go further to learn FPGA.

If you still feel we need a FPGA more than a microcontroller at this time, you can give us a brief tutorial on it and let us compare and contrast.
Science/TechnologyRe: Embedded System Tutorial For Beginners #include<module1.h> by guassian(op): 9:50pm On Mar 03, 2015
Dekatron:
Thank you so much. I am a very ardent freak of electronics(my moniker said it all). Howbeit,i have somethings to ask. How is it that YOU,AS AN ELECTONICS/EMBEDDED SYSTEMS EXPERT must/should know how to write in HEXADECIMALS( i got this from somebody i met here on NL, offline-- engr. Aksat. I follow people like him,including ENGR/TECH acorntree). I am an undergraduate, ELECTRICAL/ELECTRONIC ENGINEERING.
As a matter of fact(not priding myself o),i learnt about EMBEDDED SYSTEMS in ss3, frm my PHYSICS TEACHER,who studied EEE(uniben). He'd tell me little about LEDS and AMO-LED(Active Matrix Organic Light Emitting Diode),sensors,etc. I have learnt THESE THINGS THEORETICALLY FOR A YEAR+. Engr Aksat told me offline NL,that I NEED A LAPTOP,to learn EMBEDDED SYSTEMS/MICROCONTROLLER PROGRAMMING. My dad is not buying a system for me now(he met 100% of my other needs o,he aint a pauper). He said 200L(am in 100 now). I hope i am NOT LEARNING TO RUN before WALKING. subsequent questions coming up(yea,i ask questions). Thanks so much.
Cc: acorntree,aksat,princejude,usisky
Like Aksat said, you really need a Laptop if you want to move from theoretical realm to the practical. As you know, Embedded systems design involves hardware and software. No software can be written, compiled and burned into a chip without a PC and no hardware is simulated or monitored via RS232 without a PC. if you dont have money for laptop, a Desktop computer pentium 4, 512mb ,60gig will do.

As to why embedded system designer needs hexadecimal. Hexadecimal is just a number representation. you can write your code using binary, octal or decimal and u can also mix various number system in a source code, it all depends on how well you understand it. hexadecimal is so common, maybe because so many computers make use of bus width, memory size etc in the order of 16. i.e 16bit,32bit,64bit etc
Science/TechnologyRe: Embedded Systems: Future Of Electronics And Computer Engineering. by guassian(op): 12:42am On Mar 03, 2015
Science/TechnologyRe: Cool Projects(embedded Systems) by guassian: 12:32am On Mar 03, 2015
@usisky, nice one. this will help a lot of final year students and give them ideas of project topics
ProgrammingRe: Embedded Systems: Future Of Electronics And Computer Engineering. by guassian(op): 12:21am On Mar 03, 2015
Fulaman198:
Wow nice post it's sad because you are right. I don't know much about embedded systems myself I wish I could reverse time to when I was in Uni to learn more about them, but you know what, I'm still young I can look for an e-book on it (though I may not have time to read it.)
Its not too late for you. That's why i bring this tutorial into nairaland to instill passion into upcoming hobbyist. not so many will have time to read books, but a summary on nairaland will encourage them to want to know more and thereby picking up a book to read and also, there will be an avenue for them to ask questions.



this is the link to the next tutorial https://www.nairaland.com/2175820/embedded-system-tutorial-beginners-include
ProgrammingEmbedded System Tutorial For Beginners: #include<module1.h> by guassian(op): 12:06am On Mar 03, 2015
The tutorial is divided into modules which I will have at least a post per week. This tutorial needs at least a basic theoretical knowledge of electricity and computer, if you are totally not familiar with it you can still gain a lot but you have to read further on net.
Each module will be a new topic so as to give room for continuous comments on a particular topic.

This is the link to my previous post which talks about the importance of learning Embedded System. https://www.nairaland.com/2174624/embedded-systems-future-electronics-computer

#MODULE ONE: INTRODUCTION TO EMBEDDED SYSTEMS

A computer system (combination of hardware and software), designed for a specific control within a larger system is referred to as an embedded system. An embedded system is designed for specific task so it needs little processing power and little size of memory unlike the PC which works with larger data such as pictures, videos, sounds etc. Example of an embedded system is a system containing a microcontroller, systems like a moving message display, traffic light, code access system, finger print access system, fire alarm system, air conditioner, home office or industry automation system, stabilizers, automatic voltage switchers and controls, TV sets etc.

An embedded system is designed to run on its own without human intervention except it is programmed to accept input from a push button, it responds to input data collected via input transducers or another electronics system, process the data, and gives information through the output transducers or gives the information to another system for further processing, and may be required to respond to events in real time.
An embedded system can also be a specialized computer system that is part of a large system or machines. Typically, the heart of an embedded system is a microcontroller housed on a single chip. It is also referred to as a single chip computer. It contains a Microprocessor, ROM, RAM, EEPROM, IO ports, oscillator, ADC(Analog to digital converter) etc on a single chip with the program(software) and data stored in ROM.

Unlike a PC, PDA and smartphones that uses huge CPU processing power, RAM, ROM, disk drives etc. a microcontroller has all above features on a small scale which is enough to do functions like, displaying characters on LCD and LED display, controlling a relay, provide oscillation of any kind of waveform in an inverter or UPS circuit driving a motor, stepper motor and servo for robotics and industry automations, communicating with phones, modules or computer via RS232, Bluetooth, Zigbee, Wifi and also reading signals from transducers like LDR, thermistors, humidity sensors, magnetometer direction sensor etc. this small scale function makes it cheaper, and makes embedded systems application smaller, lighter, power efficient, and cost effective.
Virtually all appliances that have a digital interface –watches, microwaves, calculators, air conditioner, sound systems, ATM machine, DVD, VCRs etc utilize embedded systems. Some embedded systems which requires higher processing power may include an operating system such as the ATM machine, but many embedded systems are so specialized that the entire logic can be implemented as a single program which means it does not need a special operating system, the necessary application software and operating software are written together in a single program.

IMPORTANT FEATURES OF EMBEDDED SYSTEMS:
• Embedded systems perform a very specific task but can be programmed to do different things simultaneously if those tasks do not require much processing speed.
• It is a replacement for discrete logic-based circuits, and also some analog circuit like voltage comparators and the likes.
• It provides functional upgrade of equipment because the software can be reprogrammed up to 100,000 times.
• Improves mechanical performance i.e it provides precise control of mechanical systems such as a stepper motor or servo motor used in building a robot.
• Protection of intellectual property. An embedded system contains both the hard ware and the software. The hardware can be easily copied and duplicated but the microcontroller system offers software code protection which offers protection of the software against piracy.
• They are efficient, size and cost effective in their various applications because every component such as processor, RAM, ROM, EEPROM, IO ports are done on a small scale mostly in a single chip but with just few addition of peripherals like Clock controller, ADC, DAC, external RAM, ROM and IO etc to increase its functions.
• Embedded systems have very limited resources, particularly the memory. It has limited IO ports, small processing power, slower speed of operation and thereby might not be suitable for video and audio and high speed applications.
• Generally they do not have secondary devices such as CD-ROM, Floppy Disk.

APPLICATION AREAS OF EMBEDDED SYSTEMS:
• Consumer Appliances
• Office and home Automation
• Aircraft Electronics
• Medical Electronics
• Advertisement
• Telecommunication
• Robotics
• Laboratories and industrial equipment
• Vehicles
• Decorations
• Entertainment
• Military
• Mechatronics
and many more...
Indeed Embedded systems are very important in our everyday lives.

For further reading check out these books.
http://www.dauniv.ac.in/downloads/EmbsysRevEd_PPTs/Chap01Lesson_1Emsys.pdf
http://www.artist-embedded.org/docs/Events/2006/ChinaSchool/1_ESIntroduction.pdf
http://en.wikipedia.org/wiki/Embedded_system

Watch out for the next tutorial...
Science/TechnologyEmbedded System Tutorial For Beginners #include<module1.h> by guassian(op): 11:54pm On Mar 02, 2015
The tutorial is divided into modules which I will have at least a post per week. This tutorial needs at least a basic theoretical knowledge of electricity and computer, if you are totally not familiar with it you can still gain a lot but you have to read further on net.
Each module will be a new topic so as to give room for continuous comments on a particular topic.

This is the link to my previous post which talks about the importance of learning Embedded System. https://www.nairaland.com/2174624/embedded-systems-future-electronics-computer

#MODULE ONE: INTRODUCTION TO EMBEDDED SYSTEMS

A computer system (combination of hardware and software), designed for a specific control within a larger system is referred to as an embedded system. An embedded system is designed for specific task so it needs little processing power and little size of memory unlike the PC which works with larger data such as pictures, videos, sounds etc. Example of an embedded system is a system containing a microcontroller, systems like a moving message display, traffic light, code access system, finger print access system, fire alarm system, air conditioner, home office or industry automation system, stabilizers, automatic voltage switchers and controls, TV sets etc.

An embedded system is designed to run on its own without human intervention except it is programmed to accept input from a push button, it responds to input data collected via input transducers or another electronics system, process the data, and gives information through the output transducers or gives the information to another system for further processing, and may be required to respond to events in real time.
An embedded system can also be a specialized computer system that is part of a large system or machines. Typically, the heart of an embedded system is a microcontroller housed on a single chip. It is also referred to as a single chip computer. It contains a Microprocessor, ROM, RAM, EEPROM, IO ports, oscillator, ADC(Analog to digital converter) etc on a single chip with the program(software) and data stored in ROM.

Unlike a PC, PDA and smartphones that uses huge CPU processing power, RAM, ROM, disk drives etc. a microcontroller has all above features on a small scale which is enough to do functions like, displaying characters on LCD and LED display, controlling a relay, provide oscillation of any kind of waveform in an inverter or UPS circuit driving a motor, stepper motor and servo for robotics and industry automations, communicating with phones, modules or computer via RS232, Bluetooth, Zigbee, Wifi and also reading signals from transducers like LDR, thermistors, humidity sensors, magnetometer direction sensor etc. this small scale function makes it cheaper, and makes embedded systems application smaller, lighter, power efficient, and cost effective.
Virtually all appliances that have a digital interface –watches, microwaves, calculators, air conditioner, sound systems, ATM machine, DVD, VCRs etc utilize embedded systems. Some embedded systems which requires higher processing power may include an operating system such as the ATM machine, but many embedded systems are so specialized that the entire logic can be implemented as a single program which means it does not need a special operating system, the necessary application software and operating software are written together in a single program.

IMPORTANT FEATURES OF EMBEDDED SYSTEMS:
• Embedded systems perform a very specific task but can be programmed to do different things simultaneously if those tasks do not require much processing speed.
• It is a replacement for discrete logic-based circuits, and also some analog circuit like voltage comparators and the likes.
• It provides functional upgrade of equipment because the software can be reprogrammed up to 100,000 times.
• Improves mechanical performance i.e it provides precise control of mechanical systems such as a stepper motor or servo motor used in building a robot.
• Protection of intellectual property. An embedded system contains both the hard ware and the software. The hardware can be easily copied and duplicated but the microcontroller system offers software code protection which offers protection of the software against piracy.
• They are efficient, size and cost effective in their various applications because every component such as processor, RAM, ROM, EEPROM, IO ports are done on a small scale mostly in a single chip but with just few addition of peripherals like Clock controller, ADC, DAC, external RAM, ROM and IO etc to increase its functions.
• Embedded systems have very limited resources, particularly the memory. It has limited IO ports, small processing power, slower speed of operation and thereby might not be suitable for video and audio and high speed applications.
• Generally they do not have secondary devices such as CD-ROM, Floppy Disk.

APPLICATION AREAS OF EMBEDDED SYSTEMS:
• Consumer Appliances
• Office and home Automation
• Aircraft Electronics
• Medical Electronics
• Advertisement
• Telecommunication
• Robotics
• Laboratories and industrial equipment
• Vehicles
• Decorations
• Entertainment
• Military
• Mechatronics
and many more...
Indeed Embedded systems are very important in our everyday lives.

For further reading check out these books.
http://www.dauniv.ac.in/downloads/EmbsysRevEd_PPTs/Chap01Lesson_1Emsys.pdf
http://www.artist-embedded.org/docs/Events/2006/ChinaSchool/1_ESIntroduction.pdf
http://en.wikipedia.org/wiki/Embedded_system

Watch out for the next tutorial...
Science/TechnologyRe: Embedded Systems: Future Of Electronics And Computer Engineering. by guassian(op): 9:38pm On Mar 02, 2015
acorntree:
Which programming language are you good in for embedded system. You can also link this thread to https://www.nairaland.com/1988764/electronics-circuit-design-concept-implementation/ for hardware design
Woow arcontree, i saw your posts, you are a gem in this field. I hail o...
Let's do this together and add value to people's life. And this goes out to any other guru out there also, share your knowledge and encourage someone out there.

Create new topics if u have a different topic, subtopic, or any contribution worthy of notice and dont post entirely new things on already long thread because more than 50% of nairalander dont view the next page especially when they are already bored with various comments and contributions.
ProgrammingEmbedded Systems: Future Of Electronics And Computer Engineering. by guassian(op): 4:16pm On Mar 02, 2015
Many people, students, hobbyist in the field of engineering or technology would have probably heard of the word “Embedded Systems” or “Microcontroller” and wonder what is it all about. An average Nigerian student studying computer science, computer engineering, electronics engineering, electrical engineering, telecommunications etc. rarely learn or go on net for practical research on how to build circuits and be creative in their field until when they want to do their final year project, that’s when they realize that the world of technology has gone far beyond the V=IR they are being taught in class. They want to download circuit diagrams and implement it but discover that more than 70% of construction projects approvable by their supervisor are one way or the other related to the use of Embedded system and thereby would need the knowledge of Microcontroller and Embedded systems development to achieve it.
I stand to be corrected, most universities, polytechnics and technical schools don’t teach Microcontrollers and Embedded systems well enough for the student to grab useful information they will need to implement their final year project. They teach the introduction and use obsolete microcontroller or microprocessors and use obsolete programming language, and at the end of the course, students are examined by designing a kindergarten circuit and writing programs on book that will never Run if it were to be compiled and simulated. These lecturers that don’t teach embedded systems well enough will later be giving very hard project topics to students as final year project. The student who probably complains of not having the technical know-how to achieve the project would probably be told by their supervisor to go and make research or some would encourage them to contract it out and tell them to learn how to defend the project. Can You Imagine!... An higher institution that is supposed to be a research institution offering solutions to companies and inventing new things, students are going outside to contract projects to some uneducated technician at Alaba, Oshodi and the likes. The student ends up writing a shabby report because he is writing a book about what he or she doesn’t know and thereby do a lot of plagiarism by copying and pasting someone else’s work and having up to 50 references which some are fake, they virtually write nothing from their brain because they don’t have anything technical up there. Infact, so many students that has graduated ought to do their NYSC in jail for plagiarism, and also some lecturer that are not interested in the research but using students to write journals for promotion.
Come to think of it, those people that are gurus in embedded systems and microcontroller programming that you contract projects to are not super human, they figured it out too. Some went to learn it from existing gurus, and some were patient enough to learn from books, tutorials, internet and also by try-an-error. Which ever case, the endpoint is having knowledge, and the earlier you start learning the better for you because the world is now going digital.
You that knows how to design and construct any type of discrete circuits, analog circuits, digital circuits, it time for you to go flexible and dynamic by learning embedded systems because that’s where the world is moving now. Finite state machine (FSM) or discrete analog and digital circuit has limited functionality and you use so many circuit components to achieve a very small task or application but using a stored program machine (SPM) or embedded system can achieve a whole lot with a finger size circuit.
You a fresh student in school or even in your final year studying electronics engineering or computer engineering or electrical etc, I urge you to start learning how to design and construct and develop embedded systems as this will help you achieve your final year project easily and also make money from the lazy ones who cannot go extra mile than reading and passing exams.
You a graduate of engineering that is looking for Job, its high time job look for you and its high time you be an entrepreneur. If you are not in electronics/computer/electrical line, get skills related to your field. But believe you me, computer engineering, computer science, and embedded systems is one of the most lucrative job in engineering you can practice on your own and use your one room apartment as a workshop and none of your neighbor will be disturbed.
You electronics engineer and electrical engineer working and earning salary, its time to invest your spare time and money in embedded systems. Your employer will only pay you a peanut of what they actually earn, no employer can overpay you. Even if you work in a multinational company, they wont pay you to get richer than them, and they can sack you at any time except you are indispensable, and the only way to be indispensable is to have a broad and updated knowledge of your field and be exceptional. Also have another source of income, something you can fall back on if anything happens to your Job.
You practicing electrical technician or technologist, its time to get flexible also. Apart from running electrical fittings and installing electronics appliances, you can start designing and constructing fire alarm systems, security systems, home automation systems, tracking systems for valuable equipments etc. You can build these gadgets yourself and make more money.
Gadgets that involves embedded systems imported from abroad is very difficult to repair especially when the progrmmed chip is damaged. This is because no manufacturer will give out their software to enable technician change the chip and reprogram it. This lead to changing of a whole board instead of changing of a single chip. So we need to start developing our own gadget here in Nigeria that the manufacturer will be nearby and gadgets will be easily repaired.

To this effect I take it upon myself to teach people, students, hobbyist, and engineers in the area of embedded systems especially using microcontrollers. I will be giving tutorials out for free circuit, code and methodology just to encourage someone out there, I am committed to blessing someone’s life practically. I will be giving links to where you can download useful softwares and tutorials on net.
There is also solution to the major problem or challenges electronics hobbyist in Nigeria is facing which is getting electronics componets, tools, equipment and modules related to microcontroller and embedded systems. Some components like resistors and capacitors are easy to get around but components like 7 segment displays, LCD display, GSM module, Ultrasonic module, Fire sensor module, Arduino, oscilloscope, quality multimeters, etc are very hard to get and this problem discourages students and hobbyist and scare them away from practicing and doing some experiments.
Universities and polytechnics too are not helping matters because most don’t have these components in the so called modern laboratory and few that has them don’t allow students to touch them let alone giving them for experiment. You can order components online at sparkfun, alibaba, aliexpress, adafruits, hub360 etc. these companies are located abroad except hub360 which is here in Nigeria and supplies any hard-to-get component anywhere in Nigeria. They are reliable, they supply quality components for secondary schools, universities, polytechnics, technical schools, organizations, students, hobbyist etc and have good customer relation. They have embedded system engineers that are ready to help you if you have any problem or challenge concerning any component you buy from them. You can check out this site and see for yourself. www.hub360.com.ng
I use them always and get components at my doorstep, most times, I am always busy reading, performing one experiment or the other so no time to go to market to get component and when I go sometimes, I end up not getting all the exact components I read about online and need to perform my next experiment so what’s the essence of going. But hub360 will get you all the components at cheap price and you pay on delivery. They have hub360 starter kits which are groups components carefully selected by their engineers for beginners who don’t know which components to start with.

I will be doing tutorials in modules and providing links to sites and books you can download useful materials for more information.

Watch out for my next post which will be an introduction to Embedded systems. You will be learning what it is, what it entails, where they are used etc.

1 2 3 4 (of 4 pages)