Menu

Request for How to and not to do Picaxe 2 GCB

bed
2017-12-08
2021-09-02
  • bed

    bed - 2017-12-08

    I'm not want to disturb this interesting thread, https://sourceforge.net/p/gcbasic/discussion/579125/thread/07ad8a34/#1643/ac68
    While reading it, it came in my mind, it would be good to have one or two Pages ready for long standing Picaxe Users who want give Great Cow BASIC a try.
    As I found in reading the discussion above there are several behavior which was used and good practise in Picaxe.
    But this is not advised and not supported here. So who of the ex Picaxe users will become fame and write the ultimative Change_from_Picaxe_to_Great_Cow_BASIC Document?
    I'm sure here is enough wisdom about this way.
    I will take it and build a nice Page for our growing homepage.

     
    • Anobium

      Anobium - 2017-12-08

      As long as we pages for other compilers...

       
    • wperko

      wperko - 2021-09-01

      Hi,

      I think rather than a document how to translate from PICAXE BASIC to GCBASIC, there ought to be an app that does that since the PIN definitions are explicit in PICAXE BASIC translating to GCBASIC should be fairly straight forward.

      For a newbie to GCBASIC like myself, I can't wait to get into the "demo" code and start learning GCBASIC, but I have hundreds of PICAXE BASIC programs I'd like to translate over to GCBASIC, but I also have new programs to develop so spending hours manually translating programs is out of the question.

      IF I'm lucky, my PICKit3 programming port part will be here in a couple of weeks and I can get started with GCBASIC.

       
      • Anobium

        Anobium - 2021-09-01

        Anything is possible.... a quick awk program should do it

        Got some example programs?

        It would be easy to knock up the basic tool. And, then, hand over to you.



        How to handle frequency changes ? As this was to get around limitations of the language
        How to handle strings?
        How to handle variables? In PICAXE you have limitations on the number.... in other languages that limit is not imposed
        How to handle interrupts ? In PICAXE you have time slicing that pretends... real interrupts are much more easier to understand.

         
      • mkstevo

        mkstevo - 2021-09-01

        Having converted a fair few PicAxe programs over to Great Cow Basic...

        I originally tried doing a search and replace of various keywords (Endif to End If, Pause to Wait and so on) then attempted to rewrite individual commands into the correct sequence. Attempt to compile, find and remove errors. Recompile, remove more errors and so on into a working program.

        The second approach was to print out the PicAxe program, use the program flow as inspiration but start again from scratch.

        The second approach resulted in a better, faster GCB program in less time than attempting to modify an original into a compatible one.

        Conversion of a simple PicAxe program might be feasible by using a script, but in my opinion you'd be better of doing a total rewrite.

         
      • William Roth

        William Roth - 2021-09-02

        An app to do pin definitions should not be too difficult. The obstacle, as I see it, is finding someone that both able and willing to do it.

        However, writing an app or script that can take an advanced Picaxe BASIC program (PE6) and spit out an equivalent Great Cow BASIC program would be like writing a new compiler from scratch.

        I basically stopped using Picaxe for my own projects in Oct, 2013. Looking at my archives, the last Picaxe program I wrote was a "wireless programmer" using a Picaxe 20X2 to program another Picaxe over a wireless link with some LC-1000 wireless transceivers. As I look at the Picaxe code now, It seems I have forgotten quite a bit about Picaxe Basic. So I am not the guy to do this.

        Like mkstevo, for programs I wanted to convert to GCB, I found it easier to just rewrite the code than to try to convert it with scripts and such. I had the Picaxe Code open on one display and GCB on another and used the Picaxe Basic as a reference as I wrote the GCB.

         
        • stan cartwright

          stan cartwright - 2021-09-02

          I try to lure picaxe users to GCB as it's Basic can be simple like sinclair basic or be clever and more difficult like bbc basic were in the '80's.
          Picaxe is interpreted and so is the inline assembler.
          GCB creates better assembler than I could write...it's been over 30 years since I used assembler code.
          I am not the only one who "forgets" how a system works when not used. Like my 3D printers and the software like Cura.
          It would be easy to convert your own picaxe code to gcb but not translating someone else's program.
          I'd go with @williamroth's suggestion. ie if you know picaxe commands then how to convert to gcb would be easier than if you've forgotten picaxe.
          Personally I'd just use gcb... with an arduino 328 or cheap clone because they have 2k ram for variables and lots of program memory (ok the bootloader uses a bit). USB plug and play on windows.
          But with gcb there's loads of pic/avr supported so plenty of choice.

           
  • bed

    bed - 2017-12-08

    Exactly, we should not suspect that we are luring users. Something like this always goes backwards.
    But it is obvious, old habits are easily taken over, without questioning whether this makes any sense under changed circumstances.
    Well, yes, of course, if somebody from any kind of system comes here, always with the How to do not to do's.

     
  • stan cartwright

    stan cartwright - 2017-12-08

    a picaxe to gcb translation got no kudos. Not much to it but gcb changes...picaxe doesn't.
    it's just re-naming stuff...as always. William did a routine to simulate picaxe send serial in gcb.
    I can't remember picaxe after a year...looks complicated.
    ps allure users, yes? no...they're in stasis or summat. They're clockwork...needs winding...forward in time
    why did I bother with a model pic when I could have a real one? answers on a postcard to chuckle bros co bbc

     

    Last edit: stan cartwright 2017-12-08
    • bed

      bed - 2017-12-09

      How about filling your Experiences with some whole sentences, maybe some wisdoms from others added here, we could present such "Howto-not-to-do" Article soon?

       
  • stan cartwright

    stan cartwright - 2017-12-09

    I got this and found gcb alternatives http://www.picaxe.com/BASIC-Commands
    HSEROUT break, ({#}data,{#}data...) where it can be one line is different.
    Would a list of differences/equivelents be of any interest?
    My "worst" error was starting arrays in gcb from 0 instead of 1 as picaxe arrays start at 0. When you're working with a ssd1306 glcd, one byte makes a difference.
    Emphasise "read the instructions and do not assume things"?

     

    Last edit: stan cartwright 2017-12-09
    • bed

      bed - 2017-12-09

      Sure, this is that what I did expected from such a "Howto-not-to-do" Article
      Good start!

       
  • mkstevo

    mkstevo - 2017-12-11

    Here is a portion of a program for controlling the DF Player Mini MP3 player module. The first section is PicAxe basic:

    For Track = $1 To MaxTracks
        For Folder = $1 To MaxFolders 
            cmd = Play_FxxTxx
            'arg = varA
            'Track and Folder directly set the MSB and LSB through b2 and b3
            Gosub Send 
            Pause 500
            If BUSY_PIN = 0 Then
                If Track=1 Then
                    If MaxFolders=MaxFolders Then
                        Let MaxFolders=MaxFolders+1
                    EndIf
                    EndIf
                Do While BUSY_PIN = 0 
                    Pause 100 
                Loop
            EndIf 
    
        Next
    Next
    
    Send:
    SerTxd("$7E, $FF, $06, C", #Cmd, "C $00, F", #arg.msb,"F T", #arg.lsb, "T $EF", CR, LF )
      SetFreq BAUD_FREQ 
      Pause 10 
      SerOut TX, BAUD, ( $7E, $FF, $06, cmd, $00, arg.msb, arg.lsb, $EF ) 
      SetFreq MDEFAULT 
    Return 
    

    And this is the (near) equivalent for playing just one track in Great Cow Basic:

    Main:
        Wait 1 S
        Serial_Send(Volume,0x0)       'these are constants declared elsewhere...
        Serial_Send(Disk_Set,Usb_Disk)'these are constants declared elsewhere...
        Wait 4 S
        Serial_Send(Play_FxxTxx,0x1,0x1)'these are constants declared elsewhere...
        Wait 400 mS
        If Player_Busy = 0 Then
           Do
              'Disk found
               Play_Track(1,1)
               Do
                    Wait 100 mS
               Loop Until Player_Busy = 1
           While 0
        End If
    End
    
    Sub Play_Track(Fdr As Byte, Trk As Byte)
        'The Folder and track are deliberately
        'reversed below as folder needs sending
        'last to match the 'optional' parameter
        'in the serial out routine.
        Serial_Send(Play_FxxTxx,Trk,Fdr)
    End Sub    
    
    'SerOut TX, BAUD, ( 0x7E, 0xFF, 0x06, cmd, 0x00, arg.msb, arg.lsb, 0xEF )   
    Sub Serial_Send(Cmd as Byte ,A_lsb as Byte, Optional A_msb=0x0)
        SerSend 1, 0x7e
        SerSend 1, 0xff
        SerSend 1, 0x06
        SerSend 1, Cmd
        SerSend 1, 0x00
        SerSend 1, A_msb
        SerSend 1, A_lsb
        SerSend 1, 0xef
        Wait 100 mS
        SendAHigh                         'Idle High 
    End Sub
    

    There are syntactical differences in the way loops are constructed, minor differences in 'If...Then' statements (End If as opposed to EndIf). Variable declaration uses 'Dim' and Constants '#Define' as opposed to 'Symbol', Pause (and Pauseus) rather than Wait mS (Wait S and Wait uS) and so on but it isn't impossible to work through a PicAxe program line by line and make those changes. The major differences are naturally when it comes to the built in libraries such as the serial send routine used in the above examples. Even that isn't insurmountable with the generous help provided by kind members of this (and the PicAxe) forum(s).

     
  • stan cartwright

    stan cartwright - 2017-12-11

    Another difference is pause and pulsout are clock dependent in picaxe.
    "PAUSEUS microseconds
    - Microseconds is a variable/constant (0-65535) which specifies how many
    multiples of 10 microseconds to pause (at 8MHz on X2 parts, else 4MHz)."

     
  • bed

    bed - 2017-12-11

    Now, this is a good base for assembling a nice Article together. Is any candidate willing to do this?
    We should not try to build a cookbook, but some conceptional hints are very much appriciated :-)

     

    Last edit: bed 2017-12-11
  • stan cartwright

    stan cartwright - 2017-12-11

    ;picaxe-
    symbol pingecho = C.5
    high pingecho ;high sets dir to out
    pulsin pingecho,1,range ;pulsin sets dir to in
    GCB would use the srf04 include-Added support for using same pin as ping and echo

     

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.