CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC keeps reseting, UART does not receive, PIC BBQ soon!
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Tue Aug 04, 2009 1:22 pm     Reply with quote

hahaha

Well... I'll do some testing tonight... ill post my results.

I think that might solve my problem.

On an off topic issue... Why is it that every time I log in, after like 10 minutes or after comenting in a few posts, I have to log back in?

Is there like an auto log off feature I'm not aware of?


its annoying...

g
_________________
CCS PCM 5.078 & CCS PCH 5.093
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Aug 04, 2009 1:39 pm     Reply with quote

Ttelmah wrote:


First. 'Large caps on both input and output'. Unless you have a reverse biased diode across the regulator, this is a very good way to kill a 7805...
Then, how close to the 7805, is the capacitor on the output?. Have you any _small_ caps on the rails as well?. The problem is that electrolytic capacitors, have very poor HF response. If you only have a 'large' capacitor on a rail, you may have almost nothing blocking high frequencies. If the output capacitor is large, it may also make supply regulation worse. You need something like a 0.1uF ceramic, or polyester _close to the regulator_ on the output, paralleled with perhaps 100uF, and another 0.1uF, _close to the PIC_. Also similar small capacitors close to any circuitry involving high frequency switching. You may well have the regulator oscillating....
Second,. the 'series diode', is not a good way to drive MCLR. The pin is basically left floating, when you switch off, rather than being pulled down. Small capacitor from MCLR to ground. Resistor from MCLR to +5v, _paralleled_ with a reverse biased diode. This way, MCLR rises shortly after power comes on (determined by the time constant othe resistor and capacitor), but is shorted out _quickly_ when the power rail falls.


Also, always remember to consider the thermal dissipation of the regulator.

12-13V down to 5V with a 7805 and no heat-sink even at 100mA will get surprisingly warm in terms of thermal dissipation. Always keep that in check. Or, if you like, use a switcher. (TI makes some nice 7805 style drop-in switchers that put out 5V >1A with almost no need for a heat-sink <1A.)
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Tue Aug 04, 2009 3:03 pm     Reply with quote

hi bkamen

No heat coming from my regulator. I can barely feel it with my finger.
I have to concentrate to feel any heat coming from it.

My circuit has no real loads, just a MAX232 chip and a pic running a few while loops lighting a single led.... just for debug.

...ive often wondered about those switchers.... they seem nice...

I think I will consider them for a low power solar project I'm working on.

g
_________________
CCS PCM 5.078 & CCS PCH 5.093
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Tue Aug 04, 2009 3:12 pm     Reply with quote

Gabriel wrote:
hi bkamen

... ive often wondered about those switchers.... they seem nice...

g


I have not used anything OTHER than switchers to power almost everything on my boards. The only components I ever run from a linear regulator are opamps and reference diodes. Even if you are merely burning 8-10mA lighting an LED linear regulators are too wasteful. You can easily drop a quarter watt on one of these LEDs if running from a 24V industrial power supply and that is unacceptable.

Talk about 7805 there are switching versions that are drop in replacement for the 7805 linear regulators as seen here:

http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=102-1709-ND

You don't even need the catch diode and inductor.
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Tue Aug 04, 2009 3:21 pm     Reply with quote

Awesome... I'll look into it.

I agree they are wastefull...... but they are so cheap, expendable, and for prototyping, I think they are good enough.....but

I'm starting to turn to remote sensing and battery operated stuff, so I'll definetly look into them.

Thanks for the tip.

g
_________________
CCS PCM 5.078 & CCS PCH 5.093
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Tue Aug 04, 2009 3:21 pm     Reply with quote

My new favorite switcher is MC34063A. Used in many/most car adapters.
http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=MC34063ADR2GOSTR-ND
http://www.nomad.ee/micros/mc34063a/index.shtml

also check out
http://www.romanblack.com/smps/a02.htm
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Aug 04, 2009 4:47 pm     Reply with quote

Well, let's remember the environments first...

Prototyping on the bench is fine with a 7805... just watch the heat.
A TI78SV105 (switcher in a 3pin plug in style replacement) is a nice replacement for the bench proto environment too. That's what I use when I need the current but don't want the heat.

The next step for the more production environment is an LDO operating close to the in/out voltages needed. They don't waste as much. The last and best step for a noise-tolerant environment is definitely a switcher.

I use a lot National, Maxim and Linear parts for this. I won't say much about motorola after the spin-off of their semi's other than I don't use 'em if I can avoid it. :D

But yea, switchers rule. JUST DON'T SKIMP THE LAYOUTS! Big traces and heavy copper layouts! I do board design myself, but when I have others do it - they typically ALWAYS screw up the low-ESR needs of a switching design with less-than-acceptable trace-paths.

Cheers,

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Wed Aug 05, 2009 8:15 am     Reply with quote

I agree with what bkamen said. I do the design and layout of the switching regulators myself also. In general I have to say that if you are using a switcher consider getting something that accept as high an input voltage as possible (well if you can afford the $$$ that is).

The layout is critical, not so much for the operation of the switcher but for EMI control so your other components don't go bonkers.
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Thu Aug 06, 2009 9:59 am     Reply with quote

well guys,

although i thought my problems where solved...

they were not...


is not really reseting anymore... but... the code doesent really execute..
i can tell that the code is running because of LEDs i have for debugging
but i know its only partially running because the circuit is not responding...
it know its not a code problem because its the same code that ive been using since i started posting here... which i know works
and also previous code ive written that i KNOW works its not working...


one user suggested that i might not have proper fuse settings...

i changed my fuses.. added the ones that were pertinent... and the problem went away...
but, now after one day of peace.... its not working anymore

another user sugested that my power supply might be noisy.....
i have 35v@100uf cap on my 7805 input, and a 16V@100uf on its output...
power comes from a wall wart AC/DC... 220V->13V@500mA
my regulated voltage is 4.92V.

and i have a 0.1 polarized tantalum capacitor about ~1.5 cm from the chipĀ“s Vdd and Vss rails...


as a desperate attempt... i added a electrolytic cap on the output side of my regulator... a huge one.... 35V@2200uf...
my voltage output was still 4.92..... and the problem persisted...i also tried putting the cap on the input side... nothing.


my program seems like its running... LEDS flash in the right order... i get a message on hyperterminal... but when i type a response... it stays frozen.... like it never got my command....

this happened before, but was termparily solved by adding the proper fuses....

and now its happening again...


my MCLR circuit... is a resistor in series with a diode...
one user suggested that this is not a very good circuit.... so since i cant add the missing capacitor (i dont have the luxury of calling up digikey or radioshack)... i will take the diode off an return to my original
circuit which was just pulling up MCLR with a 10k R.


my code is posted in the earlier parts of this thread....


thank you all..

g
_________________
CCS PCM 5.078 & CCS PCH 5.093
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Aug 06, 2009 10:14 am     Reply with quote

you can lose the big cap. The 4.92V is about what a 7805 delivers.

However,

in your ISR,

Code:
#INT_RDA
void SerialInt()
{
   Recieve_String[counter]=getchar();
   counter++;
}


You have nothing to keep from flowing out of bounds on the buffer index!!

You MUST keep the things that increment counter from flowing past the limit of Receive_string (I before E except after C, by the way).

and also consider using separate counters for the ISR and your check routine so one doesn't mess with the other.

Always consider when you're using ISR's that they can do just that. Interrupt any function currently processing. Be vary careful about modifying global variables inside and outside ISR's.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Thu Aug 06, 2009 10:27 am     Reply with quote

hi ben,

thanks for your reply...

i am aware that i dont keep the counter from going out of bounds in the
array...

my code right now is just a rough version....but

i already modified my code to use 2 separate counters...
although it works as is... since the string i recEIve is not larger than the array....

i was thinking of implementing a "circular buffer" instead/also

by doing


Code:

#INT_RDA
void SerialInt()
{
   Recieve_String[counter]=getchar();
   counter++;
   if(counter==11) counter=0;
}



is that a Circular buffer?.... thats what i understood as a circular buffer.


hehehe, English is my second language, i speak spanish.... pardon any gramatical errors.

thanks

g
_________________
CCS PCM 5.078 & CCS PCH 5.093
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Thu Aug 06, 2009 10:35 am     Reply with quote

You are attempting to modify the value of counter both inside an ISR and in another function. To be safe I suggest you add the word "volatile" to the declaration of the variable counter as:

Code:

volatile char counter = 0;


This tells the compiler that the value of counter could be changed inside an ISR.
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Aug 06, 2009 10:37 am     Reply with quote

Code:
#INT_RDA
void SerialInt()
{
   Recieve_String[counter]=getchar();
   counter++;
   if(counter==11) counter=0;
}


That's what you want.

Another thing that will help you is to have an index to the bytes in and the bytes out. (like a FIFO) this might help your routines figure that it doesn't have to look through the whole buffer looking for OK\r\n when it might have 2 of those in the buffer.

You can also consider keying off the \r or \n in the ISR to flag that there's data needing inspection.

I do this in my GPS routines. It's a state machine (that would differ from your setup) but essentially goes like this:

0: look for start of GPS Sentence. "$"
1: Gather chars into buffer...
is char a \r?
yes? -- set have_data flag and then goto next state
no. -- keep gathering but stop at sizeof(string) (minus 2 of course where -1 == null)
2: wait until external string parse clears have_data flag then make state=0.

my parse routine clears the "have_data flag".. but not after parsing. the function IMMEDIATELY makes a copy of the gps_string (fast) so it can release the GPS ISR to get the next sentence while it parses (slow) the current one.

Like I said, your setup will be different... but this way, you'll catch "whole phrases" and then process them...

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Thu Aug 06, 2009 10:42 am     Reply with quote

Ben,

I'll repost my code tonight with all the changes I've made
... including your latest suggestion, and see what you think.

2 separate counters, one for reading data, and one for traversing the array, the volatile declaration, and the circular array.


Was my previous post a "correct" circular buffer? (imagine "counter" is an independent counter). Was at least my idea of it correct?

g
_________________
CCS PCM 5.078 & CCS PCH 5.093
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Aug 06, 2009 12:31 pm     Reply with quote

Gabriel wrote:
Was my previous post a "correct" circular buffer? (imagine "counter" is an independent counter). Was at least my idea of it correct?


Yes. It was correct. This isn't just a circular buffer, in a real sense, it's also a FIFO. (which need 2 counters.) you have one process putting data in, and another pulling data out with the buffer acting as a cushion.

Keep in mind with circular buffers, that you never want the in and out indexes to overrun each other. This is why in my GPS ISR routine I put a stop on gathering data under 2 conditions...

1. the routine has reached the end of the buffer -- and should stop.
2. the routine has gathered the data of interest... and should report it and stop until the external routine says it's ok to continue. (Another reason the CR/LF end of line markers are so nice for signaling something of interest is in the buffer).

So as you write tonight, think about how to accomplish that as well.

Cheers,

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group