I am having trouble understanding how to achieve something seemingly simple. Can someone please help with some guidance on how to do the timing logic in the following:
User selects a time in minute
Time is split into 8 discreet units
At the beginning of each discreet unit a variable is set
Or
User selects a time in minutes
A variable is set
Wait 1/8th of total time
Repeat
The two flows above seem simple but I can not get the concept working.
Please provide a more detailed explanation of what you are trying to achieve,
what you have done so far, what works, what doesn’t work…
Please show your relevant blocks,
if relevant, your data or lists,
screenshots of the Designer screen or app in action,
so we can see what you are trying to do…
Right Click in Blocks Editor and select “Download Blocks as Image”
for the best image of your blocks.
This sounds like an application for a Clock Timer and a global list.
At Screen1.Initialize time, set the Clock to disabled.
When you get the time interval, change it
to milliseconds using math and maybe Clock blocks, then divide it by 8,
then store the result in the Clock Interval property.
Set a global variable EVENTS to create empty list,
then set Clock1 to enabled and repeating.
In Clock1.Timer, add item to EVENTS:
make list(Clock1.SystemTime, whatever you want to log)
If length of list(EVENTS) >= 8 then disable Clock1.
thank you for your input, I will put some time aside this evening to looking at the lists idea. its a concept I haven’t explored - will see how I get on. Thanks again
Hello, yes on second reading my post/question was not very useful.
I took some time today put together another program that dealt specifically with the timing Im having issues with, in the below program I have only 3 periods but the logic would be the same.
In the below code the idea is to pick a time, split that time into 3 periods then do various other events in those periods (using the default 1000ms timing)
the global timer works fine and ticks down to zero, the first condition in the if sequence is met and the LED flashes however the 2 other period conditions are never met (i.e. LED2 and 3 never flash. I hope the following is better in explaining what I am trying to do.
If your events will complete between clock timer firings, then use a counter, and increment it on each firing. Then use the if/else block to test for the counter value and action the designated event:
Counter = 0
Clock fires
Add 1 to counter
If Counter = 1 then do event 1
Clock fires
Add 1 to counter
If Counter = 2 then do event 2
Why do you need two clocks?
If you define your time period (e.g. 1 minute (60000ms) which is then divided by 3 - 20000ms)
You only need one clock to fire every 20000ms
Unless of course the countdown clock is for visual purposes for the user ?
this started as an attempt to make a rubiks timer, but has since become about just getting the program i have functioning, If I may; can you see any reason in my code why periods two and three never resolve true? i.e. why LED1 blinks for one minute but nothing else happens during that time. I’m feeling somewhat apologetic at this point
Possibly because condition 1 is always satisfied, therefore things never move on to the other conditions. The way around this is to use separate if/then statements for each condition. I have expanded my original example to demonstrate this (with a second clock!)