Tuesday Mar 12, 2013

RPi with an Oscilloscope and Java Embedded: Ready for Benchmarking (Part 3)

The first step in our investigation is to reproduce what Robert Savage saw in his benchmarking. See: Java GPIO Benchmarking

In his study, Robert Savage measured the Pi4J library on Oracle Java JDK 8 Preview for Linux/ARM yielding about 153 kHz on the Raspberry Pi GPIO output. So, following the scientific method, we should be able to reproduce the experiment.

And, with the following Java Embedded app on my RPi running with Oracle JDK 8 Preview for Linux/ARM and using my HP logic analyzer/oscilloscope I'm seeing about the same: 166 kHz. Click on the above photo to zoom in and look at the red circle area.

Here's the code I used:

/*
 * Example Code
 */

/*** Pi4J Core APIs ***/
import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiPin;

//...
            
 /*** Pi4J initialization ***/
 
 // Create Pi4J GPIO Controller
 final GpioController gpio = GpioFactory.getInstance();
        
 // Use Pi4J GPIO pin #05 (Header Pin #18) as an output and turn on
 final GpioPinDigitalOutput pin = 
         gpio.provisionDigitalOutputPin(RaspiPin.GPIO_05, 
         PinState.LOW);
 
 // Loop forever to create smallest PWM as possible
 while (true) {          
     pin.setState(true);
     pin.setState(false);
 }
 

And, Robert reports he can get around 5 MHz using C native. So, that's our goal. In the next blog posts we'll explore ways to get our 166 kHz score on the benchmark a lot higher, hopefully matching C native with 5 MHz...

About

Hinkmond Wong's blog on making Machine to Machine (M2M) and the Incredible Internet of Things (IoT) smarter with Java Embedded Technologies

Search

Archives
« March 2013 »
SunMonTueWedThuFriSat
     
1
2
3
5
6
9
10
11
13
15
16
17
19
20
22
23
24
25
26
27
29
30
31
      
Today