Hello everyone, I have run into an issue that I don't know how to solve.
Overview: Similar to what the title says, I am trying to rotate a 2-axis gimbal (azimuth and elevation) that locates the highest signal gain with a directional antenna.
Components:
1x ESP8266 with a directional antenna spliced into it
2x Nema 17 Stepper Motors (1.8 degree/step)
1x MPU6050 Accelerometer & Gyroscope
2x DM332T MicroStepper Drivers
Libraries (not all of the libraries we're incorporating, but just wanted to show the big/main ones):
AccelStepper.h
MPU6050.h
wire.h
ESP8266WiFi.h
Parameters:
Max Range = 0-120 degrees along either axis
Microstepper Driver steps per revolution = 12800steps/rev
Max steps to complete 0-120 range of motion = 5,534
Theoretical Function:
My vision is to write a program that has multiple scan functions to quickly lock in on the highest signal gain. For example, start the program with the motors at the HOME/STARTING, call this A0, E0, position (0 positions in both azimuth and elevation axis). Read the initial RSSI value at the starting position, move 1,107 steps (call this A1), save and compare this RSSI value to initial value, if larger, then save this as the currentMaxRSSI value and repeat (A1 to A2 to A3.. all of which are 1,107step intervals); if not, then go back to the initial value (or newest max value) and begin a similar scan sequence along the Elevation axis (E0 to E1 to E2..).
This would be a broadScan, which would locate a general area of roughly 48 degrees (1107 steps = 24degrees). This would lead to a tighter scan or scan of a smaller area to really pinpoint the highest signal gain.
Issues:
I have no clue how to double integrate the accelerometer and gyroscope to save stepper motor position or even really how to save the position (if you even have to double integrate).
There would need to be plenty of delays to move the motor, save and compare RSSI values, convert acceleration and angular acceleration to position, save position with corresponding RSSI value, and then repeat.
How to filter accelerometer/gyroscope feedback/noise
How to minimize drift
I don't know if this actually feasible to code (I'm an ME student with limited arduino and C++ experience.
These are all of the issues I can think of at the moment.
I can post the chunk of code I've been using upon request, but as of right now, each chunk of code works fine for its single intended function (I.e. chunk of code to run two motors; chunk of code to detect and display RSSI values in serial monitor; chunk of code to display accelerometer/gyroscope values. I have yet to try and integrate everything into a single sketch yet - I wanted to test everything individually and make sure they worked as intended before I made this a large sketch.
why do you need an accelerometer to position a stepper motor? why not move the stepper motor the desired # of steps, possibly wait a moment for any vibration to die out, make a measurement, possibly update the best measurement and repeat for the next position.
I second that. If your stepper-motors have a reference-point you detect the reference-point and all positions are a well defined number of steps away from the reference point.
For finding the max You could use the halving method.
If you antenna can move in the borders of a half sphere.
You devide this half-sphere into four sections
You would move the antenna to the beginning of that section and then turn analysing if the RSSI becomes higher.
If RSSI is higher in the left half you go on with the left half
If RSSI is higher in the right half you go on with the right half
You would do this for certain angles and if the left/right position is determined
doing the same for the angle
Doing all in steps with each function on its own is a very good idea.
easiest thingh is to print the RSSI-value to the serial monitor
why do you need an accelerometer to position a stepper motor? why not move the stepper motor the desired # of steps, possibly wait a moment for any vibration to die out, make a measurement, possibly update the best measurement and repeat for the next position.
Using the accelerometer to save position in case the motor skips/slips/oversteps, because the motor is moving a fairly heavy load in multiple orientations. Also, I want to go through the scan function and inevitably return to the max RSSI position and later the starting position.
This isn't for an at-home DIY project, we're presenting this to a company and I'd like it to be as professional as possible. In my mind, saving positions and preset positions make the project seem more automated, thus more professional.
You would move the antenna to the beginning of that section and then turn analysing if the RSSI becomes higher.
If RSSI is higher in the left half you go on with the left half
If RSSI is higher in the right half you go on with the right half
I actually really like this idea! It would make the scan function a bit faster, thus reducing the extended load time on our motors.
What type of aerial you design to use for this "best RSSI" search function?
it is un-professional to use stepper-motors that loose steps.
The professional way is to use stepper-motors of a size that is big enough to always deliver enough torque to not loose steps.
For professional applications low price is not the first priority.
First priority is reliability. You could use closed-loop servo-motors which don't loose steps because servomotors have position-feedback.
There are servomotors of many sizes smaller and bigger with the closed-loop-controller mounted on the motor. You just optimise parameters to adapt the controller to the mechanics properties.
These servomotors have a perfomance that your biggest concern will be how to design the mechanic stiff enough that the mechanic does not start to oscillate or to bend.
Referencing the reference-point of the stepper-motors.
Driving slow enough to not loose steps.
With the accelstepper-library or the mobatools-library you can retrieve the momentary position measured as distance to the reference-point at any time.
You can even retrieve how many steps are left to go until target-position is reached.
Stepper-motors work this way:
create a single step-pulse motor rotates a well defined angle. Usually 1.8 degree as a full-step.
And it doesn't matter if you create the step-pulse one single pulse once every hour or 500 step-pulses every second. The rotation-angle per step is always the same.
The DMT332-datasheet says
8 selectable micro-step resolutions of 400-12800 via DIP switches
not sure what this exactly means 12800 steps per revolution for a standard 1.8 degree/fullstep steppermotor
so a maxumim resolution of 360° / (200*12800) = 0.000140625 degrees per step
Each step = rotate the same amount of degree
which means you always know the position at very high precision.
And this precision is higher than you can achieve by measuring the gravity-vector with an MPU6050
Saving a position and presetting a position is nonsense unless you first determine a starting position. Also all stepper motors begin on full steps when power is first applied. Then they can be moved fractional steps from there, if you want.
Hi,
Are you aiming to detect any WiFi or a particular WiFi device direction?
We will have an access point setup some distance away from our device. The antenna and access point will be wirelessly connected to each other. Then using the scan function we will detect the highest signal gain (aka when the directional antenna is pointing at the access point). Both are 2.4GHz and on the same channel.
Going to stick with the ESP8266 because we already have it and our antenna is already spliced/soldered onto it.
The main purpose of this thread was how to determine satellite orientation/position from the MPU6050. Which can also result from knowing the position of each motor.
Right. I'd go with an absolute encoder that maintains shaft position information regardless of power loss or processor reboots.
We decided to go with the Nema dampers too reduce jitter and shaking when rotating the antenna, thus we don't have space on the back of the motors for an encoder. And our design doesn't have any extra space to incorporate one. Which is why we got the accelerometer.