Skip to content

Examples

Filies Olaf (IFAG DES TCP PSA) edited this page Feb 4, 2021 · 4 revisions

Examples

List of examples

To run this examples use either the Arduino IDE or something similar like the PlatformIO module for code or atom

  • readAngleSpeedRevolutions - prints the rotation speed and number of revolution fast
  • readAngleTest -
  • readAngleValueProcessing - prints the angle vale fast
  • readMultipleRegisters - shows how to fetch multiple registers with on call
  • sensorRegisters - reads all registers and prints there settings
  • sensorType - reads the registers and prints the sensor and interface settings
  • readSpeedProcessing - prints the rotation speed fast
  • useMultipleSensors - reads the angle value from multiple sensors (up to four)
  • writeRegisters - show how to read and write sensor registers
  • testSensorMainValues - test Sketch on all main sensor data
  • E9000SPC - special Sketch shows how to handle the E9000 variant with SPC interface

readAngleSpeedRevolutions

This example reads the angle, the angle speed and the number of revolutions all together and prints them out.

This example will show how to:

  • read out of all major sensor values

readAngleValueProcessing

This example can be used standalone or together with some of the processing examples (Ball_Bat.pde, Bouncing_Ball_Game.pde, Circle.pde, Make_Spiral.pde, pong.pde, SnakeGame.pde, Snake_Like_Game.pde). If used as standalone set the baud rate of the console to 1000000 bytes/s. The sensor will now print out the angle value.

This example will show how to:

  • read out the angle value
  • connection of the readout with processing

readSpeedProcessing

This example can be used standalone or together with the processing game speed.pde. If used as standalone set the baud rate of the console to 1000000 bytes/s. The sensor will print out the angle speed value. Therefore use the rotating knob or something similar. The angle speed is calculated from the angle value inside the digital processing unit of the TLE5012, but due to this calculation the resolution and the possible error width is much greater than for other values. This can be seen in the output values which will vary a little bit. This can be minimized by using certain register functions (see TLE5012B manual).

This example will show how to:

  • read out of the angle speed value
  • connection of the readout with processing

readMultipleRegisters

Reads a bunch of registers with the readMoreRegisters function. This function allows to read several registers at once but without fetching each single content value. This function can be used in programms where the interpretation of the data is done outside the library and only a fast access to certain registers is needed.

This example will show how to:

  • use the readMoreRegisters function

sensorRegisters

This example reads all registers and prints out its content as a bit matrix and as an interpreted output. This kind of example need a lot of memory on the MCU, so it will not run on the original Arduino/Genuino and other MCUs with a low amount of memory.

This example will show how to:

  • handle each register function

sensorType

This function reads out all register values and prints them in a bit matrix, which represents the actual state. It also interprets some of the main registers, so that the sensor default interface type will written in words together with the most important function settings of this sensor type. Use this script to check which interface type your sensor as, because you can not get this information from the PCB board or anywhere from the silk screen. Take this example on how read and check the main sensor settings with the register functions. This example can work also on the original Arduino/Genuino with a low amount of memory.

This example will show how to:

  • read and check the sensor functions
  • to read the sensor interface type
  • to use the register functions

useMultipleSensors

This example need at least two or up to four TLE5012B sensors on own SPI interface. It shows how to address each of the sensors and how to programm them. The example is set to be used only with one sensor, so follow the instructions to use multiple sensors.

This example will show how to:

  • handle up to four sensors on the same SPI interface

writeRegisters

This example demonstrates how to write data to certain registers. Some of the sensor registers can be written, so that certain functions are switched on or off. Also the type of the default interface can be overridden until next power of or firmware reset. See at the TLE5012B manual for further information which registers can be written.

This example will show how to:

  • write registers with certain values

testSensorMainValues

Ths example is for a first test of the sensor. It prints most of the important values, so that the basic functionality can be check.

This example will show how to:

  • check the basic work of the sensor

E9000SPC

This is a special example the the TLE5012B-E9000 type of sensor. The SPC interface of this sensor type will not deliver any value until it is triggered with a certain timed signal, so almost all examples will deliver only a zero value. Please use the sensorType before, to test which interface type you have. This example will only work proper if the SPC interface type is set.

This example will show how to:

  • programm the E9000 SPC type of the TLE5012 sensor

readAngleTest

Short test script just for printing the angle value with slow speed and minimal memory usage.

This example will show how to:

  • only the angle value

Processing files

Use this link for using Processing. All of this examples need either the readAngleValueProcessing.ino or the Read_Angle_Value_Processing.ino sketches to be running. See the explanations inside the source code.

  • processing/Ball_Bat/Ball_Bat.pde
  • processing/Bouncing_Ball_Game/Bouncing_Ball_Game.pde
  • processing/Circle/Circle.pde
  • processing/Make_Spiral/Make_Spiral.pde
  • processing/pong/pong.pde
  • processing/Snake/SnakeGame/SnakeGame.pde
  • processing/Snake_Like_Game/Snake_Like_Game.pde
  • processing/speed/speed.pde

Read the header of the games which kind of sensor script is needed to be running before starting the processing script. Also check the baud speed used in the game and the script, it should be 1000000 bytes/s for all of them.