#include <stdint.h>
#include <math.h>
#include <Wire.h>
#include "I2C_16.h"
#include "TMP006.h"
#include <Stepper.h>
uint8_t sensor1 = 0x40; // I2C address of TMP006, can be 0x40-0x47
uint16_t samples = TMP006_CFG_1SAMPLE; // # of samples per reading, can be 1/2/4/8/16
const int stepsPerRevolution = 200;
int a =0;
// initialize the stepper library on pins 8 through 11:
Stepper myStepper1(stepsPerRevolution, 3,4) ;
Stepper myStepper2(stepsPerRevolution, 6,7) ;
void setup() {
Serial.begin(9600);
Serial.println("TMP006 Example");
config_TMP006(sensor1, samples);
// set the speed at 60 rpm:
myStepper1.setSpeed(10);
myStepper2.setSpeed(10);
// initialize the serial port:
}
void loop() {
float object_temp1 = readObjTempC(sensor1);
Serial.print("Object Temperature1: ");
Serial.print(object_temp1); Serial.println("*C");
float sensor_temp1 = readDieTempC(sensor1);
Serial.print("Sensor Temperature1: ");
Serial.print(sensor_temp1); Serial.println("*C");
for (int b=0; b<2; b++) {
// step one revolution in one direction:
Serial.println("counterclockwise2");
myStepper2.step(-stepsPerRevolution);
delay(2000);
}
float object_temp = readObjTempC(sensor1);
Serial.print("Object Temperature2: ");
Serial.print(object_temp); Serial.println("*C");
float sensor_temp = readDieTempC(sensor1);
Serial.print("Sensor Temperature2: ");
Serial.print(sensor_temp); Serial.println("*C");
for (int b=0; b<2; b++) {
// step one revolution in one direction:
Serial.println("clockwise2");
myStepper2.step(stepsPerRevolution);
}
// step one revolution in one direction:
Serial.println("clockwise1");
myStepper1.step(10*stepsPerRevolution);
a++;
while (a==2) {}
}
The above code is what we have so far in trying to make a temperature sensor that spins horizontally and vertically. Theoretically, it should spin 180 degrees horizontally, take a temperature reading every 60 degrees, then spin 90 degrees vertically. However, only the horizontal arm is operating. Is there any apparent error in our code? It will operate without the temperature sensor, which doesn't make sense. Thank you!
Best to get each part of the project working first and then put it all together.
Since you don't describe any of the hardware, any other response would just be a wild guess.
I'd have to wait to return, but off the top of my head, we are using a TMP006 thermopile, a NEMA 17 stepping motor, and a Arduino Yun
You need to post links to the datasheets for your hardware. There are hundreds of different Nema 17 motors. Also, what stepper driver are you using.
These links may help
Stepper Motor Basics
Simple Stepper Code
...R
I need to check which NEMA 17 stepping motor we are using, but here are the links to the other hardware datasheets:
Thank you!
Do we also have to GUESS how you wired everything together?
The standard Stepper library is not suitable for a driver that takes step and direction signals - like your DRV8825, Try the much better AccelStepper library
...R
The Stepper library can be made to work with step/direction signals if you provide custom step functions,
but its much much better to use AccelStepper which gives smooth velocity profiles anyway and is easier to
use (non-blocking).
Hallo leute bin auf ein problem gestosen
Ich habe zwei schrit motoren die ich zu osziliren bringen (etemal mochte ich es mit einem hinkrigen) mochte aber die in gewisen grenzen einhalten das heist die sollen zwischen par schriten nach link und par schriten nach rechtz gehen und sich nur in der grenzte einhalten.
aber ohen jendliche probleme in den BEWEGUNGSZOHNE den motr frei nutzen konnen
ich hete es selbst gegugelt aber mir fehlen der richtige berif
so habe ich mir das forgesteld
BACKWARD BEWEGUNGSZOHNE FORWARD
_l---------O-----------l
Step.12 Axe Step.12
AF_Stepper motor1 (100,1);
void setup()
{
pinMode(13,OUTPUT);
motor1.setSpeed(300);
motor1.step(12,BACKWARD,INTERLEAVE);
motor1.step(12,FORWARD,INTERLEAVE);
for(int a=0; a<=100;a++);
{
motor1.step(12,INTERLEAVE);
}
}
void loop()
{
digitalWrite(13,HIGH);
}
DANKE
@Mario_Blu, this is the English language section of the Forum. There is also a German language section. I have suggested to the Moderator to move your own Thread to the German section.
...R
Thank you to everyone for your help! We were able to figure out the issue. In the end, the AccelStepper library was the better choice in running two stepping motors. Additionally, we realized that the thermopile was sharing an analog with one of the stepping motors, causing them to compete. Our project is now complete!