dgelman
Posts: 14
Joined: Mon Sep 17, 2012 2:08 pm

RTOS?

Tue Sep 25, 2012 6:31 pm

Hello,

I have Raspbian on my RPi but I would like to aim for a RT OS. Can RPi support such demands? It has a high processor speed and having a RTOS would be just lovely. I can always go to either a Beaglebone or Arduino but I would really like to see if the RPi can run it. I am doing some data acquisition at a rate of +3KHz with critical timing.

Any thoughts?

Danny

User avatar
joan
Posts: 15622
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: RTOS?

Tue Sep 25, 2012 6:51 pm

Perhaps you don't need a RTOS. How will the 3kHz data be presented to the Pi? e.g. serial link, network, gpio pins. How critical is the timing?

dgelman
Posts: 14
Joined: Mon Sep 17, 2012 2:08 pm

Re: RTOS?

Tue Sep 25, 2012 7:16 pm

I havent gotten to that point just yet. I know that I have multiple (3) input encoders as well as a number of outputs to a number of servo drivers. I have many input and output pins in which exceeds the number of GPIOs that the RPi has but Ill deal with that later. I can just use a serial link but I need to know the thru-put if it can keep up with the data.

I haven't had much experience with an application like this without an RTOS so I am sceptical. Previously, my work included LabVIEW RT on a PC which was quiet nice. This post was just curiosity, if the RPi can support a RTOS and if there are any available ones out there.

What are your thoughts? You probably have more experience with the RPi than I have. Have you encountered any troubles?

Danny

dgelman
Posts: 14
Joined: Mon Sep 17, 2012 2:08 pm

Re: RTOS?

Thu Sep 27, 2012 9:43 pm

Hello,

I have come to a realization that I do need real-time control. The timing for my application is critical and a general purpose operating system will probably not cut it. I cant seem to find any tutorials on real-time applications with the RPi as well as any real-time operating systems. I have multiple inputs and outputs as well as timed PWM in which I will need control with real-time responses over a wide time frame.

Essentially, are there any modules or OS that the RPi can run in which I can for know that certain activities are happening at certain clock cycles .. etc.

Thanks,
Danny

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: RTOS?

Thu Sep 27, 2012 9:45 pm

nope - not yet.

the approach I'm taking is to write my code in c and then try to migrate it to the bare metal with help and a bit of jiggery pokery.
Ostendo ignarus addo scientia.

ghans
Posts: 7885
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: RTOS?

Thu Sep 27, 2012 10:12 pm

Aren't there enough OSS RTOS around ?
Why can't we use them ??


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

User avatar
TonyD
Posts: 453
Joined: Thu Sep 08, 2011 10:58 am
Location: Newcastle, UK
Contact: Website

Re: RTOS?

Fri Sep 28, 2012 11:52 am

I've read about a Real Timer Linux kernel (RTLinux), I suppose that could be modified and used on the RPi.
Tony

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: RTOS?

Fri Sep 28, 2012 3:47 pm

My RTOS will be available soon, theres two parts to it at the moment, one a rtos with cli and gui, two a load one program, and use the built in function, that can be coded in asm, c, basic.
The above two projects will be one OS once i have finished the SD read/write driver i am working on at the moment.
You can try the RTOS here: http://www.dex-os.com/MinDos/PiDexOS.zip
Just stick the boot files, plus kernel.img on a fat32 formated sd card.
Image
or see here for for bare metal basic coding.
http://www.dex-os.com/DexBasic/DexBasic.htm
Here it running a step motor
http://www.youtube.com/watch?v=TL71Nac2 ... el&list=UL

NOTE: Not every usb keyboard works with the above OS's usb stack (about 50%)
Here is a example of the basic code, that is very simular to arduino coding
Flash led

Code: Select all

;*
;* Blink
;*
;* Basic raspberry pi example. Turns on an LED for one second,
;* then off for one second and so on.. we use the built in green
;* OK LED, gpio number 16 (see page 102 BCM2835 PDF)to keep things
;* simple.
;*                    
include 'DexBasic\DexBasic.inc'                   
                                                  
pinMode  GPIO16, OUTPUT                        
                                                  
LetsLoop:                                         
                                                 
digitalWrite  GPIO16, HIGH                    
delayMicroseconds  1000000                       
digitalWrite  GPIO16, LOW                         
delayMicroseconds  1000000                         
                                                 
goto  LetsLoop                                   
                                                  
align 4                                           
ProgramSize:                                       
ScreenBuffer:                                     
Batteries not included, Some assembly required.

User avatar
poglad
Posts: 100
Joined: Tue Jul 31, 2012 8:47 am
Location: Aberdeen, Scotland
Contact: Website

Re: RTOS?

Sat Sep 29, 2012 7:43 am

Wow, that DexBASIC looks fantastic! :D

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: RTOS?

Sat Sep 29, 2012 6:33 pm

poglad wrote:Wow, that DexBASIC looks fantastic! :D
Thanks poglad.
Batteries not included, Some assembly required.

User avatar
raspberrypiguy1
Posts: 379
Joined: Sun Sep 02, 2012 7:01 pm

Re: RTOS?

Sat Sep 29, 2012 8:13 pm

Glad to see you are getting your questions answered! ;)

The Raspberry Pi Guy
Matt, The Raspberry Pi Guy YouTube channel, author of Learn Robotics with Raspberry Pi, available now: http://mybook.to/raspirobots, Computer Science & Electronics Undergraduate at The University of Edinburgh

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: RTOS?

Sat Sep 29, 2012 9:56 pm

How does one write a conditional statement in DexBasic?
Ostendo ignarus addo scientia.

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: RTOS?

Sun Sep 30, 2012 8:39 pm

pygmy_giant wrote:How does one write a conditional statement in DexBasic?
At the moment you would do something like this

Code: Select all

include 'DexBasic\DexBasic.inc'               
val equ r0                                        
                                                  
pinMode  GPIO18, INPUT                         
pinMode  GPIO16, OUTPUT                            
                                                 
LetsLoop:                                          
delayMicroseconds  1000                         
digitalRead   GPIO18                               
cmp   val,1                                       
blt   TurnLedOn                                   
digitalWrite  GPIO16, LOW                         
goto  LetsLoop                                    
TurnLedOn:                                       
digitalWrite  GPIO16, HIGH                        
goto  LetsLoop                                     
Which is

Code: Select all

digitalRead   GPIO18 
Read the pin value

Code: Select all

cmp   val,1 
compare the value (val) to 1

Code: Select all

blt   TurnLedOn
Branch to TurnLedOn if val < 1

But i have also coded things like
IF condition-1 THEN
branch-1
ELSEIF condition-2 THEN
branch-2
ELSEIF condition-3 THEN
branch-3
. . .

ELSEIF condition-n THEN
branch-n
ELSE
else-branch
END IF

Which i will release soon.
Batteries not included, Some assembly required.

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: RTOS?

Sun Sep 30, 2012 9:17 pm

Thanks - will give it a whirl...

I note that Chibios has now been ported: http://www.raspberrypi.org/phpBB3/viewt ... OS#p185362

Spoilt for choice!
Ostendo ignarus addo scientia.

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: RTOS?

Sun Sep 30, 2012 10:44 pm

Although emotionally wary of asm, on second reading I appreciate there is an elegance to DexBasic in the way that it directly relates to the Pi's architecture. I guess the challenge to Dex is to paradoxically hide this whilst at the same time exposing it.

I believe that my ignorance and unfamiliarity with assembly language might give me a slight advantage in suggestig some ways in which the readability of the syntax might be improved for asm noobs.

If 'digitalRead GPIO18' in the code above was 'digitalRead_r0 GPIO18' then it could make more sense to some one like me.

I think DexBasic has value in both being a practical language and an introduction to assembly language.
Ostendo ignarus addo scientia.

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: RTOS?

Mon Oct 01, 2012 4:17 pm

pygmy_giant wrote:Although emotionally wary of asm, on second reading I appreciate there is an elegance to DexBasic in the way that it directly relates to the Pi's architecture. I guess the challenge to Dex is to paradoxically hide this whilst at the same time exposing it.

I believe that my ignorance and unfamiliarity with assembly language might give me a slight advantage in suggestig some ways in which the readability of the syntax might be improved for asm noobs.

If 'digitalRead GPIO18' in the code above was 'digitalRead_r0 GPIO18' then it could make more sense to some one like me.

I think DexBasic has value in both being a practical language and an introduction to assembly language.
Thanks pygmy_giant for your insight, the main problem with that is that part of the language is based on wiring programming language
http://en.wikipedia.org/wiki/Wiring_%28 ... latform%29
Which is what the arduino is programmed in, i have used a basic like language for things that where commonly coded in basic, but for read/writing to gpio its more common these days to be coded in wiring programming language.
So hopefully it will be easy to convert a arduino example, to the PI.
Just take your project as a example, i bet most of the examples are for the arduino ;)

Asm look very hard when you first see the language, but when you learn what those instruction do, you see how logical it is.
example r0,r1,r2 etc are just like variable's, but are are much faster to read/write and the names of the instructions are just shortened names
See here: http://www.heyrick.co.uk/assembler/qfinder.html
Batteries not included, Some assembly required.

kru64
Posts: 23
Joined: Tue Aug 28, 2012 8:57 am

Re: RTOS?

Mon Oct 01, 2012 5:15 pm

DexOS
in your example you use "digitalRead GPIO18"
but now works only digitalWrite, flat assembler don't understand digitalRead
(I use DexBasic.inc from your site, it's dated 31.07.12)

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: RTOS?

Mon Oct 01, 2012 6:22 pm

kru64 wrote:DexOS
in your example you use "digitalRead GPIO18"
but now works only digitalWrite, flat assembler don't understand digitalRead
(I use DexBasic.inc from your site, it's dated 31.07.12)
Sorry, i have not got round to releasing that tut, but here you go
http://www.dex-os.com/MinDos/test_read.zip
You will need to use the DexBasic.inc and the DexOS.bin from that zip for it to work.

It now uses GPIO0 in the example in the zip and there's a wiring diagram in the "Diagram folder".
Batteries not included, Some assembly required.

kru64
Posts: 23
Joined: Tue Aug 28, 2012 8:57 am

Re: RTOS?

Mon Oct 01, 2012 7:36 pm

DexOS
Now read GPIO works! But only with GPIO 0. When I try to change pin, for example
pinMode GPIO17, INPUT
...
digitalRead GPIO17
LED OK always shine

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: RTOS?

Mon Oct 01, 2012 8:00 pm

kru64 wrote:DexOS
Now read GPIO works! But only with GPIO 0. When I try to change pin, for example
pinMode GPIO17, INPUT
...
digitalRead GPIO17
LED OK always shine
That's because some pins are pulled high and some are pulled low
Please read the button part here: https://projects.drogon.net/raspberry-p ... -a-button/

That layout is designed for that pin, so you may need to change pcb layout including adding resisters, depending on the pin you chose.
But be careful, i chose that pin as it has a built in 1.8KΩ resister .
See page 102 in the pdf to see which pin is high or low
So in your case the pin is always low if button pressed or not.
Batteries not included, Some assembly required.

kru64
Posts: 23
Joined: Tue Aug 28, 2012 8:57 am

Re: RTOS?

Tue Oct 02, 2012 5:02 pm

DexOS
Of course, you are right. I forgot about the resistors.
Again, thank you.

kru64
Posts: 23
Joined: Tue Aug 28, 2012 8:57 am

Re: RTOS?

Fri Dec 07, 2012 3:42 pm

DexOS
Today I checked benchmarking. I wrote few times the following sequence
digitalWrite GPIO8, LOW
digitalWrite GPIO8, HIGH...
I measured square wave and found only 500 Khz. This speed is very low for RTOS!
Compare with the results in usuall C:
http://codeandlife.com/2012/07/03/bench ... pio-speed/

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: RTOS?

Tue Dec 11, 2012 12:30 am

kru64 wrote:DexOS
Today I checked benchmarking. I wrote few times the following sequence
digitalWrite GPIO8, LOW
digitalWrite GPIO8, HIGH...
I measured square wave and found only 500 Khz. This speed is very low for RTOS!
Compare with the results in usuall C:
http://codeandlife.com/2012/07/03/bench ... pio-speed/
Hi kru64,
You seem to miss understand what a RTOS is, it does not mean its fast or faster than a none real time OS, it means a real-time OS is valued more for how quickly or how predictably it can respond than for the amount of work it can perform in a given period of time.

Also the latest ver (not released yet), is much more optimized ;) .
Batteries not included, Some assembly required.

Return to “General discussion”