Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:05 12 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : What happens in "Pause"

Author Message
PhilTilson
Newbie

Joined: 15/11/2015
Location: United Kingdom
Posts: 35
Posted: 06:38pm 20 Oct 2018
Copy link to clipboard 
Print this post

Hi -

Fairly new to MM so forgive what may seem a naive question.

In VB, there is a command DOEVENTS which will process other things while waiting for something (like a display update) to happen.

In MMBasic, if I use the PAUSE command, does processing just stop (apart from hardware interrupts) or can other things occur?

The question arises because I am writing a controller interface that shows circulation of water as an 'ant trail' using a custom font and pausing 200mS between rewriting the string to give the 'movement'. Am I just blocking the system from doing anything else while this is displaying, or what?

If so, I'm sure there's an obvious workaround, but I haven't yet discovered what it is!
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 07:00pm 20 Oct 2018
Copy link to clipboard 
Print this post

Easiest is to 'simulate' a pause.
You can do that by using a state machine and check the timer value.

Microblocks. Build with logic.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10572
Posted: 07:01pm 20 Oct 2018
Copy link to clipboard 
Print this post

During pause MMbasic will process Ctrl-C, buffer UART I/O, Process GUI events, keep the clock running, process FIN, CIN, COUNT, check for pin interrupts, keep PWM running - basically everything except process inline Basic statementsEdited by matherp 2018-10-22
 
PhilTilson
Newbie

Joined: 15/11/2015
Location: United Kingdom
Posts: 35
Posted: 09:37pm 20 Oct 2018
Copy link to clipboard 
Print this post

Thanks for the information above. I was hoping that there would be a way of accessing something like a timer interrupt, such as is available in the basic chip architecture, but it seems there isn't.
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1671
Posted: 10:08pm 20 Oct 2018
Copy link to clipboard 
Print this post

Hi Phil,

I don't understand why are you not using a SUB as Microblocks suggests?

Print Timer
my_pause(500)
Print Timer
end

Sub my_pause(duration As integer)
Local t=Timer+duration
Do While Timer<t
Loop
End Sub


Regards
Michael
causality ≠ correlation ≠ coincidence
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 1044
Posted: 10:57pm 20 Oct 2018
Copy link to clipboard 
Print this post

Have a look here to see settick used to simulate a background process.

pipeflow

Regards
Gerry
F4 H7FotSF4xGT
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 06:42am 21 Oct 2018
Copy link to clipboard 
Print this post

You can also very easily create a pause that doesn't pause.

do
' do something here
PauseEnd=timer+interval
BeginPausedStuff
EndPausedStuff
'do something else here
loop

Sub BeginPausedStuff
' start the paused routine
EndSub 'BeginPausedStuff

Sub EndPausedStuff
if timer>PauseEnd then
' wrap up the paused routine
endif
EndSub 'EndPausedStuff

The loop will continue cycling doing other things until the timer exceeds PauseEnd at which time the pause termination code will run.

Paul in NY
 
PhilTilson
Newbie

Joined: 15/11/2015
Location: United Kingdom
Posts: 35
Posted: 09:31am 21 Oct 2018
Copy link to clipboard 
Print this post

Again, my thanks for the prompt responses, which I shall now study!

The link that Gerry provided looks particularly interesting, but is going to take a little while to work through!
 
PhilTilson
Newbie

Joined: 15/11/2015
Location: United Kingdom
Posts: 35
Posted: 09:44am 21 Oct 2018
Copy link to clipboard 
Print this post

As I said at the very beginning, MMbasic is fairly new ground for me, and I had not appreciated the availability of SETTICK, which would seem to be the ideal solution to my problem!

MMbasic is fairly unusual in 'free' software in that the documentation is very comprehensive, which is an excellent feature. However, it also means there is a lot to remember when you get stuck into it for the first time!

 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2171
Posted: 04:17pm 21 Oct 2018
Copy link to clipboard 
Print this post

I wrote some timer handling routines that work with a state machine (they set flags when events occur) so you can pick them up nicely from a main loop - it also provides 10 timer events (instead of four and is easily expandable if you need more) and has both one-shot and continuous timers. You can stop a timer and disable then all temporarily and then re-enable them.

http://fruitoftheshed.com/MMBasic.Edit.aspx?Page=MMBasic.AFTER-EVERY-REMAIN-Flexible-State-Machine-Timers-using-Semaphor es

Just about every project, I use SM methodology because it just makes the code so easy to write and debug. I use an array of flags (upto 64 of them) in most of my code - the main loop then only has to check for a flag being set to trigger some activity. It really easily de-couples the various tasks within your code from the main thread, so you end up with code flow like

Main:
Do
If FlagTest(myflag) Then DoMySub
...
Loop

Edited by CaptainBoing 2018-10-23
 
PhilTilson
Newbie

Joined: 15/11/2015
Location: United Kingdom
Posts: 35
Posted: 11:48am 02 Nov 2018
Copy link to clipboard 
Print this post

Following the help received previously, I have now achieved the desired result in my water circulation modelling!

I adapted Capt Boing's timer routines but used a different strategy from that shown in the example given by Gerry (above).

This shows a (rather poor) image from the panel:



or you can see the animation itself on this link: Animation

In an effort to reduce processor time and storage, I elected to create a new font, using FontTweak. Each symbol has up to three variants showing the chevrons in different positions. The program then 'prints' the characters to the screen every 200mS resulting in the display shown.

I haven't yet analysed the actual processor load, but my impression is that it is light. The font and the timer routines take up just 8% of the Library space which should leave me plenty for the remainder of the program!
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2171
Posted: 12:47pm 02 Nov 2018
Copy link to clipboard 
Print this post

the animation link doesn't work for me. repost?
 
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 12:52pm 02 Nov 2018
Copy link to clipboard 
Print this post

Very interesting and nice work. I'd like to see more. The animation link does not go to the animation, but to an upload channel.
We're all here 'cause we're not all there.
 
PhilTilson
Newbie

Joined: 15/11/2015
Location: United Kingdom
Posts: 35
Posted: 02:38pm 02 Nov 2018
Copy link to clipboard 
Print this post

Sorry about the link - try this one!
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3308
Posted: 03:04pm 02 Nov 2018
Copy link to clipboard 
Print this post

Neat animation.
Geoff Graham - http://geoffg.net
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2171
Posted: 10:10pm 02 Nov 2018
Copy link to clipboard 
Print this post

nice work!
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025