pic16C84 microcontroller help

This is the place for any magazine-related discussions that don't fit in any of the column discussion boards below.
Post Reply
chrisgaz
Posts: 2
Joined: Fri Apr 26, 2002 1:01 am
Contact:

pic16C84 microcontroller help

Post by chrisgaz » Fri Apr 26, 2002 4:07 am

hi
i am a mature student
i am in the middle of a 13 week course for pic programming.<p>got an exercise to do, don't know where to start
if anyone can help, please e-mail me <p>[email protected]<p>this is what i have to do, i think it's a bit heavy !!!<p>Control Project<p>Task
You must produce a complete working control program written in PIC assembler in order to satisfy the following requirements:<p>a system is required which will recieve inputs on line RB0 - RB5 of port B. these will be treated as numeric values (as if generated by a 6 bit Analogue to Digital Converter).<p>Two light emitting diodes will be connected to RA2 and RA3 of port A.<p>The input at port B will be treated as a binary number with RB0 being the LSB and RB5 being the MSB<p>The state of the LED's will be determined by the numeric value of the inputs at port B according to the following rules<p>Value at port B State of RA2 LED State of RA3 LED<p>Less than 40(decimal) ON OFF
More than 50(decimal) OFF ON
Between 40 and 50 (inclusive) OFF OFF<p>The state of the port should be sampled at a frequency of 0.2 Hz, i.e. the sampling period should be 5 seconds. The tolerance for this period should be + or - 1%. You should provide calculations to support the period that you implement.<p>Documentation Requires<p>1. General introduction describing the problem briefly and explaining the required behaviour of the system. you should include any assumptions that you have made.<p>2. A design for the software system that you produce (flowchart)<p>3. Annotated listings of your code<p>4. A test plan with results of your test runs.<p>5. A conclusion which could include strength and weaknesses of your system and possible areas in which the program could be extended or modified.

bodgy
Posts: 1044
Joined: Tue Dec 04, 2001 1:01 am
Location: Australia
Contact:

Re: pic16C84 microcontroller help

Post by bodgy » Fri Apr 26, 2002 7:18 am

OK I'm a piccy person :D . It's not as bad as it looks - just the way they've set the problem.<p>Personally I'd work slightly backwards. First just get the leds to toggle by only using two inputs on PORTB - then it is much easier to extend the program to 6 bits.<p>What is the method of inputting the number at PORTB?<p>Where it says the sampling period, I take it that they mean sampling the state of the inputs?<p>If so then you must decide if you are going to POLL PORTB or use interrupts.<p>We might be able to exchange ideas - though I do most of my PIC programming in C and just tidy the assembler up.<p>I'd also suggest (if this is less likely to confuse you) that you write out your algorithm in PDL (plain English) first. I find this makes coding much easier and then write the flow chart for the actual project.
On a clear disk you can seek forever.

chrisgaz
Posts: 2
Joined: Fri Apr 26, 2002 1:01 am
Contact:

Re: pic16C84 microcontroller help

Post by chrisgaz » Fri Apr 26, 2002 7:34 am

thx for replying
if i knew who to do it in plain english, lol, i would,<p>what i think i need to do (think)<p>set up timer of microcontroller to generate 1 interrut for 5 secs<p>read state of port b 0,1,2,3,4,5 into a register<p>i should then have a decimal num
then look for it's value and compare it to 40 and 50<p>if num >50 set RA2 to 0
and RA3 to 1<p>how to do it don't ask me though, any further ideas please feel free

bodgy
Posts: 1044
Joined: Tue Dec 04, 2001 1:01 am
Location: Australia
Contact:

Re: pic16C84 microcontroller help

Post by bodgy » Fri Apr 26, 2002 5:17 pm

<blockquote><font size="1" face="Verdana, Helvetica, sans-serif">quote:</font><hr>Originally posted by chrisgaz:
thx for replying
if i knew who to do it in plain english, lol, i would,<p>what i think i need to do (think)<p>set up timer of microcontroller to generate 1 interrut for 5 secs<p>read state of port b 0,1,2,3,4,5 into a register<p>i should then have a decimal num
then look for it's value and compare it to 40 and 50<p>if num >50 set RA2 to 0
and RA3 to 1<p>how to do it don't ask me though, any further ideas please feel free
<hr></blockquote><p>OK PDL =<p>SETUP:
START
Initialise PORTS
Initialise TIMER0
Enable GIE ; enable global interrupt
ENDSETUP<p>MAIN:
START
etc;
etc;<p>Don't forget that the PIC will only be seeing binary not decimal. To read PORTB you will need to test what is on the pins by ANDING so
IF PORTB & 0x11 = movlw b'00111111'
andw PORTB,readport<p>download that program from bubblesoft I emailed you about. This will help in this kind of thing. Also I imagine some of this would be in your course work unless they are like a company here that gave exams in Cobal 3 to students learning Cobal 1 and thought this was fair!<p>Perhaps we should correspond by email?<p>rather than bore everyone else on this board.<p>colin
On a clear disk you can seek forever.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 34 guests