Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 21:59 18 Apr 2024 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 : Pause command rounding ARM 7 / CMM2

     Page 1 of 2    
Author Message
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1345
Posted: 04:25am 08 Jun 2021
Copy link to clipboard 
Print this post

I'm sure this has been answered before but can't find the answer.

I'm having trouble with the Pause command rounding, but only past 1ms, hoping I'm not suffering from another Seniors moment (or worse)

It means that I can't use the Pause command for accurate part millisecond.

Pause 2ms = 2ms and Pause 2.5 = 3ms, but fractional pauses below 1ms are not rounded?

I'm sure I'm missing something obvious!


Dim float X,Y
CLS
Print , " Delay","Timer"
Print
For X=0 To 4 Step .25
  Timer =0 : Pause X : Y=Timer
  Print , Str$(X,2,2," "), Str$(Y,3,2," ")
  Pause 10
Next




ARM7 5.07.00b12   - No Loop Delay (Pause 10ms)

Delay Timer

0.00  0.01
0.25  0.26
0.50  0.51
0.75  0.76

1.00  1.01
1.25  1.26
1.50  1.14
1.75  1.60

2.00  1.60
2.25  1.60
2.50  2.60
2.75  2.60

3.00  2.60
3.25  2.60
3.50  3.60
3.75  3.60

4.00  3.60



Delay   Timer  ----- With 10ms Loop delay

0.00  0.01
0.25  0.26
0.50  0.51
0.75  0.76

1.00  1.01
1.25  1.26
1.50  2.00
1.75  2.00

2.00  2.00
2.25  2.00
2.50  3.00
2.75  3.00

3.00  3.00
3.25  3.00
3.50  4.00
3.75  4.00

4.00  4.00

Edited 2021-06-08 18:41 by KeepIS
It's all too hard.
Mike.
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1345
Posted: 10:33pm 08 Jun 2021
Copy link to clipboard 
Print this post

Latest release Firmware update ArmmiteH7V5.07.00b13

The Pause command partly fixed. It runs correctly randomly but most often the results jump around with varying Pause delays been ok then incorrect'

Pause for 0 to 1.5ms seem to be ok on every run.      

Screen copy of result with new Firmware.
 

BAUD RATE 115200
FILE Timer.bas
LENGTH 182

Elapsed Time = 0.016958 Seconds

FINISHED sending the FILE to the device

Waiting for Save Response

Received Save Response
Saved

File..Send time 0.017946 seconds
Device Save time 5.482345 seconds

RUN                    RUN

Delay Timer       Delay Timer

0.00  0.01       0.00  0.01
0.25  0.26       0.25  0.26
0.50  0.51       0.50  0.51
0.75  0.76       0.75  0.76

1.00  1.01       1.00  1.01
1.25  1.26       1.25  1.26
1.50  1.51       1.50  1.51
1.75  1.76       1.75  2.76  **

2.00  2.01       2.00  2.01
2.25  2.26       2.25  2.26
2.50  2.51       2.50  2.51
2.75  2.76       2.75  3.76  **

3.00  4.01  **   3.00  3.01
3.25  4.26  **   3.25  3.26
3.50  3.51       3.50  3.51
3.75  4.76  **   3.75  4.76  **

4.00  5.01  **   4.00  5.01  **
>

Edited 2021-06-09 08:39 by KeepIS
It's all too hard.
Mike.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8566
Posted: 06:53am 09 Jun 2021
Copy link to clipboard 
Print this post

Please try attached


ArmmiteH7V5.07.00b13.zip
Edited 2021-06-09 17:33 by matherp
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1345
Posted: 07:47am 09 Jun 2021
Copy link to clipboard 
Print this post

Thank you again, that is perfect now.    
It's all too hard.
Mike.
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1345
Posted: 08:08am 09 Jun 2021
Copy link to clipboard 
Print this post

I think I spoke to soon, there is another problem.

The pause command now causes the device to APPEAR to lock up, no ctrl-C, no response to any touch, the only to get it to go is to reset, however If you leave it for a period, it runs then stops, the sequence repeats. I think this might have been in the previous Firmware as I spent some time trying to find out why an Auto timing procedure I wrote would randomly lock and run as described above.        


Dim float X,Y
Do
  CLS
  For X=0 To 5 Step .25
    Timer =0 : Pause X : Y=Timer
    Print , Str$(X,2,2," "), Str$(Y,3,2," ")
    Pause 4.2
  Next
Loop


Mike
.
Edited 2021-06-09 18:08 by KeepIS
It's all too hard.
Mike.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8566
Posted: 08:08am 09 Jun 2021
Copy link to clipboard 
Print this post

The problem occurred with a USB keyboard plugged in - I tested the previous version without
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1345
Posted: 08:10am 09 Jun 2021
Copy link to clipboard 
Print this post

Just in case you missed it, I posted another problem a fraction of a second before your last post

Mike
Edited 2021-06-09 18:21 by KeepIS
It's all too hard.
Mike.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8566
Posted: 02:22pm 09 Jun 2021
Copy link to clipboard 
Print this post

Please try again - this one is proving extremely difficult


ArmmiteH7V5.07.00b13.zip
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1345
Posted: 11:52pm 09 Jun 2021
Copy link to clipboard 
Print this post

Unfortunately it's virtually the same, runs through the loop a few times then the PAUSE command decides to pause for around 10 to 20 seconds, comes back to life, does a few more loops and halts again for 10-20 sec and on and on it goes.

The effect on the main program is that it randomly freezes for 10 to 20 seconds, but always comes back to life, responds and the cycle repeats.

Of course all interrupt's are disabled during the Pause period giving the appearance of a locked or hung device.

UPDATE When paused, the Timer command is also paused, I can't remember if this is the normal case with the Pause command, just thought I'd mention it.    


PAUSE delay: Halt execution of the running program for 'delay' ms.
Note that interrupts will be recognised and processed during a pause.


This is not the case here, all interrupts appear to be disabled, no Touch, no Keyboard, no serial Console, no Timer update.

The code shows that the Pause error is really random inside the For Next loop.


Dim float X,Y
Dim integer CT
CLS
CT=0
Do
  Timer =0
  For X=0 To 20 Step .25
    Timer =0 : Pause X : Y=Timer
    Text 20,20,Str$(X,2,2," ")
    Text 20,80,Str$(Y,2,2," ")
  Next
  CLS
  Inc CT
  Text 20,140,"Count"+Str$(CT,4,0," ")+Str$(Timer,10,2," ")
  Pause 1000
Loop

The counts returned after each Long Pause delay:

4
8
21
28
85
87

The Timer value is always 39.52


Mike
.
Edited 2021-06-10 11:28 by KeepIS
It's all too hard.
Mike.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8566
Posted: 06:55am 10 Jun 2021
Copy link to clipboard 
Print this post

I've been doing the testing on the CMM2 which had the same issue and seems to be fixed. I'm not going to have a chance to look at this further until later next week so I suggest going back to the original which had the accurate pauses below 1.5mSec and rounding after. The basic algorithm is blocking for up to 1.5mSec after that it allows MMBasic interrupts to be processed during the pause which is why there is a difference. The problems seems to lie in some sort of race condition where a timer overflows so the test for >= no longer works.
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1345
Posted: 08:11am 10 Jun 2021
Copy link to clipboard 
Print this post

Thanks, I've already gone back to the version that didn't block like this, so no problems at all, hope you can find a solution but my workaround is working just fine without one.

Mike
.
It's all too hard.
Mike.
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1345
Posted: 04:09am 11 Jun 2021
Copy link to clipboard 
Print this post

Just playing with another workaround of the Pause command until there is a solution, but this only works if you have a spare IO pin.  

The Current Pause command is only good to 1.5ms, the various timing delays I require to calibrate Dual position Sensors and associated Clock read & display procedure are around 0.3ms to 5ms, instead of using multiple successive < 1.5ms Pause commands, I tried using the Pulse command. This command is blocking below 3ms, so it acts like the Pause command but not quite as consistent in timing, most of the time the delay value I require is zero unless it's running on an ARM @ > 480Mhz (auto calculated delay for the device in setup menu), and it only changes again when the position display code is in one of 3 states. I need to keep the procedure execution time (which includes the two sensor Display code) the same in all states to maintain accurate "LO clock period" packet delimiter reset times, and constant position read times when fast automation (2 axis positioning) is running. The Pulse variation is around 15us with a this simple code over 1 or 4 delay loops, which is perfect for this situation as the LO clock period must be a minimum of 3.5ms +- 300us and procedure timing needs to be +- 50us. Dtime is the delay time and is adjusted at the start of the procedure, one of the few spare pins I have on the ARM-H72 board is pin 55 which has been initialised to data out.          
 

Local Float Dtime

'code not shown adjusts Dtime

 Do While Dtime>2.8  
   Pulse 55,2.8
   Dtime=Dtime-2.8
 loop  
 Pulse 55,Dtime


Mike
.
Edited 2021-06-12 08:25 by KeepIS
It's all too hard.
Mike.
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1345
Posted: 04:57am 12 Jun 2021
Copy link to clipboard 
Print this post

Like the code in my last post, this is running the last posted firmware with pronounced random long delays when using the Pause command with repeated delays past 1.5 ms.

Had a though and tried the following code:

The Pulse command, with P-Width above it's blocking point, has similar rounding errors like the Pause command used to have in the earlier version of this FM, and does not suffer any a long hang time like the Pause does, and is good to almost 3 ms, as it currently can't always be relied on right at 3ms.


Dim float X,Y,Dtime
SetPin 55,Dout
CLS

Do
 Timer=0
 For X=0 To 5 Step .25
  Pin(55)=0 : Timer=0
  Pulse 55,X
   Do While Pin(55)=1 : loop
   Y=Timer
   Print , Str$(X,2,2," "), Str$(Y,3,2," ")
 Next

 Dtime=3000 'delay 3s
 Do While Dtime>2.8  
   Pulse 55,2.8 : Dtime=Dtime-2.8
 loop
 Pulse 55,Dtime : CLS
Loop

Run
  X    Timer
 0.00  0.01
 0.25  0.27
 0.50  0.52
 0.75  0.76
 1.00  1.01
 1.25  1.27
 1.50  1.51
 1.75  1.77
 2.00  2.02
 2.25  2.27
 2.50  2.52
 2.75  2.77
 3.00  2.15
 3.25  2.67
 3.50  2.67
 3.75  2.67
 4.00  3.67
 4.25  3.67
 4.50  3.67
 4.75  3.67
 5.00  4.67

 Viewed on A DSO with delays of 50ms between each X steps confirms the problem.


Using this code and a DSO confirmed the rounding condition


 Pulse 55,4.3

 100Mhz DSO Trigger set to Single Shot:

 Repeatable perfect sample @ 3.08ms



Mike
.
Edited 2021-06-12 14:57 by KeepIS
It's all too hard.
Mike.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8566
Posted: 07:33am 12 Jun 2021
Copy link to clipboard 
Print this post

Have you played with the bitbang command?
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1345
Posted: 08:19am 12 Jun 2021
Copy link to clipboard 
Print this post

Dam, I forgot all about that, if I get a chance tomorrow I'll certainly do that.

In passing, I must say that by utilising the resolution below 2.8ms and the Pulse command, I now have the best fine timing control I've ever seen on the ARM-H7 for this critical automated timing sequence, finally not pulling my hair out chasing my tail.
It's all too hard.
Mike.
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1345
Posted: 11:17pm 12 Jun 2021
Copy link to clipboard 
Print this post

Can't try it, Bitbang was not added to the ARM-H7 upgrade, looks like CMM2 only command. I may have to drag out my CMM2 when I get a chance and try it there just out of interest.

Mike
Edited 2021-06-13 09:19 by KeepIS
It's all too hard.
Mike.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8566
Posted: 10:47am 13 Jun 2021
Copy link to clipboard 
Print this post

Be great if you could try pause on the CMM2 since I think I've fixed it on that version
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1345
Posted: 01:34am 14 Jun 2021
Copy link to clipboard 
Print this post

The Pause command now runs perfectly on the CMM2 with CMM2V5.07.00RC2 14-06-2021.
It's all too hard.
Mike.
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1345
Posted: 11:43pm 14 Jun 2021
Copy link to clipboard 
Print this post

Timing results using bitbang command as a temporary pause replacement.


Dim float Y,Z
Dim float A(3)
CLS
SetPin 32,DOUT

For Z=0 to 5 Step 0.25
  A(0)=Z*500 : A(1)=Z*500
  Timer=0
  Bitbang Bitstream 32,2,A()
  Y=Timer
  Print , Str$(Z,2,2," "), Str$(Y,3,2," ")
Next


 Z   Timer
0.00  0.01
0.25  0.26
0.50  0.51
0.75  0.76
1.00  1.01
1.25  1.26
1.50  1.51
1.75  1.76
2.00  2.01
2.25  2.26
2.50  2.51
2.75  2.76
3.00  3.01
3.25  3.26
3.50  3.51
3.75  3.76
4.00  4.01
4.25  4.26
4.50  4.51
4.75  4.76
5.00  5.01


Edited 2021-06-15 11:35 by KeepIS
It's all too hard.
Mike.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3008
Posted: 12:01pm 15 Jun 2021
Copy link to clipboard 
Print this post

  KeepIS said  Timing results using bitbang command as a temporary pause replacement.

Thank you for this. Now to try to understand it.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
     Page 1 of 2    
Print this page
© JAQ Software 2024