Results for
Title pretty much explains it. I can control a TMC2209 Stepper Motor controller or a BMP280 Barometric Pressure device, but when I hook both up to one MEGA if fails. Help would be greatly appreciated. The goal is to sample the barometric pressure, run a vacuum pump to bring the pressure down inside a vessel, then bring the pressure back to the sampled value and then run stepper motors with the TMC2209.
#include "SparkFunBME280.h"
//Stepper driver pin definitions #define PIN_STEP_ENABLE 14 #define PIN_STEP1_DIRECTION 13 #define PIN_STEP1_STEP 12
BME280 mySensorA; //Uses default I2C address 0x77 BME280 mySensorB; //Uses I2C address 0x76 (jumper closed)
void setup() { //Configuer stepper driver pins as OUTPUTs pinMode(PIN_STEP1_DIRECTION, OUTPUT); pinMode(PIN_STEP1_STEP, OUTPUT); pinMode(PIN_STEP_ENABLE, OUTPUT);
//ENABLE pin has to be pulled LOW for TMC2209 digitalWrite(PIN_STEP_ENABLE, LOW);
//Serial.begin(115200);
//Wire.begin();
mySensorA.setI2CAddress(0x76); //The default for the SparkFun Environmental Combo board is 0x77 (jumper open). //If you close the jumper it is 0x76 //The I2C address must be set before .begin() otherwise the cal values will fail to load.
if(mySensorA.beginI2C() == false) Serial.println("Sensor A connect failed"); //if I remark out his line and the line //like it for SensorB ( 2 lines down ) the stepper will run but I get no pressure readings, I stopped getting pressure //readings as soon as I added the code to operate the TMC2209
mySensorB.setI2CAddress(0x76); //Connect to a second sensor if(mySensorB.beginI2C() == false) Serial.println("Sensor B connect failed");
Wire.begin(); Serial.begin(115200);
}
void loop() { //determine starting direction of Stepper digitalWrite(PIN_STEP1_DIRECTION,HIGH);
// Makes 200 pulses for making one full cycle rotation for(int x = 0; x < 2000; x++) { Serial.println(" Forword "); digitalWrite(PIN_STEP1_STEP,HIGH); delayMicroseconds(50); digitalWrite(PIN_STEP1_STEP,LOW); delayMicroseconds(50); } delay(1000); // One second delay
digitalWrite(PIN_STEP1_DIRECTION,LOW); //Changes the rotations direction // Makes 400 pulses for making two full cycle rotation for(int x = 0; x < 2000; x++) { Serial.println(" Reverse "); digitalWrite(PIN_STEP1_STEP,HIGH); delayMicroseconds(50); digitalWrite(PIN_STEP1_STEP,LOW); delayMicroseconds(50); } delay(1000);
Serial.print(" PressureA: "); Serial.println(mySensorA.readFloatPressure(), 0);
//Serial.print(" PressureB: "); //Serial.println(mySensorB.readFloatPressure(), 0);
Serial.println();
delay(500); }