Replacement libraries - updated to v 1.12

General discussion on mikroBasic PRO for PIC.
Author
Message
janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Replacement libraries - updated to v 1.12

#1 Post by janni » 08 Jul 2014 23:42

The replacement libs are being updated continually and there's a web page about them (among other things). Please look for news there or at Libstock.
_____________________________________________________________________

I realized that I never properly presented my replacement libraries in mB forum although they work equally well with mB as with mP, for which they were prepared. As their installation is now easy with help of a PC program (that also allows to switch at any moment between the official libs and the replacement ones) and there's even documentation for Basic, it'd be a pity not to inform about it anyone searching for opportunity to optimize code or ease programming effort with expanded libraries. So here it goes.


Replacement libs form a group of libraries that may replace official mE libraries to decrease final code size and RAM use, increase speed of code execution and fix some quirks. Most of replacement libraries also add new functionality. There are two kinds of libraries being replaced: the system libs that are invisible to the user, like System and basic math libraries, and fully accessible libraries that may be found in Library Manager, like Conversions, String, or math functions libraries. Effectively, the replacement libs cover the most substantial areas of coding and improve performance of other libraries that use the replaced ones.

A PC program, called LibsSwitch, allows for painless installation of the replacement libraries, as well as for easy switching between them and the official ones. Therefore anyone may compare efficiency of both sets of libraries with little effort and no risk of irrevocable changes to compiler functionality.

Available replacement libraries

- Delays library (__Lib_Delays)
- Strings library (__Lib_String)
- Conversions library (__Lib_Conversions)
- C_Stdlib library (__Lib_CStdlib)
- Internal EEPROM library (__Lib_EEPROM_256 and __Lib_EEPROM_1024)
- System library (__Lib_System)
- Fixed-point math library (__Lib_Math - two versions)
- Floating-point math library (__Lib_MathDouble - two versions)
- Floating-point functions library (__Lib_Trigon)
- Trigonometric functions library (__Lib_Trigonometry)

do not necessarily have to be used together, but most are interdependent. Fortunately, one does not have to worry about it as choosing desired configuration is easy with the LibsSwich program which takes care of libraries dependency
LibsSwitch_004.png
LibsSwitch_004.png (11.46 KiB) Viewed 7101 times
More detailed information about particular replacement libraries may be found here, and for those that do not need more info, here's the direct download link to the whole bundle.
Last edited by janni on 31 Oct 2019 22:06, edited 10 times in total.

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: Replacement libraries for PIC18 processors

#2 Post by Dany » 09 Jul 2014 12:54

Thanks! :D :D
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Replacement libraries for PIC18 processors

#3 Post by filip » 25 Jul 2014 08:52

Hi,

Good work, janni, we appreciate your every day contribution to our community very much. :)

Regards,
Filip.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: Replacement libraries for PIC18 processors - package v 1

#4 Post by janni » 31 Dec 2014 18:15

New release of the replacement libs, following the release of mB PRO v6.50, is ready for download (package version 1.05). Main change involves adding C functions, setjmp and longjmp, that mE for some reason decided to add to System library (funny thing is that these routines do not even function in mC starting from v 6.40 and barely functioned before; if someone intends to use them in mP, better use the replacement System library that fixed errors in the originals). Another two internal routines that mE introduced already in mB 6.40 were also added - though one of them is nonfunctional in the original form and the other never used as it duplicates the function of already present one, some mE Ethernet libraries demand their presence.

There's also new version of LibsSwitch program (0.05) that reads compiler version also from some ini file in compiler installation directory to confront data in registry which may be wrong. Please download the packed libs from here knowing that LibsSwitch makes update of replacement libs painless :) .

For those that haven't yet updated to mB PRO v 6.50 - remember to run LibsSwitch after update so it may copy new versions of mE libs.

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: Replacement libraries for PIC18 processors - package v 1

#5 Post by Dany » 31 Dec 2014 19:28

Thanks Janni!

The installation worked flawlesly!

Have a happy 2015! :D :D :D
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

gohich
Posts: 7
Joined: 15 Sep 2010 11:18

Re: Replacement libraries for PIC18 processors - package v 1

#6 Post by gohich » 29 Feb 2016 15:21

Hello,
I have a question about replacement libraries v1.05. I use it in my software because, without it, the size of my SW is too big for PIC18f46k22. My software uses time functions and today, surprise, the date is february 1st in place of 29. I cannot try with ME libs because of the size of my software, I think the problem is in replacement libs. Is it possible that the TIME function has a problem with leap year? My card uses DCF77 software decoder to correct eventually a small shift of the MCP79400 RTC and adjust, if necessary, its clock calibration. Development software is Mikrobasic PRO for PIC v 6.6.2. I cannot make some other tests because my electronic card is used to control all the heating of my home and tomorrow it will be too late. The next problem will be the 29 february of 2020....
Hope you have an explanation and/or a solution.
Best regards
Christian.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: Replacement libraries for PIC18 processors - package v 1

#7 Post by janni » 29 Feb 2016 18:55

Hi,

If I understood you correctly, you suspect that mE's Time library does not work correctly with my replacement libs. To trace the problem I need to know which functions of this library do you use. Relevant excerpt from your code would also help.

gohich
Posts: 7
Joined: 15 Sep 2010 11:18

Re: Replacement libraries for PIC18 processors - package v 1

#8 Post by gohich » 29 Feb 2016 20:26

Hi, thanks for your reply. The functions I use are Time_dateToEpoch and Time_epochToDate.
Here after 3 sub of my code
sub procedure readRTC ' Read date et heure de l'horloge Temps réel.
dim Tempo as Byte[8]
dim i as byte
I2C2_Start
if I2C2_Wr(RTC_Add_WR) = 0 then
I2C2_Wr(0x00)
I2C2_Repeated_Start()
I2C2_Wr(RTC_Add_Rd)
for i = 0 to 7
Tempo = I2C2_Rd(1)
next i
Calibration = I2C2_Rd(0)
end if
I2C2_Stop
ts_rtc.ss = Bcd2Dec(tempo[0] and %01111111)
ts_rtc.mn = Bcd2Dec(tempo[1] and %01111111)
ts_rtc.hh = Bcd2Dec(tempo[2] and %00111111)
ts_rtc.wd = Bcd2Dec(tempo[3] and %00000111)
ts_rtc.md = Bcd2Dec(tempo[4] and %00111111)
ts_rtc.mo = Bcd2Dec(tempo[5] and %00011111)
ts_rtc.yy = Bcd2Dec(tempo[6]) + 1970
epochRTC = time_datetoepoch(@ts_rtc) ' Convertion ts_RTC en LongINT pour utilisation par le programme.
end sub
sub procedure Decodage ' DCF77 decoder
Ts_DCF.ss = 0
Ts_DCF.mn = Sel_Bit(21,4) + 10 * Sel_Bit(25,3) ' DCF_min1 + 10 * DCF_min10
Ts_DCF.hh = Sel_Bit(29,4) + 10 * Sel_Bit(33,2) ' DCF_heure1 + 10 * DCF_heure10
Ts_DCF.md = sel_bit(36,4) + 10 * sel_bit(40,2) ' DCF_jour1 + 10 * DCF_jour10
Ts_DCF.wd = sel_bit(42,3) ' DCF_Day
Ts_DCF.mo = sel_bit(45,4) + 10 * sel_bit(49,1) ' DCF_Mois1 + 10 * DCF_Mois10
Ts_DCF.yy = sel_bit(50,4) + 10 * sel_bit(54,4) + 2000 ' DCF_An1 + (10 * DCF_An10) + 2000
epoch_dcf = time_datetoepoch(@ts_dcf)
end sub
Sub procedure Update_RTC_Time (dim byref _TimeDCF as longint) 'Current_Time as timeStruct) ' DCF77_Time ==> Current_Time
dim Current_Time as timestruct
_timedcf = _timedcf - 1
Time_epochtodate(_timedcf, @current_time)
Wr_RTC_Byte(0,Dec2Bcd(Current_Time.ss) or %10000000)
Wr_RTC_Byte(1,Dec2Bcd(Current_Time.mn) and %01111111)
Wr_RTC_Byte(2,Dec2Bcd(Current_Time.hh) and %01111111)
Wr_RTC_Byte(3,Dec2Bcd(Current_Time.wd) or %00111000)
Wr_RTC_Byte(4,Dec2Bcd(Current_Time.md) and %00111111)
Wr_RTC_Byte(5,Dec2Bcd(Current_Time.mo) and %00011111)
Wr_RTC_Byte(6,Dec2Bcd16(Current_Time.yy)- 2000)
Wr_RTC_Byte(7,%01000000)
end sub

and to display time in a select case
' ##### DD/MM/YYYY xxHxx
case type_DATETIME
time_epochtodate( value, @tsTemp )
WordToStrWithZeros( tsTemp.md, strWord )
result[0] = strWord[3]
result[1] = strWord[4]
result[2] = "/"
WordToStrWithZeros( tsTemp.mo, strWord )
result[3] = strWord[3]
result[4] = strWord[4]
result[5] = "/"
WordToStrWithZeros( tsTemp.yy, strWord )
result[6] = strWord[1]
result[7] = strWord[2]
result[8] = strWord[3]
result[9] = strWord[4]
result[10] = " "
WordToStrWithZeros( tsTemp.hh, strWord )
result[11] = strWord[3]
result[12] = strWord[4]
result[13] = "H"
WordToStrWithZeros( tsTemp.mn, strWord )
result[14] = strWord[3]
result[15] = strWord[4]
result[16] = ""

Hope that will be enough for you.
BR
Christian.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: Replacement libraries for PIC18 processors - package v 1

#9 Post by janni » 29 Feb 2016 23:56

I don't see any problem with the Time library operation - coding and decoding today's date works equally well with original and replacement libs (though I wonder why you waste code space with Time functions - unless you have to store lots and lots of dates).

gohich
Posts: 7
Joined: 15 Sep 2010 11:18

Re: Replacement libraries for PIC18 processors - package v 1

#10 Post by gohich » 01 Mar 2016 01:15

Hi,

OK, so I have to look elsewhere, but it is too late now to check the result, I'll have to wait the 29 February 2020 :mrgreen: .......

For the size of my code, this is just a small part. The major part of my code is used to control the heating of my house, fuel oil for a part and an other electrical part with an individual control by room, management of short or long periods of absence. The code is required for the measurements made by various sensors like temperature sensors and oil gage, calculation, control of relays, communication with a web server, local and remote display, keyboard, recording data on SD card and a few other additional features.

Anyway, I must thank you for your work and for the replacement libraries that allowed all this code of holding in the PIC18F46K22's 64k flash memory.

Thank again,
Regards

Christian.
PS: Excuse me if sometimes my English is not correct.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: Replacement libraries for PIC18 processors - package v 1

#11 Post by janni » 01 Mar 2016 02:04

gohich wrote:OK, so I have to look elsewhere, but it is too late now to check the result, I'll have to wait the 29 February 2020 :mrgreen: .......
Not necessarily, one of next years you may see 29th of February on 1st of March if year estimation is mixed up. And it seems that you unintentionally moved 30 years to the future :lol: .
This line

Code: Select all

Wr_RTC_Byte(6,Dec2Bcd16(Current_Time.yy)- 2000)
is wrong - one should subtract 2000 from the year before conversion to BCD (and then 8-bit function will suffice). Otherwise, instead of writing 16 to RTC's year register, 46 is written. No wonder that you have to add 1970

Code: Select all

ts_rtc.yy = Bcd2Dec(tempo[6]) + 1970
instead of 2000 to year register while reading from RTC :wink: . And year 2046 is indeed not a leap year :) .

gohich
Posts: 7
Joined: 15 Sep 2010 11:18

Re: Replacement libraries for PIC18 processors - package v 1

#12 Post by gohich » 01 Mar 2016 11:39

Hi Janni,
Well done ! You are right, I will correct that and for test, I'll subtract one day in the decoding of the DCF77 time to simulate February 29. I keep you informed.
I don't know how to thank you :oops: . Many thanks again.

Regards,
Christian.

gohich
Posts: 7
Joined: 15 Sep 2010 11:18

Re: Replacement libraries for PIC18 processors - package v 1

#13 Post by gohich » 01 Mar 2016 14:15

Hi again Jorri,

The correction was done and the test with DCF77 time minus 1 day is OK .
Now, all is right :D

Thanks again for your help and I'm sorry to have had a doubt about the libraries :oops:

Have a good day. Best regards.

Christian.

antonadc
Posts: 277
Joined: 14 Dec 2012 10:15
Location: Pretoria South Africa

Re: Replacement libraries for PIC18 processors - package v 1

#14 Post by antonadc » 07 Mar 2016 15:51

Thank you Jani for the replacement Libs. I have noticed that I some projects I get code reduction up to 2k. Cool. But I have noticed in some projects using visual glcd that some variables have been copied and the compiler complains of duplicated variables. I then remove the new libs and all is ok. Just thought I would let you know.

Anton

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: Replacement libraries for PIC18 processors - package v 1

#15 Post by janni » 07 Mar 2016 18:51

Hi Anton,

Thanks for the info. I don't use VisualGLCD (prefer my own GLCD lib) so I wouldn't know. Could you list at least some of the duplicated variables?

Post Reply

Return to “mikroBasic PRO for PIC General”