I have been using Arduino already for quite a few things, but they were almost always easy processes, and I have reached a wall now, and I would love to have your assistance.
I have an idea of making a machine.
A machine, which would use:
2 stepper motors, with the driver DRV8825
1 DC motor, with the driver L298N
1 Encoder (optical, quadrature encoder)
1 Nextion TFT Screen
1 Hall sensor
2 Microswitch
So basically, this would make a machine.
It would perform multiple tasks at the same time:
Read encoder values to control the DC Motor to maintain position, pretty fast
(IFAIK, this would make the optical encoder send values to Arduino and it would make it to send a command to the DC motor according to the value.)
Make one of the stepper motor turn always in one direction at pretty fast RPM (maybe 750 RPM)
(No big deal)
Make the other stepper motor turn in one direction until it hits a microswitch, then go back at same speed until it hits the other, cycle repeats (all this in 1/8th microsteps, max at 200 RPM)
(A bit harder, but not hard neither)
Make the hall sensor count the stepper motor turns made by the stepper motor turning at ~750 RPM
(using a magnet fixed to the shaft)
Report about progress status on the nextion screen using the TX/RX ports, also displaying the Hall sensor count.
(Not hard)
So knowing my intentions, my question is to all of you more experienced about Arduino is:
Can an Arduino Mega control all these things "simultaneusly"? Is 16 MHz enough for all these?
Thanks, but I want to change variables using the display, to set how many turns the fast stepper should do, and set how fast the other stepper motor should turn accordingly.
It is beyond My knowledge how I would do that using a separate controller.
Of the things listed in the Original Post reading the encoder on the DC motor will probably impose the biggest computational load on the Arduino. How many pulses per second will it have to detect?
If the pulse rate is high this is one situation where I would think of having a second Arduino - or at least a second Atmega 328 (or some such)
Robin2:
Of the things listed in the Original Post reading the encoder on the DC motor will probably impose the biggest computational load on the Arduino. How many pulses per second will it have to detect?
If the pulse rate is high this is one situation where I would think of having a second Arduino - or at least a second Atmega 328 (or some such)
...R
I don't know so much about encoders to propose solution but possibly a clever use of a counter could take most of the burden away from CPU?
Robin2:
Of the things listed in the Original Post reading the encoder on the DC motor will probably impose the biggest computational load on the Arduino. How many pulses per second will it have to detect?
I think 10000 pulses would be sufficent in this case, since precision is needed (10000 Hz application means it pulses every 0.1 ms, right?)
manor_royal:
Ditch the L298 in favour of something newer and more efficient.
What else could I use? I never made servo controls, thus I have no knowledge about it.
Obisix:
What else could I use? Inever made servo controls, thus I have no knowledge about it.
If you just need a servo, you could use a servo maybe?
As to a L298 replacement, have a look on sites like Pololu for motor controllers; they have a range to suit various voltages and currents depending on your motor.
The DUE has a builtin quadrature decoder. You can find code tested to 3500 rpm with a 1,024 PPR Encoder (4 x 1,024 Edges) and possibly could provide a good accuracy well above.
Robin2:
You need to figure out how many pulses per second will be produced by your encoder when the motor is running at full speed.
Why would I need the full speed pulse number if the motor should always corrigate the numbers to match to an exact value specified by me? Isn't this like a self balancing robot?
As I understood, the Arduino has to read a value from the encoder at given times. For me, it would be 10 000 times a second. Any deviation from the value I provided should be corrigated by the motor to reach the given value again. Isn't that correct?
Obisix:
Why would I need the full speed pulse number if the motor should always corrigate the numbers to match to an exact value specified by me? Isn't this like a self balancing robot?
As I understood, the Arduino has to read a value from the encoder at given times. For me, it would be 10 000 times a second. Any deviation from the value I provided should be corrigated by the motor to reach the given value again. Isn't that correct?
I had not not interpreted your Reply #6 as meaning that you planned to limit the motor speed so that the maximum pulse rate was 10,000 per second. How fast will the motor be turning and how many steps per revolution does your encoder produce?
10,000 per second is one every 100 microsecs (or a bit less when the motor over-speeds slightly) so the rest of your code must be able to live with such frequent interruptions. Make sure that your Interrupt Service Routine (ISR) is very very short or it will consume all the available CPU cycles.
Read encoder values to control the DC Motor to maintain position, pretty fast
Controlling the position of a DC motor (rather than its speed) will be a complex task. On the other hand, if all you want to control is the speed you can probably do that perfectly well with a simple encoder that produces one pulse per revolution.
I really think you need to plan your actual code before you can say with any certainty whether what you want is doable. You could, for example, write some simple programs for each part of the project on its own and measure how much time the code takes. For example the code to do PID calculations for maintaining motor speed takes a fair amount of time.
Mine would do almost the same, but for different purposes.
As I see on the video, the motor is constantly having a positional feedback of the small pulley on the linear guide by an optical encoder next to it. Am I correct?
It is just an other thing that it controls tension.
To be honest I can't tell what is happening in that video. In fact it seems to me that the human hand is providing 95% of the intelligence - rather than the electronics.
You say "Mine would do almost the same, but for different purposes." so why not tell us exactly what you want to achieve - perhaps with a diagram of your proposed machine. Then we will have a basis for giving useful advice.
The device in the video SEEMS to be winding a small coil from a big coil and I THINK the idea is that the sliding mechanism will help to keep a constant tension. But it does NOT seem to be working - hence the hand. An automated coil winding machine should be well within the capacity of an Arduino but I don't immediately see how it could need stepper motors, or a high resolution encoder. Look at the simple mechanism used for winding the bobbin on any sewing machine.