Yes... all your 5 points are correct. If you understand my code thatīs a good beginning!
Thank you!
Yes... all your 5 points are correct. If you understand my code thatīs a good beginning!
Thank you!
Hello Leonel,
Yes, I pretty much understood your code...
Just a couple of suggestions.
If and then statements...
If a "IF statement has only one statement, you do not need a "endif".
The if statement below NEEDS a endif
this does not need a endif statement;Code:If a > b then c=d d=f f=g endif
This will help you on your code space and readability...(Of course I must look whos speaking too <chuckle> I think my code is some of the hardest to read <g>)Code:if a=b then c=d ... ... if d=f then d=g ....
Dwayne
Ability to Fly:
Hurling yourself towards the ground, and missing.
Engineers that Contribute to flying:
Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute
Pilots that are Flying:
Those who know their limitations, and respect the green side of the grass...
Hello Leonel,,
just had a brain fart to take care of your blinky light...
I put a separate counter for the blinky... stuck the blinky in the routine so that it will be called all the time, removed it from the end of the routine and since you said it doesn't matter too much on the exact time.... well...Code:Switching var byte; LightCount var Word Counter1 var word Counter2 Var word LightCount=0 Loop: Counter1=0 Counter2=0 Loop2: if Counter1< 20 if Counter2 <1000 if switching=1 then Pause 1 'Pause 1/1000 of a second to make 20 if switching=0 then Pause 2 'Pause 1/500 of a second to make 40 LightCount=LightCount+1 If LightCount=20000 then LightCount=0 Blink light = on Pause 200 'pause 1/5 of a second to light up the light. Blink Light = off endif if Portb.0=1 then turn on switch. goto Loop endif if Portb.1=1 then turn on switch. goto Loop endif if Portb.2=1 then turn on switch. goto Loop endif .... .... (for each of your eight switches) Counter2=Counter2+1; Endif if(Counter2>=1000) Counter1=Counter1+1; counter2=0; endif endif if Counter1<20 goto Loop2 Portb=0; 'turn off ALL of the switches! goto Loop:
Dwayne
Ability to Fly:
Hurling yourself towards the ground, and missing.
Engineers that Contribute to flying:
Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute
Pilots that are Flying:
Those who know their limitations, and respect the green side of the grass...
Iīm sorry to start by a blinky light, but my english itīs not good to explain in detaill all things, so iīve put a simple question
Iīm used to finish with endif, but if itīs better for my code space iīll follow your advise!
Just another question: my code after compiling gives me this warning " "Crossing page boundary -- ensure page bits are set." i donīt have to worry, because PBP takes care of this problem???!!! I donīt have any branch instruction so thatīs ok (pag.13 of PBP manual), my code will work great! Correct?
Hello Leonel,
Leonel
That is fine Leonel... Even I have problems... so you and I are in the same boat together... We can wave flags at each other, and sink with the ship...at least we will have a little fun.Iīm sorry to start by a blinky light, but my english itīs not good to explain in detaill all things, so iīve put a simple question
This is not a requirement Leonel... This is all up to you and your preference. You may code anyway that makes you understand it. I only made a suggestion, to show you a different way how to code. I have been corrected many times on my coding!... Sometimes I change, sometimes I don't. As long as the code compiles, and I understand it... its fine with me.Iīm used to finish with endif, but if itīs better for my code space iīll follow your advise!
You shouldn't have to worry about crossing page boundary... PBP takes care of that... I only question is why??? I don't think you have 2 k of code there... but I could be wrong. But you should not have to worry about this warning.Just another question: my code after compiling gives me this warning " "Crossing page boundary -- ensure page bits are set." i donīt have to worry, because PBP takes care of this problem???!!! I donīt have any branch instruction so thatīs ok (pag.13 of PBP manual), my code will work great! Correct?
Now about your code... If you notice my tag, one of the statements is: "Compile something that runs" There is no guarantee on your code (or my code) running to do the job you want it to do. Since I have no way how to test it, I can only give you code that is Close to what I think you are wanting.
Remember, the code I am giving you is a "shell" around your "Secret weapon" That shell is taking care of a blinky light, taking care of your 20 and 40 second timing, and also checking your switches. I noticed on your code, that my routine was used as a kind of subroutine. This may get you into a little trouble...with how your program works. But you can try it!...
Since you said the blinky light can be off by a few seconds, I made the code as a shell. A shell is the part that fits around your program and stuff. What will vary your blinky light, will be the code in my shell. But I am betting that the computer is so fast, that your code will not make that much difference between the blinky lights.
I also noticed you used a Pause 1000 . That is a 1 second delay...That means if you are pushing a button, you may have to hold it for at least 1 second! If this is ok with you, great.
My biggest question is:
Do you fully understand what my code is doing? Do you fully understand that it is a shell, and how it is taking care of the timing, switch checking, and blinky light? Do you know where to insert your code, so that my code will work like it should? I only ask these questions, because it seems you are using it as a kind of Subroutine. (I have not studied your code to fully comprehend it, but I just picked up on a few little things that made me wonder).
Dwayne
Last edited by Dwayne; - 30th June 2005 at 16:24.
Ability to Fly:
Hurling yourself towards the ground, and missing.
Engineers that Contribute to flying:
Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute
Pilots that are Flying:
Those who know their limitations, and respect the green side of the grass...
Yes i understand your code and your right, iīm using it with a subroutine, and with your explanation i understand what a shell is (an oil pump)
I used your code with a little modifications... now i have to build my hardware and test it.
I know that with pause the program doesnīt check anything, but in this case (only in 2 inputs), thereīs no problem. If you see i'll make some of my outputs high during 20s or 40s with pause. and in this time i donīt want to see any input.
Hell Leonel,
Ok! Just wanted to make sure!...
I also noticed you changed my "If" statements to "while" statements.
Since I do not have a testing ground here, I do not know what will happen, if the program "Jumps" out of the middle of a while statement too many times.
I have had no problems jumping out of a "If" statement... but I am not sure about a while statement. So, I did not use while statements, for fear of crashing <g>.
Ralph, Steve, Melanie, Darrel, Bruce... Whats the answer???
If a hits 50 a bunch of times, will this give PBP a problem and lose its stack? or run haywire? I know in some older versions of C/C++, it could cause a problem with memory...but I am not sure in PBP.Code:Loop a=1 while a <100 ..... if a==50 goto Loop ... a=a+1 wend .... goto Loop.
Dwayne
Ability to Fly:
Hurling yourself towards the ground, and missing.
Engineers that Contribute to flying:
Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute
Pilots that are Flying:
Those who know their limitations, and respect the green side of the grass...
Bookmarks