PropBASIC

Hi,
I just finished several projects that use BS2 and Propeller micro controllers. I enjoy writing programs in BASIC so I focused on coming up to speed on PropBASIC 0.1.14.

I downloaded Propelleride with PropBASIC and installed the ide correctly on my laptop with Windows 10 operating system. I also downloaded the PropBASIC 0.1.14 instructions manual. The Propeller Activity Board is connect to the USB port com3.

On page 2 of the manual is a very simple program that should blink an LED on pin 16. The program is as follows:

DEVICE P8X32A

LED PIN 16 OUTPUT

PROGRAM Start

Start:
TOGGLE LED
PAUSE 1000
GOTO Start

After performing a BUILD on the code...the compiler gave errors on each line of code... "expected end-of-line or "["". At the top of the window in bold face the result of the compile was SUCCESSFUL...which it was not since the program was not running.

The description of each line of code is so simple...it is hard to imagine what is wrong.

What is wrong so that I can begin writing PropBASIC programs for my next set of projects? I could use your help.

Sincerely,

Discovery

«13

Comments

  • 86 Comments sorted by Date Added Votes
  • Some ideas...

    Did you set the compiler option in propellerIde to use propbasic?

    Also... did you save the source code with .pbas file suffix? (Instead of .spin)
  • The editing screen came up and I entered the basic program. I will look for the option.

    No, the source code was saved as .spin. I will make the change and try again.

    Thanks,

    Discovery
  • I was able to save the source code as .pbas but I was not able to locate an option to set propellerride to use propbasic. How is that option selected?

    The code compiles but I do not see pin 16 flashing on and off at a 1 second period.

    I wanted to send some printed information to the computer screen for debugging but I don't see anyway to do that based on the instructions provided in the PropBASIC manual. In BS2 code there was a DEBUG command.

    Sincerely,

    Discovery
  • I ran propellerride again and there was no "option" available.

    When I run the compiler...it outputs (0) warnings and (0) errors but when the program is run, the entire screen flashes and the last line is in RED and says ERROR: Download timed out.

    I could use some help here.

    Sincerely,

    Discovery
  • Been a long time to help from memory, but can take a look tomorrow morning. Seems like you are close to solving.
  • Hal AlbachHal Albach Posts: 732
    edited July 15 Vote Up0Vote Down
    Are you running PropellerIDE Ver 0.38.5 which has the PropBASIC built in? Are your FTDI drivers current?

    I just downloaded PropellerIDE 0.38.5, pasted the blink program into the editor, Save As blink.pbas, clicked on the green RUN arrow and the program compiled and loaded. It is sitting in front of me blinking at 1 second intervals. Changed the Pause line to 500, hit run and now the LED blinks twice as fast.

    The PropBASIC Manual under Help indicates the PropBASIC version is 0.01.43.
    Florida, between St. Petersburg and the Gulf of Mexico

    Do not look directly into laser with remaining good eye...
  • Just downloaded PropellerIDE from here: http://developer.parallax.com/propelleride/
    Version 0.38.5.amd64 for Windows 10

    Installed, pasted in your code snippet (with LED changed to pin 26) and saved as Test.pbas
    Connected a Propeller FLiP to the USB port and pressed Run. LED blinks as expected.

    So that confirms your code works. I won't have access to an Activity Board until the morning, but in the meantime, is it sure you have the power switch on to at least position 1 ?

    And did you notice if the WX LED near the USB socket is lit? Maybe try adding a jumper wire from the SEL socket to GND or 3.3V (one of those will select WX, and the other will switch it off). You want it turned off for USB programming. You'll find that SEL socket to the right of the metal crystal can.

    If you don't have the WX LED, then maybe you have an older Activity Board that requires power at the DC Jack. You could try that anyway. Your ERROR: Download timed out message would suggest a communications issue with the Activity Board, and that is most likely an FTDI driver issue, USB cable bad connection, or lack of power at the Activity Board.

    I'll check in tomorrow in case this doesn't get you going. Best of luck.



  • I downloaded the propelleride from the link shown above and the blink program works fine. The earlier download must have had a glitch in it. All is well.

    Next question...How does one display data to the computer screen using the basic program instructions? DEBUG works fine on the BS2. I see no instructions for doing the same in PropBASIC.

    Sincerely,

    Discovery
  • Next question...How does one display data to the computer screen using the basic program instructions? DEBUG works fine on the BS2. I see no instructions for doing the same in PropBASIC.
    You need to use SEROUT. In the BS2, DEBUG is just a specialized version of SEROUT on the programming port.
    Jon McPhalen
    Hollywood, CA
    It's Jon or JonnyMac -- please do not call me Jonny.
  • Do you have a general example of how it could be used for displaying alpha numerical data from the program to the computer screen?

    Sincerely,

    Discovery
  • VonSzarvas wrote: »
    Just downloaded PropellerIDE from here: http://developer.parallax.com/propelleride/
    Version 0.38.5.amd64 for Windows 10

    Installed, pasted in your code snippet (with LED changed to pin 26) and saved as Test.pbas
    Connected a Propeller FLiP to the USB port and pressed Run. LED blinks as expected.

    So that confirms your code works. I won't have access to an Activity Board until the morning, but in the meantime, is it sure you have the power switch on to at least position 1 ?

    And did you notice if the WX LED near the USB socket is lit? Maybe try adding a jumper wire from the SEL socket to GND or 3.3V (one of those will select WX, and the other will switch it off). You want it turned off for USB programming. You'll find that SEL socket to the right of the metal crystal can.

    If you don't have the WX LED, then maybe you have an older Activity Board that requires power at the DC Jack. You could try that anyway. Your ERROR: Download timed out message would suggest a communications issue with the Activity Board, and that is most likely an FTDI driver issue, USB cable bad connection, or lack of power at the Activity Board.

    I'll check in tomorrow in case this doesn't get you going. Best of luck.



    Program works with AB-WX, with or without the Wi-Fi plugged in.
    Infernal Machine
  • JonnyMacJonnyMac Posts: 6,092
    edited July 15 Vote Up0Vote Down
    Discovery wrote: »
    Do you have a general example of how it could be used for displaying alpha numerical data from the program to the computer screen?

    Sincerely,

    Discovery

    I haven't used PropBASIC in a long time, so this code may need adjusting for the latest version of the compiler. Attached is a library that does formatted serial output (it's basically a translation of the transmit routines from FullDuplexSerial). Some of this is a little advanced because I know how to exploit the architecture of PropBASIC (while at Parallax I worked with Bean on SX/B) and I'm comfortable with PASM.
    Jon McPhalen
    Hollywood, CA
    It's Jon or JonnyMac -- please do not call me Jonny.
  • Thank you Jon,

    Then...is PropBASIC essentially dead?

    Discovery
  • Discovery wrote: »
    Thank you Jon,

    Then...is PropBASIC essentially dead?

    Discovery

    I would not say it is dead. It has worked well for a few years, but don't look for any upgrades soon. It's like Basic Stamp and SX/B , they where written, published and can be used in the current state.
    Infernal Machine
  • JonnyMacJonnyMac Posts: 6,092
    edited July 16 Vote Up0Vote Down
    Then...is PropBASIC essentially dead?
    I wouldn't say that -- but you'd have to ask Bean.

    For me, Spin wins. I live, breathe, and think in Spin; all of my Propeller consulting is done in Spin. That said, there are others who do amazing things in PropBASIC, C, Forth, and now Blockly. That's the great thing about the Propeller: you get multiple cores and the language of your choice to solve problems.
    Jon McPhalen
    Hollywood, CA
    It's Jon or JonnyMac -- please do not call me Jonny.
  • As it turns out, the write-ups and discussions that I read regarding the PropBASIC language answered my needs for a language that would be written in BASIC, a language that I prefer for my applications, store the main program in EEPROM so that the code would execute immediately after power-up, execute applications in COGs for mathematics, and perform signal processing.

    I must utilize parts of other's programs to learn how to place code in the EEPROM and how to get data into and out of COGs. Since few people recall much about PropBASIC, that fact will make my effort very hard.

    On the other hand, there are other languages that are available to run on the Propeller and that is a good thing for people like Jon who work at the nuts and bolts of code.

    I am wondering if there is a store house of existing PropBASIC software programs that are available for me to utilize as I push ahead in implementing BASIC-on-a-Propeller.

    Sincerely,

    Discovery
  • There are some libraries in this thread:
    https://forums.parallax.com/discussion/160865/propbasic-library-examples

    If you search propbasic in the forum search box there are some more threads with useful info.
    Tom
  • PropBasic is very cool...I use it exclusively for the Prop. Spin is also cool but slooooow compared to PropBasic. I still don't understand why people would want to have the Prop jumping through so many hoops, consuming more clock cycles and power than is necessary.

    I am also a fan of Viewport (no-longer supported), which is also compatible with PropBasic. With Viewport, you can simply "watch" a variable and it will show up on the terminal screen.
    PropBASIC ROCKS!
  • Twm47099 and Mickster,

    Thank you for the information...I will get on it. Hopefully, I can get a download of the Viewport code.

    My PropBASIC class just began.

    Sincerely,

    Discovery
  • BeanBean Posts: 7,951
    Discovery,
    Sorry I didn't see this thread sooner, but it looks like you have solved the initial problem.
    I am the developer of PropBasic and I use it everyday.
    If you have any further questions feel free to ask on the forums and I will help as much as I can.

    There has been some fixes to PropBasic and I'll have to post a new version since it looks like at least some people as still using it.

    Bean
    Version 00.01.43
      Changed SERIN so it doesn't wait for stop bit
      Optimize Divide and remainder operation [June 27,2014]
    
    Version 00.01.44
      Made PAUSE a subroutine
      Made *, */, **, /, and // operator subroutine
      Allow FREQ with RCSLOW or RCFAST "ProcessFreq" Feb 3, 2016
    
    Version 00.01.45
      Changed A = x - A to generate
        neg A,A
        adds A,x
      Fixed two range errors
      Fixed __remainder was __temp1, but should be __temp4 now Mar 7, 2016
      Fixed: I2C commands in LMM mode require minimum of 150 WAITCNT  Jun 28,2017
      Fixed: I2CSTART locks up if no pull-ups (should only try 10 times) Jun 29,2017
      Fixed: PAUSE, Mult, and Div subroutines were added to TASKs when not used. Jul 18,2017
      Fixed: Bug in >> and << when using var = x >> var caused by A = x - A optimization Jul 28, 2017
      Fixed: Optimize X=X*0 X=X*1, X=X*3, X=Y*0, X=Y*1  REMOVE "shl x,#0" instructions Jul 29,2017
      Fixed: Optimize X=Y*3 "MOV,ADD,ADD" Jul 30,2017
    
    Version 00.01.46
      Fixed 12-23-2017: Fix WRLONG hubVar(undefined) does not error
      Fixed 12-29-2017: __RAM() does not work in TASKs
    
    Version 00.01.47
      Fixed 4-1-2018: Firmware CON 0000_000C causes abort (no $ prefix)
      Needs Fixed: I2C Write needs 9th bit to be a 1 so slave can assert ACK
    
  • Thanks Bean for the ongoing support!
    Infernal Machine
  • Fabulous! Bean,

    I will download the new version when it is ready. Thank you.

    Sincerely,

    Discovery
  • Bean,

    Since you use PropBASIC practically every day...by what means do you DEBUG your code? Have you written DEBUG, PRINT, and WRITE statements for PropBASIC?

    Sincerely,

    Discovery
  • BeanBean Posts: 7,951
    I usually create SUBs for SendChar, SendStr and SendValue.
    Here is code pulled from my current project...
    BAUD            CON "T9600"
    SOut            PIN 30       ' Serial output
    valueStr        HUB STRING(10)
    
    SUB SendChar
       SEROUT SOut, BAUD, __PARAM1
    ENDSUB
    
    
    SUB SendStr
      __PARAM2 = __PARAM1
      DO
        RDBYTE __PARAM2,__PARAM1
        INC __PARAM2
        IF __PARAM1 = 0 THEN EXIT
        SendChar __PARAM1
      LOOP 
    ENDSUB
    
    
    SUB SendHex8
      __PARAM2 = __PARAM1
      __PARAM3 = 8 ' Do 8 digits
      DO
        __PARAM1 = __PARAM2 >> 28
        __PARAM2 = __PARAM2 << 4
        INC __PARAM1,"0"
        IF __PARAM1 > "9" THEN
          INC __PARAM1,7 ' "A"-":"
        ENDIF
        SendChar __PARAM1
      LOOP __PARAM3
    ENDSUB
    
    
    SUB SendValue ' value,digits
      __PARAM2 = 10 - __PARAM2 ' Number of digits to skip
      valueStr = STR __PARAM1,10,0 ' unsigned leading zeros z-string
      __PARAM1 = GETADDR valueStr(__PARAM2)
      DO
        RDBYTE __PARAM1, __PARAM2
        INC __PARAM1
      LOOP UNTIL __PARAM2 <> "0"
      IF __PARAM2 = 0 THEN 
        DEC __PARAM1 ' Send at least one character (may be "0")
      ENDIF
      DEC __PARAM1
      SendStr __PARAM1
    ENDSUB
    
    

    I hope this helps,
    Bean
  • JonnyMacJonnyMac Posts: 6,092
    edited July 16 Vote Up0Vote Down
    I still don't understand why people would want to have the Prop jumping through so many hoops, consuming more clock cycles and power than is necessary.
    My commercial projects tend to get big (recent project was 6000+ lines of compiled code) -- Spin, while slower I admit, has great code density.

    Still... back in the days of SX/B I created a lot of small commercial products for EFX-TEK using it; then we switched everything to the Propeller. Our most popular controller is the HC-8+; perhaps I should create a PropBASIC template for it (I have several Spin templates that our customers use).

    It's a lot to ask, I know, but I wish PropBASIC had it's own, dedicated edit/compile tool.

    @Bean: Have you ever looked at the Xojo compiler? It's x-platform and may have all the right tools to create a nice, stand-along PropBASIC IDE/compiler.

    @Bean: Have you ever done white-paper on translating a Spin+PASM object to PropBASIC. I have several library files from many years ago, but things may have changed in recent years -- I'm not sure if any of them will still work.

    Others: Is anyone using their favorite editor and CLI to compile/load programs?
    Jon McPhalen
    Hollywood, CA
    It's Jon or JonnyMac -- please do not call me Jonny.
  • Thanks Bean...I will work with it this evening.

    Discovery
  • tritoniumtritonium Posts: 233
    edited July 16 Vote Up0Vote Down
    Hi

    My observations-
    I ONLY use PropBasic to program the prop.
    I use Geany as an ide- works great- theres instructions somewhere on how to make it work. Theres no colour coding for the text- not a problem for me.
    I have dozens of little proggies for all sorts of modules.
    I've had hundreds of hours of fun thanks to PropBasic.
    I find the error reporting can be confusing- but close examination of the code usually shows the problem- eventually- though it can be frustrating.
    You HAVE to break statements that have multiple 'actions' into separate actions i.e.-
    x=z+y-3 becomes
    x=z+y
    x=x-3

    Probasic is sufficiently different to say qbasic or freebasic (which I also use a lot) to have to 'get used' to it. In this regard I start a new project by re-naming an old project and then commenting out all the code except for the boiler plate stuff like-

    DEVICE P8X32A, XTAL1, PLL16X
    FREQ 80_000_000

    etc.

    and then using that as a syntax reference and reminder how to do things.
    When you get a program running take a look at the created spin file - there you will see just how it encoded into assembler- I'ver learned enough assembler from that to tweak it for special cases.

    Vga output is as easy as adding LOAD "VGA.lib" under boiler plate and using the provided functions. (and of course adding vga connector and d/a resistors- plenty of info on that.)

    AND although you are limited normally as to how big a program will fit into a cog (as its all assembler) there is an LMM mode which is great for the large but less time critical stuff.

    I love it to pieces and would be happy to pay for it.

    When the prop2 comes out, I will definately get a P2 module, BUT, if there is no PropBasic for it, it may not get used too much.

    I don't publish my code for fear of embarrassment and mockery from the language wars pseudo intellectuals.

    Dave
  • jmgjmg Posts: 12,052
    edited July 16 Vote Up0Vote Down
    JonnyMac wrote: »
    Others: Is anyone using their favorite editor and CLI to compile/load programs?

    I use Notepad++, for many languages, and that can be setup to Launch a batch file, and it has many highlighters.
    The inbuilt Visual Basic highlighter looks usable.

    This is one for version 2.5 of the BASIC Stamp PBASIC language : http://notepad-plus.sourceforge.net/commun/userDefinedLang/PBASIC25_v1_1.xml


    Looks like someone already has a PropBASIC one here https://forums.parallax.com/discussion/comment/936037/#Comment_936037 - but no links ?


    This thread also looks useful
    https://forums.parallax.com/discussion/149659/propbasic-how-to-use-propbasic-in-simpleide

    and also this
    https://forums.parallax.com/discussion/164708/new-release-propelleride-propbasic-fun-times/p2

    ISTR there was a pathway to compile PropBASIC output, that did not need BSTC ?
  • I don't publish my code for fear of embarrassment and mockery from the language wars pseudo intellectuals.
    That made me giggle. I wish you would share code -- it would probably benefit people like me who favor something else and may have missed an opportunity. Maybe we just need to be shown the way.
    Jon McPhalen
    Hollywood, CA
    It's Jon or JonnyMac -- please do not call me Jonny.
  • tritonium wrote: »
    Hi
    I don't publish my code for fear of embarrassment and mockery from the language wars pseudo intellectuals.

    Dave

    I wish you would. When learning a new programming language, I find it very useful to read other folks programs and figure out what they are doing and how they do it. For example I have found Jon's programs very useful for seeing advanced methods of Spin programming, many of which I would never have thought of.

    Tom
Sign In or Register to comment.