Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

Motivation

There are some challenges building up the code structure that will run on the Arduino:

  1. Create an exchangeable interface that offers all methods, which are required to communicate with the hardware and environment.
    The benefit from this is, that the interface can be chosen depending on the sensors and if the flight is real or simulated.

  2. Make sure that within a single tick some sensor value is not measured multiple times just because it is requested on several occasions.
    This is important because every measurement takes time and consumes power. For that reason the above-mentioned interface should serve a resetTick function to know when a new tick hast begun. 

  3. Perform the implementation of the SCCharts-generated code as simple as possible.
    The Arduino code provides a setup method and a loop method, which are equivalent to the reset function and the tick function in SCCharts. Though KIELER can easily create some Arduino code out of any SCChart, important host code is missing:
    • At the very beginning of the Arduino code some dependencies like libraries and the interface need to be included.
    • Before every new tick the interface must be notified.


Basic Arduino sketch

QuadcopterController

#include "CompInterface.h"
#include "FlightController.h"
CompInterface comp;

void setup() {
  reset();
}

void loop() {
  comp.resetTick();
  tick();
}

This file is not generated by KIELER. It includes the interface header and the header of the SSCharts-generated FlightController, which will be output in c, not explicit for Arduino.

In the setup and loop methods the reset and tick functions of the FlightController are triggered, while before the tick function the instanced CompInterface is notified about a new tick.

CompInterface.h

#ifndef CompInterface_h
#define CompInterface_h
#include "Arduino.h"
#include "HardwareConnector.h"
#include "SimulationConnector.h"
class CompInterface {
  private:
  boolean simulation;
  
  public:
  CompInterface();
  void resetTick();
  void simulate(boolean active);
};
#endif

This file is not generated by KIELER. It includes the interface header and the header of the SSCharts-generated FlightController, which will be output in c, not explicit for Arduino.

In the setup and loop methods the reset and tick functions of the FlightController are triggered, while before the tick function the instanced CompInterface is notified about a new tick.

  • No labels