Sharing Snap! extension to work with Picaxe (with S2P)

jguille2

New Member
Hi,

I've built Snap! blocks to work with S2P (just like Scratch). Snap! is a powerful drag-and-drop programming language. I'm working in teacher training... and it's a very good option for working in Computer Science and Robotics.

I noted this in github space. Just run Snap! and import this blocks or import this project (with the blocks and an example to implement sensors mapping).

You also can trigger from the cloud this projects: only blocks or blocks+sensors mapped . Just got to 'Sensing' category and you'll find all the picaxe blocks.

A few notes:

-It's the first version, copying Scratch functions and working in the same way.
-Snap! is very customizable. Every xml is a new starting point (with different blocks). Then we can make files for different hardware, different levels ...
-It's my first time with picaxe. I've got only an Imagina board (from Robolot team). I want to test with more hardware and see the best options for snap files. Any feedback will be useful.

And my first questions:

-Is there more documentation for S2P?
-I'll want to implement pwm functions, to use servos and other components.
-I wonder about iterruptions. I test IR reportings, with some blocking issues.

Thank you,

Joan
 

stevesmythe

Senior Member
I've had a quick play with this (using the AXE023 08M2 motor driver board), Joan, and it looks good.

I noticed that when you click the red flag, the outputs are not turned off. I think all pins should be set to "low" when the red flag is clicked.

I'll carry on testing...
 

stevesmythe

Senior Member
I think another issue is that the designation "motor A", "motor B" etc. depends on which board you are using. For example, on the AXE023 board (Picaxe 08M2), motor A is ports c.0,c.1 and motor B is c.2,c.4. On the CHI035 board (Picaxe 18M2), motor C is b.4, b.5 and motor D is b.6,b.7. I think you need to follow the approach that S2P uses, where you can load different templates depending on which board/chip you are using. I realise that this is your first example, so you won't have had time to create different templates yet but it is something that I think you need to do if the motor blocks are to be useful.
 

Technical

Technical Support
Staff member
Thanks for doing this. Most of the commands should probably be in the control (not sensing) category?

The PIC micros do not have a background pwm setting compatible with driving servos. Therefore the PICAXE background 'servo' command is an internal faked command based upon internal timers/software interrupts, not a true separate pwm module. Although this works fine is most scenarios it does not mesh well with continuous serial communication (as used when the chip is continuously communicating with S2P), as the serial communication interrupts take priority other the servo timers, and hence the servos can jitter.
 

jguille2

New Member
Trying to answer some questions...

-First of all, just comment that Snap implentation uses Scratch-SP2 software. Then, the behaviour is fixed for the original software.

-Red flag doesn't turn off the outputs. Neither Scratch does this. And this responses to Snap/Scratch logical procedures. You can build multiple scripts running together, and when you stop them, they only stop. For example, if you make a blink led, when you stop (with the red flag or just clicking the script) the led continuos in the last state (on or off). If you want a reset, you must send a reset action.

-The problem with the motor identification is not in the snap (nor scratch) template. It only sends a 'motor A' (not a pin) message... and is S2P who translate this to the board (sending actions over pins). And pins identification depends on the board, not on the xip. For example, I tested all blocks with a 20M2, inside an Imagina board... and Motor C (on soft) manage Motor A of the board.

-Depending on the user target, I also want to use customized templates to the board (where 'motor A' manage real 'motor A'). I want to make more templates... but the important message i I can make my own blocks esasily with Snap. Then everyone can make his blocks, where motorA-> my motorA... or maybe I want to make a block 'Motor1-clockwise'... or 'Motor1-forward'... or 'Open the door'...

-It's a pity that PWM was not supported! I want to build a project that works both in Arduino and Picaxe. Only one soft and hardware flexibility. But many projects use servos or other pwm signals (like motor power).

-In my opinion S2P is very important to implement Picaxe solutions. Just like Firmata in Arduino's world... not only for Scratch/Snap extensions... because with these middlewares we can do everything: programming with javascript/python, controling boards with html (web pages, mobiles)... Just, open S2P and run in your browser http://localhost:50212/outputOn/B.1 (change the pin as you want) and you can begin to create new solutions...

Thanks for your feedback!

Joan
 

stevesmythe

Senior Member
Regarding the red flag, in Scratch/S2P it does turn off the outputs. If you have a "forever loop" with outputs being toggled or motors turned on or off, the outputs might be left on or off so it is useful to be able to stop the outputs by stopping the script.

Regarding the motor blocks, I understand what you are saying.

Keep up the good work.
 

jguille2

New Member
I'm sorry! I was wrong with the behaviour of red flag in scratch. I've seen red flag is sendinga "reset_all" event.

But I can't implement this in Snap! Because is a system event. We have a workaround... because i made the block "reset". I think it's the only thing i can do.

Thanks,

Joan
 

Technical

Technical Support
Staff member
-It's a pity that PWM was not supported! I want to build a project that works both in Arduino and Picaxe. Only one soft and hardware flexibility. But many projects use servos or other pwm signals (like motor power).
Do not confuse 'pwm' (e.g. motor power) with 'servo' (pulses every 20ms).

'pwm' runs on a separate silicon module inside the pic micro, and can therefore run in the background all the time without being affected by serial communication. Therefore pwm can be supported.

'servo' has to use timers instead, because there is no pwm setting in a pic micro that can give the 20ms pulses you need to drive a servo.
 

jguille2

New Member
Thanks technical!

If we can use pwm with p2s, it'll be great! I'll be waiting for this...

I understand that pwm and servo is a different thing... but in both cases we need timers! And we need to optimize these timers. I was working with Arduino UNO (three timers), building new firmata files to implement more functions... and pwm pins are disabled when I make interruptions with their timers. Then, we need to choose a configuration (servos, ir, playsound (if it was not blocking) and pwm pins) to make the best.

One question. Can I find more information about s2p code and their firmwares? Can I customize (add) new firmwares? In firmata protocol, we have the sysex commands definition, and it's easy implement new functions to 'standard' firmata.

Thanks,

Joan
 
Top