Jump to content

ContinuousAcceleration16BitCallback für Accelerometer Bricklet 2.0 in Matlab


Recommended Posts

Hallo. Kann jemand dieses Programm ändern. Ich brauche ein Programm, das jeder 0.5ms ein Beschleunigungsdata von Achse[X] zeigt. Bitte nutzen Sie  ContinuousAcceleration16BitCallback in der Sprache vom MATLAB. Vielen Dank.

 

function matlab_example_callback()
    import com.tinkerforge.IPConnection;
    import com.tinkerforge.BrickletAccelerometerV2;

    HOST = 'localhost';
    PORT = 4223;
    UID = 'XYZ'; % Change XYZ to the UID of your Accelerometer Bricklet 2.0

    ipcon = IPConnection(); % Create IP connection
    a = handle(BrickletAccelerometerV2(UID, ipcon), 'CallbackProperties'); % Create device object

    ipcon.connect(HOST, PORT); % Connect to brickd
    % Don't use device before ipcon is connected

    % Register acceleration callback to function cb_acceleration
    set(a, 'AccelerationCallback', @(h, e) cb_acceleration(e));

    % Set period for acceleration callback to 1s (1000ms)
    a.setAccelerationCallbackConfiguration(1000, false);

    input('Press key to exit\n', 's');
    ipcon.disconnect();
end

% Callback function for acceleration callback
function cb_acceleration(e)
    fprintf('Acceleration [X]: %g g\n', e.x/10000.0);
    fprintf('\n');
end

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...