Shop Learn
BlocklyProp Cogs — Parallax Forums

BlocklyProp Cogs

I understand that the P8X32A microcontroller chip has 8 cogs (cpu).
Can somebody please tell me how I can control 8 leds flashing at different rates using all 8 cogs by coding in BlocklyProp?
Thanks in advance.


  • It's really easy.

    You'll make seven new processor blocks and put an LED function in each of them. The functions will have loops inside of them to toggle the LEDs.

    Link these seven new processor blocks together - one on top of the other.

    At the bottom, make another loop in the main processor (your eighth one) to control the eighth LED. You need to be a bit careful when doing this because some of the BlocklyProp blocks also start processors. Those are listed here

    Hopefully you'll be surprised at the possibilities after getting this to work. Let me know if you need an example.

    Ken Gracey
  • I would like an example please Ken Gracey.
  • bluejay, how about this approach since I'm busy at the moment. BlocklyProp projects can be shared, so you can start a project and others can log into it. I'll walk you through it, too.

    Your first step would be to create a project and make seven new processor blocks, stacked on top of eachother. Inside each of those blocks, put a function with a unique name.

    From this point, the rest is easy.

    Ken Gracey
  • I uploaded the project as cog 1. Its for 3 cogs, which is fine . Project will not run because its incomplete. Can someone please resolve this problem? Thanks
  • Jim Alrow's article in Issue #3 of Nuts & Volts magazine ( has a great example of what you are requesting!

    His Blinkenlights example code blinks 4 LEDs at different frequencies. You would just need to add 3 more functions to enable 7 blinking LEDs, then as Ken stated, add the code to blink an 8th LED within the main program.

    I think you would end up with something like (untested, but should work):

    1405 x 1044 - 611K
  • In the bottom of this message it says" Choose file". When I click "Choose File" I can't find any of my files on my pc.
    How do I attach a file/s? Anybody could please help with answer?
  • bluejay wrote: »
    In the bottom of this message it says" Choose file". When I click "Choose File" I can't find any of my files on my pc.
    How do I attach a file/s? Anybody could please help with answer?

    @bluejay What platform are you using? FLIP, Activity Board, custom?

    I have included a file that I made with an Activity Board with LEDs on the breadboard at Pins 10 and 11 with a 220 ohm resistor in series.

    Download the file, rename and remove the .txt. You should have a .svg file to load in Blockly. You may just be able to double click on the file to open in Blockly.

  • I am using Flip. I saved your file by removing .txt. However when I try to run the project an error message "BlocklyProp Client not found" appears . BlocklyProp Client is in my computer. I am using solo.parallax software.
  • When you run the BlocklyProp client you should see the program window.

    There's a "CONNECT" button that needs clicking, and then you should see some log data appear below the button, to confirm the connection is working.

    Have you covered that step ?

  • PublisonPublison Posts: 12,154
    edited 2019-10-20 17:37
    bluejay wrote: »
    I am using Flip. I saved your file by removing .txt. However when I try to run the project an error message "BlocklyProp Client not found" appears . BlocklyProp Client is in my computer. I am using solo.parallax software.

    Even when running Solo, you must open the client and connect.

    What pins are connected to the FLIP. Are you using 220 ohm resistors in series with the LED's?

    1024 x 460 - 124K
  • When I run solo the web page shows solo logo, then I choose new project and the message appears "cannot find BlocklyProp Client".
  • Ken GraceyKen Gracey Posts: 7,327
    edited 2019-10-21 03:13
  • Thanks Ken . The video solved problem.
  • I too enjoyed Jim Arlow's Nuts and Volts article "Parallel Processing With the Propeller FLiP" (2019 issue 3). It was straightforward to implement 4 LEDs flashing at different rates, something which could be done with a, for example, PIC12F1572, but which would require a carefully constructed pile of code.

    Having never before used the cogs on a FLIP module, this article raised these questions. I would like to be able to do the following using BlocklyProp:

    A. Wanting the LEDs to blink much longer, I changed the duration for milliseconds from 100000 to 4 billion (almost max in a 32 bit variable) which gives maybe 46 days if I did the math right.

    BUT, is there some way to not have a time limit at all using these frequency functions?

    B. Setting up 4 LEDs to blink in a fibonacci sequence (3, 5, 8, and 13 Hz), I noticed with a Saleae logic probe that each cog starts at a different offset from the previous on. Is there some way to have each cog start at the same, or very close to the same time (still using BlocklyProp)?

    1492 x 603 - 68K
  • About (B). You're using the frequency function? This is the first time I've seen it used in this way, to control servo motors.

    I'm curious if you could build your code using the pulsout BlocklyProp blocks. The libraries for these functions do not start new processors, so you could use them in a similar way. You'd need to put each one in a loop, and put the loop in a function. Remember to include an appropriate pause, too.

    You could also try this with the servo angle block. This block runs in a processor and doesn't need a new processor block. Simply set the angle and move on to your next block.

    Put the logic analyzer on them and let's see if there's a difference.

    Somebody in Parallax would know the exact answer. It's a matter of how the underlying libraries have been constructed. Considering there are at least three ways to achieve this goal it would be a good idea to see if the other approaches above yield the same results.

    Ken Gracey
  • Ken, I appreciate your comments.

    I am using the frequency function but just in a trivial way, following along with the cited article to blink some LEDs at rates other than powers of 2 (no servos involved).

    Since I knew nothing about cogs (and still know so very little), those 2 questions I posted did occur to me. There is nothing really important about getting all four LEDs to start off at the same time (as much as possible), just a curiosity. I guess the real question would be, how close is it possible using cogs to have four processes start at the same time?

    I will be reading about cogs and studying some successful programs others have written.

    Thank you for your reply.
  • kwinnkwinn Posts: 8,693
    In PASM you can load programs to multiple cogs and have them wait for a specific pin state or count before starting, so it can be done. Don't know if that has been made available in Blockly, but it should be possible.
  • Can someone tell me that the file that I attached is readable? When I click on the file it does not open for me.
  • If you double-click the file from your Windows computer it will not automatically open in BlocklyProp because there is no association between the *.svg file type and the on-line BlocklyProp program (both Solo and the cloud version). Rather, open the file from within BlocklyProp and it will open successfully. I'm not sure you can associate an *.svg format with a browser-based program anyway.

    Yes, it opens fine.

    Are you using Windows or something else?

    I think you have a problem with the code, too. You're trying to drive a servo with the frequency command. I'm not certain this will generate the signals needed by a servo (1-2K us high pulses followed with 20-40 ms low pauses in a loop).

    Ken Gracey
  • JonnyMacJonnyMac Posts: 7,741
    edited 2019-10-29 12:22
    I started programming embedded microcontrollers with the Parallax BASIC Stamp 1, so I'm very stingy with resources. While you *can* use a cog per LED, it's a waste of cogs. With a little effort and a few blocks (lines of code), you can control multiple LEDs -- each flashing at its own rate -- with a single background cog. This means you can flash more than seven (maximum, if one per cog) if you choose. To keep this project simple each LED has on- and off-time values expressed in milliseconds. For convenience, the background cog also maintains a global milliseconds timer.

    I've attached a screen shot and the blocks code as an SVG. I have also made the project public:

    The current project only has two LEDs because those exist on the Activity Board and the FLiP module. You can add more by duplicating the process_ledx() function and adjusting output and timing values for it.

    For additional information, you may want to read my article on background timing using BlocklyProp:
    1920 x 1080 - 216K
  • bluejay, you seem to have summoned the King of Propellers (KoP) above AKA JonnyMac. Jon will find the most efficient way to do things and share his ways with others quite often.

    He also wrote this for us and I put the system counter to use in my own project here

    Lots of ways to go about this. Keep reading, learning and trying.

    Ken Gracey
  • Thank you JonnyMac and Ken for those links. Very useful and fun to read.
  • PROBLEM: BlocklyProp Board connection. When switching to View project code from Project Details, searching for a port (type set as Other) got slower and slower and finally would never find the connected FLIP. The slowing down became quite noticeable, increasing from maybe a second to many seconds, over the course of many hours and many logouts/logons.

    SOLUTION: Removing the folder com.ParallaxInc.BlockyPropClient.savedState from /Users/rralston/Library/Saved Application State

    REASON for problem: unknown (especially since problem was on 2 different computers and the second computer would presumably have had a fresh Saved Application State file since the BlocklyProp Client was just installed for this test).

    What did not help:
    Trying different saved project
    Different USB cable
    Different USB port
    Different FLIP board
    Using direct USB port rather than from USB hub
    Reboot iMac (running Mojave 10.14.6 <— latest; connection to router is ethernet cable)
    Download and reinstall BlocklyProp client (v0.7.5)
    Reset Chrome (78.0.3904.97. <— updated since previous version(s) had a zero day exploit
    Try Opera (64.0.3417.92. <—latest)
    Try different computer, AirBook (running Catalina 10.15.1 <— latest); installed BlocklyProp client, used latest Chrome; connection to router is wireless
    Reboot house router
  • Hey Rob,

    If I had to put money on when this problem occurred, I'd say it was sometime between last night and today at noon Pacific time. I think the issue was on our servers and had nothing to do with your computer. Yesterday, Jim updated the BlocklyProp site and somehow got his containers a bit mixed up. The Educator Hotline, personal phones and e-mail were lighting up and subject to blitzkrieg response from Parallax in response. It seems that we mixed some of the files with the files. Many people were unable to compile and download.

    Was your problem in this timeframe?

    Also, use Chrome with BlocklyProp.

    And, have you seen It saves locally and only goes to the cloud for compiling. Turns out it's a lot more reliable and in a year we'll be switching exclusively to this version.

    Sorry you got all wrapped up in this problem. We owe you some time back!

    Ken Gracey
  • Thank you Ken,

    Yes, I am convinced the problem was external from me. Today I tried my laptop expecting it to not find the FLIP and that I would have to remove the SavedState folder.

    But, not true, the laptop worked as expected. So my solution above is wrong.

    I will try the solo version.

  • Just tried the solo version, so far so good. I like having the project files local and it is easy to get all of them downloaded with that one button.

    BUT, the file length seems to be about 22 characters (excluding the project number) so many of my project titles are too short in the download. I will now alter the titles on the non-solo site and download again to retain the descriptiveness I need.
  • I'll frequently bounce around when things don't work with some basic troubleshooting: switching cables, boards, computers, power supplies. Add in cloud computing like you're using and the problem becomes more difficult to figure out because many pieces are beyond your control. Sometimes I'll end up looking in the wrong place.

    Anyway, we aim to make BlocklyProp as reliable as possible. So far the track record is really good and will improve with

    Ken Gracey
Sign In or Register to comment.