Searching \ for '[PIC:] MPLAB Simulator Correct?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/languages.htm?key=mplab
Search entire site for: 'MPLAB Simulator Correct?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC:] MPLAB Simulator Correct?'
2004\10\14@160711 by Anthony Van Herrewege

picon face
Hi,

I send this mail 2 days ago, but it doesn't seem to show up although I have received mails that were send to the PIC List today, so I figured my mail went missing. Anyway, here's the original message:

This is probably a pretty stupid question, but I'd rather ask it than have problems later.

I just wrote my first PIC code. It was a lot easier than I expected it too be, I think that most the code was finished after 1 hour and I just spend my last 2 hours simulating the code and changing & adding little things. The PIC will check for water using 3 sensors and if there's water detected it will turn on a waterpump for at least one minute. The PIC I'm using is a PIC12C509A. That's the background info, on to the real question now.

If MPLAB simulates the code and everything works, can I be 100% sure that the code will behave the same way on the PIC? I'm asking since the PIC12C509A is an OTP device, so I have to be pretty sure that it will work the same as simulated when I burn it.

Regards, Anthony




Website: http://members.lycos.nl/anthonyvh

               
---------------------------------
Do you Yahoo!?
vote.yahoo.com - Register online to vote today!
_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\14@163043 by John J. McDonough

flavicon
face
----- Original Message -----
From: "Anthony Van Herrewege" <spam_OUTanthony_v_hTakeThisOuTspamyahoo.com>
Subject: [PIC:] MPLAB Simulator Correct?


> If MPLAB simulates the code and everything works, can I be 100% sure that
the code will behave the same way on the PIC? I'm asking since the
PIC12C509A is an OTP device, so I have to be pretty sure that it will work
the same as simulated when I burn it.

Anthony

You should never say always or never.

Of course it's not 100%.  How close it is depends on your app.  But it is
pretty darned close in most cases.

And it's not like a 509 is the world's most expensive device.  Go spend $25
at Digikey and you got a couple dozen of them.  Then you don't need to fret.

--McD


_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\14@163558 by Jan-Erik Soderholm

face picon face
Anthony Van Herrewege wrote :

> If MPLAB simulates the code and everything works, can I be
> 100% sure that the code will behave the same way on the PIC?

Yes, if you are living in a perfect world. :-)

No "funny" loads on the pins that creates timing problems.
No motors (such as a waterpump or a relay) that does "interesting"
things with your power supply (spikes, EMF).
A lot of other things that the MPLAB/SIM hadn't a chance
to know about.

> I'm asking since the PIC12C509A is an OTP device,

Well, I'm ready to bet on that it will *not* work
on the first try. :-)

I supose this in a on-off project, not ?
Why use a OTP device ?

> so I have to be pretty sure that it will work the same
> as simulated when I burn it.

Since this is an unproven hardware environment, it's
very hard to say how your PIC and application will
"react" when exposed to the real world. And using
your "first PIC code"... Well, who knows... :-)

Jan-Erik.

_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\14@165438 by Herbert Graf

flavicon
face
On Thu, 2004-10-14 at 16:07, Anthony Van Herrewege wrote:
> If MPLAB simulates the code and everything works, can I be 100% sure
> that the code will behave the same way on the PIC? I'm asking since
> the PIC12C509A is an OTP device, so I have to be pretty sure that it
> will work the same as simulated when I burn it.

Most definitely not. I'd give it more like a 25% chance.

The simulator can only confirm that the code you put in the PIC will
operate the same on the hardware. But there are a multitude of issues
when you get to the real hardware that can mess things up.

You mention you are using an OTP device, why not get the JW (windowed)
version that allows you to reprogram in case there is an issue?

As another option what about switching to the 12F675 or 12F629, both are
very similar to the 509, except they're flash and have more features (if
you want them).

TTYL

-----------------------------
Herbert's PIC Stuff:
http://repatch.dyndns.org:8383/pic_stuff/

_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\14@203158 by Charles Craft

picon face
As was suggested by others you could switch to nicer 12F parts or get a JW (EPROM) version of the 12C5909A.

If you are tied to the 12C509A then look at the 12F509.
My understanding is that it is a flash replacement for the 12C509 parts without the expense of a JW part.


{Original Message removed}

2004\10\14@211716 by Anthony Van Herrewege

picon face
Hi,

Thanks for the info/tips, I'll take a look at the flash version of the PIC12F.

Anthony

> As was suggested by others you could switch to nicer 12F parts or get a JW
> (EPROM) version of the 12C5909A.

> If you are tied to the 12C509A then look at the 12F509.
> My understanding is that it is a flash replacement for the 12C509 parts without the
> expense of a JW part.


Website: http://members.lycos.nl/anthonyvh

               
---------------------------------
Do you Yahoo!?
vote.yahoo.com - Register online to vote today!
_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\15@013438 by William Chops Westfield

face picon face
On Oct 14, 2004, at 1:07 PM, Anthony Van Herrewege wrote:

>
> If MPLAB simulates the code and everything works, can I be 100% sure
> that the code will behave the same way on the PIC? I'm asking since
> the PIC12C509A is an OTP device, so I have to be pretty sure that it
> will work the same as simulated when I burn it.
>
I don't believe that the fuse bits are simulated much, or at all.
So you could burn a chip with the fuses wrong and have it not work
at all.  Likewise, I doubt whether the simulated clock 'drifts' as
much as the internally generated clock, so you could get timing
problems as well.  And of course mplab simulation is much slower
than realtime, so it's pretty useless at detecting problems that
might be timing dependent.

BillW

_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\15@045304 by Alan B. Pearce

face picon face
>And it's not like a 509 is the world's most expensive device.
>Go spend $25 at Digikey and you got a couple dozen of them.
>Then you don't need to fret.

Or better yet, get a 12F series device, which is reprogrammable flash, and
pin compatible to the 12C devices.

_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\15@124526 by Anthony Van Herrewege

picon face
Hi,

> I don't believe that the fuse bits are simulated much, or at all. So you could
> burn a chip with the fuses wrong and have it not work at all.

What do you mean with fuses? Things like brown out detector & code protection & what oscillator to use? If that's what you mean, it does simulate it. I spend over an hour trying to find an error in my code, because it kept restarting, only to find that brown out was enabled.

> Likewise, I doubt whether the simulated clock 'drifts' as
> much as the internally generated clock, so you could get timing
> problems as well. And of course mplab simulation is much slower
> than realtime, so it's pretty useless at detecting problems that
> might be timing dependent.

Timing is not a problem, the PIC is supposed to turn on a darlington which turns on a relay and after a detector goes low it has to keep the relay turned on for 1 more minute. Even if the timing's off by 10 seconds it wouldn't be a problem. I simulated all prossible scenarios and they differ max. 4 instruction cycles per half second, so I thing timing should be pretty OK for what I tend to do with the chip.

Thanks, Anthony


Website: http://members.lycos.nl/anthonyvh

               
---------------------------------
Do you Yahoo!?
vote.yahoo.com - Register online to vote today!
_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\15@140134 by Jan-Erik Soderholm

face picon face
Anthony Van Herrewege

> > I don't believe that the fuse bits are simulated much, or
> > at all. So you could
> > burn a chip with the fuses wrong and have it not work at all.
>  
> What do you mean with fuses? Things like brown out detector &
> code protection & what oscillator to use? If that's what you
> mean, it does simulate it. I spend over an hour trying to
> find an error in my code, because it kept restarting, only to
> find that brown out was enabled.

BOR is trigged when the power supply goes below some
defined level. Does SIM in MPLAB realy simulate *that* ?
Are you sure it wasn't WDT ? I know that SIM simulate *that*
one :-)

> > Likewise, I doubt whether the simulated clock 'drifts' as
> > much as the internally generated clock, so you could get timing
> > problems as well. And of course mplab simulation is much slower
> > than realtime, so it's pretty useless at detecting problems that
> > might be timing dependent.
>  
> Timing is not a problem, the PIC is supposed to turn on a
> darlington which turns on a relay...

MPLAB SIM has no way to "see" any generated "spikes" on the
power line from the relay. But maybe you have already taken care
of that, right ?

> ...and after a detector goes
> low...

What is the "detector" ? A floating switch ? Does it bounce ?
Does your code take care of that ?

> it has to keep the relay turned on for 1 more minute.
> Even if the timing's off by 10 seconds it wouldn't be a
> problem. I simulated all prossible scenarios and they differ
> max. 4 instruction cycles per half second, so I thing timing
> should be pretty OK for what I tend to do with the chip.

Now, "timing" could have a lot of meenings.
Such as lines not switching as fast as you think due to
resistive and capacitive load, just to name one scenario.

The question still is, why use a OTP part ??
You will probably go through at least 10-20 "versions"
of your code until you have a "working" application...

Jan-Erik.
_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\15@160643 by Anthony Van Herrewege

picon face
Hi,

> BOR is trigged when the power supply goes below some defined level. Does SIM in
> MPLAB realy simulate *that* ? Are you sure it wasn't WDT ? I know that SIM simulate
> *that* one :-)

Ah, yes, excuse me, that's what I ment.

> MPLAB SIM has no way to "see" any generated "spikes" on the power line from the
> relay. But maybe you have already taken care of that, right ?

Well, the power supply generates 5.7v, which is fed directly to the relay. To power the pic, this 5.7v first goes through a diode. Of course there's also a revered diode across the relay. There's also some decoupling on the PIC's power pins. Let's hope it works :).

> What is the "detector" ? A floating switch ? Does it bounce ?
> Does your code take care of that ?

Well, there's 3 detectors connected to 3 pins. Every input is tied to ground with a 10k resistor. The "detector" will probably be a very small PCB or just 2 copper wires that don't touch each other. They need to detect water so that the PIC can turn on the relay, which in turn engages a waterpump.

Bouncing shouldn't be a problem I think, since the detectors are only checked every 0.5 seconds and water won't bounce anyway, well, I can't think of any reason why it would make the detectors. One wire of the detector is wired to +5.7v through a diode (so it's actually more like 5v) and a resistor will be added too the prevent damage to the circuit in case it's shorted to ground (through the water for example). The other wire is connected to a diode, then a 1k resistor and then one of the PIC's input pins.

> Now, "timing" could have a lot of meenings. Such as lines not switching as fast as you
> think due to resistive and capacitive load, just to name one scenario.

The only lines that have to be switched is a LED and the darlington for the relay. It doesn't really matter if the relay turns on after 1ms or after 10 seconds, as long as it turns on it's fine.

> The question still is, why use a OTP part ?? You will probably go through at least
> 10-20 "versions"of your code until you have a "working" application...

Yes, yes, I'm convinced ;). I'll get myself a PIC12F part.

Thanks, Anthony


Website: http://members.lycos.nl/anthonyvh

               
---------------------------------
Do you Yahoo!?
vote.yahoo.com - Register online to vote today!
_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

More... (looser matching)
- Last day of these posts
- In 2004 , 2005 only
- Today
- New search...