Sign in

username:

password:



Not a member?

Search piclist



Search tips

Subscribe to piclist



piclist by Keywords

12F675 | 16F628 | 16F84 | 16f877 | 16F877A | 16F88 | 18F458 | ADC | AVR | Bootloader | CAN | CCS | CRC | EAGLE | EEPROM | ICD | ICSP | IDE | JDM | LED | Macros | Microchip | MPLAB | PCB-CAD | PIC10F | Pic12f675 | PIC16F84 | PIC16F84A | PIC16F877 | PIC18 | PIC18F452 | PicBasic | PICC | PICSTART | PWM | RS-485 | RS232 | SMT | SPI | UART | USART | USB | Wireless | Wisp628 | Xilinx

Ads

Discussion Groups

Discussion Groups | Piclist | Ideas please

A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.

Ideas please - hrifai - Feb 13 18:40:00 2005


Hi all

I am looking for an interesting (easy to build) project that
involves any mechanical idea + PIC16F84 !!!!!!!

The point is that I don't have to design the circuit "not my part"
and my team insist on something very interesting

Can anyone please help ???




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )


Re: Ideas please - rrkarnik - Feb 14 12:44:00 2005


How about providing quartz accuracy for a pendulum clock!

Measure the period of the pendulum of your average grandmother using
maybe an interrupted light beam, and provide an on-off method to damp
(or not) its swing.

In general, pendulum clocks tend to go faster when their energy source
wanes (small swings) and are slower when they are fully powered (yeah
baby yeah swing)

The pendulum formula sqrt(length/g)/(2*pi) is only accurate for small
amplitudes of theta, but everyone seems to forget that.

If battery powered you can actually achieve good accuracy by simply
providing a constant current source through the clock circuit. But
that's too easy.

So you should do it in a way that would make Ruth Goldberg proud -
plenty of physical (air, magnetic, audio, liquid flow) things going on
and the PIC device used simply to orchestrate everything in a crystal
clock source controlled "timely" fashion.

Extra credit for using solar power and no physical contact for your
perpetual chaos machine with the PIC circuitry. Meaning, if your PIC
dies, it continues to function more or less as before - but once you
bring it into the arena - whamo - atomic precision.

That should teach your team to outsource their lack of imagination ;)

Rahul
--- In , "hrifai" <hrifai@y...> wrote:
>
> Hi all
>
> I am looking for an interesting (easy to build) project that
> involves any mechanical idea + PIC16F84 !!!!!!!
>
> The point is that I don't have to design the circuit "not my part"
> and my team insist on something very interesting
>
> Can anyone please help ???





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Re: Ideas please - Paul Harrison - Feb 14 13:33:00 2005

Excellent idea! I work on clocks as a hobby/profession - the power
problem is probably overstated
since most grandfather/mother clocks run on weight, which doesn't change
much as the clock runs
down (just the added weight of the chain/cable). But temperature change
and pendulum swing are
something else interely.

Good suggestion!

Paul

rrkarnik wrote:

>How about providing quartz accuracy for a pendulum clock!
>
>Measure the period of the pendulum of your average grandmother using
>maybe an interrupted light beam, and provide an on-off method to damp
>(or not) its swing.
>
>In general, pendulum clocks tend to go faster when their energy source
>wanes (small swings) and are slower when they are fully powered (yeah
>baby yeah swing)
>
>The pendulum formula sqrt(length/g)/(2*pi) is only accurate for small
>amplitudes of theta, but everyone seems to forget that.
>
>If battery powered you can actually achieve good accuracy by simply
>providing a constant current source through the clock circuit. But
>that's too easy.
>
>So you should do it in a way that would make Ruth Goldberg proud -
>plenty of physical (air, magnetic, audio, liquid flow) things going on
>and the PIC device used simply to orchestrate everything in a crystal
>clock source controlled "timely" fashion.
>
>Extra credit for using solar power and no physical contact for your
>perpetual chaos machine with the PIC circuitry. Meaning, if your PIC
>dies, it continues to function more or less as before - but once you
>bring it into the arena - whamo - atomic precision.
>
>That should teach your team to outsource their lack of imagination ;)
>
>Rahul
>--- In , "hrifai" <hrifai@y...> wrote: >>Hi all
>>
>>I am looking for an interesting (easy to build) project that
>>involves any mechanical idea + PIC16F84 !!!!!!!
>>
>>The point is that I don't have to design the circuit "not my part"
>>and my team insist on something very interesting
>>
>>Can anyone please help ???
>>
> >to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
>Yahoo! Groups Links





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

RE: Re: Ideas please - Wouter van Ooijen - Feb 14 14:29:00 2005

> So you should do it in a way that would make Ruth Goldberg proud -
> plenty of physical (air, magnetic, audio, liquid flow) things going on
> and the PIC device used simply to orchestrate everything in a crystal
> clock source controlled "timely" fashion.
>
> Extra credit for using solar power and no physical contact for your
> perpetual chaos machine with the PIC circuitry. Meaning, if your PIC
> dies, it continues to function more or less as before - but once you
> bring it into the arena - whamo - atomic precision.

You do realise that the accuracy of an average crystal is not
necesarrily suprior to a pendulum clock?

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: www.voti.nl/hvu




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Re: Ideas please - michael brown - Feb 14 19:29:00 2005



----- Original Message -----
From: "Wouter van Ooijen" < > > So you should do it in a way that would make Ruth Goldberg proud -
> > plenty of physical (air, magnetic, audio, liquid flow) things going
on
> > and the PIC device used simply to orchestrate everything in a
crystal
> > clock source controlled "timely" fashion.
> >
> > Extra credit for using solar power and no physical contact for your
> > perpetual chaos machine with the PIC circuitry. Meaning, if your PIC
> > dies, it continues to function more or less as before - but once you
> > bring it into the arena - whamo - atomic precision.
>
> You do realise that the accuracy of an average crystal is not
> necesarrily suprior to a pendulum clock?

You're a smart guy Wouter, but I'm still surprised that you knew that.
Not many people fully realize the accuracy of a great many timepieces
far over 100 years old. I have a Seth Thomas 8-day double-decker empire
clock circa 1890 that keeps time to within 30 seconds/week putting it
close to the stated accuracy of allot of crystals. It's nothing really
special, just an ordinary mantle clock for an elitist Victorian of the
time. ;-) Each weight is around 15 pounds.

Almost identical to this one, but mine's in better shape:
http://www.antiqueclockspriceguide.com/pages/clock4429.php

As you probably know, laboratory/observatory clocks of the time were
*far* more impressive.





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Ideas please - rrkarnik - Feb 14 22:46:00 2005


Doh! I guess it might help to be able to trim the oscillation modes
and keep the thingy at a constant temperature. More fun to do that
using the PIC.

Some readily available consistent time bases include a 19 KHz FM radio
stereo pilot tone.

Or the common household power supply (50/60Hz) which is supposedly
ordained to be very accurate - over time.

Or ...... maybe the "team" should make a pendulum-accuracy based PLL
clock!

I've been thinking of a "clock" which works as follows:

a) Solar cell powered. Initialized with absolutely no information -
except a bunch of astronommical equations.
b) You leave it outdoors, anywhere on the planet (well maybe not in
too high latitudes)
c) Every day it gets powered by sunlight which enables it to track the
traversal of the sun across the sky.
d) At night or on cloudy days it simply sleeps.
e) Over several months, if not years, it determines its location
(latitude) to figure out local time for that location very accurately,
including calendar information.
f) The clock will extend its flexible and positionable arms to set up
an accurately shaped gnomon and also draw a sundial pattern around
itself, including corrections for the annual equation of time.
g) Once that is done, the clock is ready and can go to sleep except
for slight corrections when necessary. --- In , "Wouter van Ooijen" <wouter@v...> wrote:
> > So you should do it in a way that would make Ruth Goldberg proud -
> > plenty of physical (air, magnetic, audio, liquid flow) things going on
> > and the PIC device used simply to orchestrate everything in a crystal
> > clock source controlled "timely" fashion.
> >
> > Extra credit for using solar power and no physical contact for your
> > perpetual chaos machine with the PIC circuitry. Meaning, if your PIC
> > dies, it continues to function more or less as before - but once you
> > bring it into the arena - whamo - atomic precision.
>
> You do realise that the accuracy of an average crystal is not
> necesarrily suprior to a pendulum clock?
>
> Wouter van Ooijen
>
> -- -------------------------------------------
> Van Ooijen Technische Informatica: www.voti.nl
> consultancy, development, PICmicro products
> docent Hogeschool van Utrecht: www.voti.nl/hvu





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Ideas please - rtstofer - Feb 14 22:54:00 2005



All of which makes John Harrison's navigational watch look
spectacular: in 1762, during an 81 day voyage, the H4 lost 5 SECONDS!

This would create a positional error of perhaps 1.25 nautical miles
and even on a small boat the visible horizon is about 3 nautical
miles. I could live with that kind of accuracy!

Of course, sextant errors, ship motion, almanac accuracy, etc. would
all add to the error but time is the critical factor and Harrison
had that down to an art.

--- In , "michael brown" <spam-me@h...> wrote: > ----- Original Message -----
> From: "Wouter van Ooijen" <wouter@v...>
>
> >
> > > So you should do it in a way that would make Ruth Goldberg
proud -
> > > plenty of physical (air, magnetic, audio, liquid flow) things
going
> on
> > > and the PIC device used simply to orchestrate everything in a
> crystal
> > > clock source controlled "timely" fashion.
> > >
> > > Extra credit for using solar power and no physical contact for
your
> > > perpetual chaos machine with the PIC circuitry. Meaning, if
your PIC
> > > dies, it continues to function more or less as before - but
once you
> > > bring it into the arena - whamo - atomic precision.
> >
> > You do realise that the accuracy of an average crystal is not
> > necesarrily suprior to a pendulum clock?
>
> You're a smart guy Wouter, but I'm still surprised that you knew
that.
> Not many people fully realize the accuracy of a great many
timepieces
> far over 100 years old. I have a Seth Thomas 8-day double-decker
empire
> clock circa 1890 that keeps time to within 30 seconds/week putting
it
> close to the stated accuracy of allot of crystals. It's nothing
really
> special, just an ordinary mantle clock for an elitist Victorian of
the
> time. ;-) Each weight is around 15 pounds.
>
> Almost identical to this one, but mine's in better shape:
> http://www.antiqueclockspriceguide.com/pages/clock4429.php
>
> As you probably know, laboratory/observatory clocks of the time
were
> *far* more impressive.





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Ideas please - Vasile Surducan - Feb 15 9:40:00 2005


--- In , "hrifai" <hrifai@y...> wrote:
>
> Hi all
>
> I am looking for an interesting (easy to build) project that
> involves any mechanical idea + PIC16F84 !!!!!!! I'm thinking to this from a long time: imagine a huge hammer
in a knock position, locked by a small relay mechanism.
A 220V 100W bulb plugged into the mains below him.
An ethernet conection to a PIC16F84 and a camera on to the show.
The web surfer see a button and by pushing it, the hammer will blow
the bulb. Everything wievable on the internet.

Did you felt you're living for doing something grandious ?

:)

best regards,
Vasile
http://surducan.netfirms.com





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

RE: Re: Ideas please - Chad Russel - Feb 15 15:30:00 2005


--- Wouter van Ooijen <> wrote:

> > So you should do it in a way that would make Ruth Goldberg proud -
> > plenty of physical (air, magnetic, audio, liquid flow) things going
> on
> > and the PIC device used simply to orchestrate everything in a
> crystal
> > clock source controlled "timely" fashion.
> >
> > Extra credit for using solar power and no physical contact for your
> > perpetual chaos machine with the PIC circuitry. Meaning, if your
> PIC
> > dies, it continues to function more or less as before - but once
> you
> > bring it into the arena - whamo - atomic precision.
>
> You do realise that the accuracy of an average crystal is not
> necesarrily suprior to a pendulum clock?
>
> Wouter van Ooijen
>
> -- -------------------------------------------
> Van Ooijen Technische Informatica: www.voti.nl
> consultancy, development, PICmicro products
> docent Hogeschool van Utrecht: www.voti.nl/hvu

Right you are. Before the government came up with atomic standards,
believe it or not, most TV station, power stations, etc. used a
pendulum clock. Our standard was right there in master control. This
is not 50 years ago, maybe 30.

Chad

=====
My software has no bugs, only undocumented features.

__________________________________________________
">http://mail.yahoo.com





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Re: Ideas please - Robert Rolf - Feb 15 17:21:00 2005

And you only need do it once, then play back the video
whenever the web surfer hits the button.
Was it real or was it memorbits?

Vasile Surducan wrote: > --- In , "hrifai" <hrifai@y...> wrote:
>
>>Hi all
>>
>>I am looking for an interesting (easy to build) project that
>>involves any mechanical idea + PIC16F84 !!!!!!!
> > I'm thinking to this from a long time: imagine a huge hammer
> in a knock position, locked by a small relay mechanism.
> A 220V 100W bulb plugged into the mains below him.
> An ethernet conection to a PIC16F84 and a camera on to the show.
> The web surfer see a button and by pushing it, the hammer will blow
> the bulb. Everything wievable on the internet.
>
> Did you felt you're living for doing something grandious ?
>
> :)
>
> best regards,
> Vasile
> http://surducan.netfirms.com




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Ideas please - nford85 - Feb 16 0:45:00 2005


How bout this for an idea which uses most of the stuff already
mentioned here

Instead of getting the time for the clock from the crystal - get the
time from a radio broadcast time signal and checking the time on the
clock with the broadcast time. From this you could increase or
decrease the length of the pendulum.

This is just an idea which is probably too flawed to implement :) --- In , "rtstofer" <rstofer@p...> wrote: > All of which makes John Harrison's navigational watch look
> spectacular: in 1762, during an 81 day voyage, the H4 lost 5 SECONDS!
>
> This would create a positional error of perhaps 1.25 nautical miles
> and even on a small boat the visible horizon is about 3 nautical
> miles. I could live with that kind of accuracy!
>
> Of course, sextant errors, ship motion, almanac accuracy, etc. would
> all add to the error but time is the critical factor and Harrison
> had that down to an art. >
>
> --- In , "michael brown" <spam-me@h...> wrote:
> >
> >
> > ----- Original Message -----
> > From: "Wouter van Ooijen" <wouter@v...>
> >
> > >
> > > > So you should do it in a way that would make Ruth Goldberg
> proud -
> > > > plenty of physical (air, magnetic, audio, liquid flow) things
> going
> > on
> > > > and the PIC device used simply to orchestrate everything in a
> > crystal
> > > > clock source controlled "timely" fashion.
> > > >
> > > > Extra credit for using solar power and no physical contact for
> your
> > > > perpetual chaos machine with the PIC circuitry. Meaning, if
> your PIC
> > > > dies, it continues to function more or less as before - but
> once you
> > > > bring it into the arena - whamo - atomic precision.
> > >
> > > You do realise that the accuracy of an average crystal is not
> > > necesarrily suprior to a pendulum clock?
> >
> > You're a smart guy Wouter, but I'm still surprised that you knew
> that.
> > Not many people fully realize the accuracy of a great many
> timepieces
> > far over 100 years old. I have a Seth Thomas 8-day double-decker
> empire
> > clock circa 1890 that keeps time to within 30 seconds/week putting
> it
> > close to the stated accuracy of allot of crystals. It's nothing
> really
> > special, just an ordinary mantle clock for an elitist Victorian of
> the
> > time. ;-) Each weight is around 15 pounds.
> >
> > Almost identical to this one, but mine's in better shape:
> > http://www.antiqueclockspriceguide.com/pages/clock4429.php
> >
> > As you probably know, laboratory/observatory clocks of the time
> were
> > *far* more impressive.





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

RE: Re: Ideas please - Wouter van Ooijen - Feb 16 2:46:00 2005

> I'm thinking to this from a long time: imagine a huge hammer
> in a knock position, locked by a small relay mechanism.
> A 220V 100W bulb plugged into the mains below him.
> An ethernet conection to a PIC16F84 and a camera on to the show.
> The web surfer see a button and by pushing it, the hammer will blow
> the bulb. Everything wievable on the internet.

I you do that and instead put the 16C84 under the hammer I will donate
you a bigger pic (16F877A or 18F452 or whatever) to do the processing.

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: www.voti.nl/hvu




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Ideas please - rtstofer - Feb 16 10:59:00 2005


--- In , "Wouter van Ooijen" <wouter@v...>
wrote:
> > I'm thinking to this from a long time: imagine a huge hammer
> > in a knock position, locked by a small relay mechanism.
> > A 220V 100W bulb plugged into the mains below him.
> > An ethernet conection to a PIC16F84 and a camera on to the show.
> > The web surfer see a button and by pushing it, the hammer will
blow
> > the bulb. Everything wievable on the internet.
>
> I you do that and instead put the 16C84 under the hammer I will
donate
> you a bigger pic (16F877A or 18F452 or whatever) to do the
processing.
>
> Wouter van Ooijen

There is a practical application for this! When IC manufacturers
produce defective product, one of the biggest problems is destroying
the devices in such a way that they never get in the supply chain -
legitimate or black market. It's bad enough that the device is
defective but having to replace it with a good one under warranty
makes it even worse.

But how do you destroy an IC - it isn't as easy as you might
imagine, particularly if you want to recover the gold from the
packaging (where applicable). I once watched while thousands of TO3
packages were smashed with a jack hammer against a large steel
plate. It was costly and not particularly effective.

So, this hammer device could take an input signal from the test
machine after a chip is rejected and smash it locally. Kind of
a 'point of test reject handler'. >
> -- -------------------------------------------
> Van Ooijen Technische Informatica: www.voti.nl
> consultancy, development, PICmicro products
> docent Hogeschool van Utrecht: www.voti.nl/hvu





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Short PIC Program - Help needed badly - Devon Lee - Feb 16 12:39:00 2005

Hi there,

I'm a newbie in PIC programming using assembly
language. Recently, I've written a short program using
PIC16F876 which involves PWM and ADC.

I've tested the program in the lab but it does not
function in a proper manner. I've tried reading and
editing the program after it failed to function
properly but it seems that I still don't get to run
the PIC well. I couldn't find anything else to edit, I
will not say that no correction in the program is
needed, as obviously there is something wrong with it
as I don't get to run it in a proper manner.

Really don't know what to do to the written program.
Was just thinking if anyone is interested to take a
look at the entire program (not very long). I didn't
include the entire program here as I'm afraid it is
rude doing so.

Basically, while testing in the lab, what I observed
is certain portion of the written program works well
but randomly. Meaning, if I were to turn ON and OFF,
ON and OFF, there are times where it works well but
there are times where it doesn't. Help really needed.
Any advice?

Please? Hope to hear from you guys. Thanks a lot.
__________________________________





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

RE: Short PIC Program - Help needed badly - Chris - Feb 16 13:04:00 2005

Hi Devon,

I've been doing A LOT of PIC work lately. Almost total immersion you could
say!

Anyway, maybe I can help you out some.

One thing I've learned in the last few months of doing this is to work on
one thing at a time. In other words, get your ADC code working 100% then in
a separate program get the PWM code working 100% then merge them together.

Neither ADC or PWM simulate well so you are going to have to look at and
debug a real circuit at some point. Although the simulator is still very
useful.

Some things to check in the simulator - if your not doing this already - are
step through your port setup code - do you see the tris and port registers
change as you configure them? I can't tell you how many times I've
forgotten to switch to the correct bank.

Anyway, I would be happy to take a quick look at some of your code as well.
You can post it here - so others can comment or you can email it to me
directly.

BTW, posting code is ok. Also tell us what PIC you are using and describe
you development tools and environment.

I work exclusively in assembler so I cant help you code wise if you are
using something else.

Good luck.

Chris
http://pic.rocklizard.org
-----Original Message-----
From: Devon Lee [mailto:]
Sent: Wednesday, February 16, 2005 9:40 AM
To:
Subject: [piclist] Short PIC Program - Help needed badly Hi there,

I'm a newbie in PIC programming using assembly language. Recently, I've
written a short program using
PIC16F876 which involves PWM and ADC.

I've tested the program in the lab but it does not function in a proper
manner. I've tried reading and editing the program after it failed to
function properly but it seems that I still don't get to run the PIC well. I
couldn't find anything else to edit, I will not say that no correction in
the program is needed, as obviously there is something wrong with it as I
don't get to run it in a proper manner.

Really don't know what to do to the written program.
Was just thinking if anyone is interested to take a look at the entire
program (not very long). I didn't include the entire program here as I'm
afraid it is rude doing so.

Basically, while testing in the lab, what I observed is certain portion of
the written program works well but randomly. Meaning, if I were to turn ON
and OFF, ON and OFF, there are times where it works well but there are times
where it doesn't. Help really needed.
Any advice?

Please? Hope to hear from you guys. Thanks a lot.
__________________________________ to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

Yahoo! Groups Links




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

RE: Short PIC Program - Help needed badly - Devon Lee - Feb 17 13:02:00 2005

Hi Chris,

Thanks for your concern to a newbie like me that
doesnt not know much. Thank you very very much.

Hope you guys don't mind taking a look at the PIC
program. Hope I'm not writing nonsense. Thanks a lot
in advance.

By the way, I'm using PIC16F876 and MPLAB as a
compiler. Thanks a lot in advance...

------------------------------------------------------
PIC Program
------------------------------------------------------
LIST P=16F876
#INCLUDE "P16F876.INC"
__CONFIG _CP_OFF & _XT_OSC & _WDT_OFF & _PWRTE_ON &
_LVP_OFF & _BODEN_ON
ERRORLEVEL -306, -302

;MAIN PROGRAM 1 - BOOST

RESULTHIGH1 EQU 24H
RESULTLOW1 EQU 25H
RESULTHIGH2 EQU 26H
RESULTLOW2 EQU 27H

;**************************************************************************

;GENERAL PURPOSE REGISTER
CBLOCK 0x20
MULTA2
MULTB2
ENDC

;**************************************************************************

;INITIALIZATION FOR THE SWITCH (PORT C)
;USING 2 SWITCHES TO SWITCH BETWEEN CHARGING 6V OR 12V
;WITH 2 LEDs TO SHOW THE SELECTED CHARGING BATTERY
CAPACITY

BSF STATUS,RP0
MOVLW B'11000000' ;SW1,SW2,LED1,LED2,*,PWM,*,*
MOVWF TRISC
BCF STATUS,RP0

;**************************************************************************

;INITIALIZATION FOR ADC1 AND ADC2 (PORT A)
;ADC1 IS FOR FEEDBACK FROM BATTERY
;ADC2 IS FOR FEEDBACK FROM SOLAR PANEL

BSF STATUS,RP0
MOVLW B'10001001'
MOVWF ADCON1
BCF STATUS,RP0

;**************************************************************************

;INITIALIZATION FOR PWM (PORT C)

BSF STATUS,RP0
MOVLW B'00111111'
MOVWF PR2
BCF TRISC,0x02
BCF STATUS,RP0

;**************************************************************************

;START CHECK

RESTART CALL ADC1 ;FEEDBACK FROM BATTERY
CALL SWITCH1 ;12V BATTERY
CALL SWITCH2 ;6V BATTERY
BTFSS STATUS,C ;IF CARRY BIT SET, GO TO RESTART
BTFSC STATUS,Z ;IF ZERO BIT SET, MEANS RESULT OF
SUBSTRACT IS '0'
GOTO RESTART
CALL ADC2
BTFSC PORTC,7 ;IF SW1 = '0', SKIP CALL DUTYA
CALL DUTYA ;IF SKIP, MEANS BATTERY USED IS 6V, ELSE
12V
BTFSC PORTC,6 ;IF SW2 = '0', SKIP CALL DUTYB
CALL DUTYB ;DUTY RATIO FOR 6V BATTERY CALCULATION

;**************************************************************************

;12V BATTERY

SWITCH1 BTFSS PORTC,7 ;IF RECEIVE '1', SKIP RETURN
RETURN
CALL LED1
MOVF RESULTLOW1,W
MOVWF MULTA2
CLRC ;MULTIPLY BY 2
RLF MULTA2,F
MOVF MULTA2,W ;VALUE AFTER MULTIPLICATION FOR
COMPARISON
SUBLW B'00001101' ;TAKE 13 MINUS MULTA
BTFSS STATUS,C ;IF CARRY BIT IS SET, MEANS MULTA IS
BIGGER THAN 13, THUS SKIP
BTFSC STATUS,Z ;IF ZERO BIT IS SET, MEANS MULTA IS
13V
BSF TRISC,2 ;TURN ON MOSFET, THUS, ONLY CAPACITOR
CHARGE THE BATTERY
RETURN

;**************************************************************************

;6V BATTERY

SWITCH2 BTFSS PORTC,6
RETURN
CALL LED2
MOVF RESULTLOW1,W
MOVWF MULTB2
CLRC
RLF MULTB2,F
MOVF MULTB2,W
SUBLW B'00000111'
BTFSS STATUS,C
BTFSC STATUS,Z
BSF TRISC,2 ;TURN ON MOSFET
RETURN

;**************************************************************************

;LED 12V

LED1 CLRF PORTC
BSF TRISC,5
RETURN

;**************************************************************************

;LED 6V

LED2 CLRF PORTC
BSF TRISC,4
RETURN

;**************************************************************************

;READ BATTERY VOLTAGE LEVEL (AN0)

ADC1 MOVLW B'01000001'
MOVWF ADCON0
BSF ADCON0,GO_DONE
CHECK1 BTFSC ADCON0,GO_DONE
GOTO CHECK1
MOVF ADRESH,W
MOVWF RESULTHIGH1
BSF STATUS,RP0
MOVF ADRESL,W
BCF STATUS,RP0
MOVWF RESULTLOW1
RETURN

;**************************************************************************

;READ OUTPUT VOLTAGE OF SOLAR PANEL (AN1)

ADC2 MOVLW B'01001001'
MOVWF ADCON0
BSF ADCON0,GO_DONE
CHECK2 BTFSC ADCON0,GO_DONE
GOTO CHECK2
MOVF ADRESH,W
MOVWF RESULTHIGH2
BSF STATUS,RP0
MOVF ADRESL,W
BCF STATUS,RP0
MOVWF RESULTLOW2
RETURN

;**************************************************************************

;USING LOOK-UP TABLE TO PROVIDE PWM SIGNAL
;MULTIPLY BY 2, GET BACK ORIGINAL VALUE
;COMPARE AND APPLY CCP, REFER LOOK-UP TABLE
;COMPARE SMALLEST TO BIGGEST POSSIBILITIES

DUTYA MOVF RESULTLOW2,W
MOVWF MULTA2
CLRC
RLF MULTA2,F
MOVF MULTA2,W
SUBLW B'00001110'
BTFSS STATUS,C
BTFSC STATUS,Z
BCF TRISC,2 ;TURN OFF MOSFET, LET CHARGE AT 14V
SOURCE

MOVF MULTA2,W
SUBLW B'00000101'
BTFSS STATUS,C ;AFTER MINUS, IF C=1, MEANING ADC
RESULT > 5
BTFSC STATUS,Z ;AFTER MINUS, IF Z=1, MEANING ADC
RESULT = 5
CALL PWM5A

MOVF MULTA2,W
SUBLW B'00000110'
BTFSS STATUS,C
BTFSC STATUS,Z
CALL PWM6A

MOVF MULTA2,W
SUBLW B'00000111'
BTFSS STATUS,C
BTFSC STATUS,Z
CALL PWM7A

MOVF MULTA2,W
SUBLW B'00001000'
BTFSS STATUS,C
BTFSC STATUS,Z
CALL PWM8A

MOVF MULTA2,W
SUBLW B'00001001'
BTFSS STATUS,C
BTFSC STATUS,Z
CALL PWM9A

MOVF MULTA2,W
SUBLW B'00001010'
BTFSS STATUS,C
BTFSC STATUS,Z
CALL PWM10A

MOVF MULTA2,W
SUBLW B'00001011'
BTFSS STATUS,C
BTFSC STATUS,Z
CALL PWM11A

MOVF MULTA2,W
SUBLW B'00001100'
BTFSS STATUS,C
BTFSC STATUS,Z
CALL PWM12A

MOVF MULTA2,W
SUBLW B'00001101'
BTFSS STATUS,C
BTFSC STATUS,Z
CALL PWM13A
RETURN

;**************************************************************************

;IF 7 OR ABOVE 7, DONT BOOST

DUTYB MOVF RESULTLOW2,W
MOVWF MULTA2
CLRC
RLF MULTA2,F
MOVF MULTA2,W
SUBLW B'00000111'
BTFSS STATUS,C ;IF 7 MINUS RESULT IS NEGATIVE, C=1,
BTFSC STATUS,Z ;SO, DONT HAVE TO BOOST BUT CHARGE
BCF TRISC,2 ;TURN OFF MOSFET

MOVF MULTA2,W
SUBLW B'00000101'
BTFSS STATUS,C
BTFSC STATUS,Z
CALL PWM5B

MOVF MULTA2,W
SUBLW B'0000110'
BTFSS STATUS,C
BTFSC STATUS,Z
CALL PWM6B
RETURN

;**************************************************************************

;FROM REFERENCE TABLE

PWM5A MOVLW B'00101010' ; set bits 9 to 2
MOVWF CCPR1L
BCF CCP1CON,CCP1X ; set to => "00"
BCF CCP1CON,CCP1Y
MOVLW B'00000100' ; TMR2 = on, prescale = 1
MOVWF T2CON
MOVLW B'00001100'
MOVWF CCP1CON
RETURN

PWM6A MOVLW B'00100101' ; set bits 9 to 2
MOVWF CCPR1L
BSF CCP1CON,CCP1X ; set to => "10"
BCF CCP1CON,CCP1Y
MOVLW B'00000100' ; TMR2 = on, prescale = 1
MOVWF T2CON
MOVLW B'00101100'
MOVWF CCP1CON
RETURN

PWM7A MOVLW B'00100001' ; set bits 9 to 2
MOVWF CCPR1L
BCF CCP1CON,CCP1X ; set to => "00"
BCF CCP1CON,CCP1Y
MOVLW B'00000100' ; TMR2 = on, prescale = 1
MOVWF T2CON
MOVLW B'00001100'
MOVWF CCP1CON
RETURN

PWM8A MOVLW B'00011100' ; set bits 9 to 2
MOVWF CCPR1L
BSF CCP1CON,CCP1X ; set to => "11"
BSF CCP1CON,CCP1Y
MOVLW B'00000100' ; TMR2 = on, prescale = 1
MOVWF T2CON
MOVLW B'00111100'
MOVWF CCP1CON
RETURN

PWM9A MOVLW B'00011000' ; set bits 9 to 2
MOVWF CCPR1L
BCF CCP1CON,CCP1X ; set to => "01"
BSF CCP1CON,CCP1Y
MOVLW B'00000100' ; TMR2 = on, prescale = 1
MOVWF T2CON
MOVLW B'00011100'
MOVWF CCP1CON
RETURN

PWM10A MOVLW B'00010011' ; set bits 9 to 2
MOVWF CCPR1L
BSF CCP1CON,CCP1X ; set to => "11"
BSF CCP1CON,CCP1Y
MOVLW B'00000100' ; TMR2 = on, prescale = 1
MOVWF T2CON
MOVLW B'00111100'
MOVWF CCP1CON
RETURN

PWM11A MOVLW B'00001111' ; set bits 9 to 2
MOVWF CCPR1L
BSF CCP1CON,CCP1X ; set to => "10"
BCF CCP1CON,CCP1Y
MOVLW B'00000100' ; TMR2 = on, prescale = 1
MOVWF T2CON
MOVLW B'00101100'
MOVWF CCP1CON
RETURN

PWM12A MOVLW B'00001011' ; set bits 9 to 2
MOVWF CCPR1L
BCF CCP1CON,CCP1X ; set to => "00"
BCF CCP1CON,CCP1Y
MOVLW B'00000100' ; TMR2 = on, prescale = 1
MOVWF T2CON
MOVLW B'00001100'
MOVWF CCP1CON
RETURN

PWM13A MOVLW B'00000110' ; set bits 9 to 2
MOVWF CCPR1L
BSF CCP1CON,CCP1X ; set to => "10"
BCF CCP1CON,CCP1Y
MOVLW B'00000100' ; TMR2 = on, prescale = 1
MOVWF T2CON
MOVLW B'00101100'
MOVWF CCP1CON
RETURN

;**************************************************************************

;FROM REFERENCE TABLE

PWM5B MOVLW B'00010101' ; set bits 9 to 2
MOVWF CCPR1L
BCF CCP1CON,CCP1X ; set to => "01"
BSF CCP1CON,CCP1Y
MOVLW B'00000100' ; TMR2 = on, prescale = 1
MOVWF T2CON
MOVLW B'00011100'
MOVWF CCP1CON
RETURN

PWM6B MOVLW B'00001100' ; set bits 9 to 2
MOVWF CCPR1L
BSF CCP1CON,CCP1X ; set to => "11"
BSF CCP1CON,CCP1Y
MOVLW B'00000100' ; TMR2 = on, prescale = 1
MOVWF T2CON
MOVLW B'00111100'
MOVWF CCP1CON
RETURN

;**************************************************************************
END

------------------------------------------------------
__________________________________





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Short PIC Program - Help needed badly - Manoj R. - Feb 17 14:05:00 2005



Hi man,

I am also sorta a newbie in PIC. just had a fast look at ur code.

I dont know if its correct. But in my opinion, the PIC has the reset
address as 0000h. this is where its starts execution, once power is
given. i cant seem to locate the rest vector in your code. usually, it
is given after an ORIGIN command, like

org 0x0000 ; place the following line in 0x0000 address
goto start

start :

; {
; Main program
; }

end

I strongly believe this is required. Forgive me if i am misleading you
:-)

After all, i am also a new comer :-D

and one more thing, the interrupt vector of PIC is 0004h. In case you
are planning to use interrupts, use the org command with 4h, and give
a goto statement to your ISR

Hope this helps :-D

One test is worth a thousand expert opinions....WATZ THER!!!
--- In , Devon Lee <devonsc@y...> wrote:
> Hi Chris,
>
> Thanks for your concern to a newbie like me that
> doesnt not know much. Thank you very very much.
>
> Hope you guys don't mind taking a look at the PIC
> program. Hope I'm not writing nonsense. Thanks a lot
> in advance.
>
> By the way, I'm using PIC16F876 and MPLAB as a
> compiler. Thanks a lot in advance...
>
> ------------------------------------------------------
> PIC Program
> ------------------------------------------------------
> LIST P=16F876
> #INCLUDE "P16F876.INC"
> __CONFIG _CP_OFF & _XT_OSC & _WDT_OFF & _PWRTE_ON &
> _LVP_OFF & _BODEN_ON
> ERRORLEVEL -306, -302
>
> ;MAIN PROGRAM 1 - BOOST
>
> RESULTHIGH1 EQU 24H
> RESULTLOW1 EQU 25H
> RESULTHIGH2 EQU 26H
> RESULTLOW2 EQU 27H
>
> ;
**********************************************************************
****
>
> ;GENERAL PURPOSE REGISTER
> CBLOCK 0x20
> MULTA2
> MULTB2
> ENDC
>
> ;
**********************************************************************
****
>
> ;INITIALIZATION FOR THE SWITCH (PORT C)
> ;USING 2 SWITCHES TO SWITCH BETWEEN CHARGING 6V OR 12V
> ;WITH 2 LEDs TO SHOW THE SELECTED CHARGING BATTERY
> CAPACITY
>
> BSF STATUS,RP0
> MOVLW B'11000000' ;SW1,SW2,LED1,LED2,*,PWM,*,*
> MOVWF TRISC
> BCF STATUS,RP0
>
> ;
**********************************************************************
****
>
> ;INITIALIZATION FOR ADC1 AND ADC2 (PORT A)
> ;ADC1 IS FOR FEEDBACK FROM BATTERY
> ;ADC2 IS FOR FEEDBACK FROM SOLAR PANEL
>
> BSF STATUS,RP0
> MOVLW B'10001001'
> MOVWF ADCON1
> BCF STATUS,RP0
>
> ;
**********************************************************************
****
>
> ;INITIALIZATION FOR PWM (PORT C)
>
> BSF STATUS,RP0
> MOVLW B'00111111'
> MOVWF PR2
> BCF TRISC,0x02
> BCF STATUS,RP0
>
> ;
**********************************************************************
****
>
> ;START CHECK
>
> RESTART CALL ADC1 ;FEEDBACK FROM BATTERY
> CALL SWITCH1 ;12V BATTERY
> CALL SWITCH2 ;6V BATTERY
> BTFSS STATUS,C ;IF CARRY BIT SET, GO TO RESTART
> BTFSC STATUS,Z ;IF ZERO BIT SET, MEANS RESULT OF
> SUBSTRACT IS '0'
> GOTO RESTART
> CALL ADC2
> BTFSC PORTC,7 ;IF SW1 = '0', SKIP CALL DUTYA
> CALL DUTYA ;IF SKIP, MEANS BATTERY USED IS 6V, ELSE
> 12V
> BTFSC PORTC,6 ;IF SW2 = '0', SKIP CALL DUTYB
> CALL DUTYB ;DUTY RATIO FOR 6V BATTERY CALCULATION
>
> ;
**********************************************************************
****
>
> ;12V BATTERY
>
> SWITCH1 BTFSS PORTC,7 ;IF RECEIVE '1', SKIP RETURN
> RETURN
> CALL LED1
> MOVF RESULTLOW1,W
> MOVWF MULTA2
> CLRC ;MULTIPLY BY 2
> RLF MULTA2,F
> MOVF MULTA2,W ;VALUE AFTER MULTIPLICATION FOR
> COMPARISON
> SUBLW B'00001101' ;TAKE 13 MINUS MULTA
> BTFSS STATUS,C ;IF CARRY BIT IS SET, MEANS MULTA IS
> BIGGER THAN 13, THUS SKIP
> BTFSC STATUS,Z ;IF ZERO BIT IS SET, MEANS MULTA IS
> 13V
> BSF TRISC,2 ;TURN ON MOSFET, THUS, ONLY CAPACITOR
> CHARGE THE BATTERY
> RETURN
>
> ;
**********************************************************************
****
>
> ;6V BATTERY
>
> SWITCH2 BTFSS PORTC,6
> RETURN
> CALL LED2
> MOVF RESULTLOW1,W
> MOVWF MULTB2
> CLRC
> RLF MULTB2,F
> MOVF MULTB2,W
> SUBLW B'00000111'
> BTFSS STATUS,C
> BTFSC STATUS,Z
> BSF TRISC,2 ;TURN ON MOSFET
> RETURN
>
> ;
**********************************************************************
****
>
> ;LED 12V
>
> LED1 CLRF PORTC
> BSF TRISC,5
> RETURN
>
> ;
**********************************************************************
****
>
> ;LED 6V
>
> LED2 CLRF PORTC
> BSF TRISC,4
> RETURN
>
> ;
**********************************************************************
****
>
> ;READ BATTERY VOLTAGE LEVEL (AN0)
>
> ADC1 MOVLW B'01000001'
> MOVWF ADCON0
> BSF ADCON0,GO_DONE
> CHECK1 BTFSC ADCON0,GO_DONE
> GOTO CHECK1
> MOVF ADRESH,W
> MOVWF RESULTHIGH1
> BSF STATUS,RP0
> MOVF ADRESL,W
> BCF STATUS,RP0
> MOVWF RESULTLOW1
> RETURN
>
> ;
**********************************************************************
****
>
> ;READ OUTPUT VOLTAGE OF SOLAR PANEL (AN1)
>
> ADC2 MOVLW B'01001001'
> MOVWF ADCON0
> BSF ADCON0,GO_DONE
> CHECK2 BTFSC ADCON0,GO_DONE
> GOTO CHECK2
> MOVF ADRESH,W
> MOVWF RESULTHIGH2
> BSF STATUS,RP0
> MOVF ADRESL,W
> BCF STATUS,RP0
> MOVWF RESULTLOW2
> RETURN
>
> ;
**********************************************************************
****
>
> ;USING LOOK-UP TABLE TO PROVIDE PWM SIGNAL
> ;MULTIPLY BY 2, GET BACK ORIGINAL VALUE
> ;COMPARE AND APPLY CCP, REFER LOOK-UP TABLE
> ;COMPARE SMALLEST TO BIGGEST POSSIBILITIES
>
> DUTYA MOVF RESULTLOW2,W
> MOVWF MULTA2
> CLRC
> RLF MULTA2,F
> MOVF MULTA2,W
> SUBLW B'00001110'
> BTFSS STATUS,C
> BTFSC STATUS,Z
> BCF TRISC,2 ;TURN OFF MOSFET, LET CHARGE AT 14V
> SOURCE
>
> MOVF MULTA2,W
> SUBLW B'00000101'
> BTFSS STATUS,C ;AFTER MINUS, IF C=1, MEANING ADC
> RESULT > 5
> BTFSC STATUS,Z ;AFTER MINUS, IF Z=1, MEANING ADC
> RESULT = 5
> CALL PWM5A
>
> MOVF MULTA2,W
> SUBLW B'00000110'
> BTFSS STATUS,C
> BTFSC STATUS,Z
> CALL PWM6A
>
> MOVF MULTA2,W
> SUBLW B'00000111'
> BTFSS STATUS,C
> BTFSC STATUS,Z
> CALL PWM7A
>
> MOVF MULTA2,W
> SUBLW B'00001000'
> BTFSS STATUS,C
> BTFSC STATUS,Z
> CALL PWM8A
>
> MOVF MULTA2,W
> SUBLW B'00001001'
> BTFSS STATUS,C
> BTFSC STATUS,Z
> CALL PWM9A
>
> MOVF MULTA2,W
> SUBLW B'00001010'
> BTFSS STATUS,C
> BTFSC STATUS,Z
> CALL PWM10A
>
> MOVF MULTA2,W
> SUBLW B'00001011'
> BTFSS STATUS,C
> BTFSC STATUS,Z
> CALL PWM11A
>
> MOVF MULTA2,W
> SUBLW B'00001100'
> BTFSS STATUS,C
> BTFSC STATUS,Z
> CALL PWM12A
>
> MOVF MULTA2,W
> SUBLW B'00001101'
> BTFSS STATUS,C
> BTFSC STATUS,Z
> CALL PWM13A
> RETURN
>
> ;
**********************************************************************
****
>
> ;IF 7 OR ABOVE 7, DONT BOOST
>
> DUTYB MOVF RESULTLOW2,W
> MOVWF MULTA2
> CLRC
> RLF MULTA2,F
> MOVF MULTA2,W
> SUBLW B'00000111'
> BTFSS STATUS,C ;IF 7 MINUS RESULT IS NEGATIVE, C=1,
> BTFSC STATUS,Z ;SO, DONT HAVE TO BOOST BUT CHARGE
> BCF TRISC,2 ;TURN OFF MOSFET
>
> MOVF MULTA2,W
> SUBLW B'00000101'
> BTFSS STATUS,C
> BTFSC STATUS,Z
> CALL PWM5B
>
> MOVF MULTA2,W
> SUBLW B'0000110'
> BTFSS STATUS,C
> BTFSC STATUS,Z
> CALL PWM6B
> RETURN
>
> ;
**********************************************************************
****
>
> ;FROM REFERENCE TABLE
>
> PWM5A MOVLW B'00101010' ; set bits 9 to 2
> MOVWF CCPR1L
> BCF CCP1CON,CCP1X ; set to => "00"
> BCF CCP1CON,CCP1Y
> MOVLW B'00000100' ; TMR2 = on, prescale = 1
> MOVWF T2CON
> MOVLW B'00001100'
> MOVWF CCP1CON
> RETURN
>
> PWM6A MOVLW B'00100101' ; set bits 9 to 2
> MOVWF CCPR1L
> BSF CCP1CON,CCP1X ; set to => "10"
> BCF CCP1CON,CCP1Y
> MOVLW B'00000100' ; TMR2 = on, prescale = 1
> MOVWF T2CON
> MOVLW B'00101100'
> MOVWF CCP1CON
> RETURN
>
> PWM7A MOVLW B'00100001' ; set bits 9 to 2
> MOVWF CCPR1L
> BCF CCP1CON,CCP1X ; set to => "00"
> BCF CCP1CON,CCP1Y
> MOVLW B'00000100' ; TMR2 = on, prescale = 1
> MOVWF T2CON
> MOVLW B'00001100'
> MOVWF CCP1CON
> RETURN
>
> PWM8A MOVLW B'00011100' ; set bits 9 to 2
> MOVWF CCPR1L
> BSF CCP1CON,CCP1X ; set to => "11"
> BSF CCP1CON,CCP1Y
> MOVLW B'00000100' ; TMR2 = on, prescale = 1
> MOVWF T2CON
> MOVLW B'00111100'
> MOVWF CCP1CON
> RETURN
>
> PWM9A MOVLW B'00011000' ; set bits 9 to 2
> MOVWF CCPR1L
> BCF CCP1CON,CCP1X ; set to => "01"
> BSF CCP1CON,CCP1Y
> MOVLW B'00000100' ; TMR2 = on, prescale = 1
> MOVWF T2CON
> MOVLW B'00011100'
> MOVWF CCP1CON
> RETURN
>
> PWM10A MOVLW B'00010011' ; set bits 9 to 2
> MOVWF CCPR1L
> BSF CCP1CON,CCP1X ; set to => "11"
> BSF CCP1CON,CCP1Y
> MOVLW B'00000100' ; TMR2 = on, prescale = 1
> MOVWF T2CON
> MOVLW B'00111100'
> MOVWF CCP1CON
> RETURN
>
> PWM11A MOVLW B'00001111' ; set bits 9 to 2
> MOVWF CCPR1L
> BSF CCP1CON,CCP1X ; set to => "10"
> BCF CCP1CON,CCP1Y
> MOVLW B'00000100' ; TMR2 = on, prescale = 1
> MOVWF T2CON
> MOVLW B'00101100'
> MOVWF CCP1CON
> RETURN
>
> PWM12A MOVLW B'00001011' ; set bits 9 to 2
> MOVWF CCPR1L
> BCF CCP1CON,CCP1X ; set to => "00"
> BCF CCP1CON,CCP1Y
> MOVLW B'00000100' ; TMR2 = on, prescale = 1
> MOVWF T2CON
> MOVLW B'00001100'
> MOVWF CCP1CON
> RETURN
>
> PWM13A MOVLW B'00000110' ; set bits 9 to 2
> MOVWF CCPR1L
> BSF CCP1CON,CCP1X ; set to => "10"
> BCF CCP1CON,CCP1Y
> MOVLW B'00000100' ; TMR2 = on, prescale = 1
> MOVWF T2CON
> MOVLW B'00101100'
> MOVWF CCP1CON
> RETURN
>
> ;
**********************************************************************
****
>
> ;FROM REFERENCE TABLE
>
> PWM5B MOVLW B'00010101' ; set bits 9 to 2
> MOVWF CCPR1L
> BCF CCP1CON,CCP1X ; set to => "01"
> BSF CCP1CON,CCP1Y
> MOVLW B'00000100' ; TMR2 = on, prescale = 1
> MOVWF T2CON
> MOVLW B'00011100'
> MOVWF CCP1CON
> RETURN
>
> PWM6B MOVLW B'00001100' ; set bits 9 to 2
> MOVWF CCPR1L
> BSF CCP1CON,CCP1X ; set to => "11"
> BSF CCP1CON,CCP1Y
> MOVLW B'00000100' ; TMR2 = on, prescale = 1
> MOVWF T2CON
> MOVLW B'00111100'
> MOVWF CCP1CON
> RETURN
>
> ;
**********************************************************************
****
> END
>
> ------------------------------------------------------ >
> __________________________________





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Short PIC Program - Help needed badly - Phil - Feb 17 23:41:00 2005


You are correct if interrupts are being used - you have to jump over
the ISR vector at 4. I didn't look too closely at the code but it
appears no ints so it should work ok.

The best way to approach a non-working program is start out simple and
work up from there. Do you have the In Circuit Debugger? If so, then
you can use that to look at variables and SFRs to make sure that they
are what you want them to be. If not, then you need to attack the
problem a bit differently. The first code I wrote for a PIC was a
serial I/O driver and hex to ascii conversion. Then I used that to
output information about my code. LEDs are also useful for debugging.
Light an LED when you get to a piece of code - you will know you got
there. Do you have an oclliscope? They can be very handy, especially
for debugging PWM.

You should also use the simulator to debug as much of your code as
possible but some things have to run on the real machine. Anything
that doesn't touch the SFRs is a good candidate (like math code).

So, first thing is to determine if your program is actually loaded and
running. Light an led for that. Check to see that its actually
getting programmed into the flash memory (read it back). Then I'd get
the ADC working. Then PWM.

Phil

--- In , "Manoj R." <manojr_cet@y...> wrote: > Hi man,
>
> I am also sorta a newbie in PIC. just had a fast look at ur code.
>
> I dont know if its correct. But in my opinion, the PIC has the reset
> address as 0000h. this is where its starts execution, once power is
> given. i cant seem to locate the rest vector in your code. usually, it
> is given after an ORIGIN command, like
>
> org 0x0000 ; place the following line in 0x0000 address
> goto start
>
> start :
>
> ; {
> ; Main program
> ; }
>
> end
>
> I strongly believe this is required. Forgive me if i am misleading you
> :-)
>
> After all, i am also a new comer :-D
>
> and one more thing, the interrupt vector of PIC is 0004h. In case you
> are planning to use interrupts, use the org command with 4h, and give
> a goto statement to your ISR
>
> Hope this helps :-D
>
> One test is worth a thousand expert opinions....WATZ THER!!!
> --- In , Devon Lee <devonsc@y...> wrote:
> > Hi Chris,
> >
> > Thanks for your concern to a newbie like me that
> > doesnt not know much. Thank you very very much.
> >
> > Hope you guys don't mind taking a look at the PIC
> > program. Hope I'm not writing nonsense. Thanks a lot
> > in advance.
> >
> > By the way, I'm using PIC16F876 and MPLAB as a
> > compiler. Thanks a lot in advance...
> >
> > ------------------------------------------------------
> > PIC Program
> > ------------------------------------------------------
> > LIST P=16F876
> > #INCLUDE "P16F876.INC"
> > __CONFIG _CP_OFF & _XT_OSC & _WDT_OFF & _PWRTE_ON &
> > _LVP_OFF & _BODEN_ON
> > ERRORLEVEL -306, -302
> >
> > ;MAIN PROGRAM 1 - BOOST
> >
> > RESULTHIGH1 EQU 24H
> > RESULTLOW1 EQU 25H
> > RESULTHIGH2 EQU 26H
> > RESULTLOW2 EQU 27H
> >
> > ;
> **********************************************************************
> ****
> >
> > ;GENERAL PURPOSE REGISTER
> > CBLOCK 0x20
> > MULTA2
> > MULTB2
> > ENDC
> >
> > ;
> **********************************************************************
> ****
> >
> > ;INITIALIZATION FOR THE SWITCH (PORT C)
> > ;USING 2 SWITCHES TO SWITCH BETWEEN CHARGING 6V OR 12V
> > ;WITH 2 LEDs TO SHOW THE SELECTED CHARGING BATTERY
> > CAPACITY
> >
> > BSF STATUS,RP0
> > MOVLW B'11000000' ;SW1,SW2,LED1,LED2,*,PWM,*,*
> > MOVWF TRISC
> > BCF STATUS,RP0
> >
> > ;
> **********************************************************************
> ****
> >
> > ;INITIALIZATION FOR ADC1 AND ADC2 (PORT A)
> > ;ADC1 IS FOR FEEDBACK FROM BATTERY
> > ;ADC2 IS FOR FEEDBACK FROM SOLAR PANEL
> >
> > BSF STATUS,RP0
> > MOVLW B'10001001'
> > MOVWF ADCON1
> > BCF STATUS,RP0
> >
> > ;
> **********************************************************************
> ****
> >
> > ;INITIALIZATION FOR PWM (PORT C)
> >
> > BSF STATUS,RP0
> > MOVLW B'00111111'
> > MOVWF PR2
> > BCF TRISC,0x02
> > BCF STATUS,RP0
> >
> > ;
> **********************************************************************
> ****
> >
> > ;START CHECK
> >
> > RESTART CALL ADC1 ;FEEDBACK FROM BATTERY
> > CALL SWITCH1 ;12V BATTERY
> > CALL SWITCH2 ;6V BATTERY
> > BTFSS STATUS,C ;IF CARRY BIT SET, GO TO RESTART
> > BTFSC STATUS,Z ;IF ZERO BIT SET, MEANS RESULT OF
> > SUBSTRACT IS '0'
> > GOTO RESTART
> > CALL ADC2
> > BTFSC PORTC,7 ;IF SW1 = '0', SKIP CALL DUTYA
> > CALL DUTYA ;IF SKIP, MEANS BATTERY USED IS 6V, ELSE
> > 12V
> > BTFSC PORTC,6 ;IF SW2 = '0', SKIP CALL DUTYB
> > CALL DUTYB ;DUTY RATIO FOR 6V BATTERY CALCULATION
> >
> > ;
> **********************************************************************
> ****
> >
> > ;12V BATTERY
> >
> > SWITCH1 BTFSS PORTC,7 ;IF RECEIVE '1', SKIP RETURN
> > RETURN
> > CALL LED1
> > MOVF RESULTLOW1,W
> > MOVWF MULTA2
> > CLRC ;MULTIPLY BY 2
> > RLF MULTA2,F
> > MOVF MULTA2,W ;VALUE AFTER MULTIPLICATION FOR
> > COMPARISON
> > SUBLW B'00001101' ;TAKE 13 MINUS MULTA
> > BTFSS STATUS,C ;IF CARRY BIT IS SET, MEANS MULTA IS
> > BIGGER THAN 13, THUS SKIP
> > BTFSC STATUS,Z ;IF ZERO BIT IS SET, MEANS MULTA IS
> > 13V
> > BSF TRISC,2 ;TURN ON MOSFET, THUS, ONLY CAPACITOR
> > CHARGE THE BATTERY
> > RETURN
> >
> > ;
> **********************************************************************
> ****
> >
> > ;6V BATTERY
> >
> > SWITCH2 BTFSS PORTC,6
> > RETURN
> > CALL LED2
> > MOVF RESULTLOW1,W
> > MOVWF MULTB2
> > CLRC
> > RLF MULTB2,F
> > MOVF MULTB2,W
> > SUBLW B'00000111'
> > BTFSS STATUS,C
> > BTFSC STATUS,Z
> > BSF TRISC,2 ;TURN ON MOSFET
> > RETURN
> >
> > ;
> **********************************************************************
> ****
> >
> > ;LED 12V
> >
> > LED1 CLRF PORTC
> > BSF TRISC,5
> > RETURN
> >
> > ;
> **********************************************************************
> ****
> >
> > ;LED 6V
> >
> > LED2 CLRF PORTC
> > BSF TRISC,4
> > RETURN
> >
> > ;
> **********************************************************************
> ****
> >
> > ;READ BATTERY VOLTAGE LEVEL (AN0)
> >
> > ADC1 MOVLW B'01000001'
> > MOVWF ADCON0
> > BSF ADCON0,GO_DONE
> > CHECK1 BTFSC ADCON0,GO_DONE
> > GOTO CHECK1
> > MOVF ADRESH,W
> > MOVWF RESULTHIGH1
> > BSF STATUS,RP0
> > MOVF ADRESL,W
> > BCF STATUS,RP0
> > MOVWF RESULTLOW1
> > RETURN
> >
> > ;
> **********************************************************************
> ****
> >
> > ;READ OUTPUT VOLTAGE OF SOLAR PANEL (AN1)
> >
> > ADC2 MOVLW B'01001001'
> > MOVWF ADCON0
> > BSF ADCON0,GO_DONE
> > CHECK2 BTFSC ADCON0,GO_DONE
> > GOTO CHECK2
> > MOVF ADRESH,W
> > MOVWF RESULTHIGH2
> > BSF STATUS,RP0
> > MOVF ADRESL,W
> > BCF STATUS,RP0
> > MOVWF RESULTLOW2
> > RETURN
> >
> > ;
> **********************************************************************
> ****
> >
> > ;USING LOOK-UP TABLE TO PROVIDE PWM SIGNAL
> > ;MULTIPLY BY 2, GET BACK ORIGINAL VALUE
> > ;COMPARE AND APPLY CCP, REFER LOOK-UP TABLE
> > ;COMPARE SMALLEST TO BIGGEST POSSIBILITIES
> >
> > DUTYA MOVF RESULTLOW2,W
> > MOVWF MULTA2
> > CLRC
> > RLF MULTA2,F
> > MOVF MULTA2,W
> > SUBLW B'00001110'
> > BTFSS STATUS,C
> > BTFSC STATUS,Z
> > BCF TRISC,2 ;TURN OFF MOSFET, LET CHARGE AT 14V
> > SOURCE
> >
> > MOVF MULTA2,W
> > SUBLW B'00000101'
> > BTFSS STATUS,C ;AFTER MINUS, IF C=1, MEANING ADC
> > RESULT > 5
> > BTFSC STATUS,Z ;AFTER MINUS, IF Z=1, MEANING ADC
> > RESULT = 5
> > CALL PWM5A
> >
> > MOVF MULTA2,W
> > SUBLW B'00000110'
> > BTFSS STATUS,C
> > BTFSC STATUS,Z
> > CALL PWM6A
> >
> > MOVF MULTA2,W
> > SUBLW B'00000111'
> > BTFSS STATUS,C
> > BTFSC STATUS,Z
> > CALL PWM7A
> >
> > MOVF MULTA2,W
> > SUBLW B'00001000'
> > BTFSS STATUS,C
> > BTFSC STATUS,Z
> > CALL PWM8A
> >
> > MOVF MULTA2,W
> > SUBLW B'00001001'
> > BTFSS STATUS,C
> > BTFSC STATUS,Z
> > CALL PWM9A
> >
> > MOVF MULTA2,W
> > SUBLW B'00001010'
> > BTFSS STATUS,C
> > BTFSC STATUS,Z
> > CALL PWM10A
> >
> > MOVF MULTA2,W
> > SUBLW B'00001011'
> > BTFSS STATUS,C
> > BTFSC STATUS,Z
> > CALL PWM11A
> >
> > MOVF MULTA2,W
> > SUBLW B'00001100'
> > BTFSS STATUS,C
> > BTFSC STATUS,Z
> > CALL PWM12A
> >
> > MOVF MULTA2,W
> > SUBLW B'00001101'
> > BTFSS STATUS,C
> > BTFSC STATUS,Z
> > CALL PWM13A
> > RETURN
> >
> > ;
> **********************************************************************
> ****
> >
> > ;IF 7 OR ABOVE 7, DONT BOOST
> >
> > DUTYB MOVF RESULTLOW2,W
> > MOVWF MULTA2
> > CLRC
> > RLF MULTA2,F
> > MOVF MULTA2,W
> > SUBLW B'00000111'
> > BTFSS STATUS,C ;IF 7 MINUS RESULT IS NEGATIVE, C=1,
> > BTFSC STATUS,Z ;SO, DONT HAVE TO BOOST BUT CHARGE
> > BCF TRISC,2 ;TURN OFF MOSFET
> >
> > MOVF MULTA2,W
> > SUBLW B'00000101'
> > BTFSS STATUS,C
> > BTFSC STATUS,Z
> > CALL PWM5B
> >
> > MOVF MULTA2,W
> > SUBLW B'0000110'
> > BTFSS STATUS,C
> > BTFSC STATUS,Z
> > CALL PWM6B
> > RETURN
> >
> > ;
> **********************************************************************
> ****
> >
> > ;FROM REFERENCE TABLE
> >
> > PWM5A MOVLW B'00101010' ; set bits 9 to 2
> > MOVWF CCPR1L
> > BCF CCP1CON,CCP1X ; set to => "00"
> > BCF CCP1CON,CCP1Y
> > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > MOVWF T2CON
> > MOVLW B'00001100'
> > MOVWF CCP1CON
> > RETURN
> >
> > PWM6A MOVLW B'00100101' ; set bits 9 to 2
> > MOVWF CCPR1L
> > BSF CCP1CON,CCP1X ; set to => "10"
> > BCF CCP1CON,CCP1Y
> > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > MOVWF T2CON
> > MOVLW B'00101100'
> > MOVWF CCP1CON
> > RETURN
> >
> > PWM7A MOVLW B'00100001' ; set bits 9 to 2
> > MOVWF CCPR1L
> > BCF CCP1CON,CCP1X ; set to => "00"
> > BCF CCP1CON,CCP1Y
> > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > MOVWF T2CON
> > MOVLW B'00001100'
> > MOVWF CCP1CON
> > RETURN
> >
> > PWM8A MOVLW B'00011100' ; set bits 9 to 2
> > MOVWF CCPR1L
> > BSF CCP1CON,CCP1X ; set to => "11"
> > BSF CCP1CON,CCP1Y
> > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > MOVWF T2CON
> > MOVLW B'00111100'
> > MOVWF CCP1CON
> > RETURN
> >
> > PWM9A MOVLW B'00011000' ; set bits 9 to 2
> > MOVWF CCPR1L
> > BCF CCP1CON,CCP1X ; set to => "01"
> > BSF CCP1CON,CCP1Y
> > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > MOVWF T2CON
> > MOVLW B'00011100'
> > MOVWF CCP1CON
> > RETURN
> >
> > PWM10A MOVLW B'00010011' ; set bits 9 to 2
> > MOVWF CCPR1L
> > BSF CCP1CON,CCP1X ; set to => "11"
> > BSF CCP1CON,CCP1Y
> > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > MOVWF T2CON
> > MOVLW B'00111100'
> > MOVWF CCP1CON
> > RETURN
> >
> > PWM11A MOVLW B'00001111' ; set bits 9 to 2
> > MOVWF CCPR1L
> > BSF CCP1CON,CCP1X ; set to => "10"
> > BCF CCP1CON,CCP1Y
> > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > MOVWF T2CON
> > MOVLW B'00101100'
> > MOVWF CCP1CON
> > RETURN
> >
> > PWM12A MOVLW B'00001011' ; set bits 9 to 2
> > MOVWF CCPR1L
> > BCF CCP1CON,CCP1X ; set to => "00"
> > BCF CCP1CON,CCP1Y
> > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > MOVWF T2CON
> > MOVLW B'00001100'
> > MOVWF CCP1CON
> > RETURN
> >
> > PWM13A MOVLW B'00000110' ; set bits 9 to 2
> > MOVWF CCPR1L
> > BSF CCP1CON,CCP1X ; set to => "10"
> > BCF CCP1CON,CCP1Y
> > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > MOVWF T2CON
> > MOVLW B'00101100'
> > MOVWF CCP1CON
> > RETURN
> >
> > ;
> **********************************************************************
> ****
> >
> > ;FROM REFERENCE TABLE
> >
> > PWM5B MOVLW B'00010101' ; set bits 9 to 2
> > MOVWF CCPR1L
> > BCF CCP1CON,CCP1X ; set to => "01"
> > BSF CCP1CON,CCP1Y
> > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > MOVWF T2CON
> > MOVLW B'00011100'
> > MOVWF CCP1CON
> > RETURN
> >
> > PWM6B MOVLW B'00001100' ; set bits 9 to 2
> > MOVWF CCPR1L
> > BSF CCP1CON,CCP1X ; set to => "11"
> > BSF CCP1CON,CCP1Y
> > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > MOVWF T2CON
> > MOVLW B'00111100'
> > MOVWF CCP1CON
> > RETURN
> >
> > ;
> **********************************************************************
> ****
> > END
> >
> > ------------------------------------------------------
> >
> >
> >
> > __________________________________
>




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Short PIC Program - Help needed badly - rtstofer - Feb 18 0:23:00 2005



My guess is that the problem could be demonstrated with maybe 10% of
the posted code. That is just too much code to look through. Cut
out the unimportant stuff until you are just left with a few lines
and a problem. It will be easier to find.

In the meantime: never use EQU to set the address of varible
storage. The CBLOCK you used is better. Never use BSF STATUS,RPx
when you can use the 'BANKSEL x' macro - it is much more clear.
Yes, it will produce one more instruction but that probably isn't
important in this application. You are sending your output to
TRISx. I didn't look at this very carefully but I suspect you
should be sending it to PORTx although I have seen tri-state
examples where the pin was controlled with TRISx. I also noticed
that you didn't specifically change to bank 1 so I suspect the
output is actually going to PORTx anyway.

Personally, I wouldn't shut off the errorlevel warnings just yet.
The messages might be important.

For an application like this where you aren't utilizing the truly
ugly portions of the hardware or high speed interruupts, you might
try writing the code in C. My choice would be the free version of
cc5x or the free PIC C Lite. Unless there is some reason you have
to use ASM.

--- In , "Phil" <phil1960us@y...> wrote:
>
> You are correct if interrupts are being used - you have to jump
over
> the ISR vector at 4. I didn't look too closely at the code but it
> appears no ints so it should work ok.
>
> The best way to approach a non-working program is start out simple
and
> work up from there. Do you have the In Circuit Debugger? If so,
then
> you can use that to look at variables and SFRs to make sure that
they
> are what you want them to be. If not, then you need to attack the
> problem a bit differently. The first code I wrote for a PIC was a
> serial I/O driver and hex to ascii conversion. Then I used that to
> output information about my code. LEDs are also useful for
debugging.
> Light an LED when you get to a piece of code - you will know you
got
> there. Do you have an oclliscope? They can be very handy,
especially
> for debugging PWM.
>
> You should also use the simulator to debug as much of your code as
> possible but some things have to run on the real machine. Anything
> that doesn't touch the SFRs is a good candidate (like math code).
>
> So, first thing is to determine if your program is actually loaded
and
> running. Light an led for that. Check to see that its actually
> getting programmed into the flash memory (read it back). Then I'd
get
> the ADC working. Then PWM.
>
> Phil
>
> --- In , "Manoj R." <manojr_cet@y...> wrote:
> >
> >
> > Hi man,
> >
> > I am also sorta a newbie in PIC. just had a fast look at ur code.
> >
> > I dont know if its correct. But in my opinion, the PIC has the
reset
> > address as 0000h. this is where its starts execution, once power
is
> > given. i cant seem to locate the rest vector in your code.
usually, it
> > is given after an ORIGIN command, like
> >
> > org 0x0000 ; place the following line in 0x0000 address
> > goto start
> >
> > start :
> >
> > ; {
> > ; Main program
> > ; }
> >
> > end
> >
> > I strongly believe this is required. Forgive me if i am
misleading you
> > :-)
> >
> > After all, i am also a new comer :-D
> >
> > and one more thing, the interrupt vector of PIC is 0004h. In
case you
> > are planning to use interrupts, use the org command with 4h, and
give
> > a goto statement to your ISR
> >
> > Hope this helps :-D
> >
> > One test is worth a thousand expert opinions....WATZ THER!!!
> > --- In , Devon Lee <devonsc@y...> wrote:
> > > Hi Chris,
> > >
> > > Thanks for your concern to a newbie like me that
> > > doesnt not know much. Thank you very very much.
> > >
> > > Hope you guys don't mind taking a look at the PIC
> > > program. Hope I'm not writing nonsense. Thanks a lot
> > > in advance.
> > >
> > > By the way, I'm using PIC16F876 and MPLAB as a
> > > compiler. Thanks a lot in advance...
> > >
> > > ------------------------------------------------------
> > > PIC Program
> > > ------------------------------------------------------
> > > LIST P=16F876
> > > #INCLUDE "P16F876.INC"
> > > __CONFIG _CP_OFF & _XT_OSC & _WDT_OFF & _PWRTE_ON &
> > > _LVP_OFF & _BODEN_ON
> > > ERRORLEVEL -306, -302
> > >
> > > ;MAIN PROGRAM 1 - BOOST
> > >
> > > RESULTHIGH1 EQU 24H
> > > RESULTLOW1 EQU 25H
> > > RESULTHIGH2 EQU 26H
> > > RESULTLOW2 EQU 27H
> > >
> > > ;
> >
*********************************************************************
*
> > ****
> > >
> > > ;GENERAL PURPOSE REGISTER
> > > CBLOCK 0x20
> > > MULTA2
> > > MULTB2
> > > ENDC
> > >
> > > ;
> >
*********************************************************************
*
> > ****
> > >
> > > ;INITIALIZATION FOR THE SWITCH (PORT C)
> > > ;USING 2 SWITCHES TO SWITCH BETWEEN CHARGING 6V OR 12V
> > > ;WITH 2 LEDs TO SHOW THE SELECTED CHARGING BATTERY
> > > CAPACITY
> > >
> > > BSF STATUS,RP0
> > > MOVLW B'11000000' ;SW1,SW2,LED1,LED2,*,PWM,*,*
> > > MOVWF TRISC
> > > BCF STATUS,RP0
> > >
> > > ;
> >
*********************************************************************
*
> > ****
> > >
> > > ;INITIALIZATION FOR ADC1 AND ADC2 (PORT A)
> > > ;ADC1 IS FOR FEEDBACK FROM BATTERY
> > > ;ADC2 IS FOR FEEDBACK FROM SOLAR PANEL
> > >
> > > BSF STATUS,RP0
> > > MOVLW B'10001001'
> > > MOVWF ADCON1
> > > BCF STATUS,RP0
> > >
> > > ;
> >
*********************************************************************
*
> > ****
> > >
> > > ;INITIALIZATION FOR PWM (PORT C)
> > >
> > > BSF STATUS,RP0
> > > MOVLW B'00111111'
> > > MOVWF PR2
> > > BCF TRISC,0x02
> > > BCF STATUS,RP0
> > >
> > > ;
> >
*********************************************************************
*
> > ****
> > >
> > > ;START CHECK
> > >
> > > RESTART CALL ADC1 ;FEEDBACK FROM BATTERY
> > > CALL SWITCH1 ;12V BATTERY
> > > CALL SWITCH2 ;6V BATTERY
> > > BTFSS STATUS,C ;IF CARRY BIT SET, GO TO RESTART
> > > BTFSC STATUS,Z ;IF ZERO BIT SET, MEANS RESULT OF
> > > SUBSTRACT IS '0'
> > > GOTO RESTART
> > > CALL ADC2
> > > BTFSC PORTC,7 ;IF SW1 = '0', SKIP CALL DUTYA
> > > CALL DUTYA ;IF SKIP, MEANS BATTERY USED IS 6V,
ELSE
> > > 12V
> > > BTFSC PORTC,6 ;IF SW2 = '0', SKIP CALL DUTYB
> > > CALL DUTYB ;DUTY RATIO FOR 6V BATTERY
CALCULATION
> > >
> > > ;
> >
*********************************************************************
*
> > ****
> > >
> > > ;12V BATTERY
> > >
> > > SWITCH1 BTFSS PORTC,7 ;IF RECEIVE '1', SKIP RETURN
> > > RETURN
> > > CALL LED1
> > > MOVF RESULTLOW1,W
> > > MOVWF MULTA2
> > > CLRC ;MULTIPLY BY 2
> > > RLF MULTA2,F
> > > MOVF MULTA2,W ;VALUE AFTER MULTIPLICATION FOR
> > > COMPARISON
> > > SUBLW B'00001101' ;TAKE 13 MINUS MULTA
> > > BTFSS STATUS,C ;IF CARRY BIT IS SET, MEANS MULTA IS
> > > BIGGER THAN 13, THUS SKIP
> > > BTFSC STATUS,Z ;IF ZERO BIT IS SET, MEANS MULTA IS
> > > 13V
> > > BSF TRISC,2 ;TURN ON MOSFET, THUS, ONLY CAPACITOR
> > > CHARGE THE BATTERY
> > > RETURN
> > >
> > > ;
> >
*********************************************************************
*
> > ****
> > >
> > > ;6V BATTERY
> > >
> > > SWITCH2 BTFSS PORTC,6
> > > RETURN
> > > CALL LED2
> > > MOVF RESULTLOW1,W
> > > MOVWF MULTB2
> > > CLRC
> > > RLF MULTB2,F
> > > MOVF MULTB2,W
> > > SUBLW B'00000111'
> > > BTFSS STATUS,C
> > > BTFSC STATUS,Z
> > > BSF TRISC,2 ;TURN ON MOSFET
> > > RETURN
> > >
> > > ;
> >
*********************************************************************
*
> > ****
> > >
> > > ;LED 12V
> > >
> > > LED1 CLRF PORTC
> > > BSF TRISC,5
> > > RETURN
> > >
> > > ;
> >
*********************************************************************
*
> > ****
> > >
> > > ;LED 6V
> > >
> > > LED2 CLRF PORTC
> > > BSF TRISC,4
> > > RETURN
> > >
> > > ;
> >
*********************************************************************
*
> > ****
> > >
> > > ;READ BATTERY VOLTAGE LEVEL (AN0)
> > >
> > > ADC1 MOVLW B'01000001'
> > > MOVWF ADCON0
> > > BSF ADCON0,GO_DONE
> > > CHECK1 BTFSC ADCON0,GO_DONE
> > > GOTO CHECK1
> > > MOVF ADRESH,W
> > > MOVWF RESULTHIGH1
> > > BSF STATUS,RP0
> > > MOVF ADRESL,W
> > > BCF STATUS,RP0
> > > MOVWF RESULTLOW1
> > > RETURN
> > >
> > > ;
> >
*********************************************************************
*
> > ****
> > >
> > > ;READ OUTPUT VOLTAGE OF SOLAR PANEL (AN1)
> > >
> > > ADC2 MOVLW B'01001001'
> > > MOVWF ADCON0
> > > BSF ADCON0,GO_DONE
> > > CHECK2 BTFSC ADCON0,GO_DONE
> > > GOTO CHECK2
> > > MOVF ADRESH,W
> > > MOVWF RESULTHIGH2
> > > BSF STATUS,RP0
> > > MOVF ADRESL,W
> > > BCF STATUS,RP0
> > > MOVWF RESULTLOW2
> > > RETURN
> > >
> > > ;
> >
*********************************************************************
*
> > ****
> > >
> > > ;USING LOOK-UP TABLE TO PROVIDE PWM SIGNAL
> > > ;MULTIPLY BY 2, GET BACK ORIGINAL VALUE
> > > ;COMPARE AND APPLY CCP, REFER LOOK-UP TABLE
> > > ;COMPARE SMALLEST TO BIGGEST POSSIBILITIES
> > >
> > > DUTYA MOVF RESULTLOW2,W
> > > MOVWF MULTA2
> > > CLRC
> > > RLF MULTA2,F
> > > MOVF MULTA2,W
> > > SUBLW B'00001110'
> > > BTFSS STATUS,C
> > > BTFSC STATUS,Z
> > > BCF TRISC,2 ;TURN OFF MOSFET, LET CHARGE AT 14V
> > > SOURCE
> > >
> > > MOVF MULTA2,W
> > > SUBLW B'00000101'
> > > BTFSS STATUS,C ;AFTER MINUS, IF C=1, MEANING ADC
> > > RESULT > 5
> > > BTFSC STATUS,Z ;AFTER MINUS, IF Z=1, MEANING ADC
> > > RESULT = 5
> > > CALL PWM5A
> > >
> > > MOVF MULTA2,W
> > > SUBLW B'00000110'
> > > BTFSS STATUS,C
> > > BTFSC STATUS,Z
> > > CALL PWM6A
> > >
> > > MOVF MULTA2,W
> > > SUBLW B'00000111'
> > > BTFSS STATUS,C
> > > BTFSC STATUS,Z
> > > CALL PWM7A
> > >
> > > MOVF MULTA2,W
> > > SUBLW B'00001000'
> > > BTFSS STATUS,C
> > > BTFSC STATUS,Z
> > > CALL PWM8A
> > >
> > > MOVF MULTA2,W
> > > SUBLW B'00001001'
> > > BTFSS STATUS,C
> > > BTFSC STATUS,Z
> > > CALL PWM9A
> > >
> > > MOVF MULTA2,W
> > > SUBLW B'00001010'
> > > BTFSS STATUS,C
> > > BTFSC STATUS,Z
> > > CALL PWM10A
> > >
> > > MOVF MULTA2,W
> > > SUBLW B'00001011'
> > > BTFSS STATUS,C
> > > BTFSC STATUS,Z
> > > CALL PWM11A
> > >
> > > MOVF MULTA2,W
> > > SUBLW B'00001100'
> > > BTFSS STATUS,C
> > > BTFSC STATUS,Z
> > > CALL PWM12A
> > >
> > > MOVF MULTA2,W
> > > SUBLW B'00001101'
> > > BTFSS STATUS,C
> > > BTFSC STATUS,Z
> > > CALL PWM13A
> > > RETURN
> > >
> > > ;
> >
*********************************************************************
*
> > ****
> > >
> > > ;IF 7 OR ABOVE 7, DONT BOOST
> > >
> > > DUTYB MOVF RESULTLOW2,W
> > > MOVWF MULTA2
> > > CLRC
> > > RLF MULTA2,F
> > > MOVF MULTA2,W
> > > SUBLW B'00000111'
> > > BTFSS STATUS,C ;IF 7 MINUS RESULT IS NEGATIVE, C=1,
> > > BTFSC STATUS,Z ;SO, DONT HAVE TO BOOST BUT CHARGE
> > > BCF TRISC,2 ;TURN OFF MOSFET
> > >
> > > MOVF MULTA2,W
> > > SUBLW B'00000101'
> > > BTFSS STATUS,C
> > > BTFSC STATUS,Z
> > > CALL PWM5B
> > >
> > > MOVF MULTA2,W
> > > SUBLW B'0000110'
> > > BTFSS STATUS,C
> > > BTFSC STATUS,Z
> > > CALL PWM6B
> > > RETURN
> > >
> > > ;
> >
*********************************************************************
*
> > ****
> > >
> > > ;FROM REFERENCE TABLE
> > >
> > > PWM5A MOVLW B'00101010' ; set bits 9 to 2
> > > MOVWF CCPR1L
> > > BCF CCP1CON,CCP1X ; set to => "00"
> > > BCF CCP1CON,CCP1Y
> > > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > > MOVWF T2CON
> > > MOVLW B'00001100'
> > > MOVWF CCP1CON
> > > RETURN
> > >
> > > PWM6A MOVLW B'00100101' ; set bits 9 to 2
> > > MOVWF CCPR1L
> > > BSF CCP1CON,CCP1X ; set to => "10"
> > > BCF CCP1CON,CCP1Y
> > > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > > MOVWF T2CON
> > > MOVLW B'00101100'
> > > MOVWF CCP1CON
> > > RETURN
> > >
> > > PWM7A MOVLW B'00100001' ; set bits 9 to 2
> > > MOVWF CCPR1L
> > > BCF CCP1CON,CCP1X ; set to => "00"
> > > BCF CCP1CON,CCP1Y
> > > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > > MOVWF T2CON
> > > MOVLW B'00001100'
> > > MOVWF CCP1CON
> > > RETURN
> > >
> > > PWM8A MOVLW B'00011100' ; set bits 9 to 2
> > > MOVWF CCPR1L
> > > BSF CCP1CON,CCP1X ; set to => "11"
> > > BSF CCP1CON,CCP1Y
> > > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > > MOVWF T2CON
> > > MOVLW B'00111100'
> > > MOVWF CCP1CON
> > > RETURN
> > >
> > > PWM9A MOVLW B'00011000' ; set bits 9 to 2
> > > MOVWF CCPR1L
> > > BCF CCP1CON,CCP1X ; set to => "01"
> > > BSF CCP1CON,CCP1Y
> > > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > > MOVWF T2CON
> > > MOVLW B'00011100'
> > > MOVWF CCP1CON
> > > RETURN
> > >
> > > PWM10A MOVLW B'00010011' ; set bits 9 to 2
> > > MOVWF CCPR1L
> > > BSF CCP1CON,CCP1X ; set to => "11"
> > > BSF CCP1CON,CCP1Y
> > > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > > MOVWF T2CON
> > > MOVLW B'00111100'
> > > MOVWF CCP1CON
> > > RETURN
> > >
> > > PWM11A MOVLW B'00001111' ; set bits 9 to 2
> > > MOVWF CCPR1L
> > > BSF CCP1CON,CCP1X ; set to => "10"
> > > BCF CCP1CON,CCP1Y
> > > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > > MOVWF T2CON
> > > MOVLW B'00101100'
> > > MOVWF CCP1CON
> > > RETURN
> > >
> > > PWM12A MOVLW B'00001011' ; set bits 9 to 2
> > > MOVWF CCPR1L
> > > BCF CCP1CON,CCP1X ; set to => "00"
> > > BCF CCP1CON,CCP1Y
> > > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > > MOVWF T2CON
> > > MOVLW B'00001100'
> > > MOVWF CCP1CON
> > > RETURN
> > >
> > > PWM13A MOVLW B'00000110' ; set bits 9 to 2
> > > MOVWF CCPR1L
> > > BSF CCP1CON,CCP1X ; set to => "10"
> > > BCF CCP1CON,CCP1Y
> > > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > > MOVWF T2CON
> > > MOVLW B'00101100'
> > > MOVWF CCP1CON
> > > RETURN
> > >
> > > ;
> >
*********************************************************************
*
> > ****
> > >
> > > ;FROM REFERENCE TABLE
> > >
> > > PWM5B MOVLW B'00010101' ; set bits 9 to 2
> > > MOVWF CCPR1L
> > > BCF CCP1CON,CCP1X ; set to => "01"
> > > BSF CCP1CON,CCP1Y
> > > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > > MOVWF T2CON
> > > MOVLW B'00011100'
> > > MOVWF CCP1CON
> > > RETURN
> > >
> > > PWM6B MOVLW B'00001100' ; set bits 9 to 2
> > > MOVWF CCPR1L
> > > BSF CCP1CON,CCP1X ; set to => "11"
> > > BSF CCP1CON,CCP1Y
> > > MOVLW B'00000100' ; TMR2 = on, prescale = 1
> > > MOVWF T2CON
> > > MOVLW B'00111100'
> > > MOVWF CCP1CON
> > > RETURN
> > >
> > > ;
> >
*********************************************************************
*
> > ****
> > > END
> > >
> > > ------------------------------------------------------
> > >
> > >
> > >
> > > __________________________________
> >




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

RE: Short PIC Program - Help needed badly - Phil Seakins - Feb 18 0:52:00 2005

I haven't coded a PIC in assembler but know that all the two PIC
conditional branch instructions will do is jump you OVER the following
instruction. Therefore in almost all cases you will have a conditional test
followed by a jump or a call. I notice in your code that you have many
instances of TWO successive tests ie., BTFSS followed immediately by BTFSC.
I don't think this what you really want.

Also, in this piece of code...

BTFSC PORTC,7 ;IF SW1 = '0', SKIP CALL DUTYA

...it seems from your comments that SW1 is on bit 7 of PORTC. It would make
your code more readable and easier to maintain if you define the IO bits as
constants at the start of your code. By doing this, then should you later
decide to move a connection to a different PIC pin (perhaps for easier PCB
layout) all you need change is the "define" instead of having to step
through the code and change every reference to the port. >Hope you guys don't mind taking a look at the PIC
>program. Hope I'm not writing nonsense. Thanks a lot
>in advance.

<code snipped




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

RE: Short PIC Program - Help needed badly - Chad Russel - Feb 18 3:06:00 2005

Hi Devon,
You have some ugly looking things going on, but no disaster. I think
you are confusing PORT and TRIS, but since you don't change the bank as
someone said the result is the same, but I see CLRF port followed by
TRIS bit set this will give interesting results on an LED at clock
speed. Also on your A to D conversion, you need to leave some set up
time after input select and setting the go bit. All in the docs. I
think you are working too hard at the PWM, I have not studyied your
code, but you may want to review theory of operation.

I have to get some sleep. Maybe try to catch me on messenger in your
evening, my morning.

Chad
--- Devon Lee <> wrote:

> Hi Chris,
>
> Thanks for your concern to a newbie like me that
> doesnt not know much. Thank you very very much.
>
> Hope you guys don't mind taking a look at the PIC
> program. Hope I'm not writing nonsense. Thanks a lot
> in advance.
>
> By the way, I'm using PIC16F876 and MPLAB as a
> compiler. Thanks a lot in advance...
>
> ------------------------------------------------------
> PIC Program
> ------------------------------------------------------
> LIST P=16F876
> #INCLUDE "P16F876.INC"
> __CONFIG _CP_OFF & _XT_OSC & _WDT_OFF & _PWRTE_ON &
> _LVP_OFF & _BODEN_ON
> ERRORLEVEL -306, -302
>
> ;MAIN PROGRAM 1 - BOOST
>
> RESULTHIGH1 EQU 24H
> RESULTLOW1 EQU 25H
> RESULTHIGH2 EQU 26H
> RESULTLOW2 EQU 27H ;**************************************************************************
>
> ;GENERAL PURPOSE REGISTER
> CBLOCK 0x20
> MULTA2
> MULTB2
> ENDC ;**************************************************************************
>
> ;INITIALIZATION FOR THE SWITCH (PORT C)
> ;USING 2 SWITCHES TO SWITCH BETWEEN CHARGING 6V OR 12V
> ;WITH 2 LEDs TO SHOW THE SELECTED CHARGING BATTERY
> CAPACITY
>
> BSF STATUS,RP0
> MOVLW B'11000000' ;SW1,SW2,LED1,LED2,*,PWM,*,*
> MOVWF TRISC
> BCF STATUS,RP0 ;**************************************************************************
>
> ;INITIALIZATION FOR ADC1 AND ADC2 (PORT A)
> ;ADC1 IS FOR FEEDBACK FROM BATTERY
> ;ADC2 IS FOR FEEDBACK FROM SOLAR PANEL
>
> BSF STATUS,RP0
> MOVLW B'10001001'
> MOVWF ADCON1
> BCF STATUS,RP0 ;**************************************************************************
>
> ;INITIALIZATION FOR PWM (PORT C)
>
> BSF STATUS,RP0
> MOVLW B'00111111'
> MOVWF PR2
> BCF TRISC,0x02
> BCF STATUS,RP0 ;**************************************************************************
>
> ;START CHECK
>
> RESTART CALL ADC1 ;FEEDBACK FROM BATTERY
> CALL SWITCH1 ;12V BATTERY
> CALL SWITCH2 ;6V BATTERY
> BTFSS STATUS,C ;IF CARRY BIT SET, GO TO RESTART
> BTFSC STATUS,Z ;IF ZERO BIT SET, MEANS RESULT OF
> SUBSTRACT IS '0'
> GOTO RESTART
> CALL ADC2
> BTFSC PORTC,7 ;IF SW1 = '0', SKIP CALL DUTYA
> CALL DUTYA ;IF SKIP, MEANS BATTERY USED IS 6V, ELSE
> 12V
> BTFSC PORTC,6 ;IF SW2 = '0', SKIP CALL DUTYB
> CALL DUTYB ;DUTY RATIO FOR 6V BATTERY CALCULATION ;**************************************************************************
>
> ;12V BATTERY
>
> SWITCH1 BTFSS PORTC,7 ;IF RECEIVE '1', SKIP RETURN
> RETURN
> CALL LED1
> MOVF RESULTLOW1,W
> MOVWF MULTA2
> CLRC ;MULTIPLY BY 2
> RLF MULTA2,F
> MOVF MULTA2,W ;VALUE AFTER MULTIPLICATION FOR
> COMPARISON
> SUBLW B'00001101' ;TAKE 13 MINUS MULTA
> BTFSS STATUS,C ;IF CARRY BIT IS SET, MEANS MULTA IS
> BIGGER THAN 13, THUS SKIP
> BTFSC STATUS,Z ;IF ZERO BIT IS SET, MEANS MULTA IS
> 13V
> BSF TRISC,2 ;TURN ON MOSFET, THUS, ONLY CAPACITOR
> CHARGE THE BATTERY
> RETURN ;**************************************************************************
>
> ;6V BATTERY
>
> SWITCH2 BTFSS PORTC,6
> RETURN
> CALL LED2
> MOVF RESULTLOW1,W
> MOVWF MULTB2
> CLRC
> RLF MULTB2,F
> MOVF MULTB2,W
> SUBLW B'00000111'
> BTFSS STATUS,C
> BTFSC STATUS,Z
> BSF TRISC,2 ;TURN ON MOSFET
> RETURN ;**************************************************************************
>
> ;LED 12V
>
> LED1 CLRF PORTC
> BSF TRISC,5
> RETURN ;**************************************************************************
>
> ;LED 6V
>
> LED2 CLRF PORTC
> BSF TRISC,4
> RETURN ;**************************************************************************
>
> ;READ BATTERY VOLTAGE LEVEL (AN0)
>
> ADC1 MOVLW B'01000001'
> MOVWF ADCON0
> BSF ADCON0,GO_DONE
> CHECK1 BTFSC ADCON0,GO_DONE
> GOTO CHECK1
> MOVF ADRESH,W
> MOVWF RESULTHIGH1
> BSF STATUS,RP0
> MOVF ADRESL,W
> BCF STATUS,RP0
> MOVWF RESULTLOW1
> RETURN ;**************************************************************************
>
> ;READ OUTPUT VOLTAGE OF SOLAR PANEL (AN1)
>
> ADC2 MOVLW B'01001001'
> MOVWF ADCON0
> BSF ADCON0,GO_DONE
> CHECK2 BTFSC ADCON0,GO_DONE
> GOTO CHECK2
> MOVF ADRESH,W
> MOVWF RESULTHIGH2
> BSF STATUS,RP0
> MOVF ADRESL,W
> BCF STATUS,RP0
> MOVWF RESULTLOW2
> RETURN ;**************************************************************************
>
> ;USING LOOK-UP TABLE TO PROVIDE PWM SIGNAL
> ;MULTIPLY BY 2, GET BACK ORIGINAL VALUE
> ;COMPARE AND APPLY CCP, REFER LOOK-UP TABLE
> ;COMPARE SMALLEST TO BIGGEST POSSIBILITIES
>
> DUTYA MOVF RESULTLOW2,W
> MOVWF MULTA2
> CLRC
> RLF MULTA2,F
> MOVF MULTA2,W
> SUBLW B'00001110'
> BTFSS STATUS,C
> BTFSC STATUS,Z
> BCF TRISC,2 ;TURN OFF MOSFET, LET CHARGE AT 14V
> SOURCE
>
> MOVF MULTA2,W
> SUBLW B'00000101'
> BTFSS STATUS,C ;AFTER MINUS, IF C=1, MEANING ADC
> RESULT > 5
> BTFSC STATUS,Z ;AFTER MINUS, IF Z=1, MEANING ADC
> RESULT = 5
>
=== message truncated === =====
My software has no bugs, only undocumented features.





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Short PIC Program - Help needed badly - Phil - Feb 18 14:12:00 2005


Its not at all unusual to have 2 btfss in a row - many valid uses of
that construct. I do hate skip instructions, though. Especially when
you have to test the status SFR. I use the skp pseudo instructions -
much more intuitive.

--- In , Phil Seakins <pseakins@a...> wrote:
> I haven't coded a PIC in assembler but know that all the two PIC
> conditional branch instructions will do is jump you OVER the following
> instruction. Therefore in almost all cases you will have a
conditional test
> followed by a jump or a call. I notice in your code that you have many
> instances of TWO successive tests ie., BTFSS followed immediately by
BTFSC.
> I don't think this what you really want.
>
> Also, in this piece of code...
>
> BTFSC PORTC,7 ;IF SW1 = '0', SKIP CALL DUTYA
>
> ...it seems from your comments that SW1 is on bit 7 of PORTC. It
would make
> your code more readable and easier to maintain if you define the IO
bits as
> constants at the start of your code. By doing this, then should you
later
> decide to move a connection to a different PIC pin (perhaps for
easier PCB
> layout) all you need change is the "define" instead of having to step
> through the code and change every reference to the port. > >Hope you guys don't mind taking a look at the PIC
> >program. Hope I'm not writing nonsense. Thanks a lot
> >in advance.
>
> <code snipped





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Short PIC Program - Help needed badly - rtstofer - Feb 18 14:32:00 2005


--- In , "Phil" <phil1960us@y...> wrote:
>
> Its not at all unusual to have 2 btfss in a row - many valid uses
of
> that construct. I do hate skip instructions, though. Especially
when
> you have to test the status SFR. I use the skp pseudo
instructions -
> much more intuitive.

Time spent reviewing the pseudo instructions (or macros) is well
rewarded. They were all added in an attempt to make the programs
more understandable.

I am a big fan of macros and take every opportunity to create those
that are application specific. Once I know the macro works, I can
use it throughout the program.

And I particularly dislike the BTFSS arrangement. Like Phil said,
it isn't all that intuitive.
>
> --- In , Phil Seakins <pseakins@a...> wrote:
> > I haven't coded a PIC in assembler but know that all the two PIC
> > conditional branch instructions will do is jump you OVER the
following
> > instruction. Therefore in almost all cases you will have a
> conditional test
> > followed by a jump or a call. I notice in your code that you
have many
> > instances of TWO successive tests ie., BTFSS followed
immediately by
> BTFSC.
> > I don't think this what you really want.
> >
> > Also, in this piece of code...
> >
> > BTFSC PORTC,7 ;IF SW1 = '0', SKIP CALL DUTYA
> >
> > ...it seems from your comments that SW1 is on bit 7 of PORTC. It
> would make
> > your code more readable and easier to maintain if you define the
IO
> bits as
> > constants at the start of your code. By doing this, then should
you
> later
> > decide to move a connection to a different PIC pin (perhaps for
> easier PCB
> > layout) all you need change is the "define" instead of having to
step
> > through the code and change every reference to the port.
> >
> >
> > >Hope you guys don't mind taking a look at the PIC
> > >program. Hope I'm not writing nonsense. Thanks a lot
> > >in advance.
> >
> > <code snipped





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Re: Short PIC Program - Help needed badly - Devon Lee - Feb 20 3:49:00 2005

Hi there,

Sorry for my late reply, was having trouble with my
hardware before this. I've break the PIC code into
smaller portions, as advised but I still couldnt
obtain the desired results. As shown in the following
is a simple coding for the switches to control my
LEDs.

During the test, this is what I observed:
a.) I power up the PIC, straight away, LED2 would be
light up. => Correct, right? As it jumps to LED2

b.) I power up the PIC, straight away, LED2 would be
light up. But when I switch to the SWI-7, both LED1
and LED2 will light. Any advice? Please?

------------------------------------------------------
LIST P=16F876
#INCLUDE "P16F876.INC"
__CONFIG _CP_OFF & _XT_OSC & _WDT_OFF & _PWRTE_ON &
_LVP_OFF & _BODEN_ON
ERRORLEVEL -306, -302

;MAIN PROGRAM 1 - TEST

;**************************************************************************

ORG 0X00
GOTO START

START:
BSF STATUS,RP0
MOVLW B'11000000' ;SW-7,SW-6,LED1,LED2,****
MOVWF TRISC
BCF STATUS,RP0

AGAIN BTFSS PORTC,7
GOTO NEXT
BCF PORTC,4
BSF PORTC,5

NEXT BTFSS PORTC,6
GOTO AGAIN
BCF PORTC,5
BSF PORTC,4
GOTO AGAIN

;**************************************************************************

END
------------------------------------------------------

__________________________________





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )