Tutorial 1

Post here to discuss the PIC microcontroller tutorials.

Moderators: Chuckt, Garth, bitfogav

Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
K9ACT
newbie
newbie
Posts: 4
Joined: Thu Oct 16, 2014 2:22 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Tutorial 1

Post by K9ACT » Thu Oct 16, 2014 2:32 am

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
Last edited by K9ACT on Thu Oct 16, 2014 2:38 am, edited 1 time in total.

Garth
I practically live here!
I practically live here!
Posts: 232
Joined: Wed Jan 16, 2013 1:17 pm
Contact:

Re: Tutorial 1

Post by Garth » Thu Oct 16, 2014 2:35 am

Are you saying the next instrucion is not skipped when the variable being decremented reaches zero?
http://WilsonMinesCo.com/ lots of 6502 resources

K9ACT
newbie
newbie
Posts: 4
Joined: Thu Oct 16, 2014 2:22 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Tutorial 1

Post by K9ACT » Thu Oct 16, 2014 2:42 am

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.

Garth
I practically live here!
I practically live here!
Posts: 232
Joined: Wed Jan 16, 2013 1:17 pm
Contact:

Re: Tutorial 1

Post by Garth » Thu Oct 16, 2014 5:15 am

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.
http://WilsonMinesCo.com/ lots of 6502 resources

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Tutorial 1

Post by brad » Thu Oct 16, 2014 9:16 pm

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.

K9ACT
newbie
newbie
Posts: 4
Joined: Thu Oct 16, 2014 2:22 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Tutorial 2, was Tutorial 1

Post by K9ACT » Thu Oct 16, 2014 11:33 pm

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

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Tutorial 1

Post by brad » Sun Oct 19, 2014 7:29 am

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!

K9ACT
newbie
newbie
Posts: 4
Joined: Thu Oct 16, 2014 2:22 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Tutorial 1

Post by K9ACT » Sun Oct 19, 2014 10:59 am

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

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Tutorial 1

Post by brad » Sun Oct 19, 2014 9:13 pm

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 :)

Garth
I practically live here!
I practically live here!
Posts: 232
Joined: Wed Jan 16, 2013 1:17 pm
Contact:

Re: Tutorial 1

Post by Garth » Mon Oct 20, 2014 1:18 am

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.
http://WilsonMinesCo.com/ lots of 6502 resources

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Tutorial 1

Post by brad » Fri Oct 24, 2014 5:53 am

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!

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 5 guests