Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,205,004 members, 7,990,778 topics. Date: Friday, 01 November 2024 at 01:00 AM

Microcontrollers - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Microcontrollers (35231 Views)

Help Needed On My Project Work Using Microcontrollers / How To Write Assembly Language For Microcontrollers (2) (3) (4)

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) ... (14) (Reply) (Go Down)

Microcontrollers by hoodboi(m): 9:25pm On Mar 04, 2013
Pls are there any embedded programmers in the house who have worked with micro controllers very well. I need help on a project

1 Like

Re: Microcontrollers by davechika(m): 10:40pm On Mar 04, 2013
watz the project all about.
Re: Microcontrollers by hoodboi(m): 10:03am On Mar 05, 2013
its something on security doors, i need a micro controller that can help in opening and closing a door upon instruction from a computer. I desperately need this please. I am a computer programmer, but i basically have no experience on this sort of hardware, if i could just get a push in the right direction i will know what to do. I have done some research and i found out i have to get something called a programmer to help me convert the code written in C or C++ to hex code which will then be burnt onto the micro controller. But how to go about this is what i need to know.
Re: Microcontrollers by davechika(m): 4:31pm On Mar 05, 2013
hoodboi: its something on security doors, i need a micro controller that can help in opening and closing a door upon instruction from a computer. I desperately need this please. I am a computer programmer, but i basically have no experience on this sort of hardware, if i could just get a push in the right direction i will know what to do. I have done some research and i found out i have to get something called a programmer to help me convert the code written in C or C++ to hex code which will then be burnt onto the micro controller. But how to go about this is what i need to know.
its simple,i guess ur door already have actuators for opening and closing,atmel 8051 family of microcontroller is a good start.
burning the code to the chip is as simple as ABCD.u can get these chino (china) universal programmer like topwin (i use it mostly for my codes) etc.rememba u gat to get a microcontroller c complier (specifically for microcontroller eg keil u vision) its different from ur normal c compiler.
you need simulation sofwares also like protues to simulate ur code before burning onto the chip.
if u gat more question pls do ask.

1 Like

Re: Microcontrollers by hoodboi(m): 8:59pm On Mar 05, 2013
Thanx so much for this, I will try out this tips and get bak to u.. Do u have an idea of how much a programmer costs, I am looking into using rotors for d doors.. Do u also have a link for simulator download or were to find a c compiler for micro controllers.. Tnx
Re: Microcontrollers by davechika(m): 11:48pm On Mar 05, 2013
hoodboi: Thanx so much for this, I will try out this tips and get bak to u.. Do u have an idea of how much a programmer costs, I am looking into using rotors for d doors.. Do u also have a link for simulator download or were to find a c compiler for micro controllers.. Tnx

just google keil u vision free download or their website
www.keil.com/c51/ and download evaluation versions as for simulator go to website www.labcenter.com/index.cfm to also download evaluation versions.
as for the programmer,i got mine (Topwin 2005 its a chinco programmer) #28k like 3years ago but gues its much cheaper now.

u can use 89C2051 microcontroller,remba u gat to interface d chip to a motor driver like ULN2803 if its dc motors.

if its a sliding door,u better use a linear actuator.as for your inerface to pc ar u using USB or RS232 protocols?
Re: Microcontrollers by hopefullman: 2:47am On Mar 07, 2013
I wish 2learn microcontroler programing bt many are hidin d knowledg 2much.i wl be gr8ful if sum1 cn teach me
Re: Microcontrollers by princejude(m): 7:02am On Mar 07, 2013
@hoodboi
This site can help u. They are into embedded systems designs and training.
They also sell microcontrollers, programmers and development kits.
www.j

1 Like

Re: Microcontrollers by princejude(m): 7:09am On Mar 07, 2013
Check there blog to see some sample projects
http://www.jutronix.com

1 Like

Re: Microcontrollers by hoodboi(m): 7:43am On Mar 07, 2013
Nairalanders are the best, i knew once i put this on here i would get responses. Thank you so much guys, will check out the site and get back to you

1 Like

Re: Microcontrollers by hopefullman: 8:13am On Mar 07, 2013
@prince.thanks vry much. I neva knew ds site existed in nig.d site is very gud.bt hw do i writ my own cod as a beginer cos d cod are readymad.any brief intro 4dummybeginers lyk me.2nks
Re: Microcontrollers by nnabuike1(m): 12:00pm On Mar 07, 2013
atmel 45 is the easiest introduction to microcontrollers that I can think of
Re: Microcontrollers by princejude(m): 12:23pm On Mar 07, 2013
hopefullman: @prince.thanks vry much. I neva knew ds site existed in nig.d site is very gud.bt hw do i writ my own cod as a beginer cos d cod are readymad.any brief intro 4dummybeginers lyk me.2nks
It all depends on the type of microcontroller you wish to start with(such as 8051,PIC or AVR). Where is your location? You may try to contact them for one-on-one practical and intensive training on any of the microcontroller family you want to work with.

I may create a new thread on embedded system design tutorial, but before then, I will like us to vote on the type of microcontroller to use. If you want us to use 8051 reply with "8051", if you want us to use PIC micros reply with "PIC" and if you prefer AVR reply with "AVR".
Re: Microcontrollers by princejude(m): 12:29pm On Mar 07, 2013
nna_bu_ike: atmel 45 is the easiest introduction to microcontrollers that I can think of
which one is atmel 45 ? An MCU or tutorial ?
Re: Microcontrollers by hoodboi(m): 2:17pm On Mar 07, 2013
princejude:
It all depends on the type of microcontroller you wish to start with(such as 8051,PIC or AVR). Where is your location? You may try to contact them for one-on-one practical and intensive training on any of the microcontroller family you want to work with.

I may create a new thread on embedded system design tutorial, but before then, I will like us to vote on the type of microcontroller to use. If you want us to use 8051 reply with "8051", if you want us to use PIC micros reply with "PIC" and if you prefer AVR reply with "AVR".

I think you should be in the best position to tell us what micro controller to use. My suggestion is that you select a multipurpose micro controller so we can learn from it for majority of purposes.
Re: Microcontrollers by davechika(m): 4:55pm On Mar 07, 2013
here also is beginners site that will bgive you a jump start.

www.8051projects.net/microcontroller-tutorials/
Re: Microcontrollers by hopefullman: 6:51pm On Mar 07, 2013
princejude:
It all depends on the type of microcontroller you wish to start with(such as 8051,PIC or AVR). Where is your location? You may try to contact them for one-on-one practical and intensive training on any of the microcontroller family you want to work with.

I may create a new thread on embedded system design tutorial, but before then, I will like us to vote on the type of microcontroller to use. If you want us to use 8051 reply with "8051", if you want us to use PIC micros reply with "PIC" and if you prefer AVR reply with "AVR".
i live in akure.i duno ur locatn.i learnt dat pic is d most common.i dnt kno hw 2ru is it bt u are an xpert.u know d best as per availability,flexibility,durability and price.thanks
Re: Microcontrollers by princejude(m): 5:08am On Mar 08, 2013
hopefullman:
i live in akure.i duno ur locatn.i learnt dat pic is d most common.i dnt kno hw 2ru is it bt u are an xpert.u know d best as per availability,flexibility,durability and price.thanks
Ok, lets start with PIC microcontrollers,but before then,let us introduce what microcontroller is all about.

Introduction To Microcontrollers

Welcome to the wonderful world of microcontrollers. You are reading this thread, because you are interested in the fascinating world of electronics. This document assumes that you have basic ideas about electronics, and are able to build simple electronic projects. Although microcontrollers are hi-tech devices, yet they are extremely easy to use. Once you have mastered the ideology behind and know the procedure to control various devices, a whole range of applications is open to you. Devices which required a large number of components and skillful logic design can now be built with almost no or minimal components. One of the greatest advantages of microcontrollers is that they can reduce the hardware requirements dramatically. The logic which was going to be implemented using a number of devices and components can be replaced by software in microcontrollers. Truly speaking microcontrollers are small, one-chip computers. As opposed to microprocessors, which require a number of peripheral devices, like, memory, I/O etc. Microcontrollers have all the necessary peripheral devices built into it. However the scale is small, memory is limited, so are other features.



Remember Microcontrollers were designed to control small peripheral devices, and as such these applications do not require megabytes of memory or the entire power of your PC. Whatever memory and peripheral devices that have been integrated into the package are enough to handle the job. A large number of microcontroller units are available, each differing in terms of memory available, and the number of peripheral devices integrated on the chip. Therefore once you have mastered, how to use these devices, it then remains a matter of choice for a particular application, which microcontroller to choose. Since basic ideology is same, if you master one chip, it is very easy to migrate to another. Moreover if you tend to stick to one clone, they are all upwards compatible.
In a nutshell we can say that a microcontroller is just an integrated circuit which is programmable. Unlike most other digital ICs, which have a designated function, like NAND gates, Flip-flops, Oscillators, 7 segment display drivers, arithmetic calculators etc. Microcontroller has no designated function. If you have a Microcontroller (MCU) chip in your hand and ask what type of function is it going to do? The answer would be I don't know! It can be used to control a motor, or an LCD display, or a 7 segment LED display, or can perform mathematical calculation, or control an infra-red remote control or what else? This is such a surprise that a single chip can do so much. It is versatile, in a sense that you can get a variety of jobs done by this chip, if properly used.
In order to get a job done by this chip, you need to program it first. This program will control the various I/O lines of the chip, and these I/O lines in turn control the devices like motors, LEDs, Infrared sensors etc.
Thus in order to control a device you need to know, its control structure, for example controlling a simple DC motor is different from a stepping motor, and this in turn is different from servo motor. It is therefore essential before starting an application to understand the control requirements of the device. Then you program the microcontroller accordingly, and this makes a complete application.

Microcontroller Applications

Due to the versatile nature of these chips, they have found applications in almost every electronic device today. Think of any device which seems to be computer controlled, it will have a microcontroller working in it.
For example a microwave oven, has a magnetron gun, which heats the food, a motor which rotates the plate, and a display to show the time and cooking parameters etc. Now on the basis of cooking parameters selected by user, the microcontroller inside will be controlling the plate motor, as well as the magnetron gun, turning them on and off periodically to heat the food.
Think of a temperature regulator in your air-conditioner, the microcontroller is sensing the room temperature and according to the selected options, turns the compressor on or off, and the wind swivel motor on and off. So it has a microcontroller as well.
Think of traffic lights, they have to be turned on and off in a set order, it is easy to make them using logical gates, but what if we need to change the order and timing? A microcontroller can do the job easily.
Think of your car, it has microcontroller sitting in it, which is controlling the fuel injection, monitoring the engine RPM, tyre speed, engine temperature and many other parameters. On the other hand it is controlling the amount of fuel to be given, adjusting the appropriate gears and displaying various engine parameters on screen to driver.
Think of an industrial automation system, where small robotic arms are being used to assemble the product, all this automatic process is being carried out by microcontrollers.
Think of the moving sign-boards on airport terminals, the LEDs in them are being controlled by the microcontroller to display messages.
In short there are literally thousands of applications including cell phones, personal and industrial robots, security systems, data logging systems and what not all have microcontroller application.
So if you are interested in electronics as a hobby, or as a professional, it is mandatory to know how to use microcontrollers.

Having a basic idea of electronics, and programming is all that you need to enter into this fascinating world.
This course will take you from beginning to an intermediate level, where you should be able to design your own applications.

1 Like

Re: Microcontrollers by princejude(m): 5:17am On Mar 08, 2013
PIC Microcontrollers
There are a variety of microcontroller chips available. A large number of manufacturers like, ATMEL, STC, MOTOROLLA, MICROCHIP and many more manufacture these chips. Each manufacturer has his own unique design and architecture. Nevertheless idea is same, but the internal architecture is different, just like Apple and IBM, both are making personal computers, doing similar jobs, yet the programming methodology and structure is different. Same is the case with microcontrollers.
Microchip (www.microchip.com) is one of the leading and experienced microcontroller manufacturer. It produces a large number of microcontrollers, all varying in the level of resources available, like amount of RAM, EEPROM and variety of peripheral devices supported. However the programming and architectural structure is similar at all levels. Therefore if you master one MCU the knowledge will be applicable without modification to the next higher MCU.
The microcontrollers manufactured by microchip, are named as PIC (I don't know why, microchip never used this for the controllers). This stands for Peripheral Interface Controller. Originally designed to control peripheral devices in a computer, so that the burden of CPU is shared. However now these devices are self-sufficient and can work independently without the need of another CPU.
PIC microcontrollers are very popular among students and hobbyists because of their easy handling, portability and wealth of peripheral devices built right into the chip, requiring very little supporting hardware.
A long, long time ago General Instruments produced a chip called the PIC1650, described as a Programmable Intelligent Computer. This chip is the mother of all PIC chips, functionally close to the current PIC16C54. It was intended as a peripheral for their CP1600 microprocessor. Maybe that is why most people think PIC stands for Peripheral Interface Controller. As far as I know Microchip has never used PIC as an abbreviation, just as PIC. And recently Microchip has started calling its PIC microcontrollers PICmicro MCU's.
Re: Microcontrollers by princejude(m): 5:29am On Mar 08, 2013
For this tutorial, google and download the following material: ccs c compiler, proteus simulator and PIC16F887 datasheet
You can also buy the following material for your programming exercise: PIC16F887 MCU, PIC Programmer and PIC development kit.
Re: Microcontrollers by princejude(m): 5:39am On Mar 08, 2013
.
Re: Microcontrollers by hoodboi(m): 9:22am On Mar 08, 2013
I really appreciate this, thank you so much..I will download what you said and get back to you
Re: Microcontrollers by princejude(m): 9:56am On Mar 08, 2013
PIC Microcontroller Families



Every member of any one family shares the same core architecture and instruction set. The families are identified primarily by the first two digits of the device code. The alphabetic character that follows gives some indication of the technology used. The ‘C’ implies CMOS technology, where CMOS stands for Complementary Metal Oxide Semiconductor. The ‘F’ indicates Flash memory technology. An ‘A’ after the number indicates a technological upgrade on the first issue device. An ‘X’ indicates that a certain digit can take a number of values. For example, the 16C84 was the first of its kind. It was later reissued as the 16F84, incorporating Flash memory technology. It was then reissued as the 16F84A, with certain further technological upgrades.

Microchip also used to give each family a name. Thus, their first family, the 16C5XX, was called the ‘baseline’ family. The development of this, with device numbers starting ‘16C’ or ‘16F’ (and a fourth digit that was not 5), was called the ‘mid-range’ family. The powerful evolution of this, with codes starting from ‘17C’ up to ‘18F’, was called the ‘high-end’ family. For simplicity, to identify a PIC family, this manual will refer to ‘12 Series’, ‘16 Series’, ‘18 Series’ and so on.
Let us briefly survey each family.


The 16C5X Series family
This, the baseline family, represents the most direct descendant of its General Instrument ancestors and displays all the core features of the original PIC design. With only a two-level stack and no interrupts, there is significant limitation on the program and hardware complexity that can be developed. Particularly without interrupts there is restriction on the type of on-chip peripheral that can be included, as most peripherals use interrupts to enhance their interface with the CPU. The 16C5X family has also been issued with Flash memory, with 16F5X codes.

The PIC 16 Series family
This, the ‘mid-range’ family, represents an improved version of the 16C5XX Series, in which interrupts are introduced and the stack size increased. The instruction set is a slight extension of that of the 16C5X. A very wide range of family members exists, with many different peripherals and technical enhancements. The larger devices, with many peripherals and significant on-chip memory, are both powerful and versatile.

The 12 Series family
The 12 series microcontrollers are designed for really tiny applications, being packaged in small ICs (for example, 8- or 14-pin). They have a simple architecture and can be viewed as ‘stripped-down’ versions of the 16C5XX series, with the same instruction set. Despite their small size, 12 Series microcontrollers carry some interesting peripherals, including analog-to-digital converters and EEPROM (Electrically Erasable Programmable Read-Only Memory) data memory.

The 17 Series family
This family was introduced to give a real step-up in CPU performance compared with any of the 16 Series devices. While retaining the RISC strategy, the instruction set size is nearly doubled and the instruction word size increased to 16-bit. Thus, some programming activities that are awkward in the mid-range family, like table reads or data moves, are here much simpler. A hardware multiplier is also available. The single, often overloaded, interrupt vector of the mid-range family becomes four. Although much more powerful than the 16 Series, this family is limited in number, and Microchip appear to be focusing on the 18 Series family to move forward developments at the more powerful end of their range.

The 18 Series family
In this family Microchip comes to grips with some of the issues of sophisticated processors. The instruction set has increased to 75 instructions, in certain versions there is also an ‘extended’ instruction set, with a further small set of instructions.
There are two interrupt vectors, which can be prioritised. This is an extremely powerful family of microcontrollers and a number of new members can be expected in the future.


The PIC 16 Series family
The PIC 16 Series family is growing rapidly, with a huge and almost bewildering diversity of members. All family members have identical core and instruction set, with the difference arising from different peripherals and other features being implemented, and different package sizes.
Re: Microcontrollers by princejude(m): 10:03am On Mar 08, 2013
.
Re: Microcontrollers by princejude(m): 10:24am On Mar 08, 2013
some members of the 16 Series family
Re: Microcontrollers by princejude(m): 11:12am On Mar 08, 2013
Selecting a PIC

So which PIC should you choose to start with? A few years ago this question was easy to answer: the 16F84. These were the only affordable flash PICs and hence The hobbyist PICs. You will still find lots of designs in electronics magazines and on the internet using these chip.
But recently Microchip has broadened its offering of flash chips with types that are much more attractive. In my opinion three of these are prime candidates to be 'my first PIC': the 16F628, the 16F877 and the 18F452.
The 16F628 is somewhat cheaper than the old 16F84, has twice the code size, much more RAM, a UART and some more goodies. This is the chip for simple applications and of course for beginners.
The 16F877 is around twice the price of the old 16F84, but it has eight times the code size, much more RAM, much more I/O pins, a UART, A/D converter and a lot more. Unless your budget is very tight I would recommend the 16F877 as your first buy, otherwise you should consider the 16F628. The 16F84A (the 16F84 - without A - and the 16c84 are ob- solete) should be used only to build an existing design that you do not want to modify.
The 18F452 is part of the new (16-bit core) series of PICs. It offers an instruction set that is much improved over the 14- bit (16F) PICs, improved peripherals, twice the code space and twice the speed compared to the 16F877, at a price that is only marginally higher.
The 16F628 can be considered the next-generation 16F84, because it is pin-compatible with those older chips. But note that it is not fully software compatible. The 16F628 also has a smaller cousin, the 16F627 (1k code instead of 2k). The 16F627 does not seem to be an attractive chip as the prices I found were actually a little higher than for the 16F628.
With 8K code space and 34 I/O pins the 16F877 is the largest chip of the 16F87x family, the 16F876 comes in a smaller package with less (IO) pins. It is about the same price as a
16F877, so it is interesting only when the larger package of the 16F877 is a problem. Note that the 16F877 and 16F876 both have a UART (for asynchronous serial communication) and an MSSP (for SPI and I2C), while the smaller chips have only a UART. The 16F872 is a 16F870 but with an MSSP instead of a UART.
The 18F chips are new family of PICs, with an instruction set that is much improved over the 16F chips, with more peripherals, and more code and data space. Yet the price of the 18F chips is only marginally higher than the comparable 16F87x chips. There are variations of the 18F chips that have an integrated CAN controller - nice when you want to create a network of PIC chips.
If you can't make sense of the Microchip part numbering you are not the only one. These are the only patterns that I have found:
The prefix 12 is for chips with 8 pins.

The prefix 16 is for 12-bit and 14-bit core chips with more than 8 pins.
The prefix 18 is for 16-bit core chips.
Next the letter C is for EPROM (OTP or windowed) chips, except for the 16C84 that has EEPROM, which is (for a user) almost the same as flash.
The letter F is for flash chips. They have flash memory, which can be erased and re-programmed.
Windowed EPROM chips have a JW suffix.
For some of the chips Microchip has released improved versions, identified by appending an A to the type. Such A chips are in most aspects identical to their non-A predecessors (but it does not harm to check the data sheets or the 'migration' document), except that the programming algorithm often changed. Hence you can buy and use an A chip if it is available (they are often slightly cheaper), but check that your programmer explicitly supports the A version. Note: The 16F84A uses the same programming algorithm as the 16F84, but the A chip can run at up to 20 MHz, the non-A only up to 10 MHz.
So what chip should you choose to start with? As said before, first check which chips you can actually buy. Then consider whether you want to use an existing design or other document. In that case the choice has been narrowed down for you. If you already have a programmer, check which chips it supports. For the choice I recommend that you take the most powerful chip that still fulfills the above constraints. The 18F4520 would be the first choice, the 16F887 the next, and the 16F873 the last.
Once you have acquired some experience with your first PIC, and you have a nice project debugged and running, it might be the right time to fit it into a cheaper PIC.
Re: Microcontrollers by hopefullman: 8:30pm On Mar 08, 2013
@princejude.pls wher is ur location?mine is akure.thanks 4ur intro 2pic
Re: Microcontrollers by princejude(m): 6:42am On Mar 09, 2013
Now let move on to the real business

Install the ccs c compiler,then create a new project as follows: double-click on the icon to open it as shown below:



Click >> Project >> Pic wizard to open the next window



Type "Example1" inside the file name box. Right-click inside the "save As" window, select "New" then "Folder" to
create a new folder for the project. Rename the New Folder. Click "Save" to open the next window



Change the oscillator frequency to your crystal value and click on the arrow beside device to select the
microcontroller you want to use (select PIC16F887),uncheck the box beside "one fuse per line with comments" then click OK to open next window



This is where you will type your code.
Re: Microcontrollers by princejude(m): 8:21am On Mar 09, 2013
Excercise1: LED Blinking
This is a simple project that blinks 8 light emitting diodes connected to PORTD of PIC16F887 MCU



Type the following code under "// TODO: USER CODE !!" line

while(true)         // loop forever
{
output_D(0xFF); //on all the LEDs
delay_ms(500); // wait 500ms
output_D(0x00); //off all the LEDs
delay_ms(500); //wait 500ms
}




Click "Compile" >> "Build All" to compile the project.
Re: Microcontrollers by hopefullman: 10:46am On Mar 09, 2013
I hav picC compiler and mikroC compiler.can i write my code with them?
Re: Microcontrollers by princejude(m): 11:38am On Mar 09, 2013
Burning the hex file into the chip (PIC16F887)

To transfer the hex file of your code into the chip, you need a PIC programmer (I have Microscale's PIC USB Programmer).
It is there CLONE version of PIC KIT2 Programmer.
It cost N5000 and it can program many PICs. It uses PIC KIT2 software which can be download free here:

http://ww1.microchip.com/downloads/en/DeviceDoc/PICkit%202%20v2.61.00%20Setup%20dotNET%20A.zip OR

http://ww1.microchip.com/downloads/en/DeviceDoc/PICkit%202%20v2.61.00%20Setup%20A.zip.

Extract the first one and install. Double-click the PICkit 2 icon to open.

If you didn't succed in the installation then you need a VISUAL STUDIO software in your PC.
Install the visual studio and extract the second file and instal it. Or you can still reinstall the first
one after visual studio installation.

Open the PICkit2 software to get:



"PICkit2 not found" because PICkit2 hardware was not connected to your PC

If you have the hardware, connect it to your PC, connect the Programmer to the ICSP pin of your
development kit (I bought one from Microscale (cost N10000 )), close and reopen the PICkit2 software to get:

Re: Microcontrollers by princejude(m): 12:06pm On Mar 09, 2013
If you have compiled the Exercise1 code:

located the hex file inside your project folder, its name will be "your project name . hex)

Click "File" >> "Import hex" Select the hex file click "open" to get:



Click "Write" to program the chip.

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) ... (14) (Reply)

How Much Do You Charge As A Web Developer? / Game Development: Next Gen 3d PC Game Team / How To Make A Simple Calculator In Notepad Using .bat Format

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 85
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.