PDA

View Full Version : Download PropBASIC here... 00.01.14 LAST VERSION FOR BST



Pages : [1] 2 3 4

Bean
12-24-2009, 02:40 AM
First of all go here http://www.fnarfbargle.com/bst/Latest/
and get the latest version of BST. The .exe version is for windows, Linux for linux and osx for macintosh.

Then go here http://www.fnarfbargle.com/PropBasic/
and make sure you get the latest version of PropBASIC for BST. Version 00.01.14 is the latest version.

Extract both files.

Run the bst file. When it launches, from the menu choose:
Tools->IDE Preferences->PropBASIC click Browse and find the PropBASIC-BST file that you just extracted.

You are now ready to use PropBASIC.

Documentation and demos are available at the bottom of this post.
As well as the PASD debugger (for windows only sorry).

================================================== ====================

I'm hoping you guys will try it out and let me know about any bugs you find.

I figured most people havea lot of time off work with the holidays, so I wanted to get this out there so you could play around with it.

Make sure you run the PropBASICIDE program. This is the front-end / editor for propbasic.
With in the editor you can select "Compile" this compiles and opens the .spin file in the Propeller Tool.
Select "Run", this uses propellent to compile and run the program from RAM.
Select "EEPROM" to burn the program into the EEPROM so it will run at power-up.

Sorry about the limited documentation, Jon (Jonny Mac) is working on some much better documentation.

P.S. Make sure to check out the demo programs in the demos folder.

If you have any questions please ask.

Thanks,
Bean.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/forums/default.aspx?f=25&p=1&m=412552
March 2010 Nuts and Volts articlehttp://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
NEW PropBasic Blog: http://propbasic.blogspot.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
1) Never divulge all information
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you choose not to decide, you still have made a choice. [RUSH - Freewill]

Post Edited (Bean) : 7/21/2010 9:37:08 PM GMT

Toby Seckshund
12-24-2009, 02:43 AM
The name makes it seem that we should be realy nasty to PropBASs



Now the PropbasICIDE name has gone, this lame joke is meaningless.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Style and grace : Nil point

Post Edited (Toby Seckshund) : 4/10/2010 7:44:48 AM GMT

JonnyMac
12-24-2009, 02:49 AM
For those that have their own favorite text editor, you can use that, too. I have been using EditPlus to write, compile, and download my PropBASIC programs (downloading handled by connecting to Propellant).

Rsadeika
12-24-2009, 03:46 AM
I have a question about the serin/serout commands, does it use a cog to accomplish the deed. I can visualize a program where I might be using two 'task's, and each 'task' would be be using separate sets of pins for the serin/serout commands. So, how many cogs would be involved? A general question would be, are there any commands that use a cog(s), in order to work?

Hopefully in your future version of the IDE, you might have a tally of how many cogs are being used, along with ram usage. I have not coded a program just yet, but it feels familiar. I am sure I will have more questions. Looks good so far Bean.

Ray

Bean
12-24-2009, 03:57 AM
Ray,
None of the commands use another cog. Everything is done in-line.

Only TASKs that are started with COGSTART or COGINIT run in another cog.

Bean

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropBASIC home page www.propbasic.com (http://www.propbasic.com)
·

SamMishal
12-24-2009, 04:37 AM
Looks GREAT....will definitely be playing with it soon.

WELL DONE.....this should be a GREAT addition to the Propeller especially for people
who come from the BS2 side....good stuff.

I also LOVE the PASM side by side to the BASIC code.....this should make for a GREAT
PASM educational tool...wonderful.

Samuel

Rsadeika
12-24-2009, 05:46 AM
Another serin/serout question, can the 'pin', and 'baud' values be variables? So, you have something like 'serin inpin, baudrate, inbyte', in a function or a subroutine. If I have a UART subroutine or function, using the serin/serout commands, will I be able to call the UART from within TASK's, with each TASK using a different set of pins, and only using the one subroutine/function? I am wondering if there will be a collision, if the TASK's try to run the UART subroutine/function at the same time?

I am getting ready to do some testing of the SD card that I have, what would be the recommended way of setting up a program to accomplish this. Since the existing code is an object, propBASIC is not capable of handling existing objects, or is it?

Have you considered adding an ADC command? I have another test scenario where I want to check the charge level of a battery. I am thinking of a 'voltage divider' setup, and an ADC command that would use only one pin for the incoming data.

Ray

JonnyMac
12-24-2009, 05:50 AM
As Bean mentioned earlier we are working on formal docs -- since the cat is out of the bag I thought I should post a preview. Keep in mind this is just a preview and while it shows the syntax of all commands, it doesn't fully explain them (we're about 15% complete on this). Use the PDF included in Bean's ZIP and demo programs for the time being. And... if you think you have a great idea/demo to submit for the official help document, by all means do.

The goal is to create a nice document that you can use as a PDF or trot over to a print shop and have spiral-bound (so that it lays flat).

Happy Holidays!

[Edit] Updated 01-18 (note: still a work in progress and compiler is still in beta)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

Post Edited (JonnyMac) : 1/18/2010 10:12:43 PM GMT

RossH
12-24-2009, 06:28 AM
Hi Bean,

Very nice manual - congratulations!

Ross.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina (http://forums.parallax.com/showthread.php?p=844004)

JonnyMac
12-24-2009, 06:38 AM
Rsadeika said...
Another serin/serout question, can the 'pin', and 'baud' values be variables? So, you have something like 'serin inpin, baudrate, inbyte', in a function or a subroutine. If I have a UART subroutine or function, using the serin/serout commands, will I be able to call the UART from within TASK's, with each TASK using a different set of pins, and only using the one subroutine/function? I am wondering if there will be a collision, if the TASK's try to run the UART subroutine/function at the same time?

I am getting ready to do some testing of the SD card that I have, what would be the recommended way of setting up a program to accomplish this. Since the existing code is an object, propBASIC is not capable of handling existing objects, or is it?

Have you considered adding an ADC command? I have another test scenario where I want to check the charge level of a battery. I am thinking of a 'voltage divider' setup, and an ADC command that would use only one pin for the incoming data.

Ray


You've actually jammed a whole bunch of questions into one -- I can help (a little). With SERIN and SEROUT you can presently use a variable pin but you need to use a constant for the Baud (mode and speed) setting -- for most programs this will be fine. It would take a redesign of the SERIN/SEROUT code to support a variable baud, and I think it would generate more code, perhaps significantly more.

For the time being, you can do something like this:



' Use: TX_BYTE txpin, byteout
' -- shell for SEROUT
' -- allows selection of TX pin for multiple devices
' -- Baud is set as program constant

SUB TX_BYTE
SEROUT __param1, Baud, __param2
ENDSUB


This lets you direct your output to any pin -- given a fixed Baud setting. Again, Baud represents bot the mode (T, N, OT, or ON) and the speed (bps).

You could create tasks to handle serial IO that buffer the data; I would suggest one per device. Still, you could use some cute trickery with hub variables to control where a task sends something (I think it would create more problems than solve, however).

SD card support requires a significant chunk of code; have a look at the FSRW object for Spin to see for yourself.

Bean wrote a demo (that's in his ZIP) that demonstrates using one of the counters as an ADC -- have a look at sndmeter.pbas

Rsadeika
12-24-2009, 07:07 AM
That is what I was referring to, the FSRW object, that could be be a major project in itself, to convert it to propBASIC. The other major project could be, some propBASIC code for the use of the upcoming Memory Expansion Board. Hopefully propBASIC will be able to handle the expanded memory capabilities. Or will it? If we have to start rewriting all the existing object code to propBASIC, isn't that going backwards? And, in that case, will there be a propBASIC section in the object exchange?

Ray

BR
12-24-2009, 07:13 AM
Bean, Jon: Wow! VERY nice work! My Prop demo board suddenly looks like a stamp on steroids.

I downloaded PropBasic and ran through most of the demos in less than 5 minutes. Setup was a breeze (there wasn't any). I glanced through the manual that comes with the package, but it really wasn't necessary because the thing is virtually self-documenting. IDE simple, clean, completely intuitive. And the Pbasic syntax is quite easy to digest anyway. The in-line basic-to-PASM conversion is really neat, a great way to bust down that PASM learning curve barrier. Not to mention this should be handy for whipping up quickie assembly routines for inclusion into other Spin projects.

And this thing is FREE!?

JonnyMac
12-24-2009, 07:20 AM
Bean and I are open to Christmas presents! http://forums.parallax.com/images/smilies/smile.gif

Bean
12-24-2009, 07:50 AM
PropBASIC cannot run spin code. So the existing objects cannot be used as is.
If you look at the Mouse_to_PC demo, I took the existing mouse object and modified it slightly to work with PropBASIC.

PASM code will need slight modifications, spin code will need to be completely re-written.

The best present I could get right now is some cool PropBASIC programs. Or believe it or not some bugs discovered (I know there are some in there).

Jon needs to be commended on his dedication to the documentation. He is not being paid for all his hard work, and I kept changing/adding features on him.
I know I should have waited until his documentation was completed, but I really wanted the bugs to be found sooner rather than later.
And this is the best time of year to check members with lots of free time being off work for a couple days.

My hope is that the compiler will be useful enough to warrent inclusion in the Propeller tool.
We shall see, I just need to get Ken and some of the Parallax employees hooked on it.

Bean.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropBASIC home page www.propbasic.com (http://www.propbasic.com)


Post Edited (Bean (Hitt Consulting)) : 12/24/2009 12:58:50 AM GMT

Bean
12-24-2009, 08:16 AM
If you do want to use a different editor when you call PropBASIC.EXE to compile the code, you need to use

PropBASIC.EXE "C:\completepath\myfile.pbas" /p

The /p means to pause on errors.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropBASIC home page www.propbasic.com (http://www.propbasic.com)
·

hover1
12-24-2009, 08:56 AM
Jon and Bean,

I know this has been a huge undertaking and I want to personally thank both of you for this. From what I have tried, it works great!

As for presents, I have a few SX28 Dip chips to give you, (since they are out of stock), but I'm sure Ken keeps both of you in SX happy land.

Merry Christmas,

Jim


JonnyMac said...
Bean and I are open to Christmas presents! http://forums.parallax.com/images/smilies/smile.gif

JonnyMac
12-24-2009, 09:25 AM
Bean has done the heavy lifting, creating the compiler and putting up with my "suggestions." http://forums.parallax.com/images/smilies/tongue.gif

Cluso99
12-24-2009, 10:20 AM
Congratulations! Great work guys http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Home of the MultiBladeProps: TriBlade (http://forums.parallax.com/showthread.php?p=786418),·RamBlade (http://forums.parallax.com/showthread.php?p=849265),·SixBlade (http://forums.parallax.com/showthread.php?p=780033), website (http://bluemagic.biz/cluso.htm)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator) (http://forums.parallax.com/showthread.php?p=790917)
· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) (http://forums.parallax.com/showthread.php?p=778427) ZiCog (Z80) (http://forums.parallax.com/showthread.php?p=788511) , MoCog (6809) (http://forums.parallax.com/showthread.php?p=811043)
· Search the Propeller forums (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)·· MultiBladeProp is: www.bluemagic.biz/cluso.htm (http://www.bluemagic.biz/cluso.htm)

Bob Zero
12-24-2009, 05:29 PM
Thank you very much . I just bought a Chameleon PIC system with PIC24 and Propeller from XGS and this is the cherry on top .

Rsadeika
12-24-2009, 09:57 PM
I have a question about the COUNTERA/COUNTERB command, which mode would I use to check the values of a voltage divider? I set up a little test to check the charge level of a battery (9V), in this case. The battery is at 6.76V, and with my voltage divider the value is 2.83V, I am using 10K resistors to achieve this. There are a lot of 'mode' selections, and I am not sure what they all mean, like 'POS', is that 'point of sale' LOL. I guess I need a mode that would give me the value, that would make sense, in the program, for checking the charge level.

Thanks
Merry Xmas to everyone!

pmrobert
12-24-2009, 11:31 PM
The Prop has no internal ADCs. You can either use a sigma delta technique or a separate ADC chip to convert your divider output to a digital form the Prop can understand.
Merry Xmas back to you!

Bean
12-24-2009, 11:35 PM
Rsadeika,
· Use mode 72 (POSFB). You'll need to use two pins.
· Look at the sndmeter demo program and the demo board schematic.
· It uses microphone built into the demo board and samples it.

· The demo board uses P8 for the feedback pin, and P9 for the output pin.

· You would keep the 100K resitor, and the two 1nF caps. And connect the output of your voltage divider to the point where all three come together (so you'll have 6 leads together).
· You may need to adjust the values of your voltage divider (keeping the ratio the same) to get a good voltage range when you read it.

Bean

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropBASIC home page www.propbasic.com (http://www.propbasic.com)


Post Edited (Bean (Hitt Consulting)) : 12/24/2009 5:34:07 PM GMT

JonnyMac
12-25-2009, 12:52 AM
There's an application note for the counter modules that you can download here:
-- www.parallax.com/tabid/442/Default.aspx (http://www.parallax.com/tabid/442/Default.aspx)

See page 17 for ADC circuitry and warnings (some components must be placed very close to the Propeller).

TonyWaite
12-25-2009, 03:08 AM
I've a question regarding PropBASIC:

Could there be a workaround - however rough - that would enable one to include the functionality of some of our favorite Obex utilities?

Perhaps a template written in Spin to behave as the 'wrapper'; calling in a variety of Spin objects from the Obex, including of course the compiled output of the main application written in PropBASIC?

It may be inelegant, but it would be a very useful kludge.

T o n y

Bean
12-25-2009, 07:09 AM
Tony,
There has been some threads about starting a spin cog from PASM.
That would probably allow some of the object to work, but I haven't explored it yet.

If anyone has knowledge of how to do this, please try get it working.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropBASIC home page www.propbasic.com (http://www.propbasic.com)
·

JonnyMac
12-25-2009, 07:38 AM
Another big challenge is creating an interface between PASM (PropBASIC) and Spin methods in another cog.

Eagleman
12-25-2009, 08:54 AM
http://forums.parallax.com/images/smilies/jumpin.gif· http://forums.parallax.com/images/smilies/hop.gif· http://forums.parallax.com/images/smilies/jumpin.gif· http://forums.parallax.com/images/smilies/roll.gif http://forums.parallax.com/images/smilies/jumpin.gif·http://forums.parallax.com/images/smilies/hop.gif

Bean·and JonnyMac,·· YEEEEAAAAAHHHH!!!

Can't thank you enough for the Propbasic project!!···I just downloaded the zip files and just printed the documentation, but haven't read it yet. I'm looking forward to trying it out over the next week.· I have plenty of Pic Basic Pro code that I didn't want to rewrite.·· I imagine there will be some rewriting to port the PBP to PropBasic, but hoping that it would minimal.· But thanks, just having PropBasic will be a big help in using the Prop, learning Spin and even a big help in learning PASM.

Alex41
12-25-2009, 09:34 AM
Great work Bean and JonnyMac!!


Scanning the documentation .pdf it looks a lot like SX/B which I'm glad to see!

My beginning experience has been on the SX and this makes a great transition to the Propeller that I just received.


Alex

mcstar
12-26-2009, 06:12 AM
Since others are using editplus as well, I thought I'd post my syntax file for PropBasic.··Just create·a new file type under Tools->Preferences-> files and syta and point it at the syntax file attached. Set the file extension to pbas.

Since Editplus has the ability to run external programs, you can even set it to to build the pbas file using the Propbasic.exe and deploy the resultant file to a connected propeller using Propellent.exe!·
To set it up, make sure the user toolbar is showing (View-> Toolbars -> User Toolbars) and add two new custom buttons to the tool bar.· Point the first one at the propbasic.exe with this argument.· "$(FilePath)"
Point the second button to the Propellent.exe with this argument $(FileDir)\$(FileNameNoExt).spin

Now build and compile is just two clicks and integrated into an ide with syntax highlighting!

HollyMinkowski
12-26-2009, 06:32 PM
Bean and Jonny, this is really super! http://forums.parallax.com/images/smilies/smile.gif

I hope I get skilled enough with the prop to someday contribute something as nice as this.

Ron Sutcliffe
12-26-2009, 08:26 PM
Bean, fantastic. I can see this taking off.·· Jon, ·your work to date on the docs looks great.

This effort will draw more users to Prop. Those·who may have otherwise been put off by the idea of learning Spin. (fear of the unknown)

Query

Can more than 7 tasks be declared at compile time ?·Being able to·take advantages of the various external memory schemes that are floating around (i.e Hydra and the HX512k card in my case) is really appealing.



Regards

Ron

Mike_GTN
12-26-2009, 09:32 PM
Hi Bean,

What excellent work you have done on your PropBasic Compiler project. I hope that this will enable a few of the people that currently use the SX range and Basic Stamp to move over to the Propeller Micro and feel more at ease until they jump in to Spin & Pasm. Is a good learning tool already being able to see generated code. The next object that I would love to see is any VGA driver, as being English find the video output (PAL) from the Propeller to be - well awfull and in my personal opinion holds this device back from some actual commercial applications.

I certainly do not under estimate the hard work you and also Jonny Mac (with the documentation) have done to get this up and running so quickly. Believe 2010 will see this project as another language option for the Propeller, and this has to be very good indeed for everyone.

With regards

Mike.

JonnyMac
12-26-2009, 11:18 PM
Thanks for doing that -- I've been using EditPlus for all my PropBASIC stuff but hadn't taken the time to create a syntax file; you just saved me a bit of time.

I setup three tools:

1) Compile PropBASIC
-- command: C:\Documents and Settings\Administrator\My Documents\Programming\Propeller\PropBASIC\PropBasi c.exe
-- arguement: "$(FilePath)"

Note the quotes around the arguement -- this is required if the path contains spaces.


2) Download to RAM
-- command: C:\Documents and Settings\Administrator\My Documents\Programming\Propeller\Propellent.exe
-- arguement: "$(FileDir)\$(FileNameNoExt).spin"

3) Download to EEPROM
-- command: C:\Documents and Settings\Administrator\My Documents\Programming\Propeller\Propellent.exe
-- arguement: /EEPROM "$(FileDir)\$(FileNameNoExt).spin"




mcstar said...
Since others are using editplus as well, I thought I'd post my syntax file for PropBasic. Just create a new file type under Tools->Preferences-> files and syta and point it at the syntax file attached. Set the file extension to pbas.


Since Editplus has the ability to run external programs, you can even set it to to build the pbas file using the Propbasic.exe and deploy the resultant file to a connected propeller using Propellent.exe!

To set it up, make sure the user toolbar is showing (View-> Toolbars -> User Toolbars) and add two new custom buttons to the tool bar. Point the first one at the propbasic.exe with this argument. "$(FilePath)"

Point the second button to the Propellent.exe with this argument $(FileDir)\$(FileNameNoExt).spin



Now build and compile is just two clicks and integrated into an ide with syntax highlighting!

Ken Gracey
12-27-2009, 12:46 AM
Dear Bean and JonnyMac,

I've been sitting on the sidelines watching your PropBASIC efforts. I know what the two of you can achieve as a team from watching the SX/B progression over recent years. JonnyMac is most excellent with documentation, coding and projects; Bean is an experienced compiler developer who sticks with the project and manages the many requests he shall receive (often from JonnyMac himself) without discounting them as too difficult or not necessary. This project needs the two of you and shows what happens when two guys with unique skills put their efforts into one project. The fact that you're doing this for the Propeller is really humbling for Parallax and Propeller users everywhere, causing me to hang quietly in the background until I actually give PropBASIC a try.

We couldn't be more lucky and appreciative to have the two of you as part of the team! The early documentation looks very good and is certainly part of the key to PropBASIC long-term success.

Sincerely,

Ken Gracey
Parallax Inc.

Cluso99
12-27-2009, 09:31 AM
mcstart: nice work.
Bean & JonnyMac: Fantastic - I can see a great future for this in 2010 http://forums.parallax.com/images/smilies/smile.gif

Bean, you asked about starting a spin cog from pasm. It is fairly simple. Sorry, I don't have the time to check just at the moment. You can look at the Spin Interpreter code. You require 2 parameters. The start address which is in hub ROM for the interpreter (cannot recall the address) and the address of the spin code. If Hippy has the time he could help.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Home of the MultiBladeProps: TriBlade (http://forums.parallax.com/showthread.php?p=786418),·RamBlade (http://forums.parallax.com/showthread.php?p=849265),·SixBlade (http://forums.parallax.com/showthread.php?p=780033), website (http://bluemagic.biz/cluso.htm)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator) (http://forums.parallax.com/showthread.php?p=790917)
· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) (http://forums.parallax.com/showthread.php?p=778427) ZiCog (Z80) (http://forums.parallax.com/showthread.php?p=788511) , MoCog (6809) (http://forums.parallax.com/showthread.php?p=811043)
· Search the Propeller forums (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)·· MultiBladeProp is: www.bluemagic.biz/cluso.htm (http://www.bluemagic.biz/cluso.htm)

mcstar
12-27-2009, 11:58 AM
Errata notice :
While trying to get the video demos to work with a TV out, I had a bit of trouble. It didn't take too long to find cause, but here is the fix in case others are hitting the same snag. BTW, working through this did help me learn a few things about the video processor in the propeller that I didn't know, so if you want to solve the challenge yourself, please stop reading now http://forums.parallax.com/images/smilies/smilewinkgrin.gif

First off, let me say, I'm blown away by how little code is needed to get the video driver to work! Before compiling in PBasic, MoneVid is only ~50 lines of code. After compiling MonoVid.spin is only 167 lines of Assembly code and that's with lots of extra space and comments. Wow! Just think, that's the entire video driver.

For my setup I'm using a PRC board with the PRC TVIO card from wulfden.org which has the TV output on pins 20-23. The same problem will occur with the demo board if using TV output, but you shouldn't have to change the pins, only the VideoMode.

Originally, I tried just setting my TV output pins using the Basic variables defined near the top of the page like this.

SyncPin PIN 20 OUTPUT ' Sync signal on pin 12 (Demo board)
VideoPin PIN 22 OUTPUT ' Video (black / white) signal on pin 14 (Demo board)

But this result in no output at all. An Oscope confirmed that although I was a getting a pulse on pin 20, there was definitely no video. So, I dove deeper into the video driver (monovid). This led me to line 161, the video config. Here's what it was set to.

VCFG = %0_01_0_0_0_000_00000000000_001_0_0100_0000

A couple things here, first the pin group and pin mask are hard coded, thus changing the sync and video pin were not having any affect on the output for the video PLL. Also, the 01 indicates the video processor would be generating VGA not composite. Here's my corrected VCFG setting for showing composite video on the PRC TVIO board...

VCFG = %0_10_0_0_0_000_00000000000_010_0_1111_0000 'PRICO

And Ca-Ching~! I'm reward with a zillion little dots flying around on the screen. http://forums.parallax.com/images/smilies/yeah.gif

mcstar
12-27-2009, 12:05 PM
Thanks for the EEPROM Command JohnnyMac.
I just added that to my toolbar as well. Very Nice.

JonnyMac
12-28-2009, 05:02 AM
I played with your syntax file, adjusting it to my nutty liking (different name so you can try it without losing the other). I've also attached a screen shot of my color selections and my template file.

[Update] 12-31-2009 : Found INC and THEN missing from propbasic.stx -- update attached.

Post Edited (JonnyMac) : 12/31/2009 7:48:47 PM GMT

Bean
12-28-2009, 09:02 PM
mcstar,
I've always used the non-standard VGA setting.
I'm not sure why it wouldn't work, but if you got it working that's great.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropBASIC home page www.propbasic.com (http://www.propbasic.com)
·

Mike Huselton
12-29-2009, 12:03 AM
hippy,


Cluso said...

Bean, you asked about starting a spin cog from pasm. It is fairly simple. Sorry, I don't have the time to check just at the moment. You can look at the Spin Interpreter code. You require 2 parameters. The start address which is in hub ROM for the interpreter (cannot recall the address) and the address of the spin code. If Hippy has the time he could help.



How about it? Do I need to motivate my lumbering carcass to take up the sub-project?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH

Bean
12-29-2009, 12:32 AM
Because of the cog startup time, I think the best way to handle spin code would be to leave the spin interpreter running and use it was a dispatcher with hub variables.

Basically the spin code would wait for a "spinID" variable to get set to a value that indicates what spin routine you want to call.

The spin code would run that routine and return any values in some kind of "spinData" variables.

I'll try to mock up something in the next couple days to demonstrate what I mean.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropBASIC home page www.propbasic.com (http://www.propbasic.com)
·

TonyWaite
12-29-2009, 02:12 AM
Comment to Mike Huselton:

Hi Mike,

I check this forum several times daily with the hope of seeing exactly a reponse such as yours!

I've been researching all the variations of 'calling Spin from PASM' within the Forum to run with Cluso's advice; and am convinced that even to _understand_ the problem takes further thought.

Regards and encouragement,

T o n y

TonyWaite
12-29-2009, 02:23 AM
Comment to Bean:

This sounds promising. Phil Pilgrim has posted code previously on calling Spin from PASM - using a 'dispatch' methodology and example; but it is beyond my comprehension unfortunately.

Regards,

T o n y

skynugget
12-29-2009, 04:56 AM
* hug Bean and JonnyMac *

Post Edited (skynugget) : 12/29/2009 10:06:34 PM GMT

Mike Huselton
12-29-2009, 06:28 AM
Bean,

I hadn't considered startup time for this process. So, obviously, a monitor process already running would neatly solve several problems.

Now, to consider the nature of that dispatcher task: Spin or Pasm or PropBasic?
PropBasic would work for educational purposes and can be optionally included as the first thing to be processed in all 7 possible tasks.
I will need to reread the documents and do some testing before going too far along this path.

Optimization can come later. Time to do some 'spermentin'...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH

Post Edited (Mike Huselton) : 12/28/2009 11:35:19 PM GMT

Bean
12-29-2009, 10:02 AM
Just a note to let everyone know that a new version of the PropBASIC compiler has been posted in the first post.

Mike, The dispatcher will almost certainly have to be written in spin.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropBASIC home page www.propbasic.com (http://www.propbasic.com)
·

JonnyMac
12-29-2009, 11:50 PM
An updated version of the (work-in-progress) manual has been posted as well -- see my post on page #1 of thread.

Bean
12-31-2009, 01:15 AM
Here is a demo program showing how to interface spin objects into PropBASIC using a spin dispatcher.


If you try this demo, make sure it's NOT in the same directory as the keyboard demo PropBASIC code. The PropBASIC keyboard demo creates a "keyboard.spin" file that is NOT the one we want to this demo.


You can see that I used an ASM...ENDASM block to insert the object and dispatcher code. Even though it's not PASM code, the ASM...ENDASM commands don't care they just put whatever is between them into the output file.


' Put in code to run spin dispatcher
ASM
OBJ
Key: "Keyboard"

PUB SpinStart
CogInit(1, @__Init, @__DATASTART) ' Start PropBASIC program
Repeat
case spinCmd
spinKeyStart:
Key.Start(spinP1, spinP2)
spinCmd := 0

spinKeyGetKey:
spinP1 := Key.GetKey
spinCmd := 0

ENDASM


If you have any questions about how this works, please let me know.


Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropBASIC home page www.propbasic.com (http://www.propbasic.com)


Post Edited (Bean (Hitt Consulting)) : 12/30/2009 6:41:25 PM GMT

TonyWaite
12-31-2009, 07:44 AM
Hi all,
Just to report SUCCESS using Bean's method to call a Spin object from PropBASIC!
I spent an hour trying to use the example given, before giving up and writing some _really_ simple code.
The joy finally on hearing a 400Hz tone generated by Spin called from the Obex by PropBASIC!
Many thanks,

T o n y

TonyWaite
12-31-2009, 08:10 AM
Here's the code that I used. It may be crude, but it works!
Regards, T o n y

DEVICE P8X32A, XTAL1, PLL16X
FREQ 80_000_000
ASM
OBJ
soundmachine: "Profbrd_tonegen" 'this is one of Rayman's sound drivers, renamed "Profbrd_tonegen" in my files
PUB SpinStart
CogInit(1, @__Init, @__DATASTART)
soundmachine.tonegen(400,500,3) 'sends frequency/duration/attenuation to the tonegen subroutine
ENDASM
PROGRAM Start
Start:
END

Geekgirl
12-31-2009, 11:58 PM
Being new to the propeller, I'm hoping you guys with much greater knowledge can help.

I can't get "GOSUB" to work, but I can't find anything about declared SUB / FUNC which the documentation says replaces it.

If I use goto to get to the subroutine, and another goto (instead of return) at the end of the subroutine with a label at the place it should have "returned to" it works.

The error is "Undefined ?_RET symbol".


The other issue I can't seem to work around is "Origin Exceeds" errors.

If some one could explain what they mean, it might get me on the right track.

I keep getting the Origin Exceeds errors·once I have reached a fairly small number of code lines (about 200). If I rem (comment)·some out, I can use others, so it seems to be based on the amount of code, not some particular code.


Interestingly, the errors show up onscreen a minute or two after compiling (which shows no errors) and attempting to download to RAM, which just sort of·flashes for a second·the "downloading window", but doesn't download anything.

Bean
01-01-2010, 12:12 AM
The Origin exceeds fit limit means that you have too much code. The PASM code that PropBASIC generates must fit within the COG. So only 496 instructions are allowed.

Some PropBASIC commands generate alot of PASM code so you need to put them into a subroutine.

If you look at the template.pbas you will see that near the top of the program you declare the subroutines along with how many parameters they need.



Plot SUB 2


Means you will have a subroutine named "Plot" that takes 2 parameters.

Near the bottom of the template you will see where you put the actual subroutine code.



SUB Plot
' Parameters are in __PARAM1 and __PARAM2
ENDSUB


If you could post your code we could help you much more.

Another more complecated thing to do is to break the program into multiple TASKs. Each TASK runs in it's own COG, so each TASK can have 496 PASM instructions.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Try BASIC on the Propeller.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

Post Edited (Bean (Hitt Consulting)) : 12/31/2009 5:17:57 PM GMT

JonnyMac
01-01-2010, 01:02 AM
@Geekgirl: If you post your .pbas source Bean and/or I can fix it up for you -- that should help get you going as we continue to work on the docs.

One of the code space killers we frequently run into is PAUSE -- it's used a lot and generates several lines of code; one way to save space in your program is to create a subroutine that serves as shell for PAUSE. Start by defining the subroutine -- here's how I do it:



DELAY_MS SUB 1, 1 ' shell for PAUSE


Now you have to write the code for the definition; this one is easy:



' Use: DELAY_MS duration
' -- shell for PAUSE

SUB DELAY_MS
PAUSE __param1
ENDSUB


As you learn about PropBASIC you'll find that parameters are passed in the __paramX (1 - 5) variables. With 32-bit numbers we only need one value, and this can be dropped right into PAUSE as I've done in the DELAY_MS subroutine.

In your program you'll now substitute DELAY_MS for PAUSE (except in the body of the subroutine -- we need that one for the compiler). I had a look and PAUSE generates six lines of code. Using DELAY_MS uses only two lines -- that's a nice savings every time we need a delay, which can be frequent in many programs.

Of course, this is a very simple example but is shows the code-savings power of SUBs and FUNCs. I've attached a little working demo that uses DELAY_MS so you can see exactly how it works.

Post Edited (JonnyMac) : 12/31/2009 6:15:10 PM GMT

Geekgirl
01-01-2010, 01:23 AM
Bean (Hitt Consulting) said...
The Origin exceeds fit limit means that you have too much code. The PASM code that PropBASIC generates must fit within the COG. So only 496 instructions are allowed.

Some PropBASIC commands generate alot of PASM code so you need to put them into a subroutine.

If you look at the template.pbas you will see that near the top of the program you declare the subroutines along with how many parameters they need.




Plot SUB 2


Means you will have a subroutine named "Plot" that takes 2 parameters.

Near the bottom of the template you will see where you put the actual subroutine code.



SUB Plot
' Parameters are in __PARAM1 and __PARAM2
ENDSUB


If you could post your code we could help you much more.

Another more complecated thing to do is to break the program into multiple TASKs. Each TASK runs in it's own COG, so each TASK can have 496 PASM instructions.

Bean.

I am working from the template, and saw the place to declare subs, but have no idea how it's done or what a parameter is or how you know how many the sub would have.

I put the sub code in the lower area specified for that.

Here's the program code that works. Apparently that's all the instructions cog0 can hold.

Thanks in advance,

Darlene

JonnyMac
01-01-2010, 01:37 AM
@Darlene,

As I expected, lots of PAUSE usage (see my post above). Another way to save code is to declare pins as outputs and then write a value (0 for off, 1 for on) to the pin. I'll touch up you code and repost.

Bean
01-01-2010, 01:55 AM
Here is one way to make it smaller.

I make the LEDs pin groups, this makes it easier to assign colors to them.

I didn't convert all of your code, but you should be able to get the idea.

Bean.


P.S. I screwed up the color names. I have posted the correct version.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Try BASIC on the Propeller.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

Post Edited (Bean (Hitt Consulting)) : 12/31/2009 7:03:57 PM GMT

Geekgirl
01-01-2010, 02:08 AM
JonnyMac said...
@Darlene,

As I expected, lots of PAUSE usage (see my post above). Another way to save code is to declare pins as outputs and then write a value (0 for off, 1 for on) to the pin. I'll touch up you code and repost.
I changed all the PAUSEs to DELAY_MS, and set some times (T1, T2 ... ) as constants to use with it, and it works OK. It saved enough space that I didn't have to comment out anything.


I see what you mean about the pins thing, it's not as easy to visualize that yet as it is to think in·the way I've been doing it with the stamp, which is what the first code I posted based from.


Sometimes this stuff makes me feel like such a moron for a a while, and then the light bulb starts to flicker.


Thanks for all the help.


Darlene·

Shawn Lowe
01-01-2010, 02:26 AM
Darlene-
DONT fell stupid or foolish! PropBasic is almost exactly like SX/B, and I've been studying JonnyMac's and others code for a YEAR now and still learn new things everyday! Take your time, keep your mind open and play! It'll get easier!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Shawn Lowe


When all else fails.....procrastinate!

Geekgirl
01-01-2010, 02:33 AM
Bean (Hitt Consulting) said...
Here is one way to make it smaller.

I make the LEDs pin groups, this makes it easier to assign colors to them.

I didn't convert all of your code, but you should be able to get the idea.

Bean.
·

P.S. I screwed up the color names. I have posted the correct version.

WOW, Thanks....·

It took me a while to see how the colors worked, but then I saw how you broke the pins into groups of three and the color constants when seen as 3bit·binary, my light bulb is starting to flicker.


Darlene

JonnyMac
01-01-2010, 02:38 AM
Here's a version of Terry's program that lets you store the lighting sequences in a DATA table (does not use program space as tables are stored in the Hub) -- this will let you define sequences using Terry's color scheme, which is FAR EASIER than the high-low mash-up strategy you started with. You simply call the PLAY subroutine with the sequence you want to use and the step timing.

Geekgirl
01-01-2010, 04:10 AM
JonnyMac said...
Here's a version of Terry's program that lets you store the lighting sequences in a DATA table (does not use program space as tables are stored in the Hub) -- this will let you define sequences using Terry's color scheme, which is FAR EASIER than the high-low mash-up strategy you started with. You simply call the PLAY subroutine with the sequence you want to use and the step timing.



Thanks again!

This is wayyyy cool, at least to me.

I'm still working to understand exactly·how it all does what it does on this version, this is a lot of new ground for me, but it's coming.


Darlene

JonnyMac
01-01-2010, 04:26 AM
There's a hidden trick in there: When you pass a Hub variable or xDATA symbol to a subroutine or function it is passed by address, not by value. In order to read from the hub you have to use RDxxxx, in this case we use RDBYTE as the sequence is a table of bytes. The syntax for RDBYTE is RDBYTE hubaddress, value. This gets used six times (for your six RGB led groups) in PLAY checking for an end-of-sequence value ($FF) each time, and then incrementing (adding one to) the address for the next group. After all the LEDs are updated the delay value you passed is used with DELAY_MS (shell for PAUSE).

There is a compiler trick in use, as well. You see, PropBASIC knows how to adjust outputs for a pin group, based on the location of that pin group. The [internal] code isn't difficult, nor is it trivial. For example, if you want to do this:



CSG6 = PURPLE


... the compiler actually generates the following code. I've added comments to explain what each line does



' CS6 = PURPLE
mov __temp1,#PURPLE ' copy PURPLE (%101) to __temp1
shl __temp1,#15 ' align with base pin of CS6 group
and __temp1,CS6 ' clear non-CS6 bits from __temp1
andn outa,CS6 ' clear old CS6 group outputs
or outa,__temp1 ' write new value to CS6 group outputs

Post Edited (JonnyMac) : 1/1/2010 2:36:52 AM GMT

Bean
01-01-2010, 04:47 AM
Geekgirl,
· Yeah if you're coming from PBASIC "pin groups" are great.
· If you need more assistance please ask. It's nice to see what forum members are "up to" with PropBASIC.

· P.S. Jon must have downloaded my code before I fixed the color names.· ORANGE should be YELLOW, and PURPLE should be MAGENTA, and AQUA should be CYAN.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Try BASIC on the Propeller.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

Post Edited (Bean (Hitt Consulting)) : 12/31/2009 9:54:16 PM GMT

TonyWaite
01-01-2010, 05:24 AM
A little more development on using Bean's method to talk to Spin objects from PropBASIC, running on Rayman's PSM.
The following makes two Spin objects available on demand to the main BASIC program;
This time there actually is some code in the BASIC program; which generates a tone, then displays version detail on the LCD.
The object of posting this is so that newcomers like myself can have an easy example, with a low level of abstraction.
T o n y



DEVICE P8X32A, XTAL1, PLL16X
FREQ 80_000_000


tonegenStart CON 1
psmStart CON 2
psmDeviceinfo CON 3


spinCmd HUB BYTE = 0
hub_long1 HUB LONG
hub_long2 HUB LONG
hub_long3 HUB LONG


temp VAR LONG


ASM
OBJ
soundmachine: "psm_tonegenerator"
psmmachine: "psm_serialcontrol_a"


PUB SpinStart
CogInit(1, @__Init, @__DATASTART)
Repeat
case spinCmd
tonegenStart:
soundmachine.tonegen(hub_long1,hub_long2,hub_long3 )
spinCmd := 0

psmStart:
psmmachine.main
spinCmd := 0

psmDeviceinfo:
psmmachine.showdeviceinfo
spinCmd := 0
ENDASM


PROGRAM Start


Start:


'start tonegen driver


WRLONG hub_long1, 400
WRLONG hub_long2, 500
WRLONG hub_long3, 3
WRBYTE spinCmd, tonegenStart
'wait for driver to process
DO
RDBYTE spinCmd, temp
LOOP UNTIL temp = 0

'start psm driver
WRBYTE spinCmd, psmStart
'wait for driver to process
DO
RDBYTE spinCmd, temp
LOOP UNTIL temp = 0

'start deviceinfo driver
WRBYTE spinCmd, psmDeviceinfo
'wait for driver to process
DO
RDBYTE spinCmd, temp
LOOP UNTIL temp = 0
END

Post Edited By Moderator (Bean (Hitt Consulting)) : 1/1/2010 12:55:35 AM GMT

Bean
01-01-2010, 07:37 AM
Tony,
· If you put your code inside the "Formatted Code" area (the # icon), it will keep the spacing.
·
Bean


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Try BASIC on the Propeller.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

JonnyMac
01-01-2010, 08:13 AM
Here's another demo using the tone generator. Note that the psm_tonegenerator object hard-codes the output pins so you may need to change this (as I did) if you're using the Propeller Demo Board (I may *liberate* this code to create my own version that can pass pins and be stopped while playing).

This demo plays three tones and then goes into a random loop -- somewhat reminiscent of old sci-fi computer sounds.

Post Edited (JonnyMac) : 1/1/2010 1:18:15 AM GMT

TonyWaite
01-01-2010, 08:32 AM
JonnyMac,
Thanks for the wonderful tonegenerator example!
It's running in the background, playing music while I'm studying the code.
It's 0130 here, back to some nightwork after the party.
T o n y

Mike Huselton
01-01-2010, 11:44 AM
That is what I like about this forum. IT ROCKS!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH

Bean
01-02-2010, 10:09 PM
I have posted version 00.00.53.

Along with a couple of bug fixes, PropBASIC now supports inline strings.
Inline strings can be used anywhere a DATA label can be used.

NOTE: Inline strings are Z-strings, so the compiler will automatically add a zero·to the end of them as a "end of string" indicator byte.

Here is a demo showing inline strings:



DEVICE P8X32A, XTAL1, PLL16X
FREQ 80_000_000

Baud CON "T115200"

TX PIN 30 HIGH

temp VAR Long

SendChar SUB 1
SendStr SUB 1

Message DATA "GoodBye", 0

PROGRAM Start

Start:
GETADDR "Testing 1,2,3", temp
SendStr temp
PAUSE 1000

SendStr "Hello"
PAUSE 1000

SendStr Message
PAUSE 1000

GOTO Start
END

SUB SendChar
SEROUT TX, Baud, __param1
ENDSUB

SUB SendStr
__param2 = __param1 ' SendChar uses __param1
DO
RDBYTE __param2, __param3
IF __param3 = 0 THEN EXIT
SendChar __param3
INC __param2
LOOP
SendChar 13
ENDSUB



Bean.
·

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

Post Edited (Bean (Hitt Consulting)) : 1/2/2010 3:25:57 PM GMT

Bean
01-03-2010, 04:38 AM
Coley found a bug in "var = const * [power of 2]" and "var = const / [power of 2]".

The bug has been fixed in version 00.00.54 in the first post in this thread.

Bean

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

Bean
01-03-2010, 11:36 PM
Jon found a bug when using serial open baud modes.
I have fixed it and posted version 00.00.55 in the first post.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

TonyWaite
01-04-2010, 12:57 AM
PropBASIC/FUNC question:

Hi all,
May I tempt you with the following easy question?

The following compiles nicely; but how do I do the three steps in one?




FUNC GetToneNumberSteps
Temp1=Duration*clkfreq
Temp1=Temp1/1000
ToneNumberSteps=Temp1/200
RETURN ToneNumberSteps
ENDFUNC

Bean
01-04-2010, 01:46 AM
Assuming you don't need the temp1 value you can do:

· ToneNumberSteps·= Duration * clkfreq
· ToneNumberSteps = ToneNumberSteps / 200_000
RETURN ToneNumberSteps

Bean


TonyWaite said...
PropBASIC/FUNC question:

Hi all,
May I tempt you with the following easy question?

The following compiles nicely; but how do I do the three steps in one?




FUNC GetToneNumberSteps
Temp1=Duration*clkfreq
Temp1=Temp1/1000
ToneNumberSteps=Temp1/200
RETURN ToneNumberSteps
ENDFUNC



▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

JonnyMac
01-04-2010, 04:19 AM
TonyWaite said...
PropBASIC/FUNC question:

Hi all,
May I tempt you with the following easy question?

The following compiles nicely; but how do I do the three steps in one?




FUNC GetToneNumberSteps
Temp1=Duration*clkfreq
Temp1=Temp1/1000
ToneNumberSteps=Temp1/200
RETURN ToneNumberSteps
ENDFUNC





You need to be careful with duration -- if it goes more than 25 or so then you could get a rollover problem (from positive to negative) with the values. Since the *typical* clkfreq setting of a Propeller project is 80MHz and you have a constant value of 1000 you could boil the division down to 80_000, like this:



FUNC GetToneNumberSteps
__param1 = __param1 * 80_000
__param1 = __param1 / 200
ENDFUNC



The duration is passed in __param1 and we don't need to use RETURN (just consumes a line of precious code space) because functions use __paramx variables to send values back to the caller.

JonnyMac
01-04-2010, 04:22 AM
Whoops, now that I look at it, the function can be even simpler given a clkfreq of 80MHz



FUNC GetToneNumberSteps
__param1 = __param1 * 400
ENDFUNC



If you need to accommodate clkfreq I think you can simplify to:



FUNC GetToneNumberSteps
__param2 = clkfreq / 200_000
__param1 = __param1 * __param2
ENDFUNC

Post Edited (JonnyMac) : 1/3/2010 9:28:31 PM GMT

TonyWaite
01-04-2010, 04:25 AM
Bean & JonnyMac: many thanks!
Now to improve my code ...

TonyWaite
01-04-2010, 08:27 AM
PropBASIC/FUNC question
/Continued
(Project is to attempt re-write of Rayman's PSM_ToneGenerator in PropBASIC)

I've tried to work in the FUNC calls; the following gets past the compiler - which is encouraging.
I'm uncertain whether I've used the __paramx variables correctly to get information in and out of the FUNC.
My progress certainly improved when my blurry eyesight spotted the 'double-underscore' typography!
Thank you, T o n y




DEVICE P8X32A, XTAL1, PLL16X
XIN 5_000_000

ToneNumberSteps VAR LONG
ToneLeftPhaseStep VAR LONG
ToneRightPhaseStep VAR LONG
ToneLeftAttenuation VAR LONG
ToneRightAttenuation VAR LONG
ToneLeftPin VAR LONG
ToneRightPin VAR LONG
ToneRunning VAR LONG
Frequency VAR LONG
Duration VAR LONG
Attenuation VAR LONG
LeftFrequency VAR LONG
RightFrequency VAR LONG

Tonegen SUB 3,5
GetToneNumberSteps FUNC 1
GetTonePhaseStep FUNC 1

PROGRAM Start
Start:
DO
Tonegen(400,500,3) 'outputs test-tone of 400Hz, 500mS, attenuation level 3
PAUSE 3000
LOOP
END

FUNC GetToneNumberSteps
' use duration as __param1
__param2 = clkfreq / 200_000
__param1 = __param1 * __param2
'return of __param1 required
RETURN __param1
ENDFUNC

FUNC GetTonePhaseStep
' use Frequency as __param1
__param2 = 1 << 15
__param1 = __param1 * __param2
__param2 = clkfreq / 200
__param1 = __param1 / __param2
__param2 = 1 << 13
__param1 = __param1 * __param2
__param2 = 1 << 4
__param1 / __param1 * __param2
'return of _param1 required
RETURN __param1
ENDFUNC

SUB Tonegen (frequency,duration,attenuation)ŠLeftFrequency,Rig htFrequency)
ToneLeftPin=5
ToneRightPin=4
LeftFrequency=Frequency
RightFrequency=Frequency


ToneNumberSteps=GetToneNumberSteps Duration
ToneLeftPhaseStep=GetTonePhaseStep LeftFrequency
ToneRightPhaseStep=GetTonePhaseStep RightFrequency

ToneLeftAttenuation=Attenuation
ToneRightAttenuation=Attenuation
ToneRunning=true
'COGSTART ......assembly stuff to come here with DAT etc to follow
ENDSUB

kuroneko
01-04-2010, 09:54 AM
Out of curiosity, what's the rationale behind using cogstart instead of cognew and swapping the parameters for RDxxx/WRxxx (compared to their PASM equivalents)? Regarding the latter, not that I mind that much but people starting with BASIC and going for PASM later might find this confusing.

JonnyMac
01-04-2010, 11:12 AM
The idea behind PropBASIC is to help those coming from PBASIC make the transition, hence the RDxxxx and WRxxxx more closely match READ and WRITE from PBASIC (and SX/B) where the address is the first parameter. Mind you, that's a guess on my part -- I do docs, but didn't design the compiler.

kuroneko
01-04-2010, 11:20 AM
JonnyMac said...
The idea behind PropBASIC is to help those coming from PBASIC make the transition, hence the RDxxxx and WRxxxx more closely match READ and WRITE from PBASIC (and SX/B) where the address is the first parameter.

Fair enough, not having used PBASIC I didn't/couldn't make that connection but that sounds reasonable :)

StefanL38
01-04-2010, 11:51 AM
I guess this is very hard to do

PropBasic is compiled to PASM. I remember somebody did work on how to call SPIN from PASM.
But I think you have to fiddle around with pointers each time you change a single byte in the SPIN-files.

So it will be much easier to learn SPIN than learning how startadresses of spin-methods were changed by the SPIN-bytecode-compiler

best regards

Stefan

Bean
01-04-2010, 07:27 PM
kuroneko said...
Out of curiosity, what's the rationale behind using cogstart instead of cognew and swapping the parameters for RDxxx/WRxxx (compared to their PASM equivalents)? Regarding the latter, not that I mind that much but people starting with BASIC and going for PASM later might find this confusing.
Well, COGSTART started life as TASKSTART, but was changed because it really is starting a COG with a specific task.

RDxxxx and WRxxxx allow multiple values to be read or written with one command. This would have been a strange syntax if the address wasn't first. Plus it is a more consistant syntax.

Bean.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

TonyWaite
01-05-2010, 02:24 AM
PropBASIC/ASM query

Hi experts,

I've spent the day trying to work out how to run some Assembler within PropBASIC, in my continuing efforts to translate Rayman's fabulous PSM_ToneGenerator into PropBASIC.

My thinking is that once I can do this for a single driver, then I should have learned enough to attempt one or two of the others; thus enabling easy use of Rayman's PSM to PropBASIC users.

Appended below is my current test-stub.

It fails gloriously where I try and pass a VAR from PropBASIC into the cog, using a Spin command within the ASM-ENDASM;
I have studied the different COG commands within Spin, PASM and PropBASIC and am none the wiser.
You will see that I have not even called the SUB Tonegen; just including the asterisked line kills everything!

It seems unlikely that I will stumble on the solution without some help from my friends ...






DEVICE P8X32A, XTAL1, PLL16X
XIN 5_000_000

ToneNumberSteps VAR LONG
ToneLeftPhaseStep VAR LONG
ToneRightPhaseStep VAR LONG
ToneLeftAttenuation VAR LONG
ToneRightAttenuation VAR LONG
ToneLeftPin VAR LONG
ToneRightPin VAR LONG
ToneRunning VAR LONG
Frequency VAR LONG
Duration VAR LONG
Attenuation VAR LONG
LeftFrequency VAR LONG
RightFrequency VAR LONG

Tonegen SUB 3,5
GetToneNumberSteps FUNC 1
GetTonePhaseStep FUNC 1


PROGRAM Start 'blinks LED as minimal healthcheck!
Start:
LED PIN 0 LOW
DO
HIGH LED
PAUSE 1000
TOGGLE LED
PAUSE 1000
LOOP
END

FUNC GetToneNumberSteps
' use duration as __param1
'lots more code here
RETURN __param1
ENDFUNC

FUNC GetTonePhaseStep
' use Frequency as __param1
'lots more code here
RETURN __param1
ENDFUNC

SUB Tonegen (frequency,duration,attenuation)ŠLeftFrequency,Rig htFrequency)

ToneNumberSteps=GetToneNumberSteps Duration
ToneLeftPhaseStep=GetTonePhaseStep LeftFrequency
ToneRightPhaseStep=GetTonePhaseStep RightFrequency

ToneRunning=1

ASM

pub spinstart

cognew(@ToneStart,@ToneNumberSteps) '*******************************************
org 0
ToneStart 'Beginning of assembly tone generator
'lots of assembly code here
ENDASM
ENDSUB


Post Edited (TonyWaite) : 1/4/2010 7:31:31 PM GMT

Bean
01-05-2010, 02:37 AM
Tony,
I'm not quite following what you are trying to do ???

Do you want the tone generator to run in a seperate cog ? If so, then use a TASK.
If not, then just put
ASM
' Your assembly instructions
ENDASM

It looks like you're making it harder than it is.

Bean

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

TonyWaite
01-06-2010, 02:51 AM
PropBASIC/query re. swapping VAR/res info

@Bean
Thanks for all the advice!
I am delving deeply into Spin, PropBASIC and PASM. Of course I'm completely out of my depth but have not yet
given up hope of translating Rayman's Spin/PASM sound-driver into PropBASIC.

Here's the latest code. I have taken your advice and have started a TASK for the ASM.

I need to pass the 7 input parameters from the PropBASIC cog into the TASK cog, using the address TonenumberSteps.
These seven then become appropriately equivalent RES's declared within the TASK cog.

After much research, I am clearer about some of the memory issues; but no clearer on how to correct the code.
However, it does get past the compiler and blink the two indicator LED's, which for me is progress.

There is a great chunk of Rayman's self-contained ASM code to go back in; but I have reduced it to this stub in order
to resolve the VAR/res issue first.

Thank you, T o n y





DEVICE P8X32A, XTAL1, PLL16X
XIN 5_000_000

'following 7 variables declared and used by first cog; trying to pass these to TASK cog ***
ToneNumberSteps VAR LONG
ToneLeftPhaseStep VAR LONG
ToneRightPhaseStep VAR LONG
ToneLeftAttenuation VAR LONG
ToneRightAttenuation VAR LONG
ToneLeftPin VAR LONG
ToneRightPin VAR LONG

'other variables
ToneRunning VAR LONG 'set to 1 in Tonegen SUB; would like to set to 0 on exiting TASK ***
Frequency VAR LONG
Duration VAR LONG
Attenuation VAR LONG
LeftFrequency VAR LONG
RightFrequency VAR LONG

'SUB, FUNCs and TASK
Tonegen SUB 3,5
GetToneNumberSteps FUNC 1
GetTonePhaseStep FUNC 1
TonegenAssembly TASK

PROGRAM Start
Start:
LED PIN 0 LOW 'prepares PropBASIC program indicator LED
DO
TOGGLE LED 'blinks PropBASIC LED as minimal healthcheck
PAUSE 1000 'aids debug by slowing things down
Tonegen 400,500,3 'will eventually output test tone 400Hz, 500mS, attenuation level 3
LOOP
END

FUNC GetToneNumberSteps
' use duration as __param1
' converts the following Spin into PropBASIC: ToneNumberSteps:=(duration*(clkfreq/1000))/200)
__param2 = clkfreq / 200_000
__param1 = __param1 * __param2
'return of __param1 required
RETURN __param1 'haven't yet managed to get rid of this line
ENDFUNC

FUNC GetTonePhaseStep
' use Left or Right Frequency passed as __param1
' converts the following Spin into PropBASIC: TonePhaseStep:=(L or R Frequency*(1<<15)/(clkfreq/200))*(1<<13)*(1<<4)
__param2 = 1 << 15
__param1 = __param1 * __param2
__param2 = clkfreq / 200
__param1 = __param1 / __param2
__param2 = 1 << 13
__param1 = __param1 * __param2
__param2 = 1 << 4
__param1 / __param1 * __param2
'return of _param1 required
RETURN __param1 'haven't yet managed to get rid of this line
ENDFUNC

SUB Tonegen (frequency,duration,attenuation)ŠLeftFrequency,Rig htFrequency)
LED2 PIN 1 LOW 'prepares sub-routine indicator LED
ToneLeftPin=11
ToneRightPin=10
LeftFrequency=Frequency
RightFrequency=Frequency

ToneNumberSteps=GetToneNumberSteps Duration '***ToneNumberSteps is value I would like to pass to TASK
ToneLeftPhaseStep=GetTonePhaseStep LeftFrequency
ToneRightPhaseStep=GetTonePhaseStep RightFrequency

ToneLeftAttenuation=Attenuation
ToneRightAttenuation=Attenuation
ToneRunning=1
COGSTART ToneGenAssembly
TOGGLE LED2
PAUSE 1000
ENDSUB

TASK TonegenAssembly
ASM
DAT 'Assembly Tone Generator
org 0
Tonestart '***beginning of assembly tone generator
'***load input parameters from first cog to par in
'***TASK cog, given address ToneNumberSteps from
'***first cog; passed to par in TASK cog.

movd http://forums.parallax.com/images/smilies/tongue.gifar,#tNumberSteps 'copies 7 parameters to location starting with tNumberSteps
mov temp1,par
mov temp2,#7 'there are 7 input parameters
http://forums.parallax.com/images/smilies/tongue.gifar rdlong 0,temp1
add http://forums.parallax.com/images/smilies/tongue.gifar,dlsb
add temp1,#4
djnz temp2,#http://forums.parallax.com/images/smilies/tongue.gifar
'loads more code here
'now closing code
'would like to set ToneRunning in first cog to 0 here! ***
COGID temp1
COGSTOP temp1

'setup parameters
tCounterMode long %00011000_00000000_00000000_00000000
dlsb long 1 << 9

'phase accumulators
LeftPhase long 0
RightPhase long 0

'main loop vars
dcnt long 200 '#clocks/main loop --> gives 400kHz update rate
offset long $8000_0000

'Working variables
temp1 res 1
temp2 res 1
wait res 1
'Input Parameters
tNumberSteps res 1 'Determines tone duration (left and right)
tLeftStep res 1 'Determines left tone frequency
tRightStep res 1 'Determines right tone frequency
tLeftAtten res 1 'Determines left tone volume (0=loud, 8=soft)
tRightAtten res 1 'Determines right tone volume (0=loud, 8=soft)
tLeftPin res 1 'Pin# for left audio output (negative number disables)
tRightPin res 1 'Pin# for right audio output (negative number disables)

ENDASM
ENDTASK

Bean
01-06-2010, 04:47 AM
Tony,
· Could you provide a link to Rayman's code ?
· I did a search but I couldn't find it.

Bean

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

Post Edited (Bean (Hitt Consulting)) : 1/5/2010 9:56:17 PM GMT

TonyWaite
01-06-2010, 07:39 PM
Hi Bean,

I'd have replied more quickly, but everything's come to a halt with just 1/2" of snow!
(abandoned car last night; walked home; got it back at the midnight thaw; took 2 hours travelling 4 miles by train this morning)

Rayman's sound-driver is PSM_ToneGenerator.spin from the PSM section of his Rayslogic website:

http://rayslogic.com/Propeller/Products/PSM/Software/PSM_SerialControl - Archive [Date 2009.06.26 Time 16.54].zip

And I have uploaded it with this post.

Thanks,

T o n y

Baggers
01-06-2010, 09:48 PM
Kinda pathetic really isn't it how 1/2" of snow has caused the country to come to a stand still because they didn't prepare for it. lol

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

·

TonyF (spinvent.co.uk)
01-06-2010, 10:58 PM
now now Baggers, here in Buxton we have PLENTY of snow and everyone likes it!! (sorry to go so off-topic; what was this thread about again?) http://forums.parallax.com/images/smilies/smile.gif

Bean
01-07-2010, 08:07 AM
I have posted several updates today...

Please download the latest version if you are using PropBASIC.

Tony,
· Here is my version of Raymans tone generator.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

Post Edited (Bean (Hitt Consulting)) : 1/7/2010 1:13:50 AM GMT

TonyWaite
01-07-2010, 07:10 PM
Hi Bean,

Thanks for the brilliant code: I'm studying it to learn how it works.

I had to declare _Freq as VAR LONG to get it to run.

The demonstration loop is very sci fi!

In awe,

T o n y

Bean
01-07-2010, 07:55 PM
Tony,
Download version 00.00.58 that I just posted.

That will leave _Freq alone so you don't have to declare it.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

TonyWaite
01-07-2010, 10:11 PM
Thanks Bean!
I'd been mistakenly updating from the www.PropBASIC website, thinking it the primary source.
Now I know better.
With the new version your demo file sounds like a car alarm as opposed to a monster
hunting in the deep sometime in the future. I wondered about your musical tastes that you
would choose such a rumbling, uneasy soundbite!
It also explains some of the strange performance while I was playing with it ...
T o n y

Bean
01-08-2010, 07:29 AM
Tony,
Sorry about that. I haven't been updating the website.
I just did now, but this post will always have the latest version first.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

Bill Chennault
01-09-2010, 10:11 AM
All--

Reading this thread was like one of those books you just can't put down! The work Bean and JonnyMac are doing is beyond belief. I know it will pay off for Parallax and I sincerely hope it pays off for them, as well.

--Bill

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.

hover1
01-09-2010, 08:20 PM
Terry,

Could you change the date in the title? It would be cruel to make us wait 11 months for the next installment http://forums.parallax.com/images/smilies/tongue.gif

Jim

Bean
01-11-2010, 07:21 PM
Jim,
· Sorry about that. I'll get that fixed.

To all forum members:
· If you have some code you'd like to see converted (from PBASIC or SX/B specifically) just post it in this thread and I'll have a go at it.
· I just ask that you have the propeller hardware to try the PropBASIC code on to see if it works.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

Rsadeika
01-11-2010, 09:09 PM
@Bean, I noticed you cover NTSC, but, will you be creating any demo programs for VGA? To bad PropBasic does not have a .lib provision, could be a way of saving some time, instead of re-inserting all of the code all of the time.

Ray

TonyWaite
01-12-2010, 12:38 AM
@Ray
There is the LOAD command within PropBASIC, which I believe would enable some of the functionality
of the dot-LIB that you suggest ...
@Bean
... except that I haven't yet fathomed out how to get it to work!
Is there any chance of a working example of PropBASIC script that uses LOAD to call your tonegenerator.pbas code?
T o n y

Bean
01-12-2010, 02:10 AM
TonyWaite said...
@Bean
... except that I haven't yet fathomed out how to get it to work!
Is there any chance of a working example of PropBASIC script that uses LOAD to call your tonegenerator.pbas code?
T o n y
Tony,
· The only "trick" is that you need two files. One for the definitions at the beginning of the program. And another for the actual code at the end of the program.

· Here I have put the instructions into one file named "ToneGen.hdr" for the header. And "ToneGen.cod" for the code. You can use whatever extension works best for you.

Bean.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

JonnyMac
01-12-2010, 02:53 AM
Peter Verkaik had a good suggestion when doing this in SX/B so that code in the files could be syntax highlighted (I do this with EditPlus). You could name the files to be loaded:

TONEGEN_DEFS.PBAS
TONEGEN_CODE.PBAS

This is what I'm doing with a LCD project that I'm working through now.

Rsadeika
01-12-2010, 05:23 AM
I was looking through the DEMO code, and something very essential is missing. Where is the SIRCS propBASIC version? I would like to see how propBASIC deals with the asm code, and the timing that would be necessary?


Ray

Dr_Acula
01-12-2010, 07:14 AM
New Year's resolution and note to self: check this thread daily!

A lot has happened in the last few weeks. Very excitiing.

I've got a few questions and they lead on to some other questions.

Firstly, great to see the beginnings of strings on the 4th Jan. Looking at that code, I see there is something in a data statement and then there is output of an inline string. Mbasic from 30 years ago had

A$="Hello"
PRINT A$

where A$ never was declared, could be of any length and strings were denoted with $.

Basic moved on from that and copied what I think was a very positive aspect of C when it required the variable to be declared before it could be used. Variants on

Dim A as String
A="Hello"
Print A

The Dim told the compiler to reserve some space for A and then any references to A in the program would point the compiler to that memory location. If you want to make sure there is enough room for big strings, some variants of basic reserved 32 bytes. Or a number of bytes specified by the programmer.

So that leads to a question; is memory 'precious'? Which leads to another question - if prop basic is being compiled to pasm and then run as pasm, does that mean a program has to fit into a cog?

There is some code there from last week which shows something even more cunning - string manipulation subroutines that are written in prop basic itself. I think this shows the program has now evolved into something very useful. If you can do one string subroutine that works one byte at a time, you can add some others like left() and mid(), and do those as basic subroutines rather than as part of the language.

I've got some assembly string handling I'd like to try converting to prop basic subroutines. I think I'm almost there understanding where string data is stored, but I'm not sure if it is in one dimensional named arrays or whether it is in data statements where the data ends up being changed.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

hover1
01-12-2010, 07:28 AM
There is an article in Nuts and Volts Jan 2010 by JonnyMac about that very same thing. (Assembly).
Remember, PBasic is still in Beta and timing might be a moving target.
·

Rsadeika said...
I was looking through the DEMO code, and something very essential is missing. Where is the SIRCS propBASIC version? I would like to see how propBASIC deals with the asm code, and the timing that would be necessary?


Ray

Post Edited (hover1) : 1/12/2010 1:08:48 AM GMT

JonnyMac
01-12-2010, 07:44 AM
Rsadeika said...
I was looking through the DEMO code, and something very essential is missing. Where is the SIRCS propBASIC version? I would like to see how propBASIC deals with the asm code, and the timing that would be necessary?

Ray


Remember, PropBASIC is just a couple months old (still in early beta) and just because you want SIRCS for it does not make it "essential" (I say this because my SIRCS RX object in Obex has only been downloaded 65 times). The WIP docs show how PropBASIC handles ASM, using the same ASM..ENDASM block from SX/B. Put your SIRCS decoder in a TASK so that it can run on its own and communicate between the task and the main cog using hub variables.

My January column (posted online) shows how to receive and transmit SIRCS codes with the Propeller (my code is in PASM). This wouldn't be very difficult to move to PropBASIC, and would be a really good experience for you to code yourself.

Post Edited (JonnyMac) : 1/12/2010 12:55:48 AM GMT

Bean
01-12-2010, 07:47 AM
As far as strings go...They are typically stored in HUB ram, because in COG ram they require 1 LONG per character and COG ram is precious.

You can store strings in DATA lines. Or you can pass a string to a subroutine. So you could in fact use:



PRINT "Hello there"

If you made a subroutine named PRINT with 1 parameter. That parameter being a location in HUB ram·(using RDBYTE to get each character).

As far as working on variable strings, that is not something that typically gets done on a microcontroller very often. It can be done, but it takes alot of space.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

Post Edited (Bean (Hitt Consulting)) : 1/12/2010 12:52:19 AM GMT

Bean
01-12-2010, 08:15 AM
I don't know how many member's have a BOE-BOT and a Propeller Proto board...But if you do you can make a decent robot.

Here is some code I wrote for a Prop-BOT with a Ping.


' PropBOT (BOE-BOT with Propeller Protoboard)
'
DEVICE P8X32A, XTAL1, PLL16X
FREQ 80_000_000

' Define CONs
LeftStop CON 1524 ' 1520 TO 1528 (You may need to adjust these values for your servos)
RightStop CON 1530 ' 1526 TO 1533

' Define PINs
LeftServo PIN 0 LOW ' Left servo controlled by pin 0
RightServo PIN 1 LOW ' Right servo controlled by pin 1
PingPin PIN 2 LOW ' Ping controlled by PIN 2 through a 1K resistor

' Define HUB variables
LeftSpeed HUB LONG = 0 ' Left servo current speed
RightSpeed HUB LONG = 0 ' Right servo current speed
LeftGoal HUB LONG = 0 ' Left servo speed wanted
RightGoal HUB LONG = 0 ' Right servo speed wanted

' Define DATA (DATA, WDATA, LDATA)
' none

' Define TASKs
MoveServos TASK

' Define variables (LONGs only)
temp VAR LONG
dist VAR LONG

' Define Subroutines
ServoDir SUB 2 ' Left (-200 to +200), Right(-200 to +200) -200=full backwards; 0 = stop; +200=full forwards
PingDist FUNC 0 ' Returns inches

' Start of main code
PROGRAM Start

Start:
COGSTART MoveServos
DO
' Move forward until something is < 20 inches away
ServoDir 200, 200
DO
PAUSE 10
dist = PingDist
LOOP UNTIL dist < 20

' Backup a little bit
ServoDir -200, -200
PAUSE 1000

DO
' Turn slightly right
ServoDir 200, -200
PAUSE 200
' Stop turning
ServoDir 0, 0
PAUSE 500
' Measure distance
dist = PingDist
LOOP UNTIL dist > 20 ' Keep turning until distance is > 20

LOOP
END

' Subroutine Code
SUB ServoDir ' Left, Right
WRLONG LeftGoal, __param1, __param2
ENDSUB



FUNC PingDist ' Returns inches
ReStart:
PULSOUT PingPin, 5 ' Trigger PING
PAUSEUS 5 ' Needs to stay low for a little while
PULSIN PingPin, 1, __param1
__param1 = __param1 * 1_000 ' Convert to inches
__param1 = __param1 / 73_746
RETURN __param1
ENDFUNC

' ----------------------------------------------------------------------------

' Task Code (Runs simultaniously in a seperate cog)

TASK MoveServos
speed VAR LONG
goal VAR LONG
DO
RDLONG LeftSpeed, speed ' Get left servo speed
RDLONG LeftGoal, goal ' Get left servo goal
goal = goal - speed ' goal = delta
goal = goal MAX 10 ' keep delta(goal) with in +/- 10uSec
goal = goal MIN -10
speed = speed + goal ' Adjust speed by delta (goal)
WRLONG LeftSpeed, speed ' Save new left servo speed
speed = LeftStop + speed ' Add left servo stopping value to speed
PULSOUT LeftServo, speed ' Send pulse to left servo
PAUSE 10 ' Pause 10, so servos don't move at the same time
RDLONG RightSpeed, speed ' Get right servo speed
RDLONG RightGoal, goal ' Get right servo goal
goal = goal - speed ' goal = delta
goal = goal MAX 10 ' keep delta(goal) within +/- 10uSec
goal = goal MIN -10
speed = speed + goal ' Adjust speed by delta(goal)
WRLONG RightSpeed, speed ' Save new right servo speed
speed = RightStop - speed ' Add right servo stopping value to speed
PULSOUT RightServo, speed ' Send pulse to right servo
PAUSE 10 ' Pause 10, so servos don't move at the same time
LOOP
ENDTASK



Bean


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

Post Edited (Bean (Hitt Consulting)) : 1/12/2010 1:20:16 AM GMT

Dr_Acula
01-12-2010, 08:15 AM
Strings in hub ram - that makes sense.

I've got 512k of external ram to play with and I'm pondering some propbasic routines to use it.

Code was originally written in spin but it was just a bit slow, so it was ported to pasm. But I understand that propbasic gets compiled to pasm? So if I write a line of propbasic code to make a pin go high, that gets converted to a tiny bit of pasm code, right?

Another instruction for example, the <<. I can see how that would be converted to pasm, maybe only one pasm instruction.

Or - even simpler, I see that inline assembly code is possible. So maybe one could take some existing external ram assembly code and drop it into a propbasic subroutine?

I still don't quite understand the code limitations. Is a prop basic program limited to 2k? Or are you using overlays or some other technique to fit more code in?

Also I still don't understand local and global variables. Are variables declared locally in subroutines or are they all global? They all look global in that latest code example, but is that because they always are, or because that particular code example doesn't have local variables?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Post Edited (Dr_Acula) : 1/12/2010 1:22:28 AM GMT

Bill Chennault
01-12-2010, 08:55 AM
All--

Gee. I lobbied very hard for a version of BASIC for the Propeller. However, until I saw Bean's simple·servo code above, I really never understood what the Propeller could do for ME.

Obviously, it would pretty much eliminate my use of multiple Stamps and/or SXs. I don't know if I can come up with any more excuses for not buying into the Prop world.

--Bill

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.

Ron Sutcliffe
01-12-2010, 09:32 AM
@drac
Reading the manual.

Hub variables can be Longs, words, or bytes.
Hub variables are accessible to all tasks.
Task variables are local. They are longs because thet reside in cog ram.
Each Task runs in its own Cog. That's 16k for starters
Yes its compiled to PASM, no interpreter required
Not optimized PASM code,·but it·looks very fast.

I have been looking at the issue of xram also. Whilst only 7 tasks can be active at any one time. It would be interesting to know if more than 7 tasks could be declared so that the main program can stop a task and start another task. I can see a way to use xmem using one cog to overlay tasks into·hub ram.· Maybe Bean will shed some light on this. I did ask the question a while ago but it was over looked.

Ron

Post Edited (Ron Sutcliffe) : 1/12/2010 2:48:39 AM GMT

Bean
01-12-2010, 10:02 AM
Each task (the main code is a task too) runs in it's own cog. That is 496 instructions per COG (or TASK).

There are no local variables for subroutines. All COG variables are global. There are __paramx variables that hold values that are passed to a subroutine, but the __paramx variables can also be used like a regular variable in the subroutine. Just be careful if you nest subroutines.

The compiler is single pass. So it compiles very fast, and the generated code (while not optimized for size) runs very fast.

Also as you pointed out, since the compiler generates straight PASM code, in-line PASM is very easy to use (if you know PASM).

Future versions of the compiler will hopefully be able to generate LMM (Large memory model) code. This will be by TASK. So the main code can be LMM and other TASKs in the same program can be straight PASM (video drivers etc).

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

Ron Sutcliffe
01-12-2010, 10:18 AM
Bean

Thanks, yes forgot to mention __params.

Can we declare mode than 7 tasks at compile time even if they are not all started at the same time. They could be started and stopped to a max of 7 plus main ?


Ron

Bean
01-12-2010, 10:24 AM
Ron Sutcliffe said...
Bean

Thanks, yes forgot to mention __params.

Can we declare mode than 7 tasks at compile time even if they are not all started at the same time. They could be started and stopped to a max of 7 plus main ?


Ron
Oh, sure you can have as many as will fit into the 32K EEPROM (In Theory).
They can be started and stopped at will.

Bean.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

Post Edited (Bean (Hitt Consulting)) : 1/12/2010 3:35:40 AM GMT

Ron Sutcliffe
01-12-2010, 10:38 AM
Bean

Thanks for clearing that up.

I do hope others take the time to look at what you have done.

Ron

Dr_Acula
01-12-2010, 10:47 AM
Thanks Ron/Bean. Essentially it appears to be basic designed to work best with prop architecture.

So - 2k cogs and a hub. Ok, racing ahead with brainstorming evrything, I get to the same point Ron is at:

" It would be interesting to know if more than 7 tasks could be declared so that the main program can stop a task and start another task. I can see a way to use xmem using one cog to overlay tasks into hub ram."

How could this work? Well, lets say a compiler takes a chunk of code and compiles it so it fits in a cog. It becomes a self contained binary - just a list of bytes. You could load any number of those binary files into external ram, or external sd card, and as long as they had a name, it should be possible to call them as if they were subroutines.

A trivial example - a cog 'binary' for adding two numbers. Grab it from sd/external ram, put it in a cog, pass the variables, run it, get the answer, stop the cog. If the main program could do that, it makes the program easily expandable to many megabytes in size.

The compiler would need to flag that the code fits, which I think is easy with the FIT command.

All you need then is a common place to transfer data to and from cogs. You may not need much - maybe 10 longs or whatever, and when you call one of these cog subroutines, you pass 10 longs and when it finishes then it returns those 10 longs. Those longs could sit at the top of hub ram and I think reading them assembles to a few lines of assembly. I guess that is an issue - some sort of standardised I/O to cogs. I think this has been pondered before.

The 'main' program is a list of calls to subroutines such that the 'main' is a short piece of code that easily fits in hub.

Next challenge to think about - is there enough propbasic code already written to do the above in propbasic itself without any changes to the compiler? I might sleep on that one, but my gut feeling is that it may well be possible.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Ron Sutcliffe
01-12-2010, 11:30 AM
@drac

I don't want Hijack this thread, but I·am doing this. Two Props, Prop1 uses 2 cogs for SDcard·driver,·1cog Xram, 1cog SDcard port,·1cog xram port. Coded Spin and PASM.··(5 cogs)

Prop 2 uses·Beans PropBasic·serial I/O(using messages)·to access Prop1 via the two ports. I just need to set up a dummy file area in HUB·from which I can down a file from xmem or sdcard and then get main to load a task from that area.· Pretty crude·but just wanted to see how useful Probasic might be, and I am impressed·with how easy it is to use.·Beans previous SX compiler experience shows.

Ron

Dr_Acula
01-12-2010, 12:09 PM
I hope Bean doesn't mind us brainstorming here.

The boards I'm using have sd card and external ram, and with the hardware and building blocks of the software all working, I'm starting to think about other things besides CP/M.

One of the things I see as a problem with spin (maybe there is a way round this) is you write a whole lot of code and some of that code sits in hub and is transferred to the cog and run in the cog, but it also ends up sitting in the hub forever and taking up room.

Further, let's say you transferred some code to a cog (call it a cog subroutine), if that freed up n bytes in hub, it would be very useful to know where exactly those n bytes were so you could then reuse that space. As I see it, the location of those bytes changes each time you edit the main program.

So where you say "I just need to set up a dummy file area in HUB from which I can down a file from xmem or sdcard and then get main to load a task from that area." it looks like you are working on the same thing, a dummy file area for cog code.

This could instantly save a whole lot of hub space in a program, as say you had 7 cogs running with 7 bits of 2k cog code, well you could replace that with one dummy file area and feed those 7 cog programs through that dummy area one at a time.

So - do you have that working yet?

Is there a way in propbasic of (say) reserving an area of memory? (maybe even in spin). Reserve 2k and put a pointer at the beginning and reference that pointer.

I don't think you even need external memory for this - sd card ought to be enough and even if it is a bit slower it could prove the concept of pulling in subroutines and running them as needed. There are schematics out there for standard SD connections to the standard prop boards so anyone could join in the fun!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Ron Sutcliffe
01-12-2010, 03:39 PM
@drac
All I was suggesting was to run the stock standard SDcard software availble from the OBEX on one Prop and communicate with it via a dedicated port on a Prop running Probasic. (yes done that bit) I was thinking that if by creating a dummy file area in Hub, where a file can be downloaded from the SD card. It maybe possible to get some sort of crude task swapping going. ATM I am just interested in what PropBasic can do and trying a few things for myself.



Ron

TonyWaite
01-12-2010, 07:02 PM
@Bean
@JonnyMac
Thanks for the advice re. calling in PropBASIC code.
@Ron
I can see why you're tempted with the dual-Prop approach, one running the Spin modules and
the other PropBASIC. But I'm confident that as the PropBASIC community takes off we'll soon
develop techniques to get around the Spin/PropBASIC interworking issues and make them
relatively transparent; as well, PropBASIC code will be contributed to give us the equivalent of
a PropBASIC Obex.

T o n y

Bean
01-12-2010, 07:15 PM
Guys,
I don't mind you brainstorming here at all. Anything to bump this post ;)

This discussion is all very interesting, but PropBASIC is designed for the BS2 user. So things need to be simple (not that BS2 users are simple) and easy to understand.

The compiler just generates straight PASM, so anything you can do in PASM you should be able to do in PropBASIC. The "trick" is that the compiler is single pass, so things need to be put in a certain order so the compiler "knows" about stuff.

That is not to say that you guys might be able to get PropBASIC to "sit-up-and-beg", and that would be great. But it's not the focus right now. The focus right now is to try to arm twist forum members into writing code with PropBASIC so we can discover any bugs (Oh, and they are in there. I know).

P.S. To reserve space, just declare a HUB variable as an array.

MyCode HUB LONG(512)

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

Rsadeika
01-12-2010, 07:30 PM
Sorry Bean, I keep forgetting that this is a beta testing exercise. I have to dampen my enthusiasm for propBASIC, keep reminding myself to keep it simple, and straight forward. I will try to keep the suggestions to a minimum, and then after it gets released ...

Ray

Dr_Acula
01-12-2010, 07:55 PM
Happy to bump your post, Bean!

I'm coding Sbasic and compiled Mbasic on a propeller right now. It works fine, but is a little lacking in speed. eg I want to capture data coming back from a remote wireless login to another propeller at 19200 baud, and compiled Mbasic on the zicog is struggling to keep up (it is jolly close though, about 95% of a "DIR" comes back intact). Not surprising in a way becuase it is emulating at maybe 1000 instructions per second.

Move over to propbasic and it could go *much* faster. And maybe with not much editing needed on the code.

Re BS2 users, there are other target markets too for people who want to program Basic on small microcontrollers. The key is making it simple, and prop basic is doing a fantastic job with some great potential (and to be unbiased, I'll say that for C programmers, Catalina is doing a similar job).

I'm excited about pushing the boundaries with the code already written. So re;

"MyCode HUB LONG(512)"

I'm working my way throught the manual on the first page of this thread. I found Mycode is an array (page 14). Cool, I can fill the array with 2k from an sd card. That will work.

I'm a bit confused about "tasks". Page 17 of the manual is "Tasks" but the page is blank. I think tasks are another name for cog code, is that right?

Let's say I have 2k (512 longs) of code that is now in Mycode array. How would I move that code to, say, the next available cog and then start the cog?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Rsadeika
01-12-2010, 08:14 PM
The "manual" that you are referring to, is the jonnymac document? That is a very preliminary document with a lot of stuff that has not been covered. As to 'task', think 'TASK' = cog, there is an example, in Bean's PropBASIC document, as to how to use it. This is the document that is in the propBASIC zip file. Basically, you define (name) the 'TASK', place your code within the task confines, and then start the task in your main portion of the program.

Ray

Post Edited (Rsadeika) : 1/12/2010 1:31:12 PM GMT

Bean
01-12-2010, 08:24 PM
TASK is basically the same as a SPIN object. Except it is all in one source file.

You create a TASK header (this tells the compiler the task exists). Then you can use the do a "COGSTART taskname" to start the task. The actual TASK code comes at the end of the program.

Remember that since a TASK is code running in a different cog, you need to use HUB variables to communicate with it.

Take a look at the Prop-BOT code that I posted yesterday at 8:15pm (I put the code right in the post).

This uses a TASK to control the servo pulses. You set the HUB variable "goal", and the TASK will move the servo to the goal setting slowly. This avoids jerking the bot around and prevents power dips too.

Also look at the Serial_to_NTSC program in the demos folder.
This uses 3 cogs, one runs the main program, one receives serial data, and one generates a 64x24 character display. All written in PropBASIC in one source file.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

Post Edited (Bean (Hitt Consulting)) : 1/12/2010 1:29:57 PM GMT

Dr_Acula
01-12-2010, 08:38 PM
Yes, sorry, the JonnyMac document. I found the Bean document now in the page 1 zip. Reading it now...




TASK...ENDTASK Creates code that runs in a separate cog.
name TASK
TASK name
...
ENDTASK
* Task code runs in a separate cogs.
* VAR variables are not shared between cogs.
* SUBs and FUNCs are not shared between cogs.
* HUB variables, PINs and DATA are shared between cogs.
* Use COGSTART or COGINIT to start tasks.




I'm assuming that since this is a single pass compiler, that Task/Endtask gets converted to something like

org 0
start
... code
...data
fit or similar?

Let's take a very simple example. I want a little Task program that takes a variable and multiplies it by 2 and returns it

so my task might be (in token form)

rdlong
shl
wrlong
end

I suppose I could write that on the proptool, find out the bytes it compiled to on a real program, put them on a cog, write a program to read them off the cog, store those bytes and call that a cog subroutine. Propbasic is different as you seem to have more control over the process.

To flesh that out, rdlong needs to read from a known location in hub, and maybe that location should be up the top of hub memory somewhere. Ditto wrlong.

Maybe I'm jumping ahead here, but it would be so cool to have libraries of Task code, that you can drop into propbasic like objects from the obex, and you know that they work. Drop in a keyboard Task (would be very similar to the current object, except that it would return a flag and a byte to two fixed locations in upper hub ram). Drop in a VGA Task. An sd Task. Nothing different to the current way of doing things, except that these tasks may not take any hub memory. You pull them off an external ram or sd card, put them in the cog, run them, then discard them (or leave them running).

Some tasks would run once then end. Some would keep going and you throw variables at them and they return other variables then cycle through (like the external ram driver code from Cluso).

Maybe this is racing ahead too far? But I see so many possibilities! And I see this becoming simpler for the beginner.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Bean
01-12-2010, 10:16 PM
It's an awful lot of work to multiply a number by two...
But for just a demonstration program here is how I would write it:


DEVICE P8X32A, XTAL1, PLL16X
FREQ 80_000_000

temp VAR LONG

value HUB LONG
flag HUB LONG

Mult2 TASK

PROGRAM Start

Start:
WRLONG value, 1000
WRLONG flag, 0
COGSTART Mult2
DO
RDLONG flag, temp
LOOP UNTIL temp <> 0
RDLONG value, temp
' Temp now equals 2000
END

TASK Mult2
temp VAR LONG

RDLONG value, temp
temp = temp * 2
WRLONG value, temp
WRLONG flag, 1
COGID temp
COGSTOP temp
ENDTASK



Bean


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

mpark
01-12-2010, 11:33 PM
Have you considered adding assignment operators such as += and *=? From the few samples I've seen, it appears that assignments are limited to the form
x = x op y
Assignment operators would let you write them
x op= y
which requires less typing, is conceptually clearer (imho), and gives people a nudge toward Spin or C-family languages.

Gerry Keely
01-13-2010, 12:02 AM
Trying to get SHIFTOUT working but keep getting an error that a comma is missing.

The Propbasic manual shows command as

SHIFTOUT datapin, clockpin, mode, value[\bits]

Placing a comma between value and [\bits] compiles ok and generates spin code.

Is this correct and can bits be any value ?

Regards

Gerry

Bean
01-13-2010, 12:44 AM
Gerry,
That is a bug, I'll get that corrected. I'll post 00.00.63 ASAP.
The bits can be from 1 to 32.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

Rsadeika
01-13-2010, 03:28 AM
I am using a demo board, I tried the program below, and it sort of works. The LED flashes, but I do not get anything displayed on the PST window, here I used 115200 baud. I tried the serout command all by itself, using 'T' mode, and that did not display anything on the PST window, here I used 9600 baud.

Ray






' ================================================== ====================
'
' File...... test1.pbas
' Purpose...
' Author....
' E-mail....
' Started...
' Updated...
'
' ================================================== ====================


' ----------------------------------------------------------------------
' Program Description
' ----------------------------------------------------------------------
'

' ----------------------------------------------------------------------
' Device Settings
' ----------------------------------------------------------------------

DEVICE P8X32A, XTAL1, PLL16X
FREQ 80_000_000


' ----------------------------------------------------------------------
' Constants
' ----------------------------------------------------------------------
Baud CON "T115200"

HOME CON 1
BKSP CON 8
TAB CON 9
LF CON 10
CLREOL CON 11
CLRDN CON 12
CR CON 13
CLS CON 16

' ----------------------------------------------------------------------
' I/O Pins
' ----------------------------------------------------------------------
TX PIN 30 HIGH
LED PIN 16 LOW

' ----------------------------------------------------------------------
' Shared (hub) Variables (Byte, Word, Long)
' ----------------------------------------------------------------------
alpha VAR Long

' ----------------------------------------------------------------------
' Shared (hub) Data (DATA, WDATA, LDATA, FILE)
' ----------------------------------------------------------------------


' ----------------------------------------------------------------------
' TASK Definitions
' ----------------------------------------------------------------------


' ----------------------------------------------------------------------
' Cog Variables (Long only)
' ----------------------------------------------------------------------


' ----------------------------------------------------------------------
' SUB/FUNC Definitions
' ----------------------------------------------------------------------
TX_BYTE SUB 2, 2 ' shell for SEROUT
DELAY_MS SUB 1, 1 ' shell for PAUSE

' ================================================== ====================
PROGRAM Start
' ================================================== ====================
Start:
' Main code goes here
DELAY_MS 10 ' TX idle for 10ms
TX_BYTE TX, CLS

Main:

DO
FOR alpha = "A" TO "Z"
TOGGLE LED
TX_BYTE TX, alpha
DELAY_MS 50
NEXT
TX_BYTE TX, CR
LOOP

END


' ----------------------------------------------------------------------
' SUB/FUNC Code
' ----------------------------------------------------------------------
SUB TX_BYTE
SEROUT __param1, Baud, __param2
ENDSUB

SUB DELAY_MS
PAUSE __param1
ENDSUB

' ----------------------------------------------------------------------
' TASK Code
' ----------------------------------------------------------------------

Bean
01-13-2010, 04:43 AM
I just tried your code and it works fine.
I think your PST is not setup right.

If anyone is keeping score, the program above uses all of 57 longs. http://forums.parallax.com/images/smilies/smilewinkgrin.gif
Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

Post Edited (Bean (Hitt Consulting)) : 1/12/2010 9:48:40 PM GMT

JonnyMac
01-13-2010, 04:46 AM
Me too. Keep in mind that you may be resetting the Propeller with PST and if you didn't download to EEPROM you will lose the program.

Hint: White space is your friend; be careful getting sloppy with your listings as "sloppy" serves as great camouflage for bugs (that may compile just fine).

Rsadeika
01-13-2010, 05:08 AM
What is there to setup? I got the right com port, and the correct baud rate, is there something else? I am using Windows 7 64 bit, I ran another Spin program that used the PST without any problems. So, I am not sure what else I should do differently. Running propBASIC in Windows 7 is getting to be a problem, Windows 7 keeps popping up a window that asks me if I want to continue to run the program, and it is a real pain when I do the 'Run' command. I think you might have to consider using another compiler, or it least make it behave with Windows 7.

I have run the Propeller IDE, and seems to behave with Windows 7, it even installed the 64 bit drivers with no problem. I have only had the new system for about a week now, so I have not tried everything out just yet.

Ray

Bean
01-13-2010, 05:24 AM
Ray,
I use the compiler and PropBASICIDE with windows 7 64-bit.
You need to change the properties of the program so windows stops asking you if you want to run it. It has nothing to do with the compiler.

Yes, you need to choose the correct port and baud rate. All I can tell you is your code works fine on my Windows 7 64-bit system.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

Ron Sutcliffe
01-13-2010, 05:49 AM
@Rsadeika
It sounds like you are using COMPILE in the PropBasic IDE to create the Spin file and not compiling and loading the Spin file to EEprom. Use the EEPROM in the PropBasic IDE to compile and load the Prop in one step. There are other IDE's if you don't like what Bean has done, (I use Source Edit) but Beans IDE works fine with XP and windows 7.

Ron

Rsadeika
01-13-2010, 06:33 AM
The way I understand the propBASIC IDE is you have three choices - Compile, Run, and EEPROM. I use the 'Run' option which compiles, and loads it to RAM. As for the IDE itself, I was just making some observations as to how a new user might perceive the experience with propBASIC, when run for the first time. If this is being targeted at the Basic Stamp users, what is the tolerance level that is being used.

As for the program that I posted earlier, it was a direct copy of what is shown in the propBASIC manual, I left everything as is. Again, what will the Basic Stamp user be using as guide to learning the language? Remember, this is BETA testing!

Ray

Ron Sutcliffe
01-13-2010, 07:22 AM
Ah... loading to Ram. Use EEprom and lets know how you go
Ron

Ron Sutcliffe
01-13-2010, 11:25 AM
@ Drac
Working code, to demonstate·using SD Card·or any other Spin/Pasm objects on Prop·1··with PinIn =·8 and PinOut·= 9

Prop·2 running the code below· where PinIn = 16 and PinOut = 18

If you want to use one cog for both Keyboard and SD comms you will need to use a flow control method.·I think its best to use two separate tasks
and turn the SD cog on when you need it.

@Tony
Why re-work·all the code in the·OBEX when a you·can use High Speed comms and an extra Prop.·FSRW is a hugh lump of code to port to PropBasic.

Ron

Bean
01-13-2010, 07:17 PM
Ron,
Nice program. It looks like you have a good handle on PropBASIC.
My only suggestion would be to use PIN to define "keyin" and "sdin".

Bean

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

Ron Sutcliffe
01-13-2010, 07:47 PM
Hi Bean

This is what I was refering to with Drac·in an earlier post. A·way in·which users·could load and execute·Pbasic files from SD

The screen below uses the code that I posted to handle the file server.

Obviously they will·not be able to save a·Pbasic file to SD but they could save data.

The trick·for me now is·to get the 2K(max) files from SD to the PropHub·ram and get PropBasic to load the file into a free·cog and run it.

The main program will have to reserve 496 longs in HUB ram for the sole purpose of holding· SD based Tasks. ·In other words tasks from SD would

always run within the Main Program (AKA in a·shell)· Its all vapourware at this stage, but its interesting.

Cheers

Ron

BTW the·original code was written using only one cog for SD and Keyboard·but I got few errors and thought that flow control would be messy so I butchered·it and used·two cogs. It will all go out the window when I get a shot·at the rest of the project.

Post Edited (Ron Sutcliffe) : 1/13/2010 1:24:26 PM GMT

Dr_Acula
01-13-2010, 08:19 PM
Very impressive!

Gut feeling here, but I think this might be the hidden key to breaking out of the 32k memory limit of the propeller.

You can fit some nifty routines in 2k. Simple, such as a single floating point math operation. Or complex, like an entire string manipulation library.

So, do these have a name? Would you use an 8.3 naming convention for these, and if so, what would be a suitable extension? .COG? .TSK?

And is there an easy way to create these binary files? Could it be as easy as writing some assembly in the prop tool, starting at org 0 with no spin at the beginning at all (is that allowed?), then compiling it to a binary?

Re the specific questions:

Loading a binary off the sd card.

Pulling apart the dracblade code I think it is something like:
OBJ
sd : "fsrwFemto" ' sd card driver
VAR
byte cogbuff[2048] 'buffer for a cog binary
PUB
sd.start(variable)
FindDriveBase(0, string("MYFILE.TSK")) ' find where the file is on the sd card so quicker to find next time
CheckSDCard ' init sd card
sd.readSDCard(drive_base[0], @cogbuff, 2048) ' get 2048 bytes from file in drive_base[0] and put in cogbuff array

Then the bit I'm not sure about; move the bytes from the cogbuff array into the cog itself, start the cog, run it, set a flag when it gets to the end.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Post Edited (Dr_Acula) : 1/13/2010 1:35:46 PM GMT

Ron Sutcliffe
01-13-2010, 08:23 PM
Yes but 2k is the limit for a cog and you can only load one cog at a time

Dr_Acula
01-13-2010, 08:28 PM
Cross post - see my post edit.

You might only have one 'working' cog for this. Thinking of the dracblade, most of the cogs end up so useful for other things - fsrw, vga (x2?), keyboard, serial ports, ram

so maybe only one or two left over. But you can do so much with those if the way of loading them and talking to them ends up being only (say) one line of code, say a call to a subroutine with some parameters (filename.tsk, long1, long2 and returns long1,2 etc)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Rsadeika
01-13-2010, 10:52 PM
Well, I solved my problem with displaying the test1 program using PST. I have a propplug, and the demo board plugged in at the same time, which created a com3, com4 ports. Because propBASIC does not have a preferences, I assumed it was using com4, wrong choice, the choice should of been com3.

@ron, I just looked at your program, and I am assuming you have an SD card reader attached on pin 16. Are you using a serial communications setup, because the code does not look like spi to me, or am I wrong on that? If that is the case, have you tried writing to the SD card, and what kind of speed differences are you noticing compared to using spi code? You have a very interesting short program to learn from.

Ray

Rsadeika
01-14-2010, 12:43 AM
This is a test to see whether a program written in SX/B, will be compiled. The original SX/B program used 'byte' which I changed to 'long'. This program when compiled, has an error, in the 'sub GET_SIRCS' -
temp2 = GET_IR_PULSE
error 5 invalid parameter "GET_IR_PULSE"; ...

Not sure how to change this so it would work.

Ray



[code]
' ================================================== ====================
'
' File...... test2.pbas
' Purpose...
' Author....
' E-mail....
' Started...
' Updated...
'
' ================================================== ====================


' ----------------------------------------------------------------------
' Program Description
' ----------------------------------------------------------------------
'

' ----------------------------------------------------------------------
' Device Settings
' ----------------------------------------------------------------------

DEVICE P8X32A, XTAL1, PLL16X
FREQ 80_000_000


' ----------------------------------------------------------------------
' Constants
' ----------------------------------------------------------------------


' ----------------------------------------------------------------------
' I/O Pins
' ----------------------------------------------------------------------
Led1 pin 7 output
IRpin pin 0 input

' ----------------------------------------------------------------------
' Shared (hub) Variables (Byte, Word, Long)
' ----------------------------------------------------------------------
cmdCode var long
devCode var long

temp1 var long
temp2 var long
temp3 var long

' ----------------------------------------------------------------------
' Shared (hub) Data (DATA, WDATA, LDATA, FILE)
' ----------------------------------------------------------------------


' ----------------------------------------------------------------------
' TASK Definitions
' ----------------------------------------------------------------------


' ----------------------------------------------------------------------
' Cog Variables (Long only)
' ----------------------------------------------------------------------


' ----------------------------------------------------------------------
' SUB/FUNC Definitions
' ----------------------------------------------------------------------
GET_IR_PULSE sub 1
GET_SIRCS sub
LedTEST sub
processKeys sub

' ================================================== ====================
PROGRAM Start
' ================================================== ====================
Start:
' Main code goes here

Main:

do
GET_SIRCS
processKeys
'LedTEST
loop

END


' ----------------------------------------------------------------------
' SUB/FUNC Code
' ----------------------------------------------------------------------
sub GET_IR_PULSE
pulsin IRpin, 0, temp1
return temp1
endsub

sub GET_SIRCS
do
temp2 = GET_IR_PULSE
loop until temp2 > 216
cmdCode = 0
for temp3 = 0 to 6
cmdCode = cmdCode >> 1
temp2 = GET_IR_PULSE
if temp2 > 108 then
cmdCode.6 = 1
endif
next
devCode = 0
for temp3 = 0 to 4
devCode = devCode >> 1
temp2 = GET_IR_PULSE
if temp2 > 108 then
devCode.4 = 1
endif
next
endsub

sub LedTEST

high Led1
pause 1000
low Led1

endsub

sub processKeys
if cmdCode = 21 then Led1
cmdCode = 0
endsub
' ----------------------------------------------------------------------
' TASK Code
' ----------------------------------------------------------------------

Gerry Keely
01-14-2010, 01:17 AM
Should "sub GET_IR_PULSE" be a func as you are returning a value ?

Regards
Gerry

Rsadeika
01-14-2010, 01:58 AM
In SX/B, at one point, you were able to do a return within a 'SUB'. The attached file contains an update, changed the 'SUB' to a 'FUNC'. The next compile error is a little more difficult to resolve. The 'cmdCode.6 = 1' , and the 'devCode.4 = 1' , in the documentation I did not see any reference to being able to do this. I guess it probably needs some assembly code to handle this, but, I am not sure what the code would look like.

Ray

JonnyMac
01-14-2010, 05:43 AM
Rsadeika said...
In SX/B, at one point, you were able to do a return within a 'SUB'. The attached file contains an update, changed the 'SUB' to a 'FUNC'. The next compile error is a little more difficult to resolve. The 'cmdCode.6 = 1' , and the 'devCode.4 = 1' , in the documentation I did not see any reference to being able to do this. I guess it probably needs some assembly code to handle this, but, I am not sure what the code would look like.

Ray



There are a lot of things wrong with your program -- too many for me to fix in the time I have left today (off to class!). Since I wrote some of the SX/B code you're attempting to translate, I will do it tomorrow. I will write a demo that accepts SIRCS codes and lights LEDs on the Propeller Demo Baord.

Hints:
-- Use subroutines to work with values (passed as parameters), functions to do something and send a value back
-- minimize "global" variables to maximize code portability
* you can pass parameters to a subroutine
* you can pass parameters to a function, and get value(s) back
-- whenever possible, subroutines and functions should stand alone and not depend on others or global variables

Tip:
-- if a value is already in __param1, you don't need to use RETURN at the end of the function; for example



FUNC GET_IR_PULSE
PULSIN IR, 0, __param1
ENDFUNC


It's fine to use RETURN __param1 but it will just copy __param1 to __param1 and consume a precious instruction.

Note, too, that SX/B PULSIN worked in 10us units, PropBASIC PULSIN works in 1us units. To look for an SIRCS start pulse, then, you might do this:



FUNC GET_SIRCS

pWidth VAR Long
cmdCode VAR Long

DO
pWidth = GET_IR_PULSE
LOOP UNTIL pWidth > 2160 ' wait for valid start pulse

...

Ron Sutcliffe
01-14-2010, 07:18 AM
@Ray

My sample code is based on the use of TWO props chips. The first Prop Chip is running Spin code which handles the SD card. The second Prop Chip is running PropBasic code and simply communicates with the first Prop chip via a serial port.

Your program

I don’t think you can expect code written for the SX compiler to compile on the PropBasic compiler. Whilst the code looks very similar the Prop chip is very different. I assume that Bean designed ProBasic this way so that SX users would find it easier to migrate to the Prop chip.

@Drac

Tasks do burn up cogs very quickly, on the other hand you can declare many Tasks, but of course you can only run 7 plus the main Task at any one time. Yes you may need vga, keyb in addition to the main Task running all the time but if you require access to SD you turn on that task, then turn it off when you have finished so that you can use the cog for another task like xmem for example etc. You can do that with any software, but it will feature more with PropBasic, because tasks will often be quite small, but very specific.

Anyway its was the first thing that I wrote after reading the manual, but it has given me some ideas.

Ron


Post Edited (Ron Sutcliffe) : 1/14/2010 11:30:39 AM GMT

JonnyMac
01-14-2010, 03:35 PM
Attached is a simple 12-bit SIRCS decoder program that runs on the demo board. If you press keys [ 1 ] - [ 8 ] on the remote a corresponding LED will light.

Note that PropBASIC -- despite similarities -- is not SX/B. In PropBASIC SUBs and FUNCs are declared the same way, with the min and max number of parameters if required. Since we only have one type of variable in a cog there is no need to define the number of returned values, simply place them in the RETURN statement at the end of the FUNC. Note that as of v0.65 you can return multiple parameters, for example:



...
RETURN xval, yval
ENDFUNC


In this case you call the function like this:



myVarX = FUNC_NAME
myVarY = __param2


You need to capture second and other parameters on your own.

Post Edited (JonnyMac) : 1/14/2010 2:51:39 PM GMT

Ron Sutcliffe
01-14-2010, 08:13 PM
@Drac

This is how I think it could work, hope it makes sense. Sorry I was late responding to your post but a got a new toy from Clusso yesterday. :)




ovlay TASK

ovlCode VAR LONG(300)

'First we need to get the name of the next ovlcode file from Hub. The file name could have been written to by any other running task, which requires
'the services of the ovlcode.
'Then we open the ovlcode file for read and download the ovlcode from SDcard into the space reserved in this cog (300 LONGS MAX)
'once the code is written into the cog, we close the SDcard port and jump to the Code we have just loaded into ovlCode code area.
'once the ovlcode has completed its task it jumps back to the handler( the first 180 longs say ) and waits for the
'file name of the ovlcode file name to change in Hub. Then then the process starts again.

'NOTE that the ovlcode is called by other tasks requiring the service. It is not determined at compile time.

ENDTASK

@Bean, true PIN is there to be used :)

Ron

Dr_Acula
01-14-2010, 08:44 PM
Yes Ron, that is getting close

I am thinking that normally you have some inline asm code in a program, you just write it in. In this case, it initialises with nothing and you put it in later. so the fake code to fill up the space might be
org 0
long fakelong1
long fakelong2

etc

and/or maybe there is a way of filling up 300 longs quickly in assembly. NOP? Some sort of array declaration?

ok, next problem, you are pulling in named overlay files off the sd card. Or (down the track), off the ram chip. (and your board from cluso will be very useful for testing this sort of thing)

When you have the name of an overlay, do you mindlessly search through the names of files on the sd card till you find it? Or, at the beginning of the program, do you grab the names of all the files and put them in a list somewhere?

Or (even better) grab the names of all the files, put them in a list, and also put the files themselves on the ram chip for faster access?

I guess it can be built up in stages. Probably for the moment search the slow way on the sd card.

Then another issue - each time you call a subroutine that you know is going to call a task overlay, do you mindlessly load it into the cog each time? Or do you keep a record of the last overlay to go into the cog, and only reload if the new name is different to the name of the current overlay?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Rsadeika
01-14-2010, 10:32 PM
I was just looking at the Sirc_rx code that JonnyMac worked up, I like the clean look of the propBASIC program. Makes the program relatively easy to follow. Having said that, I am having trouble following this particular line of code, 'keyIn = keyIn & $0F'. I know this is a bitwise AND operation, which is not making any sense to me. Here is what I know, $0F=%1111, the incoming number values will be between 1 and 7= %1 and %111. I can not follow what is trying to be achieved here. When I tried the program, the LED lights up when the corresponding key is pressed on the remote, but it is not limited to the 1 through 8 keys. There are other keys that light up an LED which have a greater key value number of eight. Other than that, everything looks good.

JonnyMac
01-14-2010, 11:08 PM
Well, goes to show that no good dead goes unpunished! http://forums.parallax.com/images/smilies/tongue.gif

At 1AM I was tired and probably chose a bad mask value for keyIn -- which is hardly the point, anyway; you wanted to know how to decode 12-bits SIRCS with PropBASIC and now you can. I updated the masking of the program to prevent the Volume and Channel keys from changing LEDs.

Another note on the update: Since PropBASIC only uses the __paramx variables to passing values back and forth they are safe to use in SUBs and FUNCs. I have aliased the variables used in GET_SIRCS_12 to minimize the number of variables consuming cog ram.

Post Edited (JonnyMac) : 1/14/2010 4:33:10 PM GMT

JonnyMac
01-15-2010, 02:27 AM
For fun and to show that you can embed PASM into your PropBASIC programs, I took my SIRCS decoder from the January 2010 issue of Nuts & Volts and built it into a PropBASIC program. Note that this differs from my Spin version in that it's part of the main code -- later I'll move this to its own task so that it doesn't block. Note, too, that this program gives you the SIRCS code and bit count. The attached image shows output from the key on my TV/DVD remote; the first line press (20 bits) was in DVD mode, the next line (12 bits) in TV mode.

There's a lot of interesting PASM code in ObEx and this shows that you can -- with a little effort -- take advantage of it.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

Bean
01-15-2010, 02:56 AM
Cool program Jon.

I'd like to point out that PropBASIC users shouldn't get too wound up about the 496 instruction limit per cog. This nice demo that Jon wrote uses 145 LONGS. And some of that is HUB constants. So he only used about 30% of the space in one cog for this program.

If you use subroutines for commands that generate alot of code, you really can do alot in 496 PASM instructions.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

Rsadeika
01-15-2010, 03:42 AM
@JonnyMac, I just tried to compile sircs_rx_v3.pbas, and I get -
line 198
error 7 invalid number of parameters; 'return irCode,irBits'

For some reason I am getting a lot of those type of errors.

JonnyMac
01-15-2010, 04:28 AM
Rsadeika said...
@JonnyMac, I just tried to compile sircs_rx_v3.pbas, and I get -
line 198
error 7 invalid number of parameters; 'return irCode,irBits'

For some reason I am getting a lot of those type of errors.


Download the latest version of the compiler -- we just changed it yesterday to accommodate multiple return parameters. In the future, please trust that if I post something it has been tested.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

Ron Sutcliffe
01-15-2010, 07:01 AM
@Bean and Jon


Bean said


I'd like to point out that PropBASIC users shouldn't get too wound up about the 496 instruction limit per cog. This nice demo that Jon wrote uses 145 LONGS. And some of that is HUB constants. So he only used about 30% of the space in one cog for this program.

If you use subroutines for commands that generate alot of code, you really can do alot in 496 PASM instructions.




There is a lot room for code in a single cog. IMO It is cog’s that·will be·premium.

I will see if I can get some code working and start a new thread. Lets see if I can draw a few others into exploring PropBasic.

Ron

JonnyMac
01-15-2010, 08:10 AM
Okay, I'm worn out on SIRCS, so here's my final demo -- pure PropBASIC and handles 12- and 20-bit codes. Note that some registers in the Propeller, like phsa and phsb that are used in my program, cannot be treated like simple RAM variables in some applications. You'll see that I capture these registers into __temp1 so that I get the correct value from the accumulator.

[Edit] Bean updated the compiler (0.66) so that we can use phsa and phsb like any other value in a comparison, for example:



IF phsa > BIT_1 THEN


...now handles the gritty details of the phs registers; this keeps our PropBASIC code a little simpler and cleaner

(Jan 19) I just noticed that I had uploaded the Spin output instead of the .pbas source file -- sorry about that.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

Post Edited (JonnyMac) : 1/20/2010 6:36:57 AM GMT

jknightandkarr
01-16-2010, 01:55 PM
Just a question. Is the Syntax guide finished or is there more commands needed to be added to the list? Compaired to the BS2, how many commands are available for use? I have a program known to work in BS2, but I"m having trouble converting it to Propeller's code.

Joe

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm going insaine. It's SOOOOOO much fun. lol

Ron Sutcliffe
01-16-2010, 07:52 PM
Joe
It's a quantum leap from BS2 to Prop, but PropBasic will ease the pain.

You should post some code if you really want people to help.


Ron

Rsadeika
01-16-2010, 09:18 PM
@Joe, you may want to take up Bean's offer to convert a BS2 program to propBASIC, check out Bean's earlier post for details. As for the propBASIC commands, I think it is pretty firm that there will not be any more commands added. What specific commands are you concerned with?

Ray

jknightandkarr
01-17-2010, 12:57 AM
I'll have to add more coding in the BS2 section. My program wasn't compleated due to the BS2's lack of multiple cogs & in ability to work my program without accuracy, but let me work on my bs2 program & I'll post it then.

Joe

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm going insaine. It's SOOOOOO much fun. lol

JonnyMac
01-17-2010, 04:25 AM
jknightandkarr said...
Just a question. Is the Syntax guide finished or is there more commands needed to be added to the list? Compaired to the BS2, how many commands are available for use? I have a program known to work in BS2, but I"m having trouble converting it to Propeller's code.

Joe


The "fancy" syntax guide lists all the commands that are part of PropBASIC 1.0, but they are not fully explained. Bean and I are working hard to test all the included commands so that we can move from beta to an official release.

Bean made the offer to translate programs from PBASIC to PropBASIC to help us test. I'll help too; I have a lot of experience (probably more than most) translating PBASIC to SX/B, and PropBASIC and SX/B are very similar. Post your PBASIC program and let us show you how you might translate it to PropBASIC.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

Humanoido
01-17-2010, 02:23 PM
Where are all the programs to blink lights? And what happened to the private forum?

Another question, when I modify the code below



DEVICE P8X32A, XTAL1, PLL16X ' Device Settings
FREQ 80_000_000 ' Clock Frequency
LED PIN 16 LOW ' Pin 16 is named LED, and set LOW
PROGRAM Start ' Program starts at label "Start"
Start: ' Program label
HIGH LED ' Make LED pin HIGH
PAUSE 500 ' Wait 500 milliseconds
LOW LED ' Make LED pin LOW
PAUSE 500 ' Wait 500 milliseconds
GOTO Start ' Repeat forever
END ' End of program


to this



DEVICE P8X32A ' Device Settings
LED PIN 16 LOW ' Pin 16 is named LED, and set LOW
PROGRAM Start ' Program starts at label "Start"
Start: ' Program label
HIGH LED ' Make LED pin HIGH
PAUSE 500 ' Wait 500 milliseconds
LOW LED ' Make LED pin LOW
PAUSE 500 ' Wait 500 milliseconds
GOTO Start ' Repeat forever
END ' End of program


it will give an error (no specified frequency). How can this be prevented?
I want to use the internal clock and no crystal.

humanoido

Post Edited (humanoido) : 1/17/2010 8:22:18 AM GMT

Gerry Keely
01-17-2010, 05:42 PM
humanoido

Use RCFAST ( ~12MHz) or RCSLOW (~20kHz) in place of XTAL1.This is covered in the syntax guide by JonnyMac

regards

Gerry

JonnyMac
01-17-2010, 11:13 PM
RCFAST is supposed to be assumed when nothing is specified; for the time being just add that to the DEVICE line.

We closed the private forum because nobody but Bean and I had any time to do boring testing.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

hinv
01-17-2010, 11:45 PM
without digging into it, does this basic handle floating point numbers natively?

Mike Green
01-18-2010, 12:07 AM
No

Floating point is fairly expensive in terms of resources on the Propeller. You need one or two cogs devoted to a floating point processor and, although the existing floating point code is quite fast (about 40us for basic operations), it's several orders of magnitude slower than integer arithmetic. You don't want to use floating point unless you really need it and you need to keep its use to a minimum.

Post Edited (Mike Green) : 1/17/2010 5:17:36 PM GMT

jknightandkarr
01-18-2010, 02:40 PM
' {$STAMP BS2}
' {$PBASIC 2.5}
vss VAR Word
Mph VAR Word
Segs VAR OUTL ' Segments on P0 - P7
SegsDirs VAR DIRL ' DIRS for segments
Digs VAR OUTC ' Digit control pins
Blank CON %00000000 ' all segments off
theDig VAR Nib ' current display digit

' .GFEDCBA
Digit0 DATA %00111111 ' digit patterns
Digit1 DATA %00000110
Digit2 DATA %01011011
Digit3 DATA %01001111
Digit4 DATA %01100110
Digit5 DATA %01101101
Digit6 DATA %01111101
Digit7 DATA %00000111
Digit8 DATA %01111111
Digit9 DATA %01100111

DigSel DATA %1110 ' digit 0 active
DATA %1101 ' digit 1 active
DATA %1011 ' digit 2 active
DATA %0111 ' digit 2 active

Digs = %1111 ' all off
DIRS = $0FFF ' make segs & digs outputs

DO
COUNT 15, 1000, vss 'Get vehical speed signal
vss=67 'temporary line
Mph = vss * 9 'Turn vss signal into speed reading
DEBUG HOME, " MPH = ", DEC Mph DIG 3,DEC Mph DIG 2, DEC Mph DIG 1, DEC Mph DIG 0,CR 'temporary line Mph to pc terminal
Segs = Blank ' clear display
READ (DigSel + theDig), Digs ' select digit
READ (Digit0 + (Mph DIG theDig)), Segs ' move digit pattern to segs
theDig = theDig + 1 // 4 ' update digit pointer
LOOP



Ok here's my program I need converted to Propeller. As a note my "COUNT 15, 1000, vss" line needs to constantly run in its own cog by itself & then the "Mph=vss*9" needs to start in the other cog & loop. The vss=67 is only a temporary line, to simulate a vss signal of 67Hz, which should give me 060.3 mph after reading out on the leds. I was going to run an odometer in this as well, but I've got another job for the odometer digits as well, so I'll work on that code later.

Joe

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm going insaine. It's SOOOOOO much fun. lol

Bean
01-18-2010, 09:46 PM
Okay, well here is my translation.



DEVICE P8X32A, XTAL1, PLL16X ' {$STAMP BS2} ' {$PBASIC 2.5}
FREQ 80_000_000

Blank CON %00000000 ' all segments off
Baud CON "T115200" ' Baud rate to PC

Segs PIN 0..7 OUTPUT ' Segs VAR OUTL ' Segments on P0 - P7
' SegsDirs VAR DIRL ' DIRS for segments
Digs PIN 8..11 OUTPUT ' Digs VAR OUTC ' Digit control pins
TX PIN 30 HIGH ' Serial pin to PC

vss VAR LONG ' vss VAR Word
mph VAR LONG ' Mph VAR Word
theDig VAR LONG ' theDig VAR Nib ' current display digit
wait VAR LONG ' Used to accumulated count for 1 second
ascii VAR LONG(12) ' Used to hold string to send to PC
temp VAR LONG ' Temporary variable

digits HUB BYTE(4) = "0" ' Digits to show on multiplex display

' .GFEDCBA
Digit0 DATA %00111111 ' digit patterns
Digit1 DATA %00000110
Digit2 DATA %01011011
Digit3 DATA %01001111
Digit4 DATA %01100110
Digit5 DATA %01101101
Digit6 DATA %01111101
Digit7 DATA %00000111
Digit8 DATA %01111111
Digit9 DATA %01100111

DigSel DATA %1110 ' digit 0 active
DATA %1101 ' digit 1 active
DATA %1011 ' digit 2 active
DATA %0111 ' digit 2 active

Multiplex TASK

PROGRAM Start

Start:
Digs = %1111 ' all off
' DIRS = $0FFF ' make segs & digs outputs
COUNTERA 80, 15, 0, 1, 0 ' Setup counter to accumulate count from pin P15


ascii(0) = " "
ascii(1) = "M"
ascii(2) = "P"
ascii(3) = "H"
ascii(4) = " "
ascii(5) = "="
ascii(6) = " "
ascii(11) = 13 ' Carrage return

COGSTART Multiplex ' Start task that handles the multiplexed display

wait = cnt + _Freq


DO
WAITCNT wait, _Freq ' COUNT 15, 1000, vss 'Get vehical speed signal
vss = phsa ' Get accumulated count from counter
phsa = 0 ' Zero accumulated count

vss=67 ' ***** temporary line

mph = vss * 9 'Turn vss signal into speed reading
' DEBUG HOME, " MPH = ", DEC Mph DIG 3,DEC Mph DIG 2, DEC Mph DIG 1, DEC Mph DIG 0,CR 'temporary line Mph to pc terminal


STR ascii(7), mph, 4 ' Convert mph to ascii characters

WRBYTE Digits(0), ascii(7) ' Update digits to show on multiplex display
WRBYTE Digits(1), ascii(8)
WRBYTE Digits(2), ascii(9)
WRBYTE Digits(3), ascii(10)

FOR temp = 0 TO 11 ' Send string to PC
IF temp = 10 THEN
SEROUT TX, Baud, "."
ENDIF
SEROUT TX, Baud, ascii(temp)
NEXT

LOOP


END



TASK Multiplex
theDig VAR LONG = 0
temp VAR LONG

DO
Segs = Blank ' clear display

RDBYTE DigSel(theDig), temp ' READ (DigSel + theDig), Digs ' select digit
Digs = temp

RDBYTE Digits(theDig), temp
temp = temp - "0"
RDBYTE Digit0(temp), temp
Segs = temp

INC theDig ' theDig = theDig + 1 // 4 ' update digit pointer
theDig = theDig AND 3

PAUSE 5 ' Time to display digit


LOOP
ENDTASK



Note that you DON'T need a seperate task to do the COUNT. The hardware counters will handle that. But you do need one for the multiplex display.

I havne't tested it fully because I don't have the hardware, but it should be really close.

Bean.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

Post Edited (Bean (Hitt Consulting)) : 1/18/2010 3:01:59 PM GMT

Humanoido
01-19-2010, 01:03 AM
Gerry Keely and JonnyMac:

Thanks for the solution. After putting in RCFAST and deleting the Crystal and PLL16X Device Settings and the clock frequency, it works perfect!

This compiled PROPBASIC is absolutely fantastic. I love the choice commands and features, which are highly useful in many programming applications. It allows some really nice features running on my new Prop computer, and it's very easy to use with PropBASICide.

Other compiled languages can be a pain for those of us that don't care to type in cryptic command lines into the black box, but PROPBASIC makes it a breeze to use. I wish other languages could take the approach of PROPBASIC. You guys really did a terrific job on this, and making it more easy to use is a big key in writing code.

It's a lot of fun, and easy to use, and opens up all new doors of possibilities for the Propeller chip. A big thanks and a lot of admiration and praise to everyone involved in its development and documentation.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
humanoido
*Stamp SEED Supercomputer (http://forums.parallax.com/showthread.php?p=817126)*Basic Stamp Supercomputer (http://forums.parallax.com/showthread.php?p=765140)*TriCore Stamp Supercomputer (http://forums.parallax.com/showthread.php?p=822511)
*Minuscule Stamp Supercomputer (http://forums.parallax.com/showthread.php?p=821451)*Three Dimensional Computer (http://forums.parallax.com/showthread.php?p=799604)*Penguin with 12 Brains (http://forums.parallax.com/showthread.php?p=765509)
*Penguin Tech (http://forums.parallax.com/showthread.php?p=770232)*StampOne News! (http://forums.parallax.com/showthread.php?p=798852)*Penguin Robot Society (http://www.p-robot.com/)
*Handbook of BASIC Stamp Supercomputing
(http://forums.parallax.com/showthread.php?p=841541)*Ultimate List Propeller Languages
(http://forums.parallax.com/showthread.php?p=809630)*MC Prop Computer (http://forums.parallax.com/showthread.php?p=873623)

jknightandkarr
01-19-2010, 07:29 AM
Bean (Hitt Consulting) said...

Note that you DON'T need a seperate task to do the COUNT. The hardware counters will handle that. But you do need one for the multiplex display.
I havne't tested it fully because I don't have the hardware, but it should be really close.

Bean.


Thanks. I gotta rig my display up since i had put an order for a better display didn't go as planned. But if id need PropBasic to do my odometer display the counting part would need a constant task to count, for accuracy reasons I would think. I for got about the speedometer itself not needing that.

Joe

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm going insaine. It's SOOOOOO much fun. lol

JonnyMac
01-19-2010, 08:20 AM
Just as Bean showed you how you can spawn the display multiplexing into its own cog you can do the same thing with the tach input -- it might look something like what follows.



TASK Speedo

timer VAR Long
pulses VAR Long

COUNTERA 112, TachIn, 0, 1, 0 ' assume low-going input
timer = cnt + _FREQ ' sync with system counter

DO
WAITCNT timer, _FREQ ' wait one second
pulses = phsa ' grab pulse count
phsa = 0 ' reset for next second
WRLONG tachPulses, pulses ' write to hub
LOOP

ENDTASK


This task depends on a pin called TachIn and a hub long called tachPulses.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

Conehead
01-19-2010, 11:44 AM
I haven't had a chance to download this yet, but I want to say thank you to Bean and Jon!

Christof Eb.
01-20-2010, 03:20 AM
Hi Bean, hi Jon,

PropBasic is great! Thank you very much!

Only one question: Is there a possibility to tell the IDE to use the tabulator key?

Christof

simonl
01-20-2010, 04:39 AM
I too found PropBASICIDE a little, erm, lacking in places (!) - no TAB key; only one undo level; no colour; etc - so I've just started using NotePad++ (sorry - it's Windows only). This overcomes all of those issues, and I'm able to compile too http://forums.parallax.com/images/smilies/smile.gif (NotePad++ is available from notepad-plus.sourceforge.net/uk/site.htm (http://notepad-plus.sourceforge.net/uk/site.htm))

To get colour coding I created the attached "userDefineLang.xml". In Windows7, extract the zip contents to "C:\Users\<YOURLOGINID>\AppData\Roaming\Notepad++", then:

(NOTE: I found that NotePad++ has a few "issues" with Window7 - toolbar buttons don't work - so the following needs to be undertaken with Admin' privileges http://forums.parallax.com/images/smilies/wink.gif)

1. View > User-Defined dialogue...
2. Creat new - name it PropBASIC
3. Language > PropBASIC - this sets the CURRENT document to use the PropBASIC styling/colours

To compile, I set-up a new RUN command; as follows:

1. Run > Run...
2. Browse to PropBASICIDE
3. Add $(FULL_CURRENT_PATH) to the end of the path
4. Save...
5. Name it Compile - that's what will appear in the Run menu

Using this Run command will compile your PropBASIC file to it's SPIN equivallent and place it in the same folder.

I'm gonna see if I can get a command that'll compile AND load to RAM or EEPROM too (@BEAN: Any idea what the command line call to Propellent would be?)

Anyways - I hope this is useful. Enjoy.

@BEAN: This is WAY cool - thanks http://forums.parallax.com/images/smilies/yeah.gif

<EDIT 2010-01-22>Uploaded new version of userDefineLang.zip</EDIT>

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
-------------------------------

www.norfolkhelicopterclub.com (http://www.norfolkhelicopterclub.com)

Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.

Post Edited (simonl) : 1/22/2010 10:59:00 PM GMT

simonl
01-20-2010, 05:30 AM
I've not been able to test this yet, but here's what I think will load your PropBASIC compiled program to the Propeller:

1. Run > Run...
2. Browse to Propellent.exe
3. Add $(CURRENT_DIRECTORY)\$(NAME_PART).spin to the end of the command
4. Click Save...
5. Name it "Load to Propeller" - that's what will appear in the Run menu

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
-------------------------------

www.norfolkhelicopterclub.com (http://www.norfolkhelicopterclub.com)

Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.

Bean
01-20-2010, 06:40 AM
simonl,
Yeah I'm not much of an IDE programmer. It is just enough so members wouldn't have to use batch files.
A much better solution is in the works.

Bean

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

simonl
01-20-2010, 08:06 PM
@Bean: Don't get me wrong; your IDE's just right for getting started - and I'd much rather you spend your time making PropBASIC the best it can be http://forums.parallax.com/images/smilies/smile.gif I just happened to have a copy of NotePad++ installed, so thought I'd see if I could get it to fit (I find it much easier if the code's coloured).

BTW: I'm lovin' PropBASIC - now I have the simplicity of BASIC with the speed of PASM. That's just BRILLIANT, and I'm finding it a great tutorial for PASM to boot! Thank you http://forums.parallax.com/images/smilies/smile.gif

Also: that "much better solution" wouldn't be PropTool or BST would it?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
-------------------------------

www.norfolkhelicopterclub.com (http://www.norfolkhelicopterclub.com)

Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.

Christof Eb.
01-21-2010, 01:45 AM
Hi Bean,

I have been experimenting with PropBasic a little more. This really speeds me up! I can write the code more quickly and it will execute really fast. No assembler needed. I am astonished, how much code fits into the cog ram.

One suggestion: If you store a variable to a byte or word hub variable and read it again, then the sign causes trouble. What do you think of a parameter like that:

rdword buffer, variable[, signed]······ 'to extend the sign to 32 bits

Christof

JonnyMac
01-21-2010, 02:08 AM
@Christof: RDWORD allows multiple variables so fixing the sign is not possible as you suggest (see version 0.13 of the "fancy" docs).

If you want to convert a signed word to a signed long you can do it with a bit of inline assembly:



\ shl variable, #16
\ sar variable, #16


The first line moves the original MSB (bit15) to bit31, the second moves it back, filling the new bits (31..16) with the original MSB.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

Bean
01-21-2010, 02:26 AM
I have posted version 00.00.72 of the PropBASIC compiler.

The MAJOR change is in the way pin groups are handled.

In previous versions you had to declare pin groups as "name PIN LSBpin..MSBpin" with LSBpin always having to be a lower value than MSBpin. This was not consistent with the way spin uses groups of pins. So PropBASIC was changed.

Pin groups are now declared as "name PIN MSBpin..LSBpin" and compiler will reverse the bits if MSBpin is lower than LSBpin. This works very much like spin, so users of both languages won't get confused.

@Christof: It would probably require new commands like: WRSWORD, RDSWORD, WRSBYTE, RDSBYTE. I'll put it in the "think about it" pile.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

Christof Eb.
01-21-2010, 02:47 AM
Thanks, Jon and Bean,·for the quick answers and solution/workaround!

Christof

Christof Eb.
01-21-2010, 05:13 PM
Hi Bean,

I have another question regarding negative numbers. The intention is that everything should work with signed numbers?

··············· mov········ __remainder,temp················ '····· sample1 = temp / 2
··············· and········ __remainder,#1·················
··············· mov········ sample1,temp···················
··············· shr········ sample1,#1·

So the sign gets lost.

Best Regards Christof

Bean
01-21-2010, 07:37 PM
Christof,
· Thanks for catching that.
· I will be fixed in release 00.00.73.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

Post Edited (Bean (Hitt Consulting)) : 1/21/2010 12:47:05 PM GMT

Christof Eb.
01-21-2010, 08:47 PM
Hi Bean,

some other thing, ther seems to be a bug in str.

' Define variables (LONGs only)
temp···· VAR LONG
ascii··· VAR LONG(13) ' Conversion to ASCII
i······· VAR long

' Define Subroutines
SerNumber SUB 1

'################################################# ##############################################
' Start of main code
PROGRAM Start
Start:
· pause 2000
· for i = 0 to 100 step 10
··· SerNumber i
· next i

end



SUB SerNumber
··· STR ascii, __param1, 10,3
··· ascii(10) = 13
··· FOR temp = 0 TO 10
····· SEROUT TX, Baud, ascii(temp)
··· NEXT
ENDSUB

gives:

········ 0
······· 10
······· 20
······· 30
······· 40
········ 2
······· 12
······· 22
······· 32
········ 4
······ 100

As this is a key feature to debug, it would be nice to fix this soon.....

Best regards Christof

Bean
01-21-2010, 09:39 PM
Christof,
Yeah 32-bit values can only handle 10 digit values up to 4_294_967_296. That's why if chokes if the leading digit is > 4.
There is no problem if you use 9 digits.

I'll have to see if I can implement a 33-bit value somehow.

Bean

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

Post Edited (Bean (Hitt Consulting)) : 1/22/2010 10:18:27 PM GMT

Christof Eb.
01-21-2010, 11:31 PM
Hi Bean,

the sign eats one of the 9 digits in mode 3... Perhaps there are possibilities without having 33 bits?

Do not misunderstand me, please. I started a project right away with your compiler and your IDE this week. Working with·them is real fun! I have 4 Tasks running well, the code is about 10 screens long and gives about 800longs of cog code. So I am very happy with this betabeta Version!

Christof

Bean
01-22-2010, 01:36 AM
Christof,
I have posted version 00.00.73 with fixes for the problems you have found.

If you use mode 2 or 3 (signed) the first character is either "-" or " " (it cannot be a digit as before). So mode 2 or 3 allows 11 places to be used.

Basically if you specify mode 0 or 1(default) with 10 places or mode 2 or 3 with 11 places, the highest digit is handled before the main loop. The generates more code, but at least the result is correct.

I do not take offence...In fact I'm very glad that you are finding these bugs for me. I wish more members would be a though as you.

Bean

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

Spreader
01-23-2010, 02:38 AM
Hi Jon and Bean, congrats on a superb compiler! As a user of picbasic, I supposed we are spoilt to some extent with having some LCD character display commands. Do you envisage including the equivalent or similar in propbasic or should we just rely on LCD macros being posted by other users?

JonnyMac
01-23-2010, 02:45 AM
@Spreader: I, for one, am of the opinion that LCDs and things should not be built into the compiler. We try to focus on timing sensitive things -- LCDs really are not that sensitive at all. Do you need LCD code right away? I've got a couple other things on my plate, but I might be able to port my Spin code over in the next day or so.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

Spreader
01-23-2010, 03:01 AM
Hi Jon, I don't need anything right now, but will be experimenting with some 20x4's and possibly the odd GLCD (driver not known at present) in the near future. I get the gist of what you are saying re timing, but as I said, I find that being able to use a few basic commands to get a display up and running quickly quite useful. Thanks for the kind offer.

simonl
01-23-2010, 06:03 AM
Yeah, I tend to agree with Jon; no need lumbering PropBASIC with such code - just do a

LOAD "LCD.pbas"

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
-------------------------------

www.norfolkhelicopterclub.com (http://www.norfolkhelicopterclub.com)

Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.

Dr_Acula
01-23-2010, 07:23 AM
Just for fun I fired up PropBasic on the Dracblade. I'll document the steps since it was so easy.

1) Download propbasic from the first page of this thread into a new folder
2) Run PropBasicIDE
3) Open the file Keyboard t PC.BAS
4) Minor tweak to the code - dropped the baud rate to 19200 as my terminal program is set up for that rate
5) Compile it
6) Run a terminal program (lots of choices - they all work)
7) Type characters on the keyboard and they come up on the screen.

This is fun!!!

Of course, I immediately want to do more. I had a quick look in the demos - is there a VGA driver?

If not, given there is lots of generic code around, is this hard to add?

I'm now trying to get my head around what propbasic is doing. The keyboard driver seems to be a complete rewrite in Propbasic (which is
very impressive, as it comes to a tiny amount of code. Less even that a Z80 assembly keyboard driver I have.) So rather than drop in pre-written
spin/pasm modules, are each of these functions being rewritten for propbasic? If so, given the small code listings, and the direct to assembly translation and the extremely rapid compilation, I can see the attraction there.

Thinking aloud, is there a way to automate the translation? Or is it just a tedious matter of going through each line?

I'm thinking of other useful building blocks - eg VGA, but especially the SD card code. Both of those would be beyond me to write, but I think I could contribute code for the 20x4 LCD display.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

BradC
01-23-2010, 08:47 AM
G'day guys. I don't want to hijack Bean's thread, but I figure this is probably the best place to post this.

I'm not much of a BASIC programmer (in fact I've not used it since about 1983), but I want to set up some automated testing of the PropBasic compiler.

With spin, it's easy. I just downloaded the entire obex and built a test suite around that. I now test against ~1800 spin files.

Is anyone interested in E-mailing me zip files of their PropBasic source code that I could use in a private test suite? I could really use some programs that create multiple files, use tasks, use include files and anything else that hits the disk. Having said that, even simple examples will help greatly. No code will be examined, judged, commented on or released outside of my home network, but I could _really_ use some help here from those that are actually using PropBasic on a regular basis. <pretty please with a cherry on top>.

If you could e-mail code to proptools <at> fnarfbargle.com, I'd _really_ appreciate it.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Life may be "too short", but it's the longest thing we ever do.

Ron Sutcliffe
01-23-2010, 07:56 PM
@BradC
Have you looked at the Demos in the PropBasic Package. There are some interesting Video Files and other stuff there.

Ron

simonl
01-24-2010, 03:28 AM
@BradC: Just as soon as I have some working code I'll be happy to pass it to you http://forums.parallax.com/images/smilies/smile.gif I'm getting visions of PropBASIC within BST - cross platform (right?)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
-------------------------------

www.norfolkhelicopterclub.com (http://www.norfolkhelicopterclub.com)

Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.

Jim Fouch
01-25-2010, 10:49 PM
Terry,

Can you release the info on how to compile a .pbas program from am command line? I have looked through this thread and in the docs included with the latest v .75 and can't seem to find any info. I tried to use the Notepad++ editor (Which I like), but was not successful.

I used PropBASIC for the first larger program and was able to write a driver for an MCP23S17 I/O Expander chip pretty quickly. I used the SHIFTOUT command and then tweaked the PASM to remove the WAITCNT, because the MCP23S17 only needs 45ns between CLKs. I then reinserted the modified PASM back into the PropBASIC code using the ASM...ENDASM statements and this works so slick.

I can really see how useful this is to people that are not 100% proficient in PASM. It a great learning tool!!!!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jim Fouch

FOUCH SOFTWARE

Bean
01-25-2010, 11:14 PM
Jim,
You call PropBASIC.exe with the first parameter as the FULL path to the .pbas file (in quotes). If you add a /p switch, the compiler will pause at errors.

Example:
PropBASIC.exe "c:\full_path\myfile.pbas" /p


Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

Mike Huselton
01-26-2010, 04:19 AM
Love the documentation. Love the implementation.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH

Gerry Keely
01-27-2010, 04:14 PM
Hi

1. IF-ENDIF Statement

Compiler doesn't complain if "ENDIF" is missing.

2 IN & OUT PINS

Is it possible to control the same pin from two or more tasks?, if so how can this be done?

Regards

Gerry

jknightandkarr
01-27-2010, 04:37 PM
Bean (Hitt Consulting) said...
Okay, well here is my translation.






DEVICE P8X32A, XTAL1, PLL16X ' {$STAMP BS2} ' {$PBASIC 2.5}
FREQ 80_000_000



Blank CON %00000000 ' all segments off
Baud CON "T115200" ' Baud rate to PC



Segs PIN 0..7 OUTPUT ' Segs VAR OUTL ' Segments on P0 - P7
' SegsDirs VAR DIRL ' DIRS for segments
Digs PIN 8..11 OUTPUT ' Digs VAR OUTC ' Digit control pins
TX PIN 30 HIGH ' Serial pin to PC



vss VAR LONG ' vss VAR Word
mph VAR LONG ' Mph VAR Word
theDig VAR LONG ' theDig VAR Nib ' current display digit
wait VAR LONG ' Used to accumulated count for 1 second
ascii VAR LONG(12) ' Used to hold string to send to PC
temp VAR LONG ' Temporary variable



digits HUB BYTE(4) = "0" ' Digits to show on multiplex display



' .GFEDCBA
Digit0 DATA %00111111 ' digit patterns
Digit1 DATA %00000110
Digit2 DATA %01011011
Digit3 DATA %01001111
Digit4 DATA %01100110
Digit5 DATA %01101101
Digit6 DATA %01111101
Digit7 DATA %00000111
Digit8 DATA %01111111
Digit9 DATA %01100111



DigSel DATA %1110 ' digit 0 active
DATA %1101 ' digit 1 active
DATA %1011 ' digit 2 active
DATA %0111 ' digit 2 active



Multiplex TASK



PROGRAM Start



Start:
Digs = %1111 ' all off
' DIRS = $0FFF ' make segs & digs outputs
COUNTERA 80, 15, 0, 1, 0 ' Setup counter to accumulate count from pin P15




ascii(0) = " "
ascii(1) = "M"
ascii(2) = "P"
ascii(3) = "H"
ascii(4) = " "
ascii(5) = "="
ascii(6) = " "
ascii(11) = 13 ' Carrage return



COGSTART Multiplex ' Start task that handles the multiplexed display



wait = cnt + _Freq




DO
WAITCNT wait, _Freq ' COUNT 15, 1000, vss 'Get vehical speed signal
vss = phsa ' Get accumulated count from counter
phsa = 0 ' Zero accumulated count



vss=67 ' ***** temporary line



mph = vss * 9 'Turn vss signal into speed reading

' DEBUG HOME, " MPH = ", DEC Mph DIG 3,DEC Mph DIG 2, DEC Mph DIG 1, DEC Mph DIG 0,CR 'temporary line Mph to pc terminal




STR ascii(7), mph, 4 ' Convert mph to ascii characters



WRBYTE Digits(0), ascii(7) ' Update digits to show on multiplex display
WRBYTE Digits(1), ascii(8)
WRBYTE Digits(2), ascii(9)
WRBYTE Digits(3), ascii(10)



FOR temp = 0 TO 11 ' Send string to PC
IF temp = 10 THEN
SEROUT TX, Baud, "."
ENDIF
SEROUT TX, Baud, ascii(temp)
NEXT



LOOP




END






TASK Multiplex
theDig VAR LONG = 0
temp VAR LONG

DO
Segs = Blank ' clear display




RDBYTE DigSel(theDig), temp ' READ (DigSel + theDig), Digs ' select digit
Digs = temp


RDBYTE Digits(theDig), temp
temp = temp - "0"
RDBYTE Digit0(temp), temp
Segs = temp



INC theDig ' theDig = theDig + 1 // 4 ' update digit pointer
theDig = theDig AND 3


PAUSE 5 ' Time to display digit




LOOP
ENDTASK






Note that you DON'T need a seperate task to do the COUNT. The hardware counters will handle that. But you do need one for the multiplex display.



I havne't tested it fully because I don't have the hardware, but it should be really close.



Bean.


I tried the code with PropBasic & the information including the speed went to the Serial Terminal, however, I got no display on my LED display. I'll look at it & attempt to locate errors.

Joe

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm going insaine. It's SOOOOOO much fun. lol

eiplanner
01-27-2010, 05:11 PM
Excellent! Excellent! Excellent! I am pretty new to the forums, but I think this was a great idea for those of us new to SPIN. It should lead
to a whole new array of easy to learn educational materials for beginners. I can't even begin to imagine the amount of work that this must
have been and still probably is, I just know it's a heck of a lot. Way to go Bean & Johnny and anyone else that contributed!

Many, many accolades!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It's not the size of the dog in the fight, but the size of the fight in the dog.

JonnyMac
01-27-2010, 11:21 PM
Gerry Keely said...
Hi

1. IF-ENDIF Statement

Compiler doesn't complain if "ENDIF" is missing.

2 IN & OUT PINS

Is it possible to control the same pin from two or more tasks?, if so how can this be done?

Regards

Gerry


RE #2: It's actually quite easy in PropBASIC because IO pin definitions are global (i.e., shared across all cogs in a project) -- all you have to do is set an output or read an input in your tasks as you would the main program.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

Post Edited (JonnyMac) : 1/27/2010 4:27:37 PM GMT

Bean
01-28-2010, 12:37 AM
Someone had asked for a VGA demo.

Here is a really simple one. It creates a 320x240 pixel 4 color VGA bitmapped display.

Enjoy,
Bean


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

Gerry Keely
01-28-2010, 04:56 PM
IN and OUT again
When I try attached it· works


DEVICE P8X32A, XTAL1, PLL16X
FREQ 96_000_000

' Define pins
LED PIN 27 OUTPUT
'LED = 0 Turns LED ON
' Define TASKs
ToggleLED TASK
' Main program
PROGRAM Start
Start:
COGSTART ToggleLED
LED = 0 'if = 1 does not work
DO
LOOP
END
TASK ToggleLED
PAUSE 2000
DO
Pause 100
TOGGLE LED
LOOP
ENDTASK

but if LED is set to 1 in program Start·LED doesn't flash·-can anybody shed some light on this !

Also DO without a LOOP statement is not trapped as an error

Regards

Gerry

Dr_Acula
01-28-2010, 05:48 PM
I say, that looks like fun. VGA display for the masses. Starts with some vertical lines then a diagonal line then random pixels with red,white,blue,black. See photo.

This works straight out of the box on the dracblade. How can we take this further?

Well, I see an awful lot of pixels on the screen. Probably far more than are needed for some simple games. Is it possible, say, to halve the vertical and horizontal number which will decrease the number of bytes to 1/4, then have 4 times the number of colors, ie 4x4=16 colors?

The 512k of ram on the dracblade is not fast enough for direct drawing on the screen but it ought to be fast enough for moving sprites into screen memory, especially if the sprite is much smaller than the display - eg a little rocket ship moving across the display. I'll defer to the game experts (who I think hang out over at the hydra forum) but I think it ought to be possible in theory.

Back to the real world, I guess some fonts are the next possibility? And the 512k of ram would be a perfect spot to store some fonts, though hopefully there is some spare memory on the demo board to store some fonts too?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Gerry Keely
01-28-2010, 06:33 PM
IN and OUT again

To answer my own question I believe reason is that as outa registers are ORed together,when LED =0 ,ToggleLED task will work
but with LED =1,ToggleLED will only generate a 1 as outa in Program start is permanently set to 1(· 1 OR x = 1).

Regards
Gerry

Bean
01-28-2010, 07:10 PM
Gerry Keely said...
IN and OUT again

To answer my own question I believe reason is that as outa registers are ORed together,when LED =0 ,ToggleLED task will work
but with LED =1,ToggleLED will only generate a 1 as outa in Program start is permanently set to 1(· 1 OR x = 1).

Regards
Gerry
Gerry,
· You are right. The output from all the cogs is OR'd together. So if ANY cog makes it high, it is high.

· Also, the PIN modifiers are only for the cog running the main code, for the same reason. If you defined a pin as HIGH, and started another cog, that pin would always be held high by the other cog.

Bean


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

Bean
01-28-2010, 07:39 PM
Here is another VGA demo, pretty much line the first except you can program the palette for each horizontal line.

Bean.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

Rsadeika
01-28-2010, 07:55 PM
@Dr_A, probably the next step would be to add some kind of text capability, then after that widgets, windows, ...

Ray

Bean
01-29-2010, 11:30 PM
Ray,
I will get text working on VGA...Maybe this weekend if I get some free time.
I also uploaded an updated version of the compiler today. Please get the latest version when you get a chance.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

Bean
01-31-2010, 10:34 AM
Here is the VGA demo with fonts and palette blocks.

NOTE: You MUST use PropBASIC version 00.00.77 or later to compile this. I fixed a bug that I found while writing this.

The resolution is 320x240 with 4 colors.
Text is 40x30 with a 8x8 font.
Each palette entry controls 16 pixels x 8 pixels (or two consecutive characters).

I have attached the .spin file too.

Bean.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

Dr_Acula
01-31-2010, 04:17 PM
Some very pretty colors but I don't think I am doing this quite right. See photo. The original lines all come up as before, then it goes to this.

Mind you, it is nice to see the full range of colors there! This bodes well for games etc.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Bean
01-31-2010, 08:59 PM
Dr_Acula,
You need to download version 00.00.77 of the compiler.

Bean

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·

Cluso99
01-31-2010, 10:18 PM
Great job Bean http://forums.parallax.com/images/smilies/smile.gif I am following with great interest but too many other things on my plate :-(

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Home of the MultiBladeProps: TriBlade (http://forums.parallax.com/showthread.php?p=786418),·RamBlade (http://forums.parallax.com/showthread.php?p=849265),·SixBlade (http://forums.parallax.com/showthread.php?p=780033), website (http://bluemagic.biz/cluso.htm)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator) (http://forums.parallax.com/showthread.php?p=790917)
· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) (http://forums.parallax.com/showthread.php?p=778427) ZiCog (Z80) (http://forums.parallax.com/showthread.php?p=788511) , MoCog (6809) (http://forums.parallax.com/showthread.php?p=811043)·
· Prop OS: SphinxOS (http://forums.parallax.com/showthread.php?p=819353)·, PropDos (http://www.orrtech.us/propdos/) , PropCmd (http://obex.parallax.com/objects/440/)··· Search the Propeller forums (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)·· MultiBlade Props: www.cluso.bluemagic.biz (http://www.cluso.bluemagic.biz)

Toby Seckshund
01-31-2010, 10:47 PM
Re VGA_Demo3

Just put a message up after about 30 secs saying " No errors found, test complete" .

It would impress a lot of the clients we get

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Style and grace : Nil point

TonyWaite
02-01-2010, 12:06 AM
@Bean
Thank you for VGA#3: we now have a native PropBASIC way of getting a text onto VGA!
T o n y

Rsadeika
02-03-2010, 06:36 AM
I thought that I would give it a bump, this is to make sure that Bean does not forget about this project LOL. Any guess as to when this will be
coming out of BETA?

Ray

JonnyMac
02-03-2010, 11:25 AM
Nobody's forgetting anything. Unlike whining and complaining, testing is hard work and Bean and I are doing a lot of it. You don't have to pay a dime for PropBASIC so its "beta" versus "production" status is irrelevant (note that the documentation states there is no warranty of any kind... period). If you're serious about PropBASIC, how about posting some of you own code so that Bean and I can see what you're doing and how we might make the compiler and the documentation better.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

Post Edited (JonnyMac) : 2/3/2010 4:55:06 AM GMT

Dr_Acula
02-03-2010, 05:46 PM
VGA Text is fantastic!!

Check out the photo. Latest version of vga driver running on a Dracblade (but would work on any Prop with a VGA plug).

Letters of the alphabet, and a random palatte generator, so take your pick for a favourite color combo. This is amazing!

This brings up a technical question. I see in the demo there is a keyboard object, and the code for this sits in a TASK. I presume this goes in its own cog?

The minimum things I seem to always need are:
1) keyboard
2) Display
3) One or two serial ports
4) sd card for storing little files and data
5) some general purpose spare propeller pins. Digital in/out, and analog in/out.

Propbasic is getting jolly close to that.

I wonder, for things like the 4 serial port driver that are pretty much all PASM and only a tiny bit of spin glue code, is it possible to drop that sort of PASM code into a PROPBasic program? Call it a Task, fill a cog with the same PASM code, interface with it in the same way?

Well, ok, the serial port is already done, and you could just use two cogs for two ports. This is racing ahead so fast. So exciting. Is SD card on the list?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Post Edited (Dr_Acula) : 2/3/2010 11:18:08 AM GMT

Rsadeika
02-03-2010, 07:12 PM
@Dr_A, I think that some SD code, for propBASIC, would be a major project. I was following the Kye thread with his undertaking of some SD
code, and he ran into some snags, he is a very good programmer. So, it's going to take somebody with a lot of skill to do the conversion.
Since I also end up using more than one serial port, I wonder if there really is a simple way of combining it so you only use one cog. The
other question I would have is, for instance, can the keyboard, vga, and something else be placed, in one TASK (cog), and be run successfully?
Have to start thinking about consolidation of code to reduce the number cogs that will be used.

Keep up the good work Bean, everybody knows this is a freebie, and we are very grateful for the work that you have done.

Ray

Bean
02-03-2010, 07:44 PM
To Jon's point:
It is disheartening that while making demos and such, I seem to be the only one finding bugs.
I know that some people tend to assume that the tool (PropBASIC) wouldn't do anything wrong and that it MUST be their code. PLEASE don't do that.
This is beta testing, assume the compiler screwed up. And if you know a little PASM look at the generated code.
If something isn't working right, please make a post in this thread.

@Dr_Acula, Yeah SD will be quite an undertaking. But you should be able to use the .spin version if you use something like the dispatch demo program.

I have make yet another VGA demo (during which I found another bug) so you need to download version 00.00.78 for this demo.
I have added a line drawing routine and some other useful subroutines. Drawing now updates the palette for the points that are drawn.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

Post Edited (Bean) : 2/3/2010 12:50:11 PM GMT

Dr_Acula
02-03-2010, 07:46 PM
I thought I might have a shot at writing a bit of Propbasic code. Learning a lot as I go. The 'structure' reflects the prop architecture rather than Basic in some ways, but that is to be expected. Eg



DIM myarray(10) = 0



is replaced with



myarray HUB BYTE(10) = 0



But obviously that saves memory putting things in hub (as an aside, already thinking about putting arrays in external memory too).

Next thing I found is that subroutines need to be declared before use, with the number of parameters to be passed.



' Define Subroutines
Plot SUB 3 ' X, Y, Color(0-3)
Text SUB 3 ' X, Y, "String" (foreground is color 3, background is color 0)



I thought I would look at strings. Strings are not native to the propeller, at least not in the simple BASIC way of



A$="Hello"
PRINT LEFT$(a$,3)



But I've coded up strings in assembly so this is a similar task.

First, define a string array and fill with zeros (0 is the end marker)



string1 HUB BYTE(32) = 0



Then, fill it with some bytes. I'm still doing this one byte at a time, but there probably is a simpler way to do this aka string1 = "ABC", but anyway:



WRBYTE string1(0),"H"
WRBYTE string1(1),"e"
WRBYTE string1(2),"l"
WRBYTE string1(3),"l"
WRBYTE string1(4),"o"



And then define a little print routine



Printf SUB 2 ' X,Y and prints String1



and call it



printf 0,0 ' prints string1 at position X,Y



and this is the print routine




SUB printf ' X, Y prints STRING1
textX VAR LONG
textY VAR LONG
txtPtr VAR LONG
txtX VAR LONG
txtY VAR LONG
pixels VAR LONG
txtTemp VAR LONG
counter VAR LONG
textX = __param1
textY = __param2
counter = 0
DO
RDBYTE txtPtr, txtTemp
INC txtPtr
RDBYTE string1(counter),txtTemp
IF txtTemp = 0 THEN EXIT
INC counter
txtTemp = txtTemp - " "
txtTemp = txtTemp * 8
GETADDR font, pixels
txtTemp = txtTemp + pixels
FOR txtY = 0 TO 7
RDBYTE txtTemp, pixels
INC txtTemp
FOR txtX = 0 TO 7
IF pixels > 127 THEN
Plot textX, textY, 3
ELSE
Plot textX, textY, 0
ENDIF
pixels = pixels AND 127
pixels = pixels << 1
INC textX
NEXT
DEC textX, 8
INC textY
NEXT
DEC textY, 8
INC textX, 8
LOOP
ENDSUB





This is crude string handling at the moment. Things I'm pondering;

Put an entire string into an array with one line. Maybe pass a string pointer to a dedicated SUB to do this?
Point to arrays by name. eg pass string3 to printf
Move bytes from one string array to another by pointing to the string array start location, the @ symbol in spin?

I think with those fundamentals I can copy over LEFT, MID, RIGHT, ASC, CHR, HEX, STR from existing z80 routines. Turn these into SUBs where you pass the name of a string, and the name of the destination string.

All good fun!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Post Edited (Dr_Acula) : 2/3/2010 12:54:17 PM GMT

TonyWaite
02-03-2010, 08:07 PM
Bean,
Thanks for VGA Demo#4.
Just for clarification, are we supposed to be seeing psychadelic camels' feet at the beginning?
The reason for asking: you may remember that the very strange audio demo that I presumed was
a matter of unusual musical taste was in fact a bug ...
Regards,
T o n y

Bean
02-03-2010, 08:58 PM
Tony,
· Are you using PropBASIC version 00.00.78 that I just posted ?
· There was a bug in the SGN function (it was returning ABS) that is used in the line drawing routines.
·
· Those should be moire patterns.

Bean

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

TonyWaite
02-03-2010, 11:33 PM
Hi Bean,
Yes I'm using PropBASIC#78.
Mystery solved: one man's camels' feet is another man's Moiré fringes!
This side of the water, camels' feet are tasty pastries in the shape of a camel's foot.
It has however been pointed out that it means something else entirely in the USA.
T o n y

JonnyMac
02-04-2010, 01:09 AM
Indeed, Tony, it does -- something of a "wardrobe malfunction."

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

mwalimu
02-07-2010, 05:21 AM
I'm having a weird problem with running a program in a separate cog using v78. Since I'm new to PropBasic I tried to toggle two leds. So here is the code:

led1 pin 16 low
led2 pin 17 high

START:
do
toggle led1
toggle led2
pause 500
loop
end


I ran this and SUCCESS! The leds toggle back and forth. I am a programming demigod.

Next I want to see if I can run this in a separate cog. so...

led1 pin 16 low
led2 pin 17 high

blink TASK

START:
cogstart blink
do
loop
END

TASK blink
do
toggle led1
toggle led2
pause 500
loop
ENDTASK

Result led1 stays on and led2 blinks at about 1/2 second. If I reverse the initial states, led2 stays on and led1 blinks. My interpretation is that the cog runs one iteration of the loop and then crashes or resets. When I've run into these situations in SPIN usually increasing stack space for the cog fixes it, but that is not an option here. I've tried changing "cogstart" to "coginit" with a specified cog#, but with the same results.

I can't think of a more basic program than this, so I'm stumped.

mwalimu
02-07-2010, 05:49 AM
Never mind. I just finished reading the rest of the thread and I found:

"IN and OUT again

To answer my own question I believe reason is that as outa registers are ORed together,when LED =0 ,ToggleLED task will work
but with LED =1,ToggleLED will only generate a 1 as outa in Program start is permanently set to 1( 1 OR x = 1).

Regards
Gerry"

Don't I feel like a schmuck http://forums.parallax.com/images/smilies/mad.gif .... (in my defense, It IS a long thread...)

Rsadeika
02-07-2010, 05:55 AM
I just tried your code, on my demo board, and I get the same results. I put in a 'pause 500' between led1 and led2, in the task code, just to see what happens, I have led1 blink with a short pause, but led2 stays on all the time.

Ray

JonnyMac
02-07-2010, 07:29 AM
Once you take the time to learn the Propeller, Ray, the problem will be obvious: all cogs outputs are OR'd together. In the PIN definitions LED2 is defined as HIGH on reset -- what's happening is that the main cog is making LED turn on and masking the activity of the TASK. Set both pins to LOW or OUTPUT and the problem will go away.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

motionman
02-08-2010, 12:01 AM
Jon has asked us to post examples of what we are doing.
Here is a two axis step and direction controller using the standard technique of adding a velocity value at fixed intervals to an accumulator .
At halfway point the step output goes high and low again when the accumulator goes low.
A spare cog acts as a pulse generator .This could serve as a master speed control for a multi-axis machine.
Speeds have been tested accurate to 20 kHz

This code took less than a day to port across from code written in Proton for a (single axis ) Microchip controller.

BradC
02-08-2010, 07:38 AM
Bean has kindly allowed me to create native Mac / Linux binaries of his compiler. I have posted them here
www.fnarfbargle.com/PropBasic (http://www.fnarfbargle.com/PropBasic)

The major changes are :
- The INVALID.TXT file is built in (no need to have it in the same directory as the binary - or anywhere at all for that matter)
- The compiler accepts relative paths in addition to absolute paths for the source file

I have appended a "-bst" to the compiler name so there is no way the binaries can be confused with the originals. Please don't bug Bean about any non-code generator related issues, but feedback directly to me would be appreciated if anyone finds this stuff useful.

Unlike most *nix programs, the file to compile *MUST* be first on the command line. Subsequent command line switches are specified with / characters after the file name. Filenames with spaces must be properly escaped or quoted. (Quoted on Windows).

As I don't do basic, my test harness is limited to the programs included in the compiler demo directory. I have ensured they all compile properly, but I've not tried any programs that include anything other than binary files, so that behaviour is currently unknown.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Life may be "too short", but it's the longest thing we ever do.

BradC
02-08-2010, 10:49 AM
Well, that was a good way to get things kicked off!

I very cleverly uploaded completely broken binaries this morning. They have been fixed / re-tested & re-uploaded.

Sorry about that.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Life may be "too short", but it's the longest thing we ever do.

Mike Green
02-08-2010, 11:17 AM
@BradC - Thanks a lot. I unzipped it, removed the "-bst.osx" from the result (for less typing), and moved it to my /Applications folder. It works running it from the Terminal program. It's a beginning.

BradC
02-08-2010, 11:53 AM
Mike Green said...
@BradC - Thanks a lot. I unzipped it, removed the "-bst.osx" from the result (for less typing), and moved it to my /Applications folder. It works running it from the Terminal program. It's a beginning.


Cheers for the feedback Mike, we have to crawl before we can walk/run/fly/teleport :)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Life may be "too short", but it's the longest thing we ever do.

Brian Riley
02-09-2010, 12:28 AM
Mike Green said...
@BradC - Thanks a lot. I unzipped it, removed the "-bst.osx" from the result (for less typing), and moved it to my /Applications folder. It works running it from the Terminal program. It's a beginning.


.... I went Mike Green one farther, renamed it 'pb' ... a LOT less typing! http://forums.parallax.com/images/smilies/smile.gif

My Mac is a 2.66 GHZ Core 2 Duo with 4 GB RAM (Mar '09 vintage) running OSX 10.6.2 all up to date .... The PropBasic 0.79 binary is BLAZING fast! Way to go Bean and Brad

I made an editor path in BST to my 'pb' directory then loaded and compiled the resultant spin files just fine. It's not that big of a deal, flipping over to a terminal window for a few seconds and coming back to BST. I could live with that, if that's all it was, BUTTTTTTTTT, integrated into the BST GUI-IDE will be awesome!

cheers ... BBR

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cheers ... brian riley, n1bq, underhill center, vermont
The Shoppe at Wulfden
www.wulfden.org/TheShoppe/ (http://www.wulfden.org/TheShoppe/)

AJM
02-09-2010, 12:34 AM
BradC said...
Bean has kindly allowed me to create native Mac / Linux binaries of his compiler. I have posted them here
www.fnarfbargle.com/PropBasic


I will have to try this under Debian later on!

Thanks Bean / Brad!

Brian Riley
02-09-2010, 04:52 AM
Bean,

I dragged by old NEC Multi-Sync 15" flat panel out and hooked it to my Demo board and compiled the 4 VGA demos as they came in the 79-zipfile. VGA and VGA2 the LEDs on the demo board lit up, but it simply produced a black screen and no sync (according to the monitor) VGA3 and VGA4 seemed to run just fine. Any thoughts as to why?

cheers ... BBR

p.s. this is running Brad's binary on my iMac.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cheers ... brian riley, n1bq, underhill center, vermont
The Shoppe at Wulfden
www.wulfden.org/TheShoppe/ (http://www.wulfden.org/TheShoppe/)

Bean
02-09-2010, 10:23 PM
Brian,
I'm not sure why VGA_Demo and VGA_Demo2 don't work ?? They use the same VGA timing as VGA3 and VGA4.
Do you have a different monitor you can try ? I do notice on mine that it comes up as 640x480 62Hz (62Hz is a bit odd, but it works).

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
·

BradC
02-15-2010, 09:03 AM
I've uploaded some updated binaries here : www.fnarfbargle.com/PropBasic (http://www.fnarfbargle.com/PropBasic)

As I tend to make incremental updates in between Bean's official releases, I've appended my internal svn revision number to the binaries to make it easy to keep track of the latest code.
Those that already have -38 binaries need not update.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You only ever need two tools in life. If it moves and it shouldn't use Duct Tape. If it does not move and it should use WD40.

Bean
02-15-2010, 09:34 AM
Brian,

I have found 1 TV that won't work with the VGA code. I'll get it changed to make it more compatible and repost the demo programs.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
·

Tony B.
02-16-2010, 12:32 AM
I have just started working with PropBasic past couple of days and noticed that when I save a file using "Save As” it doesn't add the file extension ".pbas" to the files. I also noticed that if I start a new file it is named "NONAME.pbas1" and hit save (so I don’t lose the code if there is a problem during testing) it saves the file with the extension "pbas1" This makes the file in either case appear missing in the open dialog when I want to work on it later.

Do I need to manually add the extension every time?

Tony

Bean
02-16-2010, 02:22 AM
Tony,
The current IDE was just enough to get it working.
There is a MUCH better IDE in the works.
Please put-up with it for a little while longer until the new IDE is finished.

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.

PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
·

Mike Huselton
02-16-2010, 05:21 AM
Bean,

I knew you had bigger plans for this thing. Keep it up!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH

Brian Riley
02-16-2010, 05:52 AM
Bean said...
Brian,

I have found 1 TV that won't work with the VGA code. I'll get it changed to make it more compatible and repost the demo programs.

Bean.


VGA and VGA2 now work, but TV_Text produces only a black screen and video_game produces a black screen with small dot that responds to Left/Right Shift, but Fire(Spacebar) does nothing ... this is all under the latest binaries/new GUI IDE

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cheers ... brian riley, n1bq, underhill center, vermont
The Shoppe at Wulfden
www.wulfden.org/TheShoppe/ (http://www.wulfden.org/TheShoppe/)

Tony B.
02-16-2010, 06:00 AM
Bean,

More than HAPPY to wait.

Thanks to you, Terry (Syntax Manual) and all who have made it great so far!

Looking forward to writing and testing code this week to really start getting comfortable with PropBASIC.

Tony