Alex Merchen
Published © GPL3+

Laziest Way to Pass Salt

I wanted to create a way to pass salt in the laziest way imaginable using the Infineon TLE493D 3D Magnetic Sensor 2GO.

BeginnerFull instructions provided2 hours1,187

Things used in this project

Hardware components

3D Magnetic Sensor 2Go
Infineon 3D Magnetic Sensor 2Go
×1
Arduino Pro Mini 328 - 5V/16MHz
SparkFun Arduino Pro Mini 328 - 5V/16MHz
×1
SparkFun Motor Driver - Dual TB6612FNG (1A)
SparkFun Motor Driver - Dual TB6612FNG (1A)
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Breadboard (generic)
Breadboard (generic)
×1
SparkFun Stepper Motor - 125 oz.in
×1
Male Header 40 Position 1 Row (0.1")
Male Header 40 Position 1 Row (0.1")
×1
Wooden Square Dowels
×1
Duct Tape
×1

Software apps and online services

Arduino IDE
Arduino IDE
Infineon Software for 3D Magnetic Sensor 2Go
Infineon J-Link Software

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Hand drawn diagram

Follow the wiring. it's pretty straightforward

Code

Main Code

Arduino
Arduino code for loading the project
#include <Stepper.h> 
#include <Tle493d_w2b6.h>

// change this to the number of steps on your motor
#define STEPS 800

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to

Stepper stepper(STEPS, 4,5,6,8);


/**
* This example demonstrates the use of low poewr mode of sensor TLE493d-W2B6
*/

double rotationPos = 0;

Tle493d_w2b6 Tle493dMagnetic3DSensor = Tle493d_w2b6(Tle493d::MASTERCONTROLLEDMODE);
void setup() {

  // set the speed of the motor to 30 RPMs
  stepper.setSpeed(10);
  
  Serial.begin(9600);
  while (!Serial);
  Tle493dMagnetic3DSensor.begin();
  // The highest adjustable range is used for all three directions, i.e., within half of the total value range INT is disabled 
  // this has no effect on the TLE493d-A2B6 sensor
  Tle493dMagnetic3DSensor.setWakeUpThreshold(1,-1,1,-1,1,-1);

  //The update rate is set to 3 (fastest is 0 and slowest is 7)
  Tle493dMagnetic3DSensor.setUpdateRate(3);

  
}

void loop() {
  Tle493dMagnetic3DSensor.updateData();
  // rotationPos is getting the polar degree that the dial is turned
  // I converted radians to degrees to be easier to read
  rotationPos = Tle493dMagnetic3DSensor.getAzimuth()*57.3 + 180;
  // Serial print it so that I can see that the system is working
  // correctly
  Serial.println(rotationPos);

  // If I turn it to the right it'll be around 90 degrees but I 
  // put in a tolerance of 45 degrees
  if (rotationPos > 45 && rotationPos < 135) {
    Serial.println("To The Right");
    stepper.step(200);
  }
  // I did the same tolerance for turning left
  else if (rotationPos > 225 && rotationPos < 315) {
    Serial.println("To The Left");
    stepper.step(-200);
  }

  delay(50);
}

Stepper Motor Test

Arduino
This is to verify your wiring for the stepper motor portion
#include <Stepper.h>

// change this to the number of steps on your motor
#define STEPS 400

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 4, 5, 6, 8);


void setup()
{
  Serial.begin(9600);
  Serial.println("Stepper test!");
  // set the speed of the motor to 30 RPMs
  stepper.setSpeed(60);
}

void loop()
{
  Serial.println("Forward");
  stepper.step(STEPS);
}

Credits

Alex Merchen

Alex Merchen

24 projects • 39 followers
I'm an EE with a Masters in ECE. I like building things.

Comments