Go Down

Topic: How to analyze a motor control problem in great detail? (Read 246 times) previous topic - next topic


I'm building an arduino-controlled machine to help a disabled user walk better.
A motor must perform 2 functions:
a) pull the steel cable up when the leg needs to be lifted - assisting the user
b) keep the steel cable loosely under tension when a) is not needed.
I'm having problems with b): When things go wrong the cable gets twisted and damaged. I now this is a risk but I'm willing to take it. There is no other way to build something lightweight that works.
Device details:
The cable tension is measured using a HX711 scale that gives a precise reading.
The HX711 has been set to 80 SPS (Samples per second)
The motor is controlled using a ASD05 controller.
The motor is a standard coal-brush motor - (not a stepper motor) for max power efficiency.
The entire thing is battery operated.
I have written a PD controller that works slightly assymetric (pull cable and release cable work differently).
I now need to fine-tune my PD loop.
What I would like to do for this is following:
- Let the device work in normal mode, i.e. read the HX711 and control the motors.
- Add a small button that I press when I observe trouble.
- Collect various PD-control related variables 80 times per second.
- End up with an Excel sheet with 160 rows: the 80 variable collections before I pressed the button and the 80 variables after I pressed the button.
1 second after I pressed the button, the Arduino can stop operating and start dumping data.
Question: what is the best way to achieve this. Using print statements while proceeding would slow down the Arduino far too much. So I would need to store 160 variable values locally and dump them  later on. How to move these to Excel?


If you run serial at a decent speed, just printing the variables shouldn't take long. I tested it at 115200 and printing 160 floats took ~130 ms. Is that too long for your purposes?


Which Arduino? Most of them will have enough memory to store 160 values in an array in the main SRAM memory.

I think that's the best way to be able to keep a continuous recording going and store the one second before you pressed the button. The key to this kind of usage is to use a "circular buffer". The instructions to access memory are actually the slow instructions in the processor. If you are adding one more item to the end of the list, then the "obvious way" of doing it is by deleting the first one, moving the second one into the first one's place, moving third into second and so on until you have a space at the end of the list to add the new item. 80 delete-end-copy operations is a lot of work. The circular buffer idea means you just keep an index or pointer to the last item you added to the list. When you get to the end, go back to the start. When you have done that, then the oldest item is the one "ahead" of the pointer. Adding a new item erases the oldest.
"The problem is in the code you didn't post."


Thanks !!
As for the printing at fast speed: That takes too long, even at 115200.
130ms is 13% of all Arduino processing time.
I need to print multiple variables. Input and Output and a number of intermediate parameters.
It will slow down the loop and prevent the 'fine & precise tuning' that I need.

As for the circular buffer: that could work.
I still need to add some "circulation stop" after the button has been pressed.
I'm thinking about outputting in CSV structure and next importing in Excel.
The entire process (writing & testing code, importing in Excel, analyzing in Excel sounds labor-intensive. I was hoping about a simpler way to do so. But as that doesn't seem to exist, this is the way I'll go.

Go Up