Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,787 members, 7,956,016 topics. Date: Sunday, 22 September 2024 at 09:25 PM |
Nairaland Forum / Science/Technology / Programming / Microcontrollers (35057 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)
Re: Microcontrollers by Nobody: 8:00pm On Apr 01, 2013 |
@princejude and holax, thanks a lot for ur responses. Im also interestd n dis PIC stuff as I wuld like to have an automatic weather station dat culd datalog, etc! but im currently financialy weak and surely i will monitor dis thread and infact im savng every page of it and when im ok, i will like help on how to get some of d hardwares! |
Re: Microcontrollers by Nobody: 9:01pm On Apr 01, 2013 |
hopefullman: I think Mr. princejude answered this very well. Just to second him, I think you should learn C. Note that code written in assembly language may be a little faster than that written in C, but for the vast majority of applications, you do not need that extra little speed. What matters is that your code meets deadlines, which in approximately all cases it would when written in C. The major problem with assembly language appears when you have to debug your code. It is very very easy to get confused especially if your code has many lines. Secondly, if you have to switch to another family of microcontrollers, say atmel or avr, you would need to learn almost entirely new instruction sets and processor architectures. With C, you'd do far less work. Finally, code written in C is usually shorter than that written in assembly language and far more easily understandable. For example, the C equivalent of the assembly code you wrote is: void main() { TRISA = b'00000'; //set PORTA to be an output PORT PORTA = b'11111'; //send 5volts to all pins of PORTA (RA0 - RA4); while(1) PORTA = ~PORTA; //keep alternating between 5Volts and 0volts on RA0 - RA4 } I advice that you should learn to comment your codes. This will save you a lot of hard work understanding what you did if after a long time you revisit the code. |
Re: Microcontrollers by princejude(m): 11:13am On Apr 02, 2013 |
cogitoErgo: I wuld like to have an automatic weather station dat culd datalog, etc!That will be a nice project cogitoErgo:You will get most of the hardware at www.jutronix.com |
Re: Microcontrollers by hopefullman: 1:28pm On Apr 03, 2013 |
@tesla&princ jude.thanks very muck 4ur answers |
Re: Microcontrollers by princejude(m): 8:01am On Apr 04, 2013 |
hoodboi: hi princejude, thank you so much for ur efforts, it is highly appreciated. I want to ask, is there any book in pdf format you can upload to teach programming micro controllers. i downloaded a mplab compiler recently and i now have the proteus simulator. Also, pls among the exercises, can you include one to control the to and fro movement of a motor. thanx Exercise 3 : Servo motor control. In this exercise, I will copy some sections of my code in a recent project titled "Automated waste bin". This is a simple wast bin with some automatic controls. The waste bin have an ultrasonic sensor, if you come close to the bin, the bin's door will open and ones you are through and out from the bin, the door will close. The opening and closing of the door was controlled using a servo motor while your distance from the bin was measured using an ultrasonic sensor.
|
Re: Microcontrollers by Nobody: 3:02pm On Apr 04, 2013 |
princejude:heiyaa, sorry u go get favour on our behalf, abi u be d oga at the top in your working place? |
Re: Microcontrollers by Nobody: 3:27pm On Apr 04, 2013 |
princejude:The website is not opening! |
Re: Microcontrollers by Nobody: 8:36am On Apr 06, 2013 |
cogitoErgo:The website is working now! Please why is everybody not talking again, where is Princejude and co? I have been on microscale website, but Im still enjoying all the contributions here! Please OP, I will be very happy if you can change the title to "Microcontroller for Beginners". And personally, I like the emphasis on C language rather than Assembly language! |
Re: Microcontrollers by hopefullman: 11:28pm On Apr 06, 2013 |
@princjud.pls is it 2ru dt basic is more simpler than C?can i get a link 2learn Basic.thank u |
Re: Microcontrollers by princejude(m): 9:33am On Apr 08, 2013 |
hopefullman: @princjud.pls is it 2ru dt basic is more simpler than C?can i get a link 2learn Basic.thank u Basic may be more simpler but you will get more online resources/tutorials on C. if you want to learn basic check mikroBasic at mikroElectronika. http://www.mikroe.com/mikrobasic/pic/ |
Re: Microcontrollers by princejude(m): 9:57am On Apr 08, 2013 |
cogitoErgo: I was busy,will try to upload some today |
Re: Microcontrollers by princejude(m): 11:34am On Apr 08, 2013 |
princejude: Yeah am back... Here is the code for the servo motor control:
|
Re: Microcontrollers by Nobody: 7:19pm On Apr 08, 2013 |
@princejude: Nice work. Very readable code. BTW how did you ensure the blocks were indented. The last time I tried to indent code on nairaland I was unsucessful. |
Re: Microcontrollers by Nobody: 8:20pm On Apr 08, 2013 |
princejude:You are wellcome back. Thanks! |
Re: Microcontrollers by hoodboi(m): 11:09am On Apr 09, 2013 |
Very nice code,vry readable. Hw did u knw how to work wit d sensor nd oda components nd also hw did u knw d level to set for d battery |
Re: Microcontrollers by princejude(m): 2:01pm On Apr 09, 2013 |
NeoTesla: @princejude: Nice work. Very readable code. BTW how did you ensure the blocks were indented. The last time I tried to indent code on nairaland I was unsucessful. Use the code icon labelled "#" Before you type the code you want to post,Click the "#" icon and type the code between and. [.code] type your code here [./code] |
Re: Microcontrollers by princejude(m): 2:11pm On Apr 09, 2013 |
hoodboi: Hw did u knw how to work wit d sensor nd oda components I will always study there datasheets. hoodboi: hw did u knw d level to set for d battery I used the internal Analog to Digital Converter module of the chip to sense the battery level ans also used a variable resistor to calibrate the battery level. |
Re: Microcontrollers by Nobody: 7:18pm On Apr 10, 2013 |
@ princejude; Ok, I see. Thanks. |
Re: Microcontrollers by Nobody: 8:49am On Apr 13, 2013 |
@princejude, please assuming I have a project to design and construct a PIC temperture sensor that will have an analog temperature sensor connected to the PIC. The PIC will sense the ambient temperature and if it above a preset value, a red light(LED) will light, showing danger! If it is within certain range, a green light will show, indicating normal! If it is lower than another preset value, a yellow light will show, indicating temperature too low. Please, how do you guide on this project? Thanks. |
Re: Microcontrollers by hopefullman: 12:28am On Apr 15, 2013 |
@princejude.u are a 'wizard' d code is jst lyk chinese 2me.i jst wish 2 be lyk u.keep it up.thank u 4 al ur response |
Re: Microcontrollers by princejude(m): 1:05pm On Apr 15, 2013 |
. |
Re: Microcontrollers by princejude(m): 1:55pm On Apr 15, 2013 |
hopefullman: ...d code is jst lyk chinese 2me.i jst wish 2 be lyk u. Did you download the two ebooks I posted their links ? if yes, study them and you will understand the trick |
Re: Microcontrollers by Nobody: 7:43am On Apr 19, 2013 |
princejude:Thanks, but I was actually thinking of seen a teaching and learning thing, instead of ready made code! Could the tutorial on the microscale blog be arranged in such a way that u will start with the simplest program, such as blinking an LED. The code should be explained line by line and the use of CCS C compiler to compile the code explained. The retreival and burning of the HEX code into the PIC module should be explained. Subsequently, more harder and useful projects should then be given with emphasis laid on explaining the software code! I beleive that is what is called a tutorial! |
Re: Microcontrollers by hopefullman: 5:03am On Apr 20, 2013 |
cogitoErgo:gbam!!!1000 likes.xactly my thaught.it's nt easy 2undstand dcode without line by line xplanatn.i no big prjcts lyk ds cnt be easily xplaind bt smple prjcts cn easily be xplaind.we're stl hopin 4d bst |
Re: Microcontrollers by Nobody: 7:44am On Apr 20, 2013 |
@princejude, please in ur variable declaration I saw <int16>. Please which kain declaration be this? I only know <int> as in integer variable! Thanks |
Re: Microcontrollers by Nobody: 12:13pm On Apr 20, 2013 |
cogitoErgo: @princejude, please in ur variable declaration I saw <int16>. Please which kain declaration be this? I only know <int> as in integer variable!OK, @princejude, from my findings on the net, integer variable in ccs c is a little different frm traditional c language! the normal int will declare a 8-bit integer, int16 will declare a 16-bit integer while int32 will do fo 32 bit integer! |
Re: Microcontrollers by princejude(m): 11:42am On Apr 22, 2013 |
cogitoErgo: You can also declare 8-bit interger as int8 in ccs c Example of some data types are:
You can download this ccs c user manual for more info: http://www.ccsinfo.com/downloads/ccs_c_manual.pdf |
Re: Microcontrollers by Nobody: 9:17pm On Apr 22, 2013 |
princejude:Thanks for the manual. I think what remains for me is to get the PIC development kit! |
Re: Microcontrollers by princejude(m): 5:36pm On Apr 24, 2013 |
cogitoErgo:When you are ready for the PIC development kit, check this link http://www.jutronix.com They have good development kits with user manual which include many sample codes for beginners. |
Re: Microcontrollers by Nobody: 1:49pm On Apr 28, 2013 |
In order to enhance my own learning, I wish to explain the code below, line by line and I wish the professionals such as princejude will be around to correct me anytime I err! The code is from microscale site for temperature sensor. princejude provided the link as above! Please note that Im neither a pro nor any guru here, I am just a bloody learner! #include <16f887.h> |
Re: Microcontrollers by Nobody: 2:41pm On Apr 28, 2013 |
Now to work #include <16f887.h> The first line is a c pre-processor, telling the compiler to load all necessary file relating to the PIC 16F887 module. Anybody who has some knowledge of c language should know what a pre-processor is! Second line. Since our operation is to take a signal from outside in an analogue form and pass it to the MCU for processing then a digital to analoguo converter (ADC) is needed! So d second line specifies an ADC with 10 bit data capacity( d bit capacity of an MCU can always be obtained from d MCU datasheet which is freely available on d net). 3rd line specifies the clock frequency od the PIC module, here 4MHz. This is needed im order for d compiler to calculate the required number of MCU cycles. Next 4th line: It specifies the states of the comfiguration fuses that should be programmed onto d MCU. Here: XT = > clock is an internal crystal oscillator. NOWDT => No WatchDog Timer. NOPROTECT => Code protection is off! NOLVP => I really could not get this! 5th line says we are going to use RS232 for communicating with something like your computer(u can leave dis out if only u wish ur output on lcd!) Here, the baud rate (somebody should explaing this!) is set at 9600. xmit = PIN_C6, sets pin C6 of the PIC as the output pin(xmit = transmit) for d RS232. rcv = PIN_C7, sets pin C7 as the input pin (rcv = receive). Line 6: tells d compiler to include files for working with liquid crystal display (lcd). |
Re: Microcontrollers by princejude(m): 8:41am On Apr 29, 2013 |
cogitoErgo: NOLVP => NO Low Voltage Programming Well done |
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) ... (14) (Reply)
Game Development: Next Gen 3d PC Game Team / How To Make A Simple Calculator In Notepad Using .bat Format / First Thing First, Learn To Program!
(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. 73 |