Loop and component Timer/counter!
Moderator: Benj
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Loop and component Timer/counter!
Hi Need a little help!
I was testing the Timer component in simulation. I dont know If I am doing it right. I have a While1 loop in this loop I have two other loop
In one off these two loop, I make an input B0 and, stay in this loop until I press the startbottom B0. And the same for second loop Stopbottom B1. But when I simulate and run slowly I can see that these two loop are "jump over" the simulation don´t stay in the loop until I press start or stop.
Only the first time it work.
And I don´t managed to get the timer counter to count, but maybe it doesn´t work in simulation?
What am I do wrong.
Br Jorgen
I was testing the Timer component in simulation. I dont know If I am doing it right. I have a While1 loop in this loop I have two other loop
In one off these two loop, I make an input B0 and, stay in this loop until I press the startbottom B0. And the same for second loop Stopbottom B1. But when I simulate and run slowly I can see that these two loop are "jump over" the simulation don´t stay in the loop until I press start or stop.
Only the first time it work.
And I don´t managed to get the timer counter to count, but maybe it doesn´t work in simulation?
What am I do wrong.
Br Jorgen
- Attachments
-
- Counter.fcfx
- (12.42 KiB) Downloaded 320 times
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: Loop and component Timer/counter!
Hi Jorgen
Set Start=0 just before the inputs.
Kind regrads
Jan Lichtenbelt
Set Start=0 just before the inputs.
Kind regrads
Jan Lichtenbelt
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: Loop and component Timer/counter!
Hi Jorgen
Set before the first loop Start=0 and for the second loop Stop=0. Change both loops "test the loop at the:" from Start to End.
The timer is new for me. On this moment I do not know a solution
Kind regards
Jan
Set before the first loop Start=0 and for the second loop Stop=0. Change both loops "test the loop at the:" from Start to End.
The timer is new for me. On this moment I do not know a solution
Kind regards
Jan
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Loop and component Timer/counter!
Hi Jan!
Thank´s. But I don´t think I am 100% understanding what you mean. I try so set start until 0 but doesn´t help.
But in my opinion, the loop must not be left before Start = 1 or in the stoploop, stay in the loop until stop is pressed. Hope you understand what I mean.
Jan I try to play a little with it, if I set "In the end" in the loop setting it works every time and stay in the loop until I press Start/Stop.
As far I remember, the timercomponent is a component Ben create for one of our friend here. And, yes I also don´t know much about it, but was playing with it. That´s why I discover this with the loop´s
Br Jorgen
Thank´s. But I don´t think I am 100% understanding what you mean. I try so set start until 0 but doesn´t help.
But in my opinion, the loop must not be left before Start = 1 or in the stoploop, stay in the loop until stop is pressed. Hope you understand what I mean.
Jan I try to play a little with it, if I set "In the end" in the loop setting it works every time and stay in the loop until I press Start/Stop.
As far I remember, the timercomponent is a component Ben create for one of our friend here. And, yes I also don´t know much about it, but was playing with it. That´s why I discover this with the loop´s
Br Jorgen
- Attachments
-
- Inside.PNG
- (18.92 KiB) Downloaded 2873 times
-
- Loop.PNG
- (10.6 KiB) Downloaded 2875 times
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Loop and component Timer/counter!
Hi Jorgen,
With loops:
If you use test at the start then if the condition is false before the loop starts then the loop will not be entered at all!
With a condition at the end, the loop will always be entered, no matter what the variable value is.
Martin
With loops:
If you use test at the start then if the condition is false before the loop starts then the loop will not be entered at all!
With a condition at the end, the loop will always be entered, no matter what the variable value is.
Martin
Martin
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Loop and component Timer/counter!
Hi Martin!
Well well, now I understand, and of course yes, logig. And Jan´s explanation also make sense now. I just make a test and it work.
Thank´you to booth of you
Br Jorgen
Well well, now I understand, and of course yes, logig. And Jan´s explanation also make sense now. I just make a test and it work.
Thank´you to booth of you
Br Jorgen
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Loop and component Timer/counter!
Hi again Martin, MM team!
Sorry, but now I have the problem again in simulation. Sometimes the simulation work and sometime not. Mostly it work first time and then stop work. Maybe I misunderstod you.
When I activate input B0 Fjernb nothing happen.
What am I doing wrong, please?
Two examble att. One with loop and one without
It is like the input is not detected. I have not tested the program on the arduino yet. But normally it work in real world.
Br Jorgen
Sorry, but now I have the problem again in simulation. Sometimes the simulation work and sometime not. Mostly it work first time and then stop work. Maybe I misunderstod you.
When I activate input B0 Fjernb nothing happen.
What am I doing wrong, please?
Two examble att. One with loop and one without
It is like the input is not detected. I have not tested the program on the arduino yet. But normally it work in real world.
Br Jorgen
- Attachments
-
- InputWrongExLoop.fcfx
- (11.18 KiB) Downloaded 209 times
-
- InputWrong.fcfx
- (11.44 KiB) Downloaded 200 times
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Loop and component Timer/counter!
Hi Jorgen,
Does look like a simulation bug to me as if an input and output are both assigned to the same pin.
In simulation if the input is high then the same pin is turned to an output and set low, then when an input again, its ignored.
To get around that for now just use masking on the outputs.
I have modified your flowcharts to show you.
Edit. I remember with simulation in the past, that inputs and outputs on the same pin don't work as expected.
Should be fine with hardware.
So I believe this issue is known about?
Does look like a simulation bug to me as if an input and output are both assigned to the same pin.
In simulation if the input is high then the same pin is turned to an output and set low, then when an input again, its ignored.
To get around that for now just use masking on the outputs.
I have modified your flowcharts to show you.
Edit. I remember with simulation in the past, that inputs and outputs on the same pin don't work as expected.
Should be fine with hardware.
So I believe this issue is known about?
- Attachments
-
- InputWrongExLoop1.fcfx
- (11.19 KiB) Downloaded 203 times
-
- InputWrong1.fcfx
- (11.49 KiB) Downloaded 228 times
Martin
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Loop and component Timer/counter!
Hi Martin!
Thank you for looking at it. At the moment I am not on my laptop where I have the program. Look later.
But As far I remember I use not the same pin as an input and output. But ok If there is a bug in the simulation and It not can be
fixed, I have to be advare and accept it. Thank` S Martin.
Br Jorgen.
Thank you for looking at it. At the moment I am not on my laptop where I have the program. Look later.
But As far I remember I use not the same pin as an input and output. But ok If there is a bug in the simulation and It not can be
fixed, I have to be advare and accept it. Thank` S Martin.
Br Jorgen.
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Loop and component Timer/counter!
Hi Jorgen,
You're welcome.
So not a bug, just the way simulation works
You're welcome.
The input is using pin B0 & the output is set for the whole of portB, which will include B0jgu1 wrote:But As far I remember I use not the same pin as an input and output.
This was the post I had remembered.medelec35 wrote:Edit. I remember with simulation in the past, that inputs and outputs on the same pin don't work as expected.
Should be fine with hardware.
So I believe this issue is known about?
So not a bug, just the way simulation works
Martin
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Loop and component Timer/counter!
Hi Martin!
Ok If I have done this, I apologize.
I Will check when I am home.
Thank`s Martin you hear.
Br Jorgen.
Ok If I have done this, I apologize.
I Will check when I am home.
Thank`s Martin you hear.
Br Jorgen.
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Loop and component Timer/counter!
Hi Martin!
Yes, you are rigth, apologize. and of course, it is maybe not a good idea to switch a port to zero, when I use one of the pin from same port as an input also…….... my fault. we learn every day.
I try to change from hole port to B4 and B5 to zero, but still unstable in simulation. I have also testet your program (masking, good idea) The simulation
work better, but still litte unstable. So maybe there are a bug in simulation concerning updating in/output.
Ok we live with that,but would be nice, just that it work in real world.
Thank´s again Martin.
Br Jorgen
Yes, you are rigth, apologize. and of course, it is maybe not a good idea to switch a port to zero, when I use one of the pin from same port as an input also…….... my fault. we learn every day.
I try to change from hole port to B4 and B5 to zero, but still unstable in simulation. I have also testet your program (masking, good idea) The simulation
work better, but still litte unstable. So maybe there are a bug in simulation concerning updating in/output.
Ok we live with that,but would be nice, just that it work in real world.
Thank´s again Martin.
Br Jorgen