Shop OBEX P1 Docs P2 Docs Learn Events
PropBASIC Questions: — Parallax Forums

PropBASIC Questions:

davidsaundersdavidsaunders Posts: 1,559
edited 2015-04-21 14:59 in Propeller 1
I have been catching up on the propbasic version of my 3D Printer firmware (as well as the pure PASM version), though there are somethings I am having difficulty figuring out.

Is there a better manual than the 'PropBASIC Syntax Guide 0.13? Something more up to date?

How do you work with multiple source files in PropBASIC?

And is there some better info on starting tasks in PropBASIC?


I do like what I know of PropBASIC quite well, though the documentation is lacking in some areas, and I have searched the forums. I may not have seen a thread that has this info (assuming there is one).
«134

Comments

  • BeanBean Posts: 8,129
    edited 2015-04-10 06:45
    The PropBASIC manual is on the first post in this thread http://forums.parallax.com/showthread.php/118611

    I'd be interested in seeing PropBASIC 3D Printer Firmware, if you have any specific questions please ask and I'll answer them for you.

    Doing tasks is basically:
    TaskName    TASK     AUTO  ' "AUTO" means task starts automatically
    
    TASK TaskName
    ENDTASK
    

    Task code shares PIN variables and HUB variables, but all VARs are seperate in each TASKs.

    Bean
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2015-04-10 06:50
    Bean wrote: »
    The PropBASIC manual is on the first post in this thread http://forums.parallax.com/showthread.php/118611

    I'd be interested in seeing PropBASIC 3D Printer Firmware, if you have any specific questions please ask and I'll answer them for you.

    Doing tasks is basically:
    TaskName    TASK     AUTO  ' "AUTO" means task starts automatically
    
    TASK TaskName
    ENDTASK
    

    Task code shares PIN variables and HUB variables, but all VARs are seperate in each TASKs.

    Bean
    Ok, Is it possible to have SUB's between TASK and END TASK? I would think so though wish to make sure.

    Thank you for the link to the manual.
  • BeanBean Posts: 8,129
    edited 2015-04-10 07:17
    Yes, TASKs can have SUBs.

    Bean
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2015-04-10 12:59
    Bean wrote: »
    Yes, TASKs can have SUBs.

    Bean
    Thank you very much for that.

    I am writing the PropBASIC code under that assumption, so good to know it is correct.

    And I am also assuming that the "LOAD" keyword includudes the file specified inline at the location of the "LOAD" statement (at least as far as the generated output is concerned). I hope that is correct.
  • jmgjmg Posts: 15,173
    edited 2015-04-10 15:58
    Bean wrote: »
    The PropBASIC manual is on the first post in this thread http://forums.parallax.com/showthread.php/118611

    Bean,
    What is the status of work to get PropBASIC working with Propeller IDE ?
    Did you get any further along with a PropPASCAL parser version of PropBASIC ?

    See also this thread about Lazarus/FPC now running on Pi2 :
    http://forums.parallax.com/showthread.php/160718-Propeller-Chip-Raspberry-Pi-2-Interfacing-With-Free-Pascal-amp-Lazarus
  • Ken GraceyKen Gracey Posts: 7,392
    edited 2015-04-10 16:43
    jmg wrote: »
    Bean,
    What is the status of work to get PropBASIC working with Propeller IDE ?
    Did you get any further along with a PropPASCAL parser version of PropBASIC ?

    See also this thread about Lazarus/FPC now running on Pi2 :
    http://forums.parallax.com/showthread.php/160718-Propeller-Chip-Raspberry-Pi-2-Interfacing-With-Free-Pascal-amp-Lazarus

    Bean has very generously agreed to transfer PropBASIC source to Parallax, so we can more closely look into the integration with Propeller IDE. We've asked Brett Weir to look into it for us and should have a lightly integrated solution soon, later with syntax highlighting and some project management.

    Are we committed to it yet? Still looking into it, but should be able to clarify our plans by mid-May.

    Ken Gracey
  • BeanBean Posts: 8,129
    edited 2015-04-10 17:51
    Thank you very much for that.

    I am writing the PropBASIC code under that assumption, so good to know it is correct.

    And I am also assuming that the "LOAD" keyword includudes the file specified inline at the location of the "LOAD" statement (at least as far as the generated output is concerned). I hope that is correct.

    I think you want the INCLUDE keyword.

    "LOAD" is more complicated and is used to have libraries with multiple sections of code.

    Bean
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2015-04-10 18:07
    Bean wrote: »
    I think you want the INCLUDE keyword.

    "LOAD" is more complicated and is used to have libraries with multiple sections of code.

    Bean
    Ok could you give a better description of Load??

    There are not many examples, and the documentation is not to clear.

    I am looking to be able to use modular coding, as in multiple source single output.
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2015-04-11 04:13
    I have figured out that PropBASIC is the HLL to use for a 3D printer project. I wish I had figured that out sooner.

    I have decided to ditch the Spin version all together. So there will just be two versions to begin with, a PropBASIC version and a PASM version.

    That will expand on the release of the Prop 2.
  • BeanBean Posts: 8,129
    edited 2015-04-11 05:56
    Ok could you give a better description of Load??

    There are not many examples, and the documentation is not to clear.

    I am looking to be able to use modular coding, as in multiple source single output.

    David,
    Look at the VGA and VGA2 libraries in the OBEX. Search for PropBasic.
    You will see that first come all the defines, then there is a compiler directive '{$CODE} then comes the main code with a bunch of '{$IFUSED directives to remove dead code. Then comes the '{$TASKS} directive and any TASKs that are needed for the library.

    The libraries in the OBEX have the library code with an extension of .lib, but I've since just used .pbas for the library code too. To make it easier for the IDE. I suggest you do the same.

    Thanks for choosing PropBASIC for the 3D printer driver. If you have any questions please feel free to ask.

    The libraries actually get processed more than once, the defines are processed at the LOAD command, then AFTER all your main code, the compiler processes each library again but only the lines after '{$CODE}.

    Bean
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2015-04-11 06:08
    Bean wrote: »
    David,
    Look at the VGA and VGA2 libraries in the OBEX. Search for PropBasic.
    You will see that first come all the defines, then there is a compiler directive '{$CODE} then comes the main code with a bunch of '{$IFUSED directives to remove dead code. Then comes the '{$TASKS} directive and any TASKs that are needed for the library.

    The libraries in the OBEX have the library code with an extension of .lib, but I've since just used .pbas for the library code too. To make it easier for the IDE. I suggest you do the same.

    Thanks for choosing PropBASIC for the 3D printer driver. If you have any questions please feel free to ask.

    The libraries actually get processed more than once, the defines are processed at the LOAD command, then AFTER all your main code, the compiler processes each library again but only the lines after '{$CODE}.

    Bean
    Thank you much. I just looked at the examples (I had already downloaded them), and with your explanation it makes sense. That makes it even easier.

    I do not think it will take to long before I post a PropBASIC firmware, I may post it a bit at a time, or may wait till it is usable, undecided.

    Though PropBASIC makes the task fairly simple. The built in serial IO simplifies things a lot as well (as 3D printers use serial IO in most cases for G-Code, and mine uses serial for either G-Code or the binary code I developed for it [which has changed radicaly, thanks to PropBASIC and simplifying everything]).

    The original firmware supported only G-Code, and PropBASIC does simplify using strings enough that the G-Code part is easy.

    You did a very good job with PropBASIC. thank you.
  • BeanBean Posts: 8,129
    edited 2015-04-11 06:24
    David,
    Thanks. You'll probably want to use LMM for the G-Code parser. "PROGRAM label LMM" or "TASK taskname LMM".
    I can't wait to see your code.

    Bean
  • jmgjmg Posts: 15,173
    edited 2015-04-11 13:49
    Though PropBASIC makes the task fairly simple. The built in serial IO simplifies things a lot as well ...
    You did a very good job with PropBASIC. thank you.
    Yes, PropBasic is impressive.
    @Bean - re the inbuilt SEROUT, what Baudrate has that been tested to ?
    I think the inner-most optimized DJNZ loop is good for 4MBd send, (with some extra time between chars ), but I could not decide if the start bit would be the correct width at highest baud rates ?
    Simple 'ricegrain' slaves can ~match Prop fSys with a 3.07MBd setting.
    ( & also ~ 0.5% errors @ 2.051MBd, 1.739MBd, 1.538MBd, 1.355MBd, 1.230MBd .. etc )
  • pmrobertpmrobert Posts: 673
    edited 2015-04-11 17:27
    Don't be afraid to try/use a 100mHz clock/6.25mHz crystal. It's a cheap, reliable, easy speed enhancement in my limited experience.
  • BeanBean Posts: 8,129
    edited 2015-04-11 17:52
    jmg wrote: »
    Yes, PropBasic is impressive.
    @Bean - re the inbuilt SEROUT, what Baudrate has that been tested to ?
    I think the inner-most optimized DJNZ loop is good for 4MBd send, (with some extra time between chars ), but I could not decide if the start bit would be the correct width at highest baud rates ?
    Simple 'ricegrain' slaves can ~match Prop fSys with a 3.07MBd setting.
    ( & also ~ 0.5% errors @ 2.051MBd, 1.739MBd, 1.538MBd, 1.355MBd, 1.230MBd .. etc )

    I've never timed it, but I regularly use 1MBaud with the FTDI chip. And I'm sure I've used 2MBaud at times.

    Bean
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2015-04-12 05:34
    @Bean:
    I just stumbled acrossed your blog, and noticed the picture. How do you get syntax highlighting for PropBASIC in BST? It would be helpful.

    Though I am getting the hang of PropBASIC quite quickly.
  • BeanBean Posts: 8,129
    edited 2015-04-12 05:45
    David,
    That blog is really old. I don't remember doing anything extra special. Maybe it's a configuration setting or something ?

    As you are learning PropBASIC and looking at the documentation it would be helpful if you could keep some notes about what needs to be better documented, or added to the existing documentation. Then next time I update the documentation I'll incorporate what notes you have.

    Bean
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2015-04-12 05:52
    Bean wrote: »
    David,
    That blog is really old. I don't remember doing anything extra special. Maybe it's a configuration setting or something ?

    As you are learning PropBASIC and looking at the documentation it would be helpful if you could keep some notes about what needs to be better documented, or added to the existing documentation. Then next time I update the documentation I'll incorporate what notes you have.

    Bean
    Ok I will start making notes on where the Documentation is lacking.
  • David BetzDavid Betz Posts: 14,516
    edited 2015-04-12 06:05
    Hi Bean,

    I'm glad to see your PropBASIC is finally getting some attention! Is it pretty much complete or do you have plans to enhance it? What sorts of changes are you planning?

    Thanks,
    David
  • BeanBean Posts: 8,129
    edited 2015-04-12 06:16
    David Betz wrote: »
    Hi Bean,

    I'm glad to see your PropBASIC is finally getting some attention! Is it pretty much complete or do you have plans to enhance it? What sorts of changes are you planning?

    Thanks,
    David

    In the works to transfer ownership of PropBASIC to Parallax. The language is pretty much complete, but the documentation needs some work. That is what I'll be working on in the near future.

    Bean
  • David BetzDavid Betz Posts: 14,516
    edited 2015-04-12 06:18
    Bean wrote: »
    In the works to transfer ownership of PropBASIC to Parallax. The language is pretty much complete, but the documentation needs some work. That is what I'll be working on in the near future.

    Bean
    Will it be open source once it has been transferred to Parallax?
  • BeanBean Posts: 8,129
    edited 2015-04-12 06:25
    David Betz wrote: »
    Will it be open source once it has been transferred to Parallax?

    It's up to Parallax, but I assume it would since it can be compiled for Windows, Linux, and IOS.

    Bean

    P.S. Source is in Delphi / Lazarus / Free Pascal
  • David BetzDavid Betz Posts: 14,516
    edited 2015-04-12 06:48
    Bean wrote: »
    It's up to Parallax, but I assume it would since it can be compiled for Windows, Linux, and IOS.

    Bean

    P.S. Source is in Delphi / Lazarus / Free Pascal
    Yes, I know it is written in Delphia. You sent me the code a while back to get it running on the Mac. It's nicely written!
  • jmgjmg Posts: 15,173
    edited 2015-04-12 12:41
    Bean wrote: »
    IThe language is pretty much complete, but the documentation needs some work.

    Last time I checked, PropBASIC did not have Conditional Compile, is that planned ?

    as in
    #define PropBASIC  ' implicit in the compiler
    
    #IfDef PropBASIC 
    'PropCode goes here 
    #Else
    ' PC host testing compatible calls go here
    #EndIf
    
    - and of course, a PropPASCAL would have immediate appeal, now Lazarus/FPC works well on Pi2
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2015-04-12 13:09
    jmg wrote: »
    Last time I checked, PropBASIC did not have Conditional Compile, is that planned ?

    as in
    #define PropBASIC  ' implicit in the compiler
    
    #IfDef PropBASIC 
    'PropCode goes here 
    #Else
    ' PC host testing compatible calls go here
    #EndIf
    
    You mean like:
    '{$DEFINE PropBASIC}
    'some code.
    
    '{$IFDEF PropBASIC}
    'Code to compile if PropBASIC is defined.
    '{$ENDIF}
    
    That is supported by PropBASIC (at least as documented, I have not yet used conditional compilation).
  • BeanBean Posts: 8,129
    edited 2015-04-12 13:33
    Yes, PropBASIC does support conditional compilation as shown above.

    Even nested !!!

    Bean
  • jmgjmg Posts: 15,173
    edited 2015-04-12 13:57
    Bean wrote: »
    Yes, PropBASIC does support conditional compilation as shown above.
    Even nested !!!
    Ah, yes, I remember there was some issue around it - the form I gave is portable across FreeBASIC ( and almost portable to xojo (nee RealBasic) http://docs.xojo.com/index.php/%EF%BC%83If...%EF%BC%83Endif )
    whilst I've not seen any other Basic use the conditional in comments form.

    One of the primary areas I use Conditional Defines, is for Code test, often on other hosts, & for that it is important the conditional syntax is portable.

    However, the form you have now should port to a Pascal parser very easily ;)
    {$DEFINE SetCall }
    {$IFDEF SetCall }
    //....
    {$ELSE no pre Call }
    //..
    {$ENDIF SetCall }
    
  • jmgjmg Posts: 15,173
    edited 2015-04-12 14:06
    Bean wrote: »
    ... You'll probably want to use LMM for the G-Code parser. "PROGRAM label LMM" or "TASK taskname LMM".

    Have you looked at gdb support for PropBASIC, at least in LMM mode ?

    From another thread, I've found this out about gdb, which seems to be emerging for the Prop

    ["The debug code in the propeller is a (PropGCC) kernel extension, so the COG part of it fits in the 256 bytes from 0x6c0 to 0x7c0 (the kernel extension space, into which the kernel loads overlays such as debug, floating point, and integer math). There is a bit of LMM code added as well, but it's merged in to the .hub section so I'm not sure of the exact size.
    ...
    at the moment gdb only works in some LMM derivative form (LMM, CMM, XMM). It relies on changes to the LMM interpreter loop."]
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2015-04-12 14:52
    jmg wrote: »
    Have you looked at gdb support for PropBASIC, at least in LMM mode ?

    From another thread, I've found this out about gdb, which seems to be emerging for the Prop

    ["The debug code in the propeller is a (PropGCC) kernel extension, so the COG part of it fits in the 256 bytes from 0x6c0 to 0x7c0 (the kernel extension space, into which the kernel loads overlays such as debug, floating point, and integer math). There is a bit of LMM code added as well, but it's merged in to the .hub section so I'm not sure of the exact size.
    ...
    at the moment gdb only works in some LMM derivative form (LMM, CMM, XMM). It relies on changes to the LMM interpreter loop."]
    While some people like GDB because it is all they know, GDB has to be one of the worst debuggers on any platform (it requires the cooperation of the program, and does not have any means to do real debugging).
  • ersmithersmith Posts: 6,053
    edited 2015-04-12 15:09
    While some people like GDB because it is all they know, GDB has to be one of the worst debuggers on any platform (it requires the cooperation of the program, and does not have any means to do real debugging).

    While GDB certainly has its flaws, what on earth do you mean by "requires the cooperation of the program" and "does not have any means to do real debugging"?
Sign In or Register to comment.