It is currently 15 Oct 2018 20:05

All times are UTC + 1 hour




Post new topic Reply to topic  [ 75 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
PostPosted: 29 Nov 2010 14:20 
Offline

Joined: 18 Feb 2006 13:17
Posts: 4978
sem wrote:
Ok... I would like to know how to use the "unofficial" unit of mikropascal pro.
I had unzipped and copy to the P18 folder.
Now , i use in a "uses" part, " uses __Lib_Conversions,__Lib_MathDouble, fpmath;"
I can see the new functions in the library manager, but there is not the MATH functions in the library7 manager.
Why? Where i can found int, trunc, round functions ?
Thanks, Sem

You only need to include the FPmath lib in a uses clause. You'll have access to all it's routines, even if you do not see them in Library Manager. All other libs are replacements, so they're known to compiler and governed by Library Manager.

To have the FPmath lib treated in the same way, i.e. visible in Library Manager, you'd have to modify the .mlk file of the processor you use. It's described in Help, but I'll try to make it easier for you.

Find in mP installation directory a subdirectory called Defs. There you'll find the .mlk file of your processor. Lets assume you use PIC18F4620. It's file is called P18F4620.mlk. Open it in simple text editor, like Notepad, and you'll see the details of processor description. Search for LIBRARIES. Every lib appropriate for this processor is listed with it's filename, alias and category (SYSTEM or REGULAR). All you need to do is to add the following
      <LIB>
         <ALIAS>FP_math</ALIAS>
         <FILE>fpmath</FILE>
         <TYPE>REGULAR</TYPE>
      </LIB>
to the file (best at the end of libs list, just before </LIBRARIES>). After such modification you won't need to add FPmath to uses clause - checking it in Library Manager will be enough.

_________________
Replacement libraries for mP PRO and PIC18 processors, mP PRO tips & trics


Top
 Profile  
 
PostPosted: 30 Nov 2010 15:03 
Offline

Joined: 27 May 2009 11:08
Posts: 12
WONDERFULL !!!
Thanks Janni. :D


Top
 Profile  
 
PostPosted: 01 Dec 2010 00:47 
Offline

Joined: 18 Feb 2006 13:17
Posts: 4978
Conversions lib has been updated (v 1.08) as Dany noticed that space was added instead of zero in some ...2StrWithZeroes routines. The whole package of replacement libs is available as before here, but it's enough to replace just the __Lib_Conversions.mcl file.

_________________
Replacement libraries for mP PRO and PIC18 processors, mP PRO tips & trics


Top
 Profile  
 
PostPosted: 10 May 2011 18:34 
Offline

Joined: 18 Feb 2006 13:17
Posts: 4978
The replacement libs are being updated continually, but I didn't have time to write about it :( . There's more of them now and I had some time to prepare a web page about them (among other things). Please look for details there.

_________________
Replacement libraries for mP PRO and PIC18 processors, mP PRO tips & trics


Top
 Profile  
 
PostPosted: 10 May 2011 19:41 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3764
Location: Nieuwpoort, Belgium
janni wrote:
The replacement libs are being updated continually, but I didn't have time to write about it :( . There's more of them now and I had some time to prepare a web page about them (among other things). Please look for details there.
Thanks Janni for the new version of your libraries.
The website looks great! Lots of usefull info.
The addition of Quirks, Tips and Tricks and Assembly Syntax will be very usefull I think. That kind of documentation is something we miss already for a long time! :D :D

_________________
Kind regards, Dany.
There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
PostPosted: 02 Jul 2011 16:57 
Offline

Joined: 18 Feb 2006 13:17
Posts: 4978
New release of the replacement libs, following the release of mP PRO v5.00, is ready for download.

_________________
Replacement libraries for mP PRO and PIC18 processors, mP PRO tips & trics


Top
 Profile  
 
PostPosted: 21 Jan 2012 16:38 
Offline

Joined: 18 Feb 2006 13:17
Posts: 4978
Delays lib has been updated. I've forgotten to update it when Math library replacement was added :( . As the Math library replacement procedures are more efficient, delay procedures needed adjustments. But now they're even more accurate and less clock frequency dependent than before.
When using the Delays lib replacement with Math lib replacement, please remember to uncomment respective DEFINE directive in __Lib_Delays.ppas (or __Lib_Delays.pbas).

Here's a comparison of VDelay_ms procedure accuracy:
                    VDelay_ms(1)              VDelay_ms(1000)
                  mE lib     this lib        mE lib     this lib
osc. freq.[MHz]       delay [us]                 delay [ms]
    2             1136        1004           1000.52     1000.01
    4              968        1006           1000.26     1000.00
    6              997        1001           1000.17     1000.00
    8              996        1003           1000.13     1000.00
   10             1008        1000            985.02     1000.00
   12             1016        1002            977.85     1000.00
   16             1018        1001            955.48     1000.00
   20             1019        1001            945.64     1000.00
   32             1024        1001            930.87     1000.00
   48             1018        1000            922.66     1000.00
   
                          4MHz clock
                VDelay_ms         mE lib    this lib
                parameter            delay [ms]
                    1              0.968      1.006
                   10             10.213     10.005
                   50             50.221     50.005
                  100            100.234    100.005
                  500            500.258    500.005
                10000           1000.258   1000.002

("this lib" means Delays lib replacement used together with Math lib replacement)
For most applications accuracy of VDelay_ms and VDelay_Advanced_ms should now be good enough without the need to resort to the exact inline procedure Delay_ms.

A new procedure has been added, namely VDelay_us, allowing to obtain variable delays in sub-millisecond range (from clock-dependent minimum up to 1024us). It's been written in assembly, but it still has some limitations. Real 1us resolution and accuracy may be achieved only with clock frequencies in excess of 16MHz.
VDelay_us limitations:
      - minimum clock frquency: 1MHz
      - maximum clock frquency: 48MHz
      - minimum delay & resolution depend on clock frequency, for example:
        clock   min. delay  resolution  error (Time_us-delay)
         4MHz     60us         4us       0,1,2 or 3us
         8MHz     30us         2us       0 or 1us
        12MHz     20us         1us       <+/-1us
        16MHz     15us         1us       0
        32MHz      8us         1us       0
        48MHz      5us         1us       0
      - due to compiler optimisation, delays for zero parameter are shorter
        than minimal by half of resolution (two asm instructions).


Always keep in mind that servicing active interrupts will lenghten software delay.

_________________
Replacement libraries for mP PRO and PIC18 processors, mP PRO tips & trics


Top
 Profile  
 
PostPosted: 21 Jan 2012 18:17 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3764
Location: Nieuwpoort, Belgium
Thanks! :D :D

_________________
Kind regards, Dany.
There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
PostPosted: 02 Jul 2012 19:07 
Offline

Joined: 18 Feb 2006 13:17
Posts: 4978
An error in Conversions lib replacement (when used with my version of MathDouble lib) was found (thanks Dany :) ). Float2str procedure produced wrong output strings in some cases. Though one may then use more efficient Real2str instead, Float2str should work as well, so the lib was updated and may be downloaded from the usual place.

_________________
Replacement libraries for mP PRO and PIC18 processors, mP PRO tips & trics


Top
 Profile  
 
PostPosted: 14 Jul 2013 10:14 
Offline

Joined: 12 May 2007 13:01
Posts: 171
Location: Bristol, UK
Replacement Libraries "Bad absolute address 'nn'" and "Unsuccessful linking"

mP PRO V5.6.1 janni's Replacement Libraries: latest version for mP PRO 5.01 and newer (880kB, 02.07.2012) and PIC18F87K22.

Uses: uGLCDlib, uGLCD_ST7528 and RAMscr function which statistics reports is using 2080 bytes.

I have replaced the following mE libraries with the Replacement Libraries:

__Lib_Conversions       2012/07/02  07:17PM
__Lib_Delays            2012/01/22  08:27PM
__Lib_EEPROM_256        2011/07/02  03:04AM
__Lib_EEPROM_1024       2011/07/02  03:04AM
__Lib_Math_exc          2011/07/02  01:54AM
__Lib_MathDouble_exc    2011/07/02  02:02AM
__Lib_String            2012/07/02  07:17PM
__Lib_Trigon            2012/02/03  10:20PM
__Lib_Trigonometry      2012/02/03  10:20PM

Compiles with ME Libraries:

0 1144 Used RAM (bytes): 3400  (89%)  Free RAM (bytes): 441   (11%) Used RAM (bytes): 3400  (89%)  Free RAM (bytes): 441   (11%)
0 1144 Used ROM (bytes): 91509 (70%)  Free ROM (bytes): 39563 (30%) Used ROM (bytes): 91509 (70%)  Free ROM (bytes): 39563 (30%)
0 103 Finished successfully: 14 Jul 2013, 08:39:41 EMA_V0_L.mpppi

Compiling with the Replacement Libraries:

0  134 Compiled Successfully C:\Program Files\Mikroelektronika\mikroPascal PRO for PIC\Projects\EMA\EMA_V0_L.mpas
0  139 All files Compiled in 4609 ms 
69 363 Bad absolute address 'nn' __Lib_Trigonometry.mpas
69 363 Bad absolute address 'nn' __Lib_Trigonometry.mpas
0  453 Unsuccessful linking 'EMA_V0_L.mpppi' Unsuccessful linking 'EMA_V0_L.mpppi'
0  102 Finished (with errors): 14 Jul 2013, 09:52:27 EMA_V0_L.mpppi

Additional info: I can successfully compile another project with the Replacement Libraries. This project however does not use FP or Trig functions and the processor is a PIC18F46K22.


Top
 Profile  
 
PostPosted: 14 Jul 2013 13:41 
Offline

Joined: 18 Feb 2006 13:17
Posts: 4978
Malcolm_M wrote:
Additional info: I can successfully compile another project with the Replacement Libraries. This project however does not use FP or Trig functions and the processor is a PIC18F46K22.
Indeed. Looks like a compiler quirk (or inadequately prepared *.mlk files) showing up for processors that have no gaps in SFR space. Such gaps are declared in processor *.mlk file as BADRAM - when there's no gap, compiler interprets empty declaration
<!-- badram limitations -->
   <BADRAM>
      <MIN_ADDR></MIN_ADDR>
      <MAX_ADDR></MAX_ADDR>
   </BADRAM>
as a forbidden memory cell at address 0 (which, obviously, makes no sense as internal registers start at this address in PIC18s).

At the moment, only solution is to remove empty BADRAM declaration from *.mlk file (or never use absolute address 0 in code, but this would reduce efficiency of math libs replacements). Without empty BADRAM declaration compiler makes no assumptions, and there's no forbidden RAM cells.

You may delete the empty declaration yourself or use the P18F67K22.mlk file attached.


Attachments:
File comment: corrected PIC18F87K22 mlk file
P18F87K22.rar [4.1 KiB]
Downloaded 132 times

_________________
Replacement libraries for mP PRO and PIC18 processors, mP PRO tips & trics


Last edited by janni on 14 Jul 2013 14:11, edited 1 time in total.
Top
 Profile  
 
PostPosted: 14 Jul 2013 14:11 
Offline

Joined: 12 May 2007 13:01
Posts: 171
Location: Bristol, UK
Many thanks janni :D Now compiles, the reduction in ROM used is 4746 and RAM used is 11 :D


Top
 Profile  
 
PostPosted: 14 Jul 2013 14:22 
Offline

Joined: 18 Feb 2006 13:17
Posts: 4978
Malcolm_M wrote:
...the reduction in ROM used is 4746 and RAM used is 11 :D
Yeah, that's one of advantages of libs replacements :) .

Just to remind you, when one uses the math lib replacements with exception mechanism, it's important to call Clear_FPstatus at code beginning.

_________________
Replacement libraries for mP PRO and PIC18 processors, mP PRO tips & trics


Top
 Profile  
 
PostPosted: 14 Jul 2013 15:45 
Offline

Joined: 12 May 2007 13:01
Posts: 171
Location: Bristol, UK
janni wrote:
Just to remind you, when one uses the math lib replacements with exception mechanism, it's important to call Clear_FPstatus at code beginning.

Thanks janni I had picked this up when reading your library PDFs but had forgotten to un-comment it for compiling with the mE libraries :shock:

The reduction in ROM used is a bonus but I am interested to see if your corrected errors in atan2 function, solve inaccuracies I am getting in the ‘haversine’ formula I am using to calculate the great-circle distance between two points if the distance is less than 100km. At present I have two procedures: > 100km uses haversine and <= 100km uses Pythagoras (assume earth is flat over shorter distances - membership of the flat earth society pending :lol: ).

Tomorrow I will go to the local Copy Shop and get your PDF's printed and bound so I can study them in detail. I find a paper copy useful as things can be highlighted and notes made in the margins.


Top
 Profile  
 
PostPosted: 14 Jul 2013 17:36 
Offline

Joined: 18 Feb 2006 13:17
Posts: 4978
Errors are removed and calculations accuracy should not be a problem compared to (in)accuracy of commonly used average Earth radius estimate :) .

_________________
Replacement libraries for mP PRO and PIC18 processors, mP PRO tips & trics


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 75 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: