Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,143,497 members, 7,781,500 topics. Date: Friday, 29 March 2024 at 03:34 PM |
Nairaland Forum / Science/Technology / Programming / Microcontrollers (34139 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: 11:46am On Apr 29, 2013 |
princejude:Thanks prince, but dont foget to correct and add to my explanations, dat s d esence of me trying to explain, so I can learn too! |
Re: Microcontrollers by Nobody: 11:57am On Apr 29, 2013 |
Now to the main program! void main(void) The main class is declared and void, since it returns no value, it just does its work over and over! The other void inside (), says no value is passed to the main class(infact it can be omitted!). lines 4 and 5, declare the variables as integer and floating point values(princejude explained this above). |
Re: Microcontrollers by Nobody: 7:01pm On May 04, 2013 |
"yaakuri jamaa" fo d long break man must wak! setup_adc(ADC_CLOCK_DIV_8); now, d next three lines set up the ADC we hav included n our design: the 1st line setup the clock source fo d ADC, Im not really sure but I thnk d bracket says d processors clock shuld b divided by 8 fo use by d ADC. the 2nd line declares pin AN0 of d MCU as d analouge input pin(i really dnt kno what dat small s is fo!). the 3rd line chooses d 1st channel of the 14 available channels as d input channel. the 4th line initialised d lcd and prepares it fo use! |
Re: Microcontrollers by Nobody: 8:54pm On May 05, 2013 |
printf ( lcd_putc, "Temperature 1st printf prints to our initialised lcd, the word "Temperature is". The same word is printed to the RS232 com port by the second printf! Our lcd has 16 columns and two rows of character, since our printf did not specify any position to start printing, the printing will start by default, at line 1, column 1! The next line is a while loop that says, "continue this process as long as power is supplied!" |
Re: Microcontrollers by princejude(m): 11:45am On May 06, 2013 |
cogitoErgo:setup_adc(ADC_CLOCK_DIV_8); Hello CogitoErgo, Have you installed the CCS C Compiler in your PC? If yes, open the 16f887.h file from the installation location: C/Program Files/PICC/Devices then scroll down to ADC Function setups, you will see the ADC registers definition as shown below:
thats where the small 's' is from. Note that NOT ALL PIC MCUs use the small 's'. For example the ADC register definition for 16F877A is below
So is important to look at the header file of any chip before you can use its ADC module |
Re: Microcontrollers by Nobody: 11:55am On May 06, 2013 |
@princejude, Im yet to get my starter package, I surely will get it today and take a look at those things. But I beleive its better to focus on one MCU first and master it very well, instead of trying to understand all MCUs at d same time? I thnk I have decided to start with 16f887! |
Re: Microcontrollers by Nobody: 8:24am On May 10, 2013 |
@princejude, please i need ur guide on how to get the compiled program wit ccs c compiler in to the MCU! |
Re: Microcontrollers by princejude(m): 10:26pm On May 11, 2013 |
To transfer your hex file(compiled ccs code)to your MCU, you will need the following: 1. PIC Programmer (i.e, Pickit2 or Pickit3 or ICD2 or any)Note: Pickit2 (cloned) N5500 and Pickit3 N7000 If you are using pickit2 or pikit3, install its software in your PC. 2. PIC Development kit with PI16F887 3. And of course a computer system. I have explained how to program an MCU in my earlier post in this thread. Check from first page. |
Re: Microcontrollers by Nobody: 11:59am On May 12, 2013 |
princejude: To transfer your hex file(compiled ccs code)to your MCU, you will need the following:I don wait tire fo ur reply but I finaly managed to get the hex file onto the MCU myself! The only problem is that the temperature reading Im getting is obviously wrong, instead of say 38 to 40 deg C, Im getting 199 to 200 deg C! I dont kno where d problem is fo now. |
Re: Microcontrollers by Nobody: 12:15pm On May 12, 2013 |
I adjusted VR2 on the development board and that actually calibrated the temperature reading! But please Princejude, how did they get that conversion formular (i.e, temp=5.00*temp_adc*100.00/1023.00)? |
Re: Microcontrollers by princejude(m): 2:34pm On May 12, 2013 |
cogitoErgo: Sorry for late reply, I was busy with office work. cogitoErgo: Check this second line of your code:
|
Re: Microcontrollers by princejude(m): 3:11pm On May 12, 2013 |
cogitoErgo: I adjusted VR2 on the development board and that actually calibrated the temperature reading! But please Princejude, how did they get that conversion formular (i.e, temp=5.00*temp_adc*100.00/1023.00)? That formula was used to convert the ADC value to temperature in degree Celcius Note that the ADC module was configured to 10 bits (#device ADC=10) 10 bits = 210 = 1024 but you are counting from zero,0 to 1023 |
Re: Microcontrollers by usisky(m): 10:58pm On May 12, 2013 |
cogitoErgo: I adjusted VR2 on the development board and that actually calibrated the temperature reading! But please Princejude, how did they get that conversion formular (i.e, temp=5.00*temp_adc*100.00/1023.00)? I think d above eqaution is a bit 'SUSPECT'. Given an ADC resolution of 10 bits , an upper and lower input voltage range of 5V and 0V. The equation should b: Vin(temp)= (((VREFP-VREFM)/1024) *conversion_result*scaling_factor) - VREFM. where ; VREFP--- positive refrence voltage(5V in dis case). VREFM--- negative voltage reference(0V in dis case). conversion result(adc value). scaling factor(the factor by which u scaled ur input voltage i.e if u scale ur input by 100, den u multiply it by dis factor to obtain correct result). while ur equation above will give seemingly d correct result, it wil however be off by at least 1LSB(of d ADC resolution). This is because u devided by 1023 intead of 1024. It may not appear to b a problem in such application(temperature sensing). However, when dealing with signals with narrow differential input voltages, dis wil b unacceptable. |
Re: Microcontrollers by Nobody: 4:12am On May 13, 2013 |
usisky:Great man, Im loving NL bcause of u guys Another problem, from the progrm code the thermometer seems not to be able to measure negative temp( I may be wrong though, since I have not tested it on that!), if this is true, how could I solve this? Thanks a lot! |
Re: Microcontrollers by princejude(m): 6:29am On May 13, 2013 |
usisky: welldone for ur input, we want more contribution to this thread, let it not be one man show because am a bit busy with other programming stuffs like FPGA, ARM and PSoC |
Re: Microcontrollers by hopefullman: 3:53pm On May 13, 2013 |
@princejude,usisky.2nks 4ur post.i(we) wish 2contribute bt we aren't up 2ur level.nt easy 2talk where our ogas are talking.pls bear with us and keep it up because u're improving lives with ur knowledge. |
Re: Microcontrollers by princejude(m): 3:40am On May 14, 2013 |
This Embedded System Design Magazine might help someone http://www.facebook.com/notes/microscale-embedded/new-release-embedded-systems-magazine/531179500262381 |
Re: Microcontrollers by princejude(m): 4:04am On May 14, 2013 |
Example 4: Moving LEDs This is another simple LED example that will ON eight LEDs sequentially(one at a time). The LEDs were connected to PORTB
|
Re: Microcontrollers by princejude(m): 4:42am On May 14, 2013 |
SEVEN SEGMENT DISPLAY The segments in a 7-segment display are arranged to form a single digit from 0 to F as shown in the figure below: Segments are marked with non-capital letters: a, b, c, d, e, f, g and dp, where dp is the decimal point. The 8 LEDs inside each display can be arranged with a common cathode or common anode. With a common cathode display, the common cathode must be connected to the 0V rail and the LEDs are turned on with a logic one. Common anode displays must have the common anode connected to the +5V rail. The segments are turned on with a logic zero. To display these numbers, the following LED segments will be ON 0 = a,b,c,d,e,f 1 = b,c 2 = a,b,d,e,g 3 = a,b,c,d,g 4 = b,c,f,g 5 = a,c,d,f,g 6 = a,c,d,e,f,g 7 = a,b,c 8 = a,b,c,d,e,f,g 9 = a,b,c,f,g Digit coding for Common Cathode Digit coding for common anode Example 5: 0 to 9 Counter This sample counts from 0 to 9 on a single digit common anode 7-segment display
|
Re: Microcontrollers by princejude(m): 5:04am On May 14, 2013 |
EXAMPLE 6: 00 - 99 Counter
|
Re: Microcontrollers by princejude(m): 5:10am On May 14, 2013 |
. |
Re: Microcontrollers by Nobody: 1:03pm On May 14, 2013 |
This place: http://embedded-lab.com/blog/?page_id=26 also have a lot of examples and tutorials on PIC but its like their programs are for MikroC! |
Re: Microcontrollers by Nobody: 11:08am On May 15, 2013 |
@princejude or anybody, please how many times can I erase and re-write PIC16f887? Please do not refer me to the datasheet, just give me the answer here! Thanks |
Re: Microcontrollers by Nobody: 6:55pm On May 15, 2013 |
@princejude, I tried example 5 but instead of the 7-segment to come on, it was the led that was flashing! |
Re: Microcontrollers by princejude(m): 2:31am On May 16, 2013 |
cogitoErgo: @princejude or anybody, please how many times can I erase and re-write PIC16f887? Please do not refer me to the datasheet, just give me the answer here! Thanks You can erase and re-write more than a million times |
Re: Microcontrollers by princejude(m): 2:38am On May 16, 2013 |
cogitoErgo: @princejude, I tried example 5 but instead of the 7-segment to come on, it was the led that was flashing!Are you testing it with a development kit or with a soldered(vero)board? If you are using dev. kit can you post the link to the kit. We will like to know about your hardware. |
Re: Microcontrollers by Nobody: 6:30am On May 16, 2013 |
princejude:Thanks, God bless u! |
Re: Microcontrollers by Nobody: 6:32am On May 16, 2013 |
princejude:Im using the PIC dev. kit I got from microscale-embedded! |
Re: Microcontrollers by princejude(m): 6:49am On May 16, 2013 |
cogitoErgo: Which of the kits ? The one with on-board ISP programmer or the one without ? The kits have a user manual that explains how to use them in a CD with some sample codes. Study the manual, there is a jumper used to enable the 7-segment and other peripherals. Maybe you only enabled the LEDs. Note that the LEDs and 7-segments are connected on the same port. |
Re: Microcontrollers by Nobody: 9:54am On May 16, 2013 |
princejude:Thanks. I have already gotten it working! I changed the jumper from W2 to W1 to enable the 7-segment(I did that by trial and error, noting carefully I could spoil things ). The ICSP programmer is NOT onboard. |
Re: Microcontrollers by princejude(m): 11:41am On May 16, 2013 |
cogitoErgo: Did you see the Pic Development Kit user manual and software (CCS C Compiler, MPLAB, Proteus) in the CD? If yes, try all the sample codes |
Re: Microcontrollers by Nobody: 4:13pm On May 16, 2013 |
princejude:Ha, which one be Proteus? I saw everytng except dat Proteus! some of d examples will nid aditional pats and I also want to build external power source fo the the breadboard which will b adapted fo final package later. microscale said the #15000/15500 starter pack has lcd graphics display(not 16x2) but i did not see it in my package! i taught maybe its bcause i paid 15000naira! |
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) ... (14) (Reply)
First Thing First, Learn To Program! / Share Your Remote Job Experience As A Developer / 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. 66 |