[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 580: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 636: sizeof(): Parameter must be an array or an object that implements Countable
Brads Electronic Projects Forum • Tutorial 1
Page 1 of 1

Tutorial 1

Posted: Thu Oct 16, 2014 2:32 am
by K9ACT
The project works in hardware but I wanted run it with the sim and it seems to get hung up on the decfsz.

I changed the 255 to 2 so I could step it through but it decs when at 0 and it rolls over to 255 and never seems to quit.

What might I be doing wrong?

Thanks,

Jack

Re: Tutorial 1

Posted: Thu Oct 16, 2014 2:35 am
by Garth
Are you saying the next instrucion is not skipped when the variable being decremented reaches zero?

Re: Tutorial 1

Posted: Thu Oct 16, 2014 2:42 am
by K9ACT
Garth wrote:Are you saying the next instrucion is not skipped when the variable being decremented reaches zero?
Yes. It just decs it again.

Actually, it goes to the second delay and when that is zero, it goes back to the first and that is where the problem is. The first delay is now and zero and it decs again.

I am looking at the file registers, BTW. The hardware does what it should and blinks.

Jack... wow that was a quick answer.

Re: Tutorial 1

Posted: Thu Oct 16, 2014 5:15 am
by Garth
Ah-- I guess I missed that the hardware works as expected, but the simulator is messing up. I used MPSIM years ago and it was so cumbersome that it wasn't helpful.

Re: Tutorial 1

Posted: Thu Oct 16, 2014 9:16 pm
by brad
It's great to hear that you have it working on real hardware however it is annoying that it won't work in the sim. In fact, I spent a few hundred dollars a few years back on a circuit simulator only to find I had problems with it!

So I guess it looks as though the simulator is the thing that is at fault here. once the second delay gets to zero it should be exiting the loop.

Also, when the second delay isn't yet at zero, it loops back to decrement the first delay, since each delay variable holds 8 bits (which means it can hold any decimal number from 0 to 255). If it was zero before we called the decfsz line, then the first thing it will do is decrement (so zero will loop back around to 255) then because it is now not zero, it will keep decrementing until it does get to zero.

Re: Tutorial 2, was Tutorial 1

Posted: Thu Oct 16, 2014 11:33 pm
by K9ACT
Just noticed the error in the subject line. I have been discussing #2 and not #1.

............


Since posting this, I have learned how to use the Stop Watch on MPLAB.

Using this, I find that it is only the single step and animate functions that have this issue.

Pressing the Run button, the delay is exactly as set in the delay routine.

It seems like the simulator only decs zero on the first recall of the first loop. After that it clears normally but in the Run mode, it acts as it should.

I got into this as I decided it was time to understand how the nested delays work that I have been using on faith. Turns out I have learned more about the simulator than about nested loops.

Going to go through the rest of your tutes now that I am over this hump.

However, I might suggest that a schematic of the project would be a lot more convenient than working through the text. Maybe you do this on the other projects but don't know yet.

Thanks,

Jack

Re: Tutorial 1

Posted: Sun Oct 19, 2014 7:29 am
by brad
Great to hear that you have been making progress :)

I certainly agree with you about the schematic diagrams - it would make it much easier for everyone trying to follow through. However I have included these for the later tutorials because they are quite a bit more involved.

Be sure to let us know how you go!

Re: Tutorial 1

Posted: Sun Oct 19, 2014 10:59 am
by K9ACT
brad wrote:Great to hear that you have been making progress :)

I certainly agree with you about the schematic diagrams - it would make it much easier for everyone trying to follow through. However I have included these for the later tutorials because they are quite a bit more involved.

Be sure to let us know how you go!
One other thing you could do to make following your tutes easier.

It's a bit of a pain to have to download a zip and then unzip and display it to see the program.

You need a way to view it while reading the web page without having to download something.

Now, the original issue has been resolved and the sim in MPLAB is doing exactly what it should.

The rollovers from decrementing through zero are part of the delay. If you just multiply D1 times D2, you get nothing close to the desired delay. All those 255's do the trick.

Just got through the T3 and really think you did a great job of explaining RFR/L. The graphics made it unnecessary to even run the program.

Thanks,

Jack

Re: Tutorial 1

Posted: Sun Oct 19, 2014 9:13 pm
by brad
You are right again - It would be much better to have the code in the page although when I wrote the tutorials back in 2008 (I think) I only had a basic web site to display it all on. Now I am using wordpress and I could certainly re-vamp them to include the code in the page however I just need to find some time to do this :)

Re: Tutorial 1

Posted: Mon Oct 20, 2014 1:18 am
by Garth
brad wrote:You are right again - It would be much better to have the code in the page although when I wrote the tutorials back in 2008 (I think) I only had a basic web site to display it all on. Now I am using wordpress and I could certainly re-vamp them to include the code in the page however I just need to find some time to do this :)
I just write up my web pages in a text editor, and I have a cheat sheet of html tags to look at if I don't remember one. To put a piece of code inline, put it between <pre> and </pre> (for pre-formatted, meaning it will give you monospace and won't remove white space, and lines will wrap only where you wanted). To see the html source on any of the pages of my (or any other) website, press <Ctrl>U when you're viewing them in your browser. I understand <Ctrl>U works the same in lots of browsers. My pages super simple.

Re: Tutorial 1

Posted: Fri Oct 24, 2014 5:53 am
by brad
It certainly gets the job done Garth. It reminds me of the good old days of the Internet back in the 90's :)

All the relevant content was there and you didn't need to really dress up the site, it just didn't need it!