nr.
Posts: 144
Joined: Wed Oct 03, 2012 8:51 am
Location: The Fens
Contact: Website

Gertboard, RISC OS and BASIC

Tue Nov 20, 2012 10:02 pm

In an effort to seperate this from the existing python thread, here's a quick bit of info on starting to use the gertboard with RISC OS. It's not intended to be in any way complete or authoritative. Just a case of my fiddling around with BASIC for the first time in many years and getting my gertboard to flash some LEDS.

So, let's assume that you have RISC OS running on your pi already. If not, go and do it now. Or buy a new one just to run as a RISC OS desktop machine. Honestly, it's well worth it. So, RISC OS is up and running happily. First thing to do is to grab the GPIO modules handily provided by another forum member, tank. Take a look at the thread at http://www.raspberrypi.org/phpBB3/viewt ... 55&t=22250, then go to http://www.tankstage.co.uk/software.html and download the zip file. You can either just double click on the GPIO module, or create an RMload line in an obey file as detailed in the thread.

Secondly, strap up your gertboard as if you were running the supplied LED.c test program. I won't re-describe that here, as it's described elsewhere in detail, and my typing finger is already starting to hurt.

Then, enter the following BASIC:

Code: Select all

REM check we're on a Pi, just bail out if otherwise
SYS "GPIO_GetBoard" TO a%
IF a% = 11 OR a% = 12 THEN
 REM build array to map LEDs to GPIO
 DIM b%(11)
 IF a% = 12 THEN
  REM set pin to LED mappings for rev A
  b%() = 7,8,9,10,11,17,18,21,22,23,24,25
 ELSE
  REM Set pin to LED mappings for rev B
  b%() = 7,8,9,10,11,17,18,27,22,23,24,25
 ENDIF
 REM loop through LEDs one way, flashing them
 FOR x% = 0 TO 11
  g%=b%(x%)
  REM read the current pin mode
  SYS "GPIO_ReadMode" ,g% TO a%
  REM is it output ?
  IF a% <>1 THEN
   REM no - set it as output
   SYS "GPIO_WriteMode" ,g%,1 TO a%
  ENDIF
  REM flash LED 3 times
  FOR z% = 1 TO 3
   PROC_ledon(x%)
   PROC_delay(10)
   PROC_ledoff(x%)
   PROC_delay(10)
  NEXT
 NEXT
 REM loop through LEDs the other way, flashing them
 REM no need to check mode this time through
 FOR x% = 11 TO 0 STEP -1
  REM flash LED 3 times
  FOR z% = 1 TO 3
   PROC_ledon(x%)
   PROC_delay(10)
   PROC_ledoff(x%)
   PROC_delay(10)
  NEXT
 NEXT
ENDIF
END

DEF PROC_delay(delay%)
 tnow%=TIME:REPEAT:UNTIL TIME>tnow%+delay%
ENDPROC

DEF PROC_ledon(led%)
  SYS "GPIO_WriteData" ,b%(led%),1
ENDPROC

DEF PROC_ledoff(led%)
  SYS "GPIO_WriteData", b%(led%),0
ENDPROC
Executing that code *should* chase the LEDs forwards and backwards (technically, it's actually backwards then forwards, but that's eaily fixed if you *really* want to. If it throws a strange error that you've never seen before, check that you've got the GPIO module loaded.

I'm not a RISC OS expert (I've only been using it for about a week now) so I can't offer much in the way of advice, as I'm learning myself. I've not used BASIC for about 25 years or so either... I've managed to get the C test programs to compile, but they don't work, as they reference the /dev/mem directory which doesn't exist in RISC OS. I may put a bit of effort into trying to convert these, or I may just carry on in BASIC and relive my lost youth.

Anyway. It works for me. Hope you enjoy it.
--
nr.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2848
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Gertboard, RISC OS and BASIC

Tue Nov 20, 2012 10:32 pm

DEF_PROC and END_PROC

takes me back 30 years to typing in all those Beebug games, which I could never get working. :D

Excellent work nr. Keep going - you know you want to :lol:
Alex Eames RasPi.TV, RasP.iO

User avatar
Burngate
Posts: 5967
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Gertboard, RISC OS and BASIC

Wed Nov 21, 2012 10:31 am

alexeames wrote:DEF_PROC and END_PROC
What's with your under-scores?

User avatar
[email protected]
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: Gertboard, RISC OS and BASIC

Wed Nov 21, 2012 2:32 pm

If you want to play with the Gertboard it in BASIC under Linux, then my Return to Basic will work fine ;-)

The light chaser is:

Code: Select all

//
// Light chaser - first 8 GPIO LEDs
//
FOR i = 0 TO 7 CYCLE 
  PinMode (i, 1) // Output
  DigitalWrite (i, 0)
REPEAT 
//
CYCLE 
  //
  // Cycle down the ladder board
  //
  FOR i = 0 TO 7 CYCLE 
    PROC doLed(i)
  REPEAT 
  //
  // and back up again
  //
  FOR i = 7 TO 0 STEP -1 CYCLE 
    PROC doLed(i)
  REPEAT 
  //
REPEAT 
END 
//
// doLed:
//    Light an LED for a period of time
//
DEF PROC doLed(led)
DigitalWrite (led, 1)
WAIT (0.1)
DigitalWrite (led, 0)
WAIT (0.1)
ENDPROC 
simples ;-)

https://projects.drogon.net/return-to-basic/

-Gordon
--
Gordons projects: https://projects.drogon.net/

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2848
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Gertboard, RISC OS and BASIC

Wed Nov 21, 2012 5:53 pm

Burngate wrote:
alexeames wrote:DEF_PROC and END_PROC
What's with your under-scores?
Told you the programs never worked. :lol:
Alex Eames RasPi.TV, RasP.iO

nr.
Posts: 144
Joined: Wed Oct 03, 2012 8:51 am
Location: The Fens
Contact: Website

Re: Gertboard, RISC OS and BASIC

Fri Jan 25, 2013 1:23 pm

I now have a WIMPified version of the RISC OS LED chasing program in case anyone is interested, available from http://www.ronketti.org.uk/

The WIMP stuff is done using the RISC OS DrWimp framework, which makes building WIMP enabled applications in BASIC simple, even for a confirmed non-programmer such as myself. (This is a polite way of indicating that there are any number of bugs in my code that are likely to crash your pi, set fire to your cat, or cause an unexplained plague of frog in your neighbourhood).

Ta,
--
nr.

nr.
Posts: 144
Joined: Wed Oct 03, 2012 8:51 am
Location: The Fens
Contact: Website

Re: Gertboard, RISC OS and BASIC

Tue Jan 29, 2013 8:06 pm

Just in case anyone is still reading this thread, there's now a version of the Buttons program WIMPified and available from the linkie above.

This was slightly more interesting to code, as WIMP applications typically stop and wait for the user to click on something before they do any processing. Which of course is no good when you're listening for input from a GPIO pin. And as RISC OS isn't pre-emptive, I had a few unplanned reboots when I stuck it in a tight loop polling the GPIO without ceding control at any time back to other tasks... So, with a bit of reading I found that the WIMP tool I'm using (DrWIMP) has a routine called PROCuser_null that is called whenever the WIMP is idle, as long as you set variable NULL% to TRUE. So, I just use this routine to poll the GPIO pins.

All seems to be well so far. Anyway - be happy to hear of any bugs, just on the offchance that anyone else is looking at this.
--
nr.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2848
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Gertboard, RISC OS and BASIC

Tue Jan 29, 2013 10:49 pm

nr. wrote:Just in case anyone is still reading this thread
I am :D Haven't tried RISC OS yet though. Keep it up :)
Alex Eames RasPi.TV, RasP.iO

User avatar
Gert van Loo
Posts: 2482
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertboard, RISC OS and BASIC

Tue Jan 29, 2013 10:56 pm

Just in case anyone is still reading this thread,
I have to read every thread in the Gertboard forum of course.
Same as below: I have not tried Risk OS yet.
I have not even tried the Python Gertboard SW yet. Too many things going on.
I recently counted them: I have 6 Pi-related HW projects in parallel which I am responsible for or have to look at on a regular basis.

Bakul Shah
Posts: 320
Joined: Sun Sep 25, 2011 1:25 am

Re: Gertboard, RISC OS and BASIC

Thu Jan 31, 2013 10:23 pm

Gert van Loo wrote:I recently counted them: I have 6 Pi-related HW projects in parallel which I am responsible for or have to look at on a regular basis.
Tell us more, Gert!

doglitbug
Posts: 7
Joined: Sat Sep 03, 2011 9:18 am

Re: Gertboard, RISC OS and BASIC

Sun Jun 16, 2013 10:41 am

Thread still being read!

User avatar
Gert van Loo
Posts: 2482
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertboard, RISC OS and BASIC

Sun Jun 16, 2013 12:23 pm

On the Design-West conference in April I disclosed the GertDuino.
Prototype is working and coming to a theater near you soon.

-- Gert
Attachments
pictt.JPG
pictt.JPG (203.6 KiB) Viewed 6093 times

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2848
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Gertboard, RISC OS and BASIC

Thu Jun 20, 2013 9:18 pm

I caught Drew's tweet about that, but apart from that there's been virtually no info leaked out about it. :lol:
Alex Eames RasPi.TV, RasP.iO

User avatar
liz
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 5201
Joined: Thu Jul 28, 2011 7:22 pm
Contact: Website

Re: Gertboard, RISC OS and BASIC

Thu Jun 20, 2013 9:19 pm

If you're interested in learning more, I heartily suggest attending the next Cambridge Raspberry Jam. ;)
Director of Communications, Raspberry Pi

User avatar
Gert van Loo
Posts: 2482
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertboard, RISC OS and BASIC

Thu Jun 20, 2013 10:02 pm

alexeames wrote:I caught Drew's tweet about that, but apart from that there's been virtually no info leaked out about it. :lol:
The reason is that we did not want to set too high expectations until the productions was a bit more secure.
e.g. It still has to go through EMC testing and if that fails it would set us back probably a month or maybe even two.
Prototypes are being made in China as we speak. (Not exactly "as we speak" as it is currently 5 am in China.
That is a bit early even for them)

I will bring my own had-soldered prototype to the Cambridge Jam and I have been told to make a little presentation.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2848
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Gertboard, RISC OS and BASIC

Fri Jun 21, 2013 6:35 am

liz wrote:If you're interested in learning more, I heartily suggest attending the next Cambridge Raspberry Jam. ;)
I will if I'm about. I expect it'll be while I'm in Poland for the summer though :( unless I bribe Mike to delay it. :lol:
Alex Eames RasPi.TV, RasP.iO

DaveTheWalker
Posts: 36
Joined: Wed Jul 04, 2012 9:06 pm

Re: Gertboard, RISC OS and BASIC

Wed Nov 20, 2013 9:21 am

Hi Gert,

I noticed that Farnell are now advertising the Gertuino....but there's still no data on it! Can you spill the beans yet?

Dave


User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12110
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Gertboard, RISC OS and BASIC

Wed Nov 20, 2013 10:16 am

Yes, including that you can see the non fitted (optional) SMTP in the picture, (the ugly dark picture on the farnell sales page still has it if you look closely).

I do note a spelling mistake
"The Gerduino board also has a RS232 level converter which will convert the signals form a UART to the RS232 standard voltages".

Return to “HATs and other add-ons”