Shop OBEX P1 Docs P2 Docs Learn Events
Open Propeller Project #5: BlocklyProp - Page 5 — Parallax Forums

Open Propeller Project #5: BlocklyProp

1235789

Comments

  • Michel LMichel L Posts: 141
    edited 2014-05-30 03:29
    jazzed wrote: »
    Excellent!

    Ran the app, went to the web page and selected the programming type. Compiled.

    Will do more later after paying gig is done and the grass is cut.

    I'm glad. Just a couple things I forgot to mention:
    • just like the java version, the spin compiler and propeller loader are included but the c compiler needs to be installed.
    • I've improved the c compiler command line. Where the java version still had the libraries hardcoded, now they are configured using a json file and is easily extended. Meaning that if new blocks need new libraries all that needs to be done is extend this file. (As long a the libraries themselves are present)

    This json file (lib-descriptor.json in the propeller-c-lib directory) specifies the name, lib-directory (where the headers are) and where the compiled implementations are. It then also specifies for which include each lib is needed. Before compiling I parse the source file, get the includes and then look up the libraries that in turn are used to build the command for the compiler.

    The client source code is available on Github

    Next up:
    • continue-es polling to check if the client is available or not with display on the page.
    • configurable client url (if you don't run the client on localhost
    • redesign of the editor screen options
    • user accounts with preferences and projects

    EDIT: I now added a build for Linux. Just like the windows users, you should be able to just extract and run the executable.
    I advice to start the executable from the command line using ./BlocklyPropClient as just running the executable from the graphical environment doesn't open a console window and as such, you can't shut down the client/server.
    As the application currently uses the working directory to find the libraries and executables you can't start it from an other directory. I hope to be able to change that in the near future.
  • Michel LMichel L Posts: 141
    edited 2014-05-31 12:00
    Michel L wrote: »

    Next up:
    • continue-es polling to check if the client is available or not with display on the page.
    • configurable client url (if you don't run the client on localhost
    • redesign of the editor screen options
    • user accounts with preferences and projects

    3 done, 1 to go.

    Today I've restyled the menu in the spin and C editors. Now it's consistent with the other pages.
    Now there's checking if the client is running. So, you can start and stop your client at will, and also the location of the client can be configured.
    By default it will presume localhost but it can be changed. (When user accounts are implemented these shall be able to be saved)
  • Michel LMichel L Posts: 141
    edited 2014-06-08 14:32
    Been working a whole week on the community system. The user accounts and projects.

    A lot of features are still missing: configuration, friends, lost passwords, project tags,...

    But it starts to become a use-able system. So, give it a try and please report any improvements you can think of or bugs you find.
  • Michel LMichel L Posts: 141
    edited 2014-06-11 14:11
    Community is now at a use-able point. More features are on the to-do list but its time to add more blocks so you all have more to play with.

    I just added drive_goto and drive_speed to the c version.

    I'm currently only maintaining the hosted version with the community features. This version requires the BlocklyPropClient on your own computer to compile and load programs.

    The latest version of the client (v0.2) can be downloaded from: Github release v0.2
    I'll try to make a linux version as soon as possible.

    For those who lost the link to the application: BlocklyProp
    BlocklyProp Community includes some demo projects
  • FredBlaisFredBlais Posts: 375
    edited 2014-06-12 05:45
    Hello Michel, you did a really great job with BlocklyProp :)

    I'm planning to give electronics/robotics to students of a secondary school near my home. Teaching them robot programming using Blockly would be an excellent way to introduce them to the Propeller.
  • Michel LMichel L Posts: 141
    edited 2014-06-12 07:14
    FredBlais wrote: »
    Hello Michel, you did a really great job with BlocklyProp :)

    I'm planning to give electronics/robotics to students of a secondary school near my home. Teaching them robot programming using Blockly would be an excellent way to introduce them to the Propeller.

    Thanks, it's great to have some real usage. If there's anything you're missing or you want a separate installation just ask. It grows a bit every day but I'm willing to change priorities if needed.

    Michel
  • FredBlaisFredBlais Posts: 375
    edited 2014-06-12 12:30
    @Michel

    Would it be doable for me to create custom blocks? Let's say I have a method in Spin that returns the value of an ADC, and I want to have access to this with Blockly. It could be intersting to have a little tutorial on how to create custom blocks!
  • Michel LMichel L Posts: 141
    edited 2014-06-12 13:19
    FredBlais wrote: »
    @Michel

    Would it be doable for me to create custom blocks? Let's say I have a method in Spin that returns the value of an ADC, and I want to have access to this with Blockly. It could be intersting to have a little tutorial on how to create custom blocks!

    Frederick,

    creating new blocks is not very hard. If you use the existing functionality and don't need anything new it's just 3 steps.
    • create a block definition that describes text, color, category, inputs and outputs.
    • then create a code generator for that block. Reading the inputs and creating lines of code.
    • add the javascript file to the frame and add the block to the list of blocks.

    The best way is to look at other blocks and copy paste and edit till you have what you want.

    Most of the block definitions and code generators for spin are in blockly/generators/spin. While the editor frame for spin is frame.html in the webcontent directory.
    If you use an external spin object you have to put it in the propeller-lib directory of the BlocklyPropClient.

    I'll see to create a more extensive manual for developing BlocklyProp. Sadly, today I've started writing a manual for my job, what means that I rather write some code at the moment then more manuals.

    If you want you can send me a PM and then I'll send you my skype name. Then you can ask questions and is it easier to get you started.

    Michel
  • Michel LMichel L Posts: 141
    edited 2014-06-18 12:11
    My ActivityBot just made its first walk. Not just with a hardcoded route, but with logic based on Ping))) measurements.

    I've mounted the Ping))) on a bracket so that it can be turned 180°. It takes 3 measurements, and if the middle one is the highest, it will drive forward. If not, it will turn towards the highest reading.

    You can download the video at: http://owncloud.creatingfuture.eu/public.php?service=files&t=526f45c611b9ac07c8657183b7006190

    first-walk.png
    960 x 572 - 44K
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-06-18 20:53
    What is the latest Blockly Prop version?
  • Michel LMichel L Posts: 141
    edited 2014-06-19 01:43
    NWCCTV wrote: »
    What is the latest Blockly Prop version?

    Andy,

    the latest version of BlocklyProp is the one hosted at http://blocklyprop.creatingfuture.eu

    And to compile your programs and load them into your prop you have to download the BlocklyPropClient: you can download a windows version of this at http://owncloud.creatingfuture.eu/public.php?service=files&t=0eae565db031cd3ca3f1163de91c5984
    I have currently no Linux or Mac version, you have to run these from the source code (Python): https://github.com/michel-cf/BlocklyPropClient

    (In the BlocklyPropClient is currently a problem with the C compiler. For some reason I'm unable to get the compiler output. It is shown in the console instead of the web application)

    The above project can be viewed at: http://blocklyprop.creatingfuture.eu/blocklyc.html?project=16

    Michel
  • Michel LMichel L Posts: 141
    edited 2014-06-20 15:37
    Although I've stopped posting every day what I've done, mainly because the features I'm implementing take more than one day to do so, I've been expanding the project every day. I'm now at 40 consecutive days of doing so.

    Currently I'm working on an improved way to create projects. Allowing you to select what sensors you use and how they are connected. (I plan to later add a way to draw/generate a breadboard diagram)
    This will inform other users what sensors are needed and how they need to be connected to run your project.

    I'll be taking a break now, for one week, as I go on holiday. If you all could take a little time and play with the application so that you all got tons of ideas as I get back, that would be great :P

    40 days.png
    166 x 237 - 5K
  • twm47099twm47099 Posts: 867
    edited 2014-06-20 16:44
    Michel,
    I downloaded the BlockyPropClient in post 132. But when I tried to run BlockyPropClient.exe on my Windows XP computer and on a Windows 7 (32bit) computer and received an error that it was not a valid Win32 application.

    Help!
    Thanks
    Tom
  • Michel LMichel L Posts: 141
    edited 2014-06-21 01:02
    twm47099 wrote: »
    Michel,
    I downloaded the BlockyPropClient in post 132. But when I tried to run BlockyPropClient.exe on my Windows XP computer and on a Windows 7 (32bit) computer and received an error that it was not a valid Win32 application.

    Help!
    Thanks
    Tom

    Tom,

    Apparently the generated exe files are 32bit/64bit specific.
    I don't have access to a 32bit Windows anymore. I'm afraid that the only solution is to run BlocklyPropClient from code.
    I'll see if I can get my hands on a 32bit Windows system anywhere, but that will be for after my holiday.


    EDIT:
    I just remembered I still had a virtual machine running Windows XP. So, to be more friendly to the community, I quickly set up my development environment on that machine and build you a 32 bit version.
    I've added it to my file sharing site: http://owncloud.creatingfuture.eu/public.php?service=files&t=0eae565db031cd3ca3f1163de91c5984. I hope this works for both of your computers.

    Running the application (or even building it), is not that hard. The required python packages are list at: BlocklyPropClient on Github
    It does require that you know how to set up python and install packages.


    Michel
  • twm47099twm47099 Posts: 867
    edited 2014-06-21 10:10
    Michel,
    Thank you for taking the time to build the 32 bit version. It works well, and I've tried running a few of the introductory projects. I really like how easy it is to try different modifications to the projects. I have to add some hardware to my ActivityBot, and then I'll try your project driving with Ping.

    Thanks again and have a good holiday.

    Tom
  • twm47099twm47099 Posts: 867
    edited 2014-06-21 10:43
    Michel,
    While you are away, I'll post some of my findings. These are not urgent but could be considered in a future update.

    When selecting the QuickStart board from the Intro page for either Propeller C or Spin, the usable pins are 0 - 7 and 16 -23. These are the predefined QS pins - 0 - 7 = Touchpads, and 16-23 = built in LEDs. The unused pins (pins available for user applications) are 8 - 15 and 24 - 27. These should be added to the pins lists in the drop downs. (I've worked around this by selecting Board Type Other which gives access to all pins.)

    There is a similar issue with the Activity Board. That board has pins P0 - P17 available for user circuits. Pins P12 - P17 are connected to the servo connectors, although P12- P15 are also on the breadboard header. Pins above 17 are connected to specific components/functions on the board.

    Thanks
    Tom
  • twm47099twm47099 Posts: 867
    edited 2014-06-24 06:44
    Michel,
    I am writing a project to use the PIXY vision sensor with the ActivityBot. Since the project is very incomplete, I have tried to make it a private project. But it keeps showing in the main community space (even if I am not logged in.) I am not sure if I am doing something wrong.

    I'd like to let you know that I find BlockyProp very enjoyable to use. When programming in C my typical problems are keeping track of braces and forgetting the semicolons. Those are not issues with Blocky. There are some parts of Blocky that take some getting used to, for example building an if - if else statement. But once figured out, its nice to just build the logic without having to worry about grammar. As this develops I think it will make programming more available for younger children. The ability to read (and copy and paste) the actual generated C code is also very useful.

    I am able to use BlockyProp directly with my Windows XP desktop computer. But my portable computer is a Windows 7 netbook, and I am still having problems getting the client to work with it. Without the client the serial port dropdown works (but I obviously can't compile), but when I run the client, the serial port dropdown goes blank and no com ports show up. If I then click on compile, the compile window opens, but nothing else happens. For portable use, after arranging the blocks, I go to C code view and copy / paste the code into Simple IDE, then compile and load into the bot.

    Tom
  • Michel LMichel L Posts: 141
    edited 2014-07-01 10:59
    Tom,

    thanks for the input. I've started today again with some development.

    I've started with changing the digital pin lists for the ActivityBoard and the QuickStart. The ActivityBoard now had 0-17 for the I/O pins, and I've given the quickstart everything up to 27. As I do not have separate lists for in's and out's at this moment. Is this is a feature that would be wanted, I could split them. (My project is based on the Arduino version of Blockly where they only have I/O pins and analog pins)

    I'll take a look at the shared and private projects. There might be something wrong with my query. Please note: selecting private doesn't do anything yet. This makes the project invisible for your friend, and I've not yet added the friends feature.
    It's either shared (visible to the community), or not (visible to you, and, when implemented, your friends).

    I sadly have no access to a Windows 7 32 bit. The only option I see, is to check out the code from Github, install Python and the required libraries and run it like that. It could be that some of the binaries used differ between Windows XP and Windows 7, even when both are 32 bit.
    The serial port dropdown is populated with some demo values when the server is not available when loading the page.

    I've looked up the PIXY vision sensor and I'm sad I missed that Kickstart project. It look great to combine with the propeller as you can focus on your main implementation instead of using a lot of processing power for the recognition. I believe I once saw a prop project that also did object recognition.
    If you would need anything (Blocks or something else), I'll gladly implement them first.

    Michel

    PS: the new pin layouts will be only shortly
  • Michel LMichel L Posts: 141
    edited 2014-07-01 11:26
    I've now put up a new build. This now not only contains the new pin lists, but also correctly saves projects as not being shared.

    The problem was not with the query, when saving the "shared" value I had to check the text ("true" or "false" and replace it with 1 or 0). For the private setting I correctly used a "==" but for the share setting I accidentally used a "=".
    Being PHP, both were correct where it was used.

    So, you can now set your project as not shared.

    Michel
  • twm47099twm47099 Posts: 867
    edited 2014-07-02 14:28
    Michel,
    Thanks for the help.
    I also missed the PIXY Kickstarter, but they are now available on Amazon, that's where I got mine.
    Is there a way to copy a group of blocks from one program to a different one?

    I'd like to make a suggestion regarding the Activity Bot ADC function.

    BlockyProp uses the ad_in(ch#) function. That returns a value that is 4096ths of 5v. For a beginner (like me) it is easier to use ad_volts(ch#) that returns a floating point voltage value. My version of the BlockyProp program pixy-servo uses the voltages, and didn't work when I complied and loaded the EEPROM from the web page. Just looking at the Blocks view I couldn't tell what was wrong with my program. I copied the C view generated by BlockProp to SimpleIDE and changed the ad_in(ch#) to ad_volts(ch#) and it worked.

    I've posted the C code below:

    Tom

    /*  Use PIXY to control standard servo (Ping Bracket) on Activity Bot to track a laser dot
      Pixyservo as generated by BLOCKYPROP
     
    
        This did not work as generated by BLOCKYPROP
        It worked when I replaced ad_in(ch#) with ad_volts(ch#) so I could get an actual voltage value, 
        I think it would be better for a beginner to use a voltage rather than 4096ths of 5v. 
     
    
     Build info:
     Teach PIXY to recognize a laser dot using PIXYMON, Reduce brightness to about 30
     Uses interface mode 3 on Pixy - set using PIXYMON 
     Pixy Pin 1 -- to ABOT ADC channel 0.  = high if object detected 
     Pixy Pin 3 -- to ABOT ADC ch 1.  = 0 - 3.3 volts proportional to x position of object, 0 = full left, 3.3 = full right
     Pixy Pin 2 -- to ABOT +5v
     Pixy Pin 6 -- to ABOT GND 
     Ping Bracket Servo connected to ABOT pin 16 
     */
     #include "simpletools.h"
     #include "servo.h"
     #include "abvolts.h"   
     
     int angle;
     float got_x;
     float pixy_x;
    
     void read_pixy_x() {
        //  got_x = ad_in(0);                      // ad_volts(0) worked -- see next line
       got_x = ad_volts(0);                    // I used an ADc for this because most of my ABot pins are used
       if (got_x > 2) {                                // PIXY detected object
         //  pixy_x = ad_in(1);                      // ad_volts(1) worked -- see next line
         pixy_x = ad_volts(1);    
         pixy_x = (pixy_x * 64) / 3.3;
         // Should result in an angle of 58 to 122 degrees - PIXY has Field of View of 75 degrees
         // and straight ahead on ABOT is 90 deg
         pixy_x = 122 - pixy_x;
       }
     }
    
     int main() {
       angle = 0;
       got_x = 0;
       pixy_x = 0;
       ad_init(21, 20, 19, 18);        
       while(1) {
         read_pixy_x();
         angle = pixy_x;
         servo_angle(16, angle * 10);
         pause((10));
       }
     }
     
    
    
    
  • Michel LMichel L Posts: 141
    edited 2014-07-02 16:06
    Tom,

    I don't believe that copying is possible in Blockly. I'll see if I could add something.

    Because I can't currently get the output from the compiler you need to look in the console of the BlocklypropClient. I'll see if I can open your project and test it myself. The creating of the compiler call is a bit tricky and might not be correct for this application.

    I'll also move up the adc voltage block up in my todo list. I just need to finish what I'm creating now, so that I don't have half finished features.

    Michel
  • twm47099twm47099 Posts: 867
    edited 2014-07-02 17:22
    Michel,
    I think that the C code that BlockyProp generated would have worked if I had realized that the ADC block used ad_in(ch#) and then I added a step to convert the returned value to a voltage (pixy_x = pixy_x * 5.0 / 4096) or just used the returned value and calculated the angle from that value. I appreciate your effort and don't want to disrupt your progress. I have to try modify my project to use ad_in(ch#). I'll let you know how it works.

    Tom
  • twm47099twm47099 Posts: 867
    edited 2014-07-02 18:27
    I added the statement to convert the value from ad_in(ch#) to a value from 0 to 3.3v and pixy-servo compiled by BlockyProp works (as long as I remember to plug in the activitybot battery pack).

    I've attached a pdf showing the blocky program.

    pixy-servo.pdf

    I saved the program on the blockyprop community web page. The C-listing in post 141 explains the build.

    Tom
  • ValeTValeT Posts: 308
    edited 2014-10-17 06:00
    Is anyone still working on this, or has the project been completed?

    From the github page, this seems to still be in development. I would like to contribute, but I do not know where to find the blocks section of the code to edit. Can anyone show me the way?

    Thanks,
    ValeT
  • FredBlaisFredBlais Posts: 375
    edited 2014-10-17 13:40
    Michel told me that he gave a 3 month rest to the project and he wanted to start working on this again soon
  • ValeTValeT Posts: 308
    edited 2014-10-17 16:24
    Awesome! Thanks for the fast response.

    I am still unable to find where all of the modules are. Do you have any idea where, on the github page, they are located?
  • FredBlaisFredBlais Posts: 375
    edited 2014-10-17 20:00
    ValeT wrote: »
    Awesome! Thanks for the fast response.

    I am still unable to find where all of the modules are. Do you have any idea where, on the github page, they are located?

    Do you mean this? https://github.com/michel-cf/BlocklyProp/tree/master/blockly/generators/spin
    That's where the spin blocks functionalities are defined (like servo or ping)
  • ValeTValeT Posts: 308
    edited 2014-10-18 08:05
    FredBlais wrote: »
    Do you mean this? https://github.com/michel-cf/BlocklyProp/tree/master/blockly/generators/spin
    That's where the spin blocks functionalities are defined (like servo or ping)

    Yes. That is exactly what I am looking for. Thanks for finding it!
  • ValeTValeT Posts: 308
    edited 2014-10-18 13:02
    Do you know what Parallax plans to use this for?

    I am curious just because there are other IDEs for the Propeller already available.
  • FredBlaisFredBlais Posts: 375
    edited 2014-10-18 15:46
    ValeT wrote: »
    Do you know what Parallax plans to use this for?

    I am curious just because there are other IDEs for the Propeller already available.

    For me, one of the strengths of the Propeller/Spin language is the level of abstraction that the objects provides. There is so much drivers you can find on the Obex so you dont have to always reinvent the wheel with complicated stuff like video generation and SD card routines etc...

    Graphical programming like Blockly helps a lot non-programmer and young people to be able to make something work quickly, it`s just so intuitive. Give them great "blocks" and making cool stuff takes a matter of minutes. Just think about the success of Lego Mindstorms in robotics.

    I hope an IDE like this is something that is going to be shipped with Parallax Robots to make them intelligible for everyone.
Sign In or Register to comment.