PDA

View Full Version : after all ... PBP is not so bad ...



Acetronics2
- 30th April 2010, 17:13
Hi,

I never had the time to make compiler comparisons ...

but, today a friend of mine leaded me to :

the Goal : read a voltage and display it as a heading ( boat autopilot app. ) and use a 16F819

Result is astonishing :

Another Basiç compiler ... 2504 Words ... The ' 819 is unusable !!! :eek:
its " PRO " version ..... 1722 Words ... :o

PicBasicPro ... ahaaaaa ...461 Words. :D

Of course I can prove the test is true and honest ...

Some Comments, chaps ???

Alain

Mike, K8LH
- 30th April 2010, 20:23
Just curious about the hardware (16F819? LCD?), etc? Would like to compare it to my favorite C compiler and assembly language just for fun (grin)...

Mike

Acetronics2
- 30th April 2010, 20:53
Just curious about the hardware (16F819? LCD?), etc? Would like to compare it to my favorite C compiler and assembly language just for fun (grin)...

Mike

Hi, Mike

Let's compare what can be compared ... won't you ???

those BASIC tested compilers were proud to show on their site a totally subjective " side by side comparison " ... backdraw of Humour, eh !!! :D

Now, i also use C ... and sometimes assembler ( under torture only ...) and know what can be obtained ...

Note also THEIR C compilers @ 90% of examples need lots more room than my favourite PBP Compiler ... @ equal result.

So, one seems to have to pay " whisles and bells " the price in bytes ... looks to be a question of compiler producer and not of language ...


Were not here to re-start a Nth Compiler war ( really boring ...) ... but to tell ( and prove ! ) PBP works not so bad ... in the end !!!

In the end ... you may choose the one you want, Mike ... nobody will criticize you. ;)

Alain

Mike, K8LH
- 30th April 2010, 21:04
Hi Alain,

I was genuinely interested in the application that you were trying to create. I apologize if it seemed I was embarking on a comparison war.

Kind regards, Mike

tenaja
- 1st May 2010, 02:02
What was the "other" compiler? I have PBP, but switched my primary compiler to Proton because I was running out of room on a project. It wouldn't fit with PBP, but it would with Proton. In fact, I saved about 20% with with switch... I had room for feature creep!

lester
- 1st May 2010, 04:15
Hi,

the Goal : read a voltage and display it as a heading ( boat autopilot app. ) and use a 16F819

Result is astonishing :

Another Basiç compiler ... 2504 Words ... The ' 819 is unusable !!!
its " PRO " version ..... 1722 Words ...

PicBasicPro ... ahaaaaa ...514 Words.

Of course I can prove the test is true and honest ...

Please publish your code example and name the compilers that you used. or your post leaves the reader to rely on innuendo and speculation.

If your code example is valid and the compilers are genuine versions and have been used correctly, there is nothing to gain by not mentioning the names of the compilers that you tested.

AS a moderator, you must make the effort to set a good example, when making a post on a subject that is obviously going to stor up some emotive discussion.

Furter, if your comparisoons are valid, your post could easily become the core of an article in the WIKI or even an article in the catalogue section where we advertise and promote PBPro.

Come on, you can do better, if the jobs worth doing, do it well. If you're going to promote PBPro in this way, lets see it done openly with transparency.

Quote:

Of course I can prove the test is true and honest ...

mackrackit
- 1st May 2010, 10:08
Alain,

That all is interesting but I have a question.

Why did you modify someones post to post your test?

I always hate it when a post has a major edit because there is not any notification of the edit. Doing a major edit to another s post is really out there.

Acetronics2
- 1st May 2010, 10:52
As requested ...


want proof ??? Ok ... let's go !

1St attempt : Mikrobasic 7.2 ...




program Gouvernail ' program PiloteAT50
'************************************************* ****************************
' microcontroleur : 16F819 sur EasyPic 5
'
' Projet : PPE 2010
'
' En entree : A0 Up3 = entree analogique
'
' En sortie : portB Affichage des consignes "Babord et Tribord" sur lcd
'
'************************************************* ****************************
'program PiloteAT50
symbol Up3 = PORTA.0 ' tension analogique (<5V)
' déclaration des variables
dim result as word

dim tension as longint
dim angle as longint

dim text as string[9]
dim valeur as string[11]

const Vref = 5000

'************************************************* *****************************
sub Procedure Init ' Initialisation

'CMCON = 7

trisb = %00000000 ' portB en sortie
trisa = %11111111 ' portA en entrée

Delay_ms(500)
Lcd_Config(PORTB, 3, 2, 1, 0, PORTB, 4, 6, 5) ' Initialize LCD connected to PORTB
'LCD_init(PORTB) ' initialisation Lcd sur PortB

Lcd_Cmd(lcd_Clear)
Lcd_Cmd(lcd_cursor_off)

end sub

'************************************************* ******************************
main: ' ********* Principal *********
'************************************************* ******************************
Init ' config. et init. du PIC

while true ' début de la boucle

result = adc_read(0)
tension = result * Vref /1024 ' en mv !!!

'************************************************* *************************
' < ou > 4.02 v ??? ( 1024 * 4.02/5 = 823 !!! )

if tension < 4020 then

text = " Tribord "
else
Text = " Babord "

end if
'************************************************* ****************************
' Calcul de l'angle

angle = 3133 * Fabs(tension - 4020) / 120000
'************************************************* ****************************
' Affichage

LongintTostr(angle,valeur)

Lcd_out(1, 1, text)

Lcd_out(2,1,valeur)

delay_ms(100)

wend
end.


1:1 E-0 Linker error: NOT ENOUGH ROM

NOTA: 2504 Words compiled for a 16F877A

2nd Attempt : MikroBasic 7.2 ... NOT USING Fabs () ... = PbP ABS()



program Gouvernail ' program PiloteAT50
'************************************************* ****************************
' microcontroleur : 16F877A sur EasyPic 5
'
' Projet : PPE 2010
'
' En entree : A0 Up3 = entree analogique
'
' En sortie : portB Affichage des consignes "Babord et Tribord" sur lcd
'
'************************************************* ****************************
'program PiloteAT50
symbol Up3 = PORTA.0 ' tension analogique (<5V)
' déclaration des variables
dim result as word

dim tension as longint
dim angle as longint

dim text as string[9]
dim valeur as string[11]

const Vref = 5000

'************************************************* *****************************
sub Procedure Init ' Initialisation

' CMCON = 7

trisb = %00000000 ' portB en sortie
trisa = %11111111 ' portA en entrée

Delay_ms(500)
Lcd_Config(PORTB, 3, 2, 1, 0, PORTB, 4, 6, 5) ' Initialize LCD connected to PORTB
'LCD_init(PORTB) ' initialisation Lcd sur PortB

Lcd_Cmd(lcd_Clear)
Lcd_Cmd(lcd_cursor_off)

end sub

'************************************************* ******************************
main: ' ********* Principal *********
'************************************************* ******************************
Init ' config. et init. du PIC

while true ' début de la boucle

result = adc_read(0)
tension = result * Vref /1024 ' en mv !!!

'************************************************* *************************
' < ou > 4.02 v ??? ( 1024 * 4.02/5 = 823 !!! )

if tension < 4020 then

text = " Tribord "
angle = 3133 * (4020 - tension ) / 120000
else
Text = " Babord "
angle = 3133 * (tension - 4020) / 120000

end if
'************************************************* ****************************
' Calcul de l'angle

' angle = 3133 * Fabs(tension - 4020) / 120000
'************************************************* ****************************
' Affichage

LongintTostr(angle,valeur)

Lcd_out(1, 1, text)

Lcd_out(2,1,valeur)

delay_ms(100)

wend
end.


0:0 S-100 Success (Release build) - Timestamp: 10:15:57
0:0 W-101 Used ROM: 1774 (86%) Used RAM: 80 (31%)
0:0 W-102 Free ROM: 273 (14%) Free RAM: 176 (69%)

a small bit better ...

3rd attempt : MikroBasic PRO 3.2



program Gouvernail
' program PiloteAT50
'************************************************* ****************************
' microcontroleur : 16F819 sur EasyPic 5
'
' Projet : PPE 2010
'
' En entree : A0 Up3 = entree analogique
'
' En sortie : portB Affichage des consignes "Babord et Tribord" sur lcd
'
'************************************************* ****************************
'program PiloteAT50

' Lcd module connections

dim LCD_RS as sbit at RB4_bit
LCD_EN as sbit at RB5_bit
LCD_D4 as sbit at RB0_bit
LCD_D5 as sbit at RB1_bit
LCD_D6 as sbit at RB2_bit
LCD_D7 as sbit at RB3_bit
LCD_RS_Direction as sbit at TRISB4_bit
LCD_EN_Direction as sbit at TRISB5_bit
LCD_D4_Direction as sbit at TRISB0_bit
LCD_D5_Direction as sbit at TRISB1_bit
LCD_D6_Direction as sbit at TRISB2_bit
LCD_D7_Direction as sbit at TRISB3_bit
' End Lcd module connections

' Symbol Up3 = PORTA.0 ' tension analogique (<5V)
' déclaration des variables
dim resulta as word

dim tension as longint
dim angle as longint

dim text as string[9]
dim valeur as string[11]

const Vref = 5000

'************************************************* ******************************
main:
'************************************************* ******************************
' Init ' config. et init. du PIC
' CMCON = 7
trisb = %00000000 ' portB en sortie
trisa = %11111111 ' portA en entrée
Delay_ms(500)
'Lcd_Config(PORTB, 3, 2, 1, 0, PORTB, 4, 6, 5) ' Initialize LCD connected to PORTB
LCD_init() ' initialisation Lcd sur PortB
Lcd_Cmd(_LCD_CLEAR)
Lcd_Cmd(_Lcd_Cursor_Off)

while true ' début de la boucle
resulta = adc_read(0)
tension = resulta * Vref /1024 ' en mv !!!
'************************************************* ***********************
' < ou > 4.02 v ??? ( 1024 * 4.02/5 = 823 !!! )
if tension < 4020 then
text = " Tribord "
'************************************************* ********************
' Calcul de l'angle
angle = 3133 * ( 4020 - tension ) / 120000
else
Text = " Babord "
angle = 3133 * (tension - 4020) / 120000
end if
'************************************************* ****************************
' Affichage
LongintTostr(angle,valeur)
Lcd_out(1, 1, text)
Lcd_out(2,1,valeur)
delay_ms(100)
wend
end.



0 133 Compiled Successfully C:\Program Files\Mikroelektronika\ProjetsBPro\Gouvernail\Gouv ernail.mbas
0 1143 Used ROM (program words): 1722 (84%) Free ROM (program words): 326 (16%)
0 1143 Used RAM (bytes): 44 (18%) Free RAM (bytes): 196 (82%)

a tiny little bit better ...

4Th attempt : Our favourite PicBasicPro v 2.60 / MPASM/ MCS ( left MkB lines commented besides PbP lines ...)



'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 30/04/2010 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
'program Gouvernail ' program PiloteAT50
'************************************************* ****************************
' microcontroleur : 16F819 sur EasyPic 5
'
' Projet : PPE 2010
'
' En entree : A0 Up3 = entree analogique
'
' En sortie : portB Affichage des consignes "Babord et Tribord" sur lcd
'
'************************************************* ****************************
'program PiloteAT50

@ ERRORLEVEL -306
@ __config _HS_OSC & _WDT_ON & _PWRTE_ON & _BODEN_ON & _LVP_OFF & _CP_OFF

entree var PORTA.0 ' tension analogique (<5V)
' déclaration des variables
' dim result as word

' dim tension as longint
' dim angle as longint

' dim text as string[9]
' dim valeur as string[10]

' const Vref = 5000
result var word
tension var word
angle var word
dummy var word
vref con 5000

'************************************************* *****************************
'sub Procedure Init ' Initialisation


DEFINE OSC 8

CLEAR
;----[LCD definitions]------------------------------------------------------
DEFINE LCD_DREG PORTB ' LCD Data port
DEFINE LCD_DBIT 0 ' starting Data bit (0 or 4)
DEFINE LCD_EREG PORTB ' LCD Enable port
DEFINE LCD_EBIT 5 ' Enable bit (on EasyPIC 5 LCD)
DEFINE LCD_RSREG PORTB ' LCD Register Select port
DEFINE LCD_RSBIT 4 ' Register Select bit (on EasyPIC 5 LCD)
DEFINE LCD_BITS 4 ' LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' number of lines on LCD
DEFINE LCD_COMMANDUS 2000 ' Command delay time in us
DEFINE LCD_DATAUS 50 ' Data delay time in us
;----[LCD definitions]------------------------------------------------------
DEFINE ADC_BITS 10 ' set number of bits in result
DEFINE ADC_CLOCK 3 ' set clock source
ADCON1 = %10000000 ' right formatted

' CMCON = 7

trisb = %00000000 ' portB en sortie
trisa = %11111111 ' portA en entrée

'Delay_ms(500)
PAUSE 500
'Lcd_Config(PORTB, 3, 2, 1, 0, PORTB, 4, 6, 5) ' Initialize LCD connected to PORTB
'LCD_init(PORTB) ' initialisation Lcd sur PortB

' Lcd_Cmd(lcd_Clear)
' Lcd_Cmd(lcd_cursor_off)
LCDOUT $FE,1

' end sub

'************************************************* ******************************
main: ' ********* Principal *********
'************************************************* ******************************
' Init ' config. et init. du PIC

'while true ' début de la boucle
while 1=1

' result = adc_read(0)
adcin 0, result
dummy = result * Vref
tension = DIV32 1024 ' en mv !!!

'************************************************* *************************
' < ou > 4.02 v ??? ( 1024 * 4.02/5 = 823 !!! )

if tension < 4020 then

LCDOUT $FE,2, " Tribord "
else
LCDOUT $FE,2, " Babord "
endif
'************************************************* ****************************
' Calcul de l'angle

' angle = 3133 * abs(tension - 4020) / 120 / 1000
dummy = 3133 * abs(tension - 4020)
angle = DIV32 12000
angle = angle /10
'************************************************* ****************************
' Affichage

' LongintTostr(angle,valeur)

' Lcd_out(1, 1, text)

' Lcd_out(2,1,valeur)
LCDOUT $FE, $C0, dec3 angle

' delay_ms(100)
PAUSE 100

wend
end


Success ; 461 Words ...


Really astonishing for such a simple work !!!, don't you think ???

Alain

PS; as we are under the 2K limit EVERYONE can verify it with the Demo available versions of MikroBasic and MikroBasic Pro ...

tenaja
- 1st May 2010, 16:04
That is quite good. PDS only gets it down to 457, with 25 variables used.
(PBP uses 32 variable bytes.) Where PDS really shines, however, is when the file gets very large, when you use interrupts (it's built in; Darrel's utility is not needed), and with great implementation of mixing words and longs.

rmteo
- 1st May 2010, 18:33
Might be interesting if you would post your findings over at the mikroE forums.

Acetronics2
- 1st May 2010, 18:48
Might be interesting if you would post your findings over at the mikroE forums.

I do think it would be a very bad idea ... :(

totally unfair, overall ...

much too wide a gap !!! , don't you think ???

Alain

rmteo
- 1st May 2010, 19:11
It could be an incentive for them to improve their products to be as good as PBP.

Mike, K8LH
- 1st May 2010, 19:35
Hi Alain,

Thank you for posting the examples. May I impose to ask about the analog signal you're measuring and how it relates to degrees port and starboard? It seems you're sensing the port and starboard switch over at 4.020 volts (adc value 823). I'm just wondering if you couldn't use a different formula to produce the same results and eliminate the step of converting adc values of 0..1023 to voltage 0..4995-mvolts).

Kind regards, Mike

Ioannis
- 1st May 2010, 20:16
How about using in PBP 2.60 Long variables as in the MkB examples?

Also the LongintTostr(angle,valeur) function if replaced with a lines of commands like in PBP to do the job, would make any difference? Can you commend this line and see how many bytes is the code from MikroBasic?

I have a feeling that the comparisson is not exactly 'fair'.

Ioannis

Acetronics2
- 1st May 2010, 20:20
Hi Alain,

May I impose to ask about the analog signal you're measuring and how it relates to degrees port and starboard? ).

Kind regards, Mike

Hi, Mike,

I'd also had liked a way to find some easier calculations ...

but the guy who gave me the formulas ( a final project for student ...) gave it in the " ax+b " form ... with a and b being ... floating point numbers with 2 or 3 decimals !!!

I already have extracted integer ratios to avoid any floating point calculations ...;) ...

I wonder it is a voltage given by a pot ( position of a helm ) that is the input value...

do not bash ... I perfectly know :

1) the pot has 5% garanteed linearity ...

2) as the input swings from 3.02v to 5.02 v ... the output value is ... 26 starboard to 26 port ...

So, I know there's overkilling math here, but it can't be modified or re-studied because of the final projects rush ...;)

The HEX just fits into the PIC Flash memory... so, it will be enough here ... :rolleyes:


being serious ... that doesn't rub the 4+ x ratio between compilers ... for same little job !!!

Alain

Acetronics2
- 1st May 2010, 20:44
How about using in PBP 2.60 Long variables as in the MkB examples?

Also the LongintTostr(angle,valeur) function if replaced with a lines of commands like in PBP to do the job, would make any difference? Can you commend this line and see how many bytes is the code from MikroBasic?

I have a feeling that the comparisson is not exactly 'fair'.

Ioannis

Hi, Ioannis

Longs with a 16F819 ??? ... you're serious ???

use of strings to print to lcd is a quasi MUST with MkE compilers ... longint to str is only 221 bytes ... surely less than parsing number and converting into characters.

... and we're still far fom the PBP count ...

Alain

Mike, K8LH
- 1st May 2010, 20:56
Thank you Alain,

Would this work?

Regards, Mike


while 1=1
adcin 0, result '

if result < 823 then ' if < 4.020 volts then
LCDOUT $FE,2," Tribord " '
else ' else
LCDOUT $FE,2," Babord " '
endif '

angle = 13 * abs(result - 823) / 100 '

LCDOUT $FE, $C0, dec3 angle '

PAUSE 100 '
wend

Acetronics2
- 2nd May 2010, 08:55
Would this work?



Hi, Mike

Of course it can be convenient ... ;)

just for the fun ... the initial query was :

If tension < 4.02 v , angle=(-77/2.8952)*tension+(100.5/0.94) ...

so, we were really far from your " simplified " formula ( that fits perfectly well, with its < .5 degree error !!! )

... some comments about our new students ???? ... :D


Back to our Compilers ... MkBasic 7.2 now shows ... 1001 Words , MkBasicPro ... 601 Words !!! ( using WORDS ); to answer Ioannis, we loose here 1/2 degree in the result ... so, depending on the resolution required, ( 1 or .1 degree), program size changes a lot with MkE compilers !!!

PbP " only " 470 Words ... always is the winner.

Alain

Art
- 2nd May 2010, 10:35
It would be nice to see a comparison of some programs that are more simple such as flashing an LED
with an IF/THEN statement,
or printing HELLO WORLD to an LCD.

Then disassembling the hex file to asm and looking at the results.

Acetronics2
- 2nd May 2010, 10:59
It would be nice to see a comparison of some programs that are more simple such as flashing an LED
with an IF/THEN statement,
or printing HELLO WORLD to an LCD.

Then disassembling the hex file to asm and looking at the results.

Hi, Art

Would be a huge work to test and compare the most used functions of a selection of compilers, don't you think ???

...

I think the analyst's work and programmer's way of coding are far away the first reasons for huge or compact programs ...
we just got the proof here ... some lines ago ...:D

add to that, compilers always improve ... ( MkBasic 7.2 to MkBasicPro show a neat difference, CCS did so some months ago, PBP 2.60 enhanced some functions to save Program Words too ... ( WRITE/READ i.e ) ...
so, the time you write it, it's true ... but few months later, It's changed !!!

Alain

Mike, K8LH
- 2nd May 2010, 12:13
... MkBasic 7.2 now shows ... 1001 Words , MkBasicPro ... 601 Words !!! ( using WORDS ); to answer Ioannis, we loose here 1/2 degree in the result ... so, depending on the resolution required, ( 1 or .1 degree), program size changes a lot with MkE compilers !!!

PbP " only " 470 Words ... always is the winner.


Bravo Alain!!!

Mike, K8LH
- 4th May 2010, 13:19
après quelques tortillages de cerveau ...

on se rend compte que " angle " passe de 26 tribord à 26 babord pour la tension d'entrée qui passe de 3.02v à 5.02v , ce, de façon linéaire ...

si l'on y regarde de plus près ... et ,compte tenu de l'affichage en degrés, sans décimales ...

ça nous fait tout simplement ...

26 degrés de variation pour 200 points de variation du résultat de conversion ...

d'où ... la fabuleuse équation devient tout simplement :

angle = 13 * ABS ( result-823 ) / 100 ...

Qui a éclaté de rire ???

Hi Alain,

Was it too late for the original student to use this new formula considering the time constraints you mentioned?

Regards, Mike

Acetronics2
- 4th May 2010, 15:57
Hi Alain,

Was it too late for the original student to use this new formula considering the time constraints you mentioned?

Regards, Mike

Halas yes, Mike ... He PMed me he had no time to change his report and explain how to simplify the formula, once having seen the practical result, so he had to use the whole original formula for programming ...

despite I sent him the reduced program.

no " magics " allowed in such reports ... ;)

he's just authorized to mention the soft can be modified and reduced , while presenting his work at the blackboard ... and next year students will make the mod ...

Alain

But ... being honest ... you've cheated a bit !!!

Mike, K8LH
- 4th May 2010, 17:21
But ... being honest ... you've cheated a bit !!!
How so? If you mean that I took advantage of all your hard work and careful analysis when I simplified the formula then you are correct (LOL).


2) as the input swings from 3.02v to 5.02 v ... the output value is ... 26 starboard to 26 port ...

Your summary made it easy to recognize the ralationship of 52° spread across 100 (8-bit) or 400 (10-bit) ADC counts. You really should have spotted this yourself when you wrote it (LOL).

Anyway, I'm sorry the student could not take advantage of the simplified formula.

Regards, Mike