Shop OBEX P1 Docs P2 Docs Learn Events
P2 Quick Bytes: Seeking Input on Concept — Parallax Forums

P2 Quick Bytes: Seeking Input on Concept

Ken GraceyKen Gracey Posts: 7,386
edited 2021-01-13 05:51 in Propeller 2
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/

QB.jpg

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

QB.jpg 32.9K
«1

Comments

  • These are great, make another 100 or so! :)
  • Roy Eltham wrote: »
    These are great, make another 100 or so! :)

    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

  • hinvhinv Posts: 1,252
    edited 2021-01-13 01:05
    Hi Ken,
    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.
  • hinv wrote: »
    Hi Ken,
    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 or...

    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), HyperRAM, and all of portA free to connect to things on a breadboard.
    </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

  • I think Propeller 2 Manual plus Quick bytes are great !! I'm also agree with @hinv, a DemoBoard like the P1 had, would be also great, with all that, no excusses for me to begin with P2 now.
  • hinvhinv Posts: 1,252
    I understand where you are coming from as well. One advantage of the P2 archetecture is that you know you're not getting spied on, as with those 16 Intel cores, there are low level cores also that can snoop memory and control ethernet ports. I still think you could sell a LOT of DemoBoards if you got them under $100 and the development environment, to program the local P2 or other P2 boards, just worked out of the box. The education market cold be based around it, and with a Bluetooth connection one could connect to it through a phone or tablet...but just the interface goes on the the phone/tablet, and a way for getting downloaded code from the phone to the P2, which should be a LOT simpler than current WiFi over esp8266. The compilers would live on the P2Demo, and bootable microSD card could reloaded from image like the Raspberry Pi does.
  • hinvhinv Posts: 1,252
    I really think the Propeller 2 Live Forums. I don't get to watch them live, but I go though every one, multiple times because I save them off with youtube-dl.org. Now that you guys have the resolutions figured out, the saved videos are an excellent resource that we didn't have at the launch of the P1.

    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
  • You need a bigger better audience. There is a loyal audience here, but the market has not heard from Parallax...yet.

    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.
  • Tutorials like the Quick Bytes are definitely a good idea to attract newcomers. And real life examples are definitely much easier to learn from than theoretical documentation that only lists instructions and hardware registers.

    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.
  • Cluso99Cluso99 Posts: 18,066
    ManAtWork wrote: »
    Tutorials like the Quick Bytes are definitely a good idea to attract newcomers. And real life examples are definitely much easier to learn from than theoretical documentation that only lists instructions and hardware registers.

    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.
  • hinvhinv Posts: 1,252
    ManAtWork wrote: »
    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.

    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.
  • I agree with @"John Abshier" on the written manual, I'm inclined toward paper pretty much always. I'd love to see something like DEC's old architecture handbooks, which gave very detailed explanations of the instructions and their behavior. I've not used them much, as I wasn't around when DEC was in business, but the time I spent writing a VAX emulator made me greatly appreciate their manual style and explanations.
    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.
  • Ken, Quick Bytes looks great, but I'd mostly like to respond to your first paragraph.

    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 idea but Definitely need a paper copy manual. please!
  • David B wrote: »
    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.
    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/.
  • movin wrote: »
    why not just get the basic drivers that ur aware u need from prop1 working on prop2 did u think of that?

    That's about where this is headed, so I think you'll be happy. Core drivers for communication are coming first.

    Ken Gracey
  • JonnyMacJonnyMac Posts: 8,912
    edited 2021-01-14 06:20
    why not just get the basic drivers that ur aware u need from prop1 working on prop2 did u think of that?
    I have written and posted drivers for full-duplex serial, SPI, I2C, and 1-Wire. A lot of specifics can be built from those basics, and I've been doing it.
  • Moderator note- some posts where removed from this discussion to keep things on topic. This thread is all about Quick Bytes please !
  • Ken GraceyKen Gracey Posts: 7,386
    edited 2021-01-14 15:58
    We also pay for Quick Bytes. We have requirements and can sometimes supplement the contributor's skillset to produce a complete submittal. This means taking pictures, running their code as a test, making a drawing, editing an explanation, etc. An effort like this represents a combination of everybody's best skills (like me putting stuff in a box as described above) because nobody can do everything on their own.

    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

  • Some comments:

    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
  • About concepts:

    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?



  • "This is a community effort."
    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?)
  • @"Christof Eb." It appears you are well versed in the topic! I look forward to your contributions

    Paul
  • @Christof Eb. At first, please use the quote function of the forum as this shows easy whom your are cite. It's quite easy to use.
    "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.)
    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.
    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?
    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.
    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?)
    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.
  • Christof Eb.Christof Eb. Posts: 1,087
    edited 2021-01-16 15:07
    Hm, the info about speed of Micropython comes from P.D.George, who should know, I think. 1:100 for C:Micropython.

    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.



  • tritoniumtritonium Posts: 539
    edited 2021-01-16 16:55
    @Ken Gracey

    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!!


    _pin     = 0                          'do conversion on this pin
     
    PUB go() | i
      pinstart(_pin, p_adc_1x | p_adc, 13, 0) 'init ADC pin
     
      repeat                                 'print sample set every 100ms
        i := rdpin(_pin)
        debug(sdec_(i), dly(100))
    

    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
    const alogpin = 16
    dim i as integer
    pinstart(alogpin, (p_adc_1x) or (p_adc) ,13 , 0) 'init ADC pin
     
    do                                 'print sample set every 100ms
    	i = rdpin(alogpin)
    	print (i-2955)*3.095/10000	'scaled for 0-3.3v
    	pausems 250
    print chr$(27);"[1A";		'does work- move cursor up one
    loop
    
    end
    
    [/code]

    This works a treat!!
    So looking at the docs to explain-
    /'
       SMARTPIN METHODS FROM SPIN DOCS
    PINSTART(PinField, Mode, Xval, Yval)
    	Start PinField smart pin(s): DIR=0, then WRPIN=Mode, WXPIN=Xval, WYPIN=Yval, then DIR=1
    
    PINCLEAR(PinField)
    	Clear PinField smart pin(s): DIR=0, then WRPIN=0
    WRPIN(PinField, Data)
    	Write mode register(s) of PinField smart pin(s) with Data
    WXPIN(PinField, Data)
    	Write X register(s) of PinField smart pin(s) with Data
    WYPIN(PinField, Data)
    	Write Y register(s) of PinField smart pin(s) with Data
           logic logic                            Dir/Out
       _A  _B   Filt  Pin Control     Mode
    =%AAAA_BBBB_FFF_PPPPPPPPPPPPP_TT_MMMMM_0
    P_ADC =%0000_0000_000_0000000000000_00_11000_0	(11000  = ADC sample/filter/capture, internal clocked)
    
    
    P_ADC_1X =%0000_0000_000_1000110000000_00_00000_0
    
    
    '/
    

    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





  • @tritonium It's great that you make progress using smart pins. I was run in the same problem as you, didn't found a complete description about these.

    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.
  • Hm, the info about speed of Micropython comes from P.D.George, who should know, I think. 1:100 for C:Micropython.
    [video]
    Here he shows some work arounds.

    I did some own measurements ,not with P2, and found similar results.
    @"Christof Eb." This ratio is known for interpreted languages. But this is more as sufficient for most of usual applications running on BBC micro:bit, P2 or other microcontrollers supporting Micropython. Not every application needs realtime acqusition of i/o.
    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.
    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 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?
    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.
    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.
    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.
  • @"Ken Gracey"

    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.
Sign In or Register to comment.