How to get a list motor angles into an Arduino to drive a motor

Hello all!

I am currently working on a project involving IMU testing.

Basically we have built a gyroscope and written code to simulate the orientation of an object in flight between Earth and Jupiter. The code gives us 2 long (hundreds) lists of small angles.

We want to take each list and "feed" it into the Arduino which will control two respective stepper motors that will turn to simulate the flight orientation.

I've never used Arduino before but it's what we have. We have the Arduino connected to the motor drivers and the drivers connected to the motors. The final bottleneck is actually turning them how we want!

Currently our angles are in a 2 column csv/excel file. What is the best way to go about importing the angles we have into the Arduino? Thanks in advance for any suggestions!

Edit: Adding More Info to Better Follow Guidelines

We have:
An Arduino Uno
Two 3540M Stepper Drives
Two Lin Engineering W0-416-05-04 Motors

Using a power supply for the motors and just plugging the ardunio into a computer I think?

Roughly 300 values, they should just be floats (not sure but should be easy to switch)

The data won't change as the code is executing, we have generated all the angles we need and now want the motors to step through each angle.

How are the tables related to the motors? DC motors are not very useful in outer space :wink:

viveyves:
Currently our angles are in a 2 column csv/excel file. What is the best way to go about importing the angles we have into the Arduino?

That depends on what Arduino and other hardware you have. If you have a device with enough memory you could just convert your data into a header file and compile it into your code.

Another option is to use SDcard. They are fairly easy to use. There are simple module for the hardware side (micro SD) and they connect via SPI peripherals and are supported by a simple library.

Here is a link to the library reference with examples

https://www.arduino.cc/en/reference/SD

We need to know exactly what motors, drivers and Arduino board you have.

How is everything powered (motor power supply and Arduino power supply).

How many values are there? What are their data types? Will the data change while the code is executing?

What is the best way to go about importing the angles we have into the Arduino?

 const uint32_t angleSequence [] PROGMEM = {
#include "angleFile.csv"
};

groundFungus:
We need to know exactly what motors, drivers and Arduino board you have.

How is everything powered (motor power supply and Arduino power supply).

How many values are there? What are their data types? Will the data change while the code is executing?

Sorry that’s my bad. I believe we have:
An Arduino Uno
Two 3540M Stepper Drives
Two Lin Engineering W0-416-05-04 Motors

We are using a power supply for the motors and just plugging the ardunio into a computer I think?

There are roughly 300 values, they should just be floats. The data won’t change as the code is executing, we have generated all the angles we need and now want the motors to step through each angle.

Thanks again and sorry for the confusion!

viveyves:
We are using a power supply for the motors and just plugging the ardunio into a computer I think?

If the Arduino stays connected to the PC you can also send the data in real time.

viveyves:
There are roughly 300 values, they should just be floats.

If you store the data on the Arduino I would recommend you convert the float data into smallest data type required for control. Float is a 32-bit data type. You do not need that ever for a couple of steppers.

I don’t know how much help this might be, but here is a short program using the Accelstepper library that sends a stepper to different positions at set speeds using and array of positions and an array of speeds.

#include <AccelStepper.h>

const unsigned int NUM_STEPS = 6;

unsigned int xArray[NUM_STEPS] = {0, 900, 650, 400, 650, 100};
unsigned int xSpeeds[NUM_STEPS] = {200, 2000, 200, 100, 400, 50};

const byte enablePin = 8;  // necessary for my CNC shield

AccelStepper stepper(AccelStepper::DRIVER, 2, 5);

void setup()
{
   Serial.begin(115200);
   pinMode(enablePin, OUTPUT);
   digitalWrite(enablePin, LOW);
   stepper.setAcceleration(2000);
   stepper.setMaxSpeed(200);
   stepper.setSpeed(200);
   stepper.setCurrentPosition(0);
}

void loop()
{
   static unsigned int index = 0;
   if (stepper.run() == 0)   
   { // stepper has reached position, load a new position and speed
      Serial.println(index);
      stepper.moveTo(xArray[index]);
      stepper.setMaxSpeed(xSpeeds[index]);
      index++;
      if (index >= NUM_STEPS)  // restart the sequence
      {
         index = 0;
      }
   }
}

Your stepper motors have 400 steps per full rotation. You can only move the motor to 1 of 400 positions or 1 of some integer multiple of 400 steps. You cannot move a stepper to some degree position. Compute the nearest step or 1/2 step or 1/4 step, or other multiple, depending on how you have controller set up.
Paul

Consider to convert your tables on the PC into something immediately usable by the Arduino. The result may be a table of steps and speeds for the transition between two angles?

Depending on your timing requirements you can use direct PC connection, SD card or internal or external flash or EEPROM.

DrDiettrich:
How are the tables related to the motors? DC motors are not very useful in outer space :wink:

Although it does make me wonder how many DC motors there are on the ISS…

a7

And these motors turn the ISS? :wink:

Maybe… for your spare time

https://llis.nasa.gov/lesson/893

all types of DC motors doing all kindsa work all over space.

a7

That's not different from the many motors inside modern cars. But due to the lack of friction the ISS can not be moved or turned by DC motors and wheels.

DrDiettrich:
But due to the lack of friction the ISS can not be moved or turned by DC motors and wheels.

You can use the conservation of momentum to create movement. By spinning a mass into one direction the ISS will rotate into the opposite direction. Because the spinning mass is smaller than the ISS, the rotation will be slower, but you can spin a mass with many rpm using a motor and create a considerable angular momentum.

Consider the ISS makes exactly one 360 degree rotation every time it goes around the earth.
Paul

The Hubble Space Telescope is positioned with motor driven reaction wheels that are sped up or slowed to point the telescope.

Paul_KD7HB:
Consider the ISS makes exactly one 360 degree rotation every time it goes around the earth.

The moon does the same, without any motors.

DrDiettrich:
The moon does the same, without any motors.

Well, maybe given a few billion years, so will the ISS - what’s your point?