Main Site Documentation

Why are G120 so extremely slow?


#1

I have made a project where I couldn’t understand why the code is executing so slow. Then I tried to made a blank project where I just put a GPIO High/Low in a while loop using .NET Framework . This is executing at only 4.65 kHz!

Why use a 120 MHz processor when it is so slowly? What is the other 119 MHz used for?


#2

Can you post your code?


#3
        

public static void Main()
        {
            OutputPort IOtest;
            IOtest= new OutputPort(Pin.P1_10, false);

            while (true)
            {
                IOtest.Write(true);
                IOtest.Write(false);
            }
        }

#4

We’ve been here before. Netmf is NOT a real time system. Toggling a pin is not a sensible test.


#5

In 90% off all project I have made, there are sampling from some kind of sensor and then an algorithm that determent outputs for motor controller ect.

How do you normally run fast executing code in Netmf? Including C or assembly?

The reason for this thread are my current project where I control a step motor with my own software algorithm driver.


#6

RLP is the solution for such algorithms. But if you detail what you are trying to crate we can tell you if NETMF is the right solution or not.

I have seen commercial designs where a little micro is added to handle the little but time sensitive things and then NETMF was used for the high level things, like the user interface and networking. This depends entirely on what you are making.


#7

He is not running a ‘Real-Time’ system. This seems like a reasonable method to test how fast module runs. EDIT :- I didn’t see LARSC reply before posting. He IS trying to run a Real-Time system from NETMF. The G120 uProc does have dedicated motor control hardware peripheral but I do not know how to use it.

I tested this myself with slightly modified code and got 9KHz rather than 4.5KHz…I also measured about 33KHz when running a loop of a single integer addition or multiplication.

What I will say is that small functions like these are dominated by the interpreter overhead. More complex function such as say Bitmap.Flush() are much more comparable to the performance you would get when writing native code.

You can use RLP to boost the performance of critical code segments if you need.


#8

Some of the system have to be Real Time.

The system I work with are divided into control of stepper motor, which must run in real time. The second part of the system is Bluetooth, Ethernet, GSM communication.

I do not know of RLP, it sounds useful. what is this and how is it used. Are there a thread which you can recommend.


#9

RLP is a GHI specific way to use C code on a NETMF device.
You can create an elf file for the processor (by using yagarto tool chain.
You can then run these C functions from NETMF code.
When a RLC C function is running, the NETMF interpreter is stopped.
You can also create native C interrupts, which are as accurate as the processor allows.
These interrupts will also stop the NETMF interpreter (means all managed threads) until the ISR has exited.

You can start here:
https://www.ghielectronics.com/docs/50/rlp-enhanced

A simple working sample for NETMF 4.2 and G120 is here:
https://www.ghielectronics.com/community/codeshare/entry/843


#10

These link should get you started with RLP
https://www.ghielectronics.com/docs/50/rlp-enhanced
https://www.ghielectronics.com/docs/151/rlp-realtime-audio-recording#1399

The audio recording example is probably closest to what you want to do as it also needs to run in the background without blocking other things.


#11

Thank you everybody.

I will look into RLP in the weekend :wink:


#12

BTW Yagarto seems to no longer be in development. You can download the latest version of the Tool Chain from sourceforge http://sourceforge.net/projects/yagarto/

emIDE looks good and much nicer than YAGARTO, but im not sure how to configure it to generate ELF files for RLP. Has anyone used this yet? Maybe someone could submit an example emIDE solution to codeshare?


#13

EmBlocks works even better.


#14

https://www.ghielectronics.com/community/codeshare/entry/895