P2 Quick Bytes: Seeking Input on Concept
Ken Gracey
Posts: 7,392
Hello,
At Parallax, I receive many messages from our customers about getting started with the P2. Reading praise, congratulations on the completion of the P2 is really rewarding, but some messages show where we need to improve and might yield the greatest return on our efforts. At this moment in time (January 2021) getting started is quite a challenge for those who are jumping in. Code and examples are available on forums, inside 200 hours of P2 Live Forum YouTube videos, on product pages, etc. Engineers and experienced programmers seem to have no problem, but many of them have been using the P2 before it was born (since the FPGA images and P2-Hot).
For the newcomer, it's a challenge.
We're considering consolidating examples into single pages called Quick Bytes. A Quick Byte would contain an explanation, the code (a zip, if an archive), pictures, video links, etc. A Quick Byte would have one topic (show a single driver, a smart pin features, or a programming tool tip like using PST or ANSI terminals). Quick Bytes could be sequential and build upon themselves. Looking forward the idea could be scaled down or up (a Quick Bit may show how to blink an LED, whereas a Quick Word may show a full project). Imagine hundreds of Quick Bytes.
Two examples I quickly assembled from content others shared:
https://www.parallax.com/category/quick-byte/
Content could come from the community or Parallax. You could request topics, too.
Could our community envision this system growing into a useful, indexed set of resources that aid those looking for examples?
Would like your true thoughts on the subject.
Ken Gracey
At Parallax, I receive many messages from our customers about getting started with the P2. Reading praise, congratulations on the completion of the P2 is really rewarding, but some messages show where we need to improve and might yield the greatest return on our efforts. At this moment in time (January 2021) getting started is quite a challenge for those who are jumping in. Code and examples are available on forums, inside 200 hours of P2 Live Forum YouTube videos, on product pages, etc. Engineers and experienced programmers seem to have no problem, but many of them have been using the P2 before it was born (since the FPGA images and P2-Hot).
For the newcomer, it's a challenge.
We're considering consolidating examples into single pages called Quick Bytes. A Quick Byte would contain an explanation, the code (a zip, if an archive), pictures, video links, etc. A Quick Byte would have one topic (show a single driver, a smart pin features, or a programming tool tip like using PST or ANSI terminals). Quick Bytes could be sequential and build upon themselves. Looking forward the idea could be scaled down or up (a Quick Bit may show how to blink an LED, whereas a Quick Word may show a full project). Imagine hundreds of Quick Bytes.
Two examples I quickly assembled from content others shared:
https://www.parallax.com/category/quick-byte/
Content could come from the community or Parallax. You could request topics, too.
Could our community envision this system growing into a useful, indexed set of resources that aid those looking for examples?
Would like your true thoughts on the subject.
Ken Gracey
Comments
When you tell me to, Mr. Eltham, I know you'll stick with me through the process.
Could feature Python, Spin, BASIC, or whatever language people want in these examples.
Ken Gracey
I think those are excellent.
<soapbox>
I am not able to try them out yet as I haven't shelled out the $150 for the P2Edge kit. The Edge & JonnyMac board seem like a replacement for the Propeller Professional Development Board, and it still doesn't provide a microSD, or video out or HyperRam or other large/fast storage that isn't going to wear out or keyboard or mouse, which would cost another $150.
I've got a mental block when it comes to spending that much money one when I can get a 16 core server with 128GB of memory and 300GB hard drive for that in the used market. I know it's not an apples to apples comparison, but for me it is reality. Couple that with the fact that you guys still don't take Bitcoin Cash, and it is a hindrance for me.
I think the P2 really needs a DemoBoard like the P1 had. That and a real paper manual with QuickBytes in it bundled together like the old days would be excellent!
Having the hardware to show off it's features and provide a base system is the Ideah. Keyboard, Mouse, Audio In/Out, microSD, Video out (Yeah, I still like VGA too, but HDMI is acceptable because that is where the market is going), some LEDs, HyperRAM, and all of portA free to connect to things on a breadboard. I'm sure it is going to be done, but it would be better coming from Parallax, and bundled with the P2 Manual, and all of the hardware was just there to show them off. You build a base system like that as a standard, and you will see lots of Tutorials and Demos that will knock your sox off. The P2 DemoBoard could also host it's own development/debugging system similar to PNut but without the latency and multi platform hassles.
</soapbox>
I hope a lot more people contribute more QuickBytes to go into a quality manual like the P1 has. Keep up the good work.
I like this input. Agreed on the JonnyMac and how it would be nice to have microSD. I think the other needs we can take care of with accessory boards.
I think the P2 architecture is so unique, accessible and the developer access is so good that it's hard to compare it to a 16 core server with 128GB of memory. The P2 was developed in the open and it's a unique tool for inventors, totally American, etc. It's designed to be a precision-timed multicore microcontroller, too, not for running server software. But I understand your point: it's about what you get, for what kind of cost - some kind of performance/$ ratio. Yet those processors are manufactured in mass volume by big companies; we're also a mom-and-pop that who completed a significant technical accomplishment
As for Bitcoin Cash, you're the first person to ask. I haven't had a request before for Bitcoin. It's entirely possible to add a Bitcoin plug-in to our web site. It's a matter of cost-benefit. It would take us about several thousand $$ to apply, configure and prepare to handle Bitcoin. Then we still need to turn it into USD to integrate with our accounting. While I love the idea of supporting non-Federal currency, we've got other fish to fry first. For example, this forum's search tool is broken (and image insertion is whacky, yada yada).
The Propeller 2 Manual is coming. It's going to take a while, but we'll have it in time.
Thanks for the feedback here, hinv!
Ken Gracey
P.S. Sorry for hijacking your thread. I just would love a P2Demo or P2Pi and it gain a cult following like the Raspberry Pi. Did you know that the Amiga and even C64 fanbases are still going strong? Feel free to move unrelated replies to https://forums.parallax.com/discussion/172175/propeller-pi-or-p2-demo
The recent article in Nuts & Volts was great, it reached a lot of people. But having something at a trade show, hamfest, or Maker Faire would introduce thousands more to the P2 product line.
What ever happened to the big bot that was welded up a couple of years ago. If that was packaged up and shipped in a (standard) FedEx container, to any trade show, people like me would be more than happy to go to a trade show, and maybe do a "professional" forum / clinic to demo the P2. I would need a Power Point presentation, a short video, product flyer handouts, a few samples, etc
Getting back to the Quick Bytes. There is sooo much misinformation out there on media sites like You Tube. Some guy will do a video on his project, it all sounds good, but at the end not any type of engineer, technician or anything - "I'm on You Tube and it hasn't smoked yet" type of thing. I'm glad this fellow took the time to build his project, but the circuit has been hacked a dozen times over - and the sketch is spaghetti code...
Whatever you decide it has to be - Fun, Easy to understand with no gaps in assumptions (ADC, DAC, i2c definitions in meaningful detail) and Professional.
But please don't neglect the task of writing something like the P1 manuals for the P2. As many others already said I also like them very much. Tutorials are a good starting point. But as soon as you want to start your own project you have to look up the details, what exactly does this instruction or pin mode, can it be used for my idea...? Then you definitely need a good manual with an index/TOC.
And I have to repeat, we definitely need a data sheet. This might be not very important for the education or hobby market. But no serious engineer would dare to tell his boss that he wants to use an IC for a new product when there is no data sheet. For a student project you can try things out and if it works it works. But if you have to develop a product for the industrial environment you have to rely on guaranteed limits.
I might belong to a minority. Probably the P2 is not aimed for industrial products. But I think it is suited very well for motion control and industrial instrumentation. And I'm different because I'm my own boss and I know I can trust in that Chip has done his job well. But I think many other companies still depend on classical papers.
Absolutely agree. I’ve always been that boss, and I would never allow one of our engineers to design a product without looking at the docs (yes I’m hands on) and checking out the company. It doesn’t need to be a big company but it does need a pedigree - Parallax has the P1 which has been in continuous production for over 14 years and is definitely not on the end-of-life horizon. It has only the original silicon (no revisions or bug fixes). I doubt there are many micros that can claim this!!! It also has the previous Basic Stamp although I don’t know much about it. So, provided the docs and tools stack up, and it would do the job, I would have no problem in signing off on using the P2. I would much rather have a micro used that’s likely to be around for many years to come than one of a family that changes daily. The current lifetime of many micros seems to be shrinking into a few years, if that.
Agreed. It was a manual included that got me started with Parallax (What's a Microcontroller) and it was the Manual that came with Propeller DemoBoard that got me started on the Propeller. You guys really did an excellent job on that, and even though I have a 1.2 pdf version online, I never look at it, it's always the paper manual, for better or worse (unless I need to do a word search). I would love to see P2's in the classroom, and even these days, a good P2 Manual would help that, I think.
As for the 2 existing QuickBytes you have posted, I don't think it's anything that the P1 can do easily. What is needed is examples that only the P2 can do, but that is dependent on objects being written. Simple ADC shows how few external parts are needed for the P2, which is good. I would like to see a Simple MP3/Ogg Player using objects for SDcard, LCD display, headphone jack, and buttons. Maybe until the MP3/Ogg decoder object is written, you could use a MOD/SID/WAV/AIFF player. It's not anything that can't be done on a P1, but if you put it together now, once the MP3/Ogg decoder object is written, you could just plug it in.
Another idea, as an add-on to the player, you could provide a simple FM radio transmitter. I'm guessing that the P2 could transmit FM radio with just the right length of wire and a single pin. @"Phil Pilgrim (PhiPi)" could probably whip that object up in a weekend.
The Christmas Lights thing that JonnyMac put together would make a good write-up for a QuickWord.
Another suggestion: Don't just have them on the website. Having all of the information available as a PDF is good. That doesn't have to be difficult either, as anyone can print to PDF, it could just be a print button that doesn't include all of the rest of the website baggage. You're almost there with that middle pane. You just need to move the author and Title, author, date into the middle pane, and a print button that just prints the middle pane.
1. For people new to microcontrollers, basic stuff like needing a pullup/pulldown on a switch. Examples are What's a Microcontroller or Picaxe's Section 3, Microcontroller Interfacing Circuits
2. P2 specific examples for new and experienced users. Smart pins, interrupts, memory access, streamer, etc.
I don't need a datasheet, but it is essential for commercial use and I would like a one stop document for things like pin current, frequency etc. Perhaps it shows my age (73), but I prefer a written manual for learning with a PDF version for lookup while coding.
John Abshier
Here's a scan of the VAX Architecture Handbook on bitsavers for reference to see what I mean: http://bitsavers.org/pdf/dec/vax/handbook/VAX_Architecture_Handbook_Vol1_1977.pdf
The above copy is older than mine, but all revisions are quite good. Page 90 of the PDF is where the instruction listing begins.
As a P2 user for about 3 weeks, here's what would have helped me get started (and still would be useful).
I'd like to see one place for keeping just up-to-date documents. Don't make a new user have to jump all over the website to collect necessary information and don't store years of old development documents in that place.
Put most reference material in PDF form, not web pages or Word docs, with prominent version numbers so it's easy tell when a copy is out-of-date.
Make a "Getting-started" PDF guide containing everything a new user needs to know from opening the box up to blinking an LED. Describe Prop tool, pnut, spin2, C, forth, and all the variations of programming for Windows, Mac, Linux. This is not the place for lots of details; this is just to help a new user get started. But explain things a new user does need to know, like that proptool won't run on an old WinXP box that may have run P1 proptool, or that debug doesn't run in P2 proptool. This is a getting-started guide, not a programming guide; it shouldn't go much beyond blinking an LED.
Make a spin2 programming PDF guide. This doesn't need to go into every little engineering detail, but a new user needs a place to look up all available spin2 commands, to see program structure, how to launch cogs, how to do simple pin IO, etc.
Make separate detail PDF guides for the deeper topics like P2 asm, smart pins, video, ADC, Goertzel, high speed data transfer around the P2, etc. These topics can be overwhelming for a new user, but when you come to want to use them then you do need a reference for every little detail without having to search the forums.
"How-to" guides used to be popular in the Linux world, like this:
https://tldp.org/HOWTO/pdf
A similar collection of P2 "How-tos" would be useful. There are so many great ideas that get lost in old forum pages that the best of them really should be saved in reference PDF form.
And yes, sample programs like Quick Bytes are extremely helpful. Like that expression "a picture is worth a thousand words", there is so much information in just one simple working program. They're a great way to get started on any particular aspect of programming.
David
I like the quick bytes as they are essential for newcomers. And I agree with David about to have docs linked as PDF on the website. The links to the Google Docs should be put somewhere in a forum thread to have them in place for whom has to working on it.
BTW, the PropTool and PNut are still working fine on WinXP. Only the installer of PropTool doesn't run on it. I haven't tried if it starts on Windows 7. That's very lovely that one can use the tools with the old Windows systems. I'm using it in an old VM on my Mac without any problem.
I personally don't need printed docs as a good documentation in PDF is sufficient. Nowadays printed docs are rare. Hence, I would see they as optional for products.
@"Ken Gracey" On the I2C Quick Bytes example the link to the Propeller Tool is wrong. It should link to propeller-2/software/ instead of propeller-2/get-started/spin2/.
That's about where this is headed, so I think you'll be happy. Core drivers for communication are coming first.
Ken Gracey
This is a community effort.
The contributions above have been really valuable in shaping our Quick Byte direction. The P2 Manual and datasheet are in our future, too.
Parallax is really thankful for what we're receiving from the community. The list of people we can thank spans several pages already.
Ken Gracey
The datasheet and Manual pdf has to be priority One!!! As much reliable information in a structured way, easy to find in one document.
"Could feature Python, Spin, BASIC, or whatever language people want in these examples."
These use different ides!
- Did you calculate the number of hours needed here? You forgot Pasm, which is needed, because Spin is so slow and you forgot C which is the typical language for microcontrollers because it is so powerful, that you don't need Assembler.
Sorry to repeat once again: Python does not make any sense for P2 as long as it does not support 8 cores. (And then it will still be the ultra low speed language.)
Well, for a well defined language like C, there are very good tutorials avaliable. For the restricted, special Parallax Spin you have to write them from scratch. And because Spin needs Assembler, you have to write the Assembler docu and Tutorials too. And your customers are forced to learn both of these. For Esp32 assembler is not even offered, as nobody asks for it as with C(++) it is not necessary.
So the advice to get going is:
0. Have a really close look, what your competitors do! Esp32, Arduino, Teensy. Do not invent everything newly!
1. Write the datasheet.
2. Focus!!! on C! (Arduino C++ would be better)
3. Put the examples (instead of inventing Bytes) into the tool/ide, where they can be accessed directly.
4. Use function names and their parameters that are established in Arduino for the libraries.
5. Make one! getting started tutorial, which ends with a blinking led.
6. Offer a complete (with USB serial, USB power, and SD card holder, reset button, 1 Led), breadboard friendly, board for a competitive price.
Regards Christof
Well Structured Online Documentation:
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/adc.html#application-examples
Something like this "Quick Bytes", done very well:
https://bitluni.net/esp32-vga
https://randomnerdtutorials.com/esp32-adc-analog-read-arduino-ide/
Perhaps Parallax may want to get into contact with one of them?
I don't think, that this is possible, because the information has to be very reliable, very complete and very well structured to make it easy and fast to find it. At least the beginning has to be made by Parallax.
It is good, that Parallax is looking for a concept of documentation now! I tried to watch the youtube about ADC. But you have to invest a lot time to get to the points, that are really important information for a user. (What is the benefit to show assembler code and do not explain it?)
Paul
I don't know why you are saying "Spin is so slow". Did you ever check the performance of Spin on the P2? Or did you compare it with other microcontrollers running the same program using C.
And why should you say "Python does not make any sense for P2 as long as it does not support 8 cores."? Maybe currently is does support only one cog. But that can change in the future as the development is still in progress. Other microcontrollers have only ONE processor core and they work well with Python. Why not the P2 too?
And again why do you saying "And then it will still be the ultra low speed language." Maybe you are one of the people saying Java is slow.
It makes me angry if somebody is spreading wrong information about technologies and products.
The video from the first tutorial you mentioned is quite nice explaining the VGA and the limits of the implementation on the ESP32. But this tutorial is not really better than the Quick Byte for Simple Analog Input from Parallax as you suppose.
The second tutorial you mentioned is quite more detailed which is fine but too much for a quick tutorial as Parallax want to do.
The video about ADC is showing you how to use it with a simple code example. It is not to show you how to code in assembler the P2. But if you has used the P1 before there is not much difference in the mostly common instructions. The code for using the ADC is still new for all.
You've written much content but at the end I feel there is not much usable for Parallax. Sorry, that I have to say this.
Here he shows some work arounds.
I did some own measurements ,not with P2, and found similar results.
I meant, that if you have to use a language made for only one core, than it does make most sense to use a high volume production controller which is optimised for speed of that single core. Does it make sense to pay for 8 cores and have most of them in idle mode? P2 has this specific strength of these 8 cores, why use a language, that wastes the huge effort to create this device? This means to split things: For the educational market of Python take a different controller together with its documentation.
I do have to admit, that I have not yet seen a direct speed comparison between Pasm, C (cog and hub Ram) , Spin and Python on P2, what are actual benchmark numbers?
Of course, if I have written anything wrong here, we should correct that!
It is a pity, that my posts have not seen helpful for Parallax. A main statement was meant to be that if Parallax cannot support 4 languages (pasm, Spin2, C, Python (and spin1 )) with 3 IDEs for P2 so they need to focus. If focus is needed, then the most useful should be preferred. Well, there is at least the reason of speed, that for microcontrollers C/C++ is used widely. And you do not have to document the language itself.
I have been really struggling to get my head around the smartpins. I use Erics FlexBasic and can bitbang most things I need, but no matter what docs I look at understanding smartpins is beyond my whits.
Then I saw the Quick Byte Simple Analog Input!
MARVELOUS!!
Ok its written in spin but seems to easily convert to FlexBasic-
I connected a 10K potentiometer wiper to pin 16 with the ends of the pot' connected to 3v3 and 0v
[/code]
This works a treat!!
So looking at the docs to explain-
So then with this knowledge I thought it would be good to output a dc voltage on another pin just to track the input voltage.
Then I hit a brick wall.
I could find various Dac modes in the spin docs but what else for Xval and Yval etc?
So sample quickbytes for smartpin functions like Dac, pwm, sawtooth, quad encoder, serial spi, serial async, etc etcwould be great to get us going
Dave
Then I have found more details and examples in the Smart Pin Supplementary Documentation by Jon Titus which you can find here.
I think it will be also helpfull for you.
As Python is most popular, increasing over the last years, one can start using it with the P2. This makes sense if one is already familiar with this programming language and has experience with it on other microcontrollers, or if one will start learning it. Later then one can learn Spin and/or assembly for the P2, not only if more performance is needed in the application.
The 10 Most Popular Programming Languages to Learn in 2020 by Northeastern University—Seattle
8 of the most popular programming languages by TechRepublic.com
I honor your honesty. I cannot provide detailed comparision for the P2. I did only check the Fibonacci test provided with flexprop and was impressed how fast it is running with Spin using PropTool. I didn't not compare it with P1 yet but it must be much slower.
For fibo(40) the program counted 8704 clocks on the P2 with the iterative version. That are 108.8 us running at 80 MHz as the P1. The recursive version is much slower.
The same program running in assembly (flexprop compiles Spin to assembly) shows 430 clocks. It uses only 5375 ns at 80 MHz.
So, there is a ratio of approximately 1:20 for PASM compared to Spin.
There is currently only one IDE supported by Parallax and that is the Propeller Tool. PNut is the playground from Chip for introducing and testing new features. Other tools are supported by the community.
I don't know if Parallax will support all programming languages available for the P2. But I agree they should focus on C as this programming language is most popular on other microcontrollers and it was missing a long time for the P1. But for the P2 it available right from the start.
I think, Spin will be recommended as programming language to start with the P2 if one is not familiar with C. This will allow to use the P2 without the limitation you was mention for Python. And one can start learning assembly using short code snippets per in-line in Spin methods. This is still not possible with the P1 and a great feature using the P2.
As others suggested the smartpins topic is one peculiar feature of this platform and one that needs many Quick Bytes.
Other topics of interest to me:
1. When and how to use Inline Pasm
2. Methods pointers
3. How to use the DAT area to create arrays of data
4. How to use the Serial Terminal for debugging (assuming use of Prop Tool)
... I should have a million more things I would like to have a Quick Byte as a reference but I cant think of any more right now. But in general for every feature of Spin2 I would love it, like Arduino Reference always have explanation and code to follow along.
Love this, thanks.