Scratch for Control Technology

Drop in for a chat and a cup of tea

13 posts
by hastklass » Sun Apr 29, 2012 8:39 pm
RE: [CAS] Pi I/O and Scratch

I wish to use the R-Pi to teach Control Tecnology to 8 to 13 age range.  Therefore Scratch is my preferred language.

I am expecting a PicoBoard to arrive next week and will try to connect it to my Pi but I suspect that this will be problematic.  I have not used a PicoBoard so have no knowledge of its connections.  Also do not know if there are PicoBoard drivers for Linux computers.

I do not have a technical background - no knowledge of GPIO.  Not sure how sophisticated you can get with Scratch and BYOB in this regard?

Graham
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 26
Joined: Mon Dec 12, 2011 11:20 am
Location: Cambridge
by davidmam » Fri May 04, 2012 11:29 pm
I'm hoping that someone can prove me wrong but I haven't found a way with scratch to be able to get outside the box, ie interact with files or GPIO. I may be completely wrong and I'd love to find a way to include system calls or GPIO reads/writes in Scratch.

The Picoboards look good so they must have been able to sort this out.
Posts: 98
Joined: Tue Dec 06, 2011 4:13 pm
by rurwin » Sat May 05, 2012 10:04 am
The picoboard should work with the RaspPi, it searches for a COM(sic) port with a picoboard on it.

The protocol for the picoboard is published as is everything else including the schematics, and would be easy to replicate. However the picoboard has no outputs. The motor control blocks expect to see a "WeDo Robotics" thingy. That uses USB and LabView (sheesh!), and I don't see where Scratch plugs into it -- is it a USB driver or does it talk to LabView?

It is possible to write your own Scratch blocks, but you have to learn Smalltalk first, and that would be an interesting journey.

See this thread from the Scratch forums
User avatar
Forum Moderator
Forum Moderator
Posts: 2933
Joined: Mon Jan 09, 2012 3:16 pm
by morphy_richards » Sat May 05, 2012 11:43 am
rurwin said:


It is possible to write your own Scratch blocks, but you have to learn Smalltalk first, and that would be an interesting journey.
See this thread from the Scratch forums


That would really be a worthwhile project. If blocks that can do external control could be done well, there would be lots of happy educators across the world :-D
User avatar
Posts: 876
Joined: Mon Mar 05, 2012 3:26 pm
Location: London
by csoutreach » Sat May 05, 2012 9:27 pm
I can't say too much just yet, but you might be interested in a forthcoming announcement for schools, scratch and control….

Let's just say we're pretty sure it's possible to control GPIO with scratch and the architecture diagram may give a hint.

http://piface.openlx.org.uk/ar.....ture-75365
http://piface.openlx.org.uk/ Raspberry Pi IO Interface Board
User avatar
Posts: 32
Joined: Mon Nov 28, 2011 1:06 pm
by rurwin » Sat May 05, 2012 10:47 pm
I'd agree, it is certainly possible, and not too hard either. I got deep enough into it this morning to see that. I also got deep enough into it to see that the documentation of the underlying Sqeak environment was pitiful.

It seems to me that Scratch has missed a chance to implement a real I/O API. The blocks for WeDo and Scratch Sensors are special purpose and non-reusable. It would have been trivial to implement an output protocol as well as an input protocol for Sensors and WeDo is limited to two devices.

Even going the same route, it should be trivial (once past the learning curve for Smalltalk and the Sqeak environment) to implement blocks for, for example, the GertBoard. However a fuller solution should probably involve an intermediate layer with some sort of scripting, still possible but rather more work.
User avatar
Forum Moderator
Forum Moderator
Posts: 2933
Joined: Mon Jan 09, 2012 3:16 pm
by davidmam » Sat May 05, 2012 11:39 pm
I started to look at Squeak, and Smalltalk, and realised very rapidly that the documentation is very muddled between versions and that my brain hasn't yet learned to think that way (or translate the jargon).

I'd love to be able to e.g. put custom parsers as blocks in Scratch so it can read files do stuff with the content. Almost a graphical Perl.

I look forward to the hints becoming reality. Scratch that can get out of the box would be great.
Posts: 98
Joined: Tue Dec 06, 2011 4:13 pm
by hastklass » Sun May 06, 2012 3:20 pm
My PicoBoard arrived last week and with the the help of Alex Bradbury of Cambridge University I managed to get my Pi to talk to the PicoBoard.  I have copied his instructiuons below:

Now, to get it going on the Pi. Firstly, it connects via USB and you
have only 2 USB ports on the Pi, which will already be used by
keyboard and mouse. If you have an externally powered USB hub, you
could connect through that. Otherwise, let's start with this:
* Through the 'start menu' equivalent, go applications->lxterminal to
open a terminal window. Maximise it
* Unplug your mouse and plug in the picoboard
* Type `dmesg` then enter and see if there's something about a new USB
device being plugged in on the last few lines it displays
* Type `sudo modprobe ftdi_sio` and enter
* Do `dmesg` and enter again. There might be some new lines at the end
of the output, for instance another Linux picoboard user reported
this:
[451394.964027] usb 4-1: new full speed USB device using uhci_hcd and address 5
[451395.140265] usb 4-1: configuration #1 chosen from 1 choice
[451395.144909] pl2303 4-1:1.0: pl2303 converter detected
[451395.164947] usb 4-1: pl2303 converter now attached to ttyUSB0
[451470.917714] USB Serial support registered for FTDI USB Serial Device
[451470.917840] usbcore: registered new interface driver ftdi_sio
[451470.917843] ftdi_sio: v1.5.0:USB FTDI Serial Converters Driver

Now we're ready to give it a try. Again, assuming you're not using a
USB hub then just unplug the keyboard and replace that with the mouse.
You should be able to open scratch and make a simple test just with
mouse input.

There is an appreciable delay between trigering an input to the PicoBoard and the graphics on Scratch producing a visible response.  Alex has said that he will look into this when he has some time and I will post any solution here.

As it stands I can see the set up working for projects where a rapid response is not required.  It is early days yet and it is likely that this problem can be resolved.

If anyone manages to improve on my initial experiments I would love to hear from you.

Graham

(St John's College School)
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 26
Joined: Mon Dec 12, 2011 11:20 am
Location: Cambridge
by csoutreach » Tue Jul 10, 2012 5:25 pm
We struggle with the performance of Scratch too doing IO stuff. We're hoping it's linked to the way it repaints the windows and as such it might be possible to use hardware acceleration somewhere in the Squeak VM. Anyone else got any other progress?

You can see the slight lag in the video.
http://www.youtube.com/watch?v=OhaWDUAuajE
http://piface.openlx.org.uk/ Raspberry Pi IO Interface Board
User avatar
Posts: 32
Joined: Mon Nov 28, 2011 1:06 pm
by asb » Wed Jul 11, 2012 7:29 am
csoutreach wrote:We struggle with the performance of Scratch too doing IO stuff. We're hoping it's linked to the way it repaints the windows and as such it might be possible to use hardware acceleration somewhere in the Squeak VM. Anyone else got any other progress?

You can see the slight lag in the video.
http://www.youtube.com/watch?v=OhaWDUAuajE


Yes, I suspect it's due to UI redrawing. We have a student here who's just started looking at optimising scratch performance.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 799
Joined: Fri Sep 16, 2011 7:16 pm
by simplesi » Wed Jul 25, 2012 10:25 pm
I've documented a simple way (hopefully the actual simplest :) ) of getting Scratch to use 4 GPIO pins as outputs and 4 as inputs if anyone wants to have a simple play with some leds and switches.

http://cymplecy.wordpress.com/2012/07/2 ... #comment-8

Just looking for a cheap way of buffering the GPIO before I let the pupils in my primary schools loose on a Pi :)

Simon
@cymplecy on Twitter, SimpleSi on Edugeek.
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter
Posts: 2116
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
by techpaul » Fri Aug 10, 2012 10:58 pm
Thank you documenting your work.

Link noted and passed onto interested teaching parties...
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
Posts: 1510
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
by simplesi » Sun Aug 12, 2012 5:03 pm
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter
Posts: 2116
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK