Menu

GCbasic vs melabs vs XC8

Herb Sgm
2020-04-06
2020-04-08
  • Herb Sgm

    Herb Sgm - 2020-04-06

    Hello GCbasic community,

    I am working since many years with the melabs (2xx) compiler and wrote several programs for PIC.

    Now I have to decide if I stay with this compiler (go to PBP3) or migrate to something new, e.G.: MPLAB XC8.
    But recently I discovered GCbasic and I am really very impressed.

    So my questions to you experts:

    What is your experience in comparison melabs to GCbasic?
    How difficult would it be to migrate existing PBP code?

    I could not find a discusion MPLAB XC8 vs GCbasic (I know C is hardly comparable to basic)
    but what are your pros and cons?
    When are you prefering XC8 and when GCbasic?
    I have many years experience with assembler, pic-basic and other languages, except C. My programms have around 1000 lines of code and I use it for controlling I/Os and serial communication. Migrating this software to a new system might be an issue.
    So I guess GCbasic would be quicker to start with?

    many thanks for you answers.

    BR from Austria,
    Herb.

     
  • Anobium

    Anobium - 2020-04-06

    @Herb

    Great questions.

    My assumption is that https://melabs.com/samples/LABX1-16F1934/adcin10_1934X.htm are examples of MELAB.

    I have not see MELAB - Please confirm that the URL and the samples on that page represent MELAB, No point in my starting from the wrong example of the MELAB language.


    Meanwhile have a look at an example to compare and contrast MELAB and Great Cow BASIC.

    Evan

    ' Name        : ADCIN10_1934X.pbp
    ' Compiler    : PICBASIC PRO Compiler 2.6
    ' Assembler   : MPASM
    ' Target PIC  : 40-pin 16F1934 or similar
    ' Hardware    : LAB-X1 Experimenter Board
    ' Oscillator  : 4MHz external crystal
    ' Keywords    : ADCIN, LCDOUT
    ' Description : PICBASIC PRO program to display result of
    ' 10-bit A/D conversion on LCD. Connect analog input to
    ' channel-0 (RA0).
    '
    
    ' Define LCD registers and bits
    Define LCD_DREG  PORTD
    Define LCD_DBIT  4
    Define LCD_RSREG PORTE
    Define LCD_RSBIT 0
    Define LCD_EREG  PORTE
    Define LCD_EBIT  1
    
    ' Define ADCIN parameters
    Define  ADC_BITS     10   ' Set number of bits in result
    Define  ADC_CLOCK    4    ' Set clock source Fosc/4
    Define  ADC_SAMPLEUS 50   ' Set sampling time in uS
    
    adval Var Word            ' Create adval to store result
    
       Gosub Init             ' Hardware initialization routine
    
    mainloop:
       Adcin 0, adval         ' Read channel 0 to adval
       Lcdout $fe, 1          ' Clear LCD
       Lcdout "Value: ", DEC adval ' Display the decimal value  
    
       Pause 100              ' Wait .1 second
       Goto mainloop          ' Do it forever
    
       Init:
       ANSELA = 1    ' Set PortA 0 to analog POT input
       ANSELB = 0    ' portb all digital
       ANSELD = 0    ' portd all digital
       ANSELE = 0    ' porte all digital
    
       ADCON1 = %11000000  ' Right justify for 10-bit, Fosc/4, +Vref/-Vref = Vdd/gnd
    
       OPTION_REG.7 = 0 ' Enable PORTB pullups
       TRISD = 0        ' PORTD all outputs
    
       Pause 100        ' Wait for LCD to start
       Return           ' Return to caller
    
       End
    

    a port to Great Cow BASIC. This took about two minutes over a coffee. :-)

    ' Name        : ADCIN10_1934X.gcb
    ' Compiler    : Great Cow BASIC
    ' Assembler   : Great Cow BASIC ( or MPASM which would just take more time... :=) )
    ' Target PIC  : 40-pin 16F1934 or similar
    ' Hardware    : LAB-X1 Experimenter Board
    ' Oscillator  : 4MHz external crystal
    ' Description : Port to Great Cow BASIC to display result of
    ' 10-bit A/D conversion on LCD. Connect analog input to
    ' channel-0 (RA0).
    '
      #chip 16f1934, 4
      #option Explicit
    
    ' Define LCD registers and bits
    
      #define LCD_IO 4
      #define LCD_NO_RW
    
    ; ----- Define Hardware settings
      #define LCD_RS PORTE.0
      #define LCD_Enable PORTE.1
      #define LCD_DB4 PORTD.3
      #define LCD_DB5 PORTD.2
      #define LCD_DB6 PORTD.1
      #define LCD_DB7 PORTD.0
    
    
      Dim adval as  Word            ' Create adval to store result
    
    
    
      DO Forever
    
       adval = ReadAD10( AN0 )                  ' Read channel 0 to adval
       CLS                                ' Clear LCD
       Print "Value: " + str(adval)       ' Display the decimal value
       Wait 100 ms                        ' Wait .1 second
    
      Loop
    
     
  • Anobium

    Anobium - 2020-04-06
    Index Query Comment
    1 What is your experience in comparison melabs to GCbasic? Personally none. Other may have experience but if the code above represents the language then it is very easy
    2 How difficult would it be to migrate existing PBP code? Easy. Learn the syntax, look at the 1000s of examples and it will be easy. As I do not know what is in your 1000 lines of code it is truely hard to say - but, we have libraries to reduce the porting work.
    3 I could not find a discusion MPLAB XC8 vs GCbasic [I know C is hardly comparable to basic] but what are your pros and cons? You ask a great question. This has not been asked before. See next section as we need define the list......
    4 When are you prefering XC8 and when GCbasic? XC8 with MPLAB-IDE... I only use to generate reference code. I gave up using XC8 with MPLAB-IDE years ago. I used Great Cow BASIC only. I only use MPASM to generate reference HEXs to compare to the Great Cow BASIC generated HEX file. So, I may be the wrong person to comment.
    5 I have many years experience with assembler, pic-basic and other languages, except C. My programms have around 1000 lines of code and I use it for controlling I/Os and serial communication. Migrating this software to a new system might be an issue. I cannot really assess without seeing the 1000 of lines of code. If you want to review - then, send me an email.
    6 So I guess GCbasic would be quicker to start with? Any language has a learning curve. We have a friendly community that can assist.

    Index Scope/Feature Pro Con
    1 Product Support tbc tbc
    2 Licensing tbc tbc
    3 Architectures Supported tbc tbc
    4 Chips Supported tbc tbc
    5 Libraries Suppored tbc tbc
    6 Community tbc tbc

    What else? There must a mega list of questions that you can add to this list.


     
  • Herb Sgm

    Herb Sgm - 2020-04-06

    Hello,
    many thanks for your detailed answers!

    about the comparison code above:

    It seems both are similar, great cow basic seems even easier to set up.
    as I understand: GCB is taking care about your TRISA, ANSEL etc registers, so less traps when starting a new project. And you dont have to go too often into the PIC datasheet.

    I wonder how far a C compiler (e.G XC8) supports you to find the right register settings. I fear that more pitfalls are possible?

    So as I see it -please add your experience:

    melabs picbasic: (I have 20 years experience, but not too intensely)
    + simple and easy to start and understand
    + special debugging over serial port
    + debugging over MPLAB IDE integration (but never tried)
    - not too many examples / libraries
    - maybe not too many users nowadays, not much present in internet

    gread cow basic (have not yet tried)
    + simple and even easier to start
    + open source with all its benefits -GREAT !
    + my impression so far: pretty good community support
    + many answers one can find by searching in internet
    ? debugging possibilities
    - maybe the name creates confusion among engineers :-)

    C-compiler e.G MPLAB XC8 (have not yet tried)
    + used by professional programmers
    + debugging possibilities
    + I guess thousands of libraries and examples
    + no limitations - only you own time and brain maybe...
    - maybe tricky to start with ? Especially when one is not yet familiar with C?
    or is the learning curve comparable to picbasic/gcbasic???
    - free version limited (not sure how far this is a disadvantage)

    BR from Austria
    Herb

     
  • Herb Sgm

    Herb Sgm - 2020-04-06
     
    👍
    1

    Last edit: Herb Sgm 2020-04-07
  • Herb Sgm

    Herb Sgm - 2020-04-07

    Many thanks, Amobium!

    The debugging over RS232+Terminal is in my opinion the easiest and a very efficient method. Thanks also for the video to debug over ASM code in MPLAB, very interesting.

    just for information,

    PBP offeres some integration into MPLAB to debug the basic code directly, but not sure if one can read the memory/ registers also, I never tried it. This is the only video I could find:

    https://www.youtube.com/watch?v=2tHxbGHVR_4

    I think, I will install both GBC and XC8 and try a simple bink + serial out program. Then I can compare to PBP on my own and will report my experience.

    BR from Austria
    Herb.

     
    • Anobium

      Anobium - 2020-04-07

      https://www.youtube.com/watch?v=IuYqMOYyD50&feature=youtu.be

      If it takes more than 4 minutes to flash an LED get back to us.

       
    • Chris Roper

      Chris Roper - 2020-04-07

      Hi Herb,

      I have been working on an enhanced method of debugging over RS232 that eliminates, or greatly reduces, the memory overhead of serial debugging and at the same time emulates some of the features of hardware debugging.

      It uses a custom application in place of the terminal emulator to cut down on the overhead of VT100 code strings but also to add features that exceed the capabilities of a normal serial port debugger.

      I have had it on the back burner for a while now but as my overseas holiday is no longer possible and I still have another two weeks of Lockdown to look forward to now may be a good time to revisit it.

      I will create a thread soon to cover the development for those who would like to beta test it and comment on the project, I hope you will contribute.

      Cheers
      Chris

       
  • Herb Sgm

    Herb Sgm - 2020-04-08

    Hi,
    what I really like on GCB, its kept simple and smart, no fat, no bloatware. no overengineering. Perfect, quick and reliable for many control tasks.
    This is real engineering !
    I will definitely use it for my next projects, where IO control, timing, serial etc is necassary.
    Then I would like to come back to your offer, chris to test the enhanced debugging.

    But in near future I will also have to do a more complex project:
    - to read wave files from a flash memory (or SD card, which might be more complex)
    - output this signal as PWM over a filter or over a DAC.
    please give me your opinion to this. I am not sure if this would be possible with GCB.
    are there examples for SPI flash reading or handling SD cards?

    many thanks and greetings,
    Herb

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.