Buenas tardes.
Lo primero que tengo que hacer es darle las gracias por su tiempo y por sus indicaciones, que sin duda, son de gran valor para mí.
Resulta muy difícil pedir ayuda sobre un proyecto, si no se explica de alguna manera, y también resulta muy difícil explicar un proyecto de más de 4 años de investigación, en muy pocas líneas. Por lo que le pido disculpas por la extensión de mis comentarios. Pero si necesito su ayuda, también necesito explicarle todos mis problemas desde el principio.
Le cuento un poco mi historia, para ponerle en antecedentes, y aclararle varias cosas sobre mí, y sobre mi proyecto.
Estoy metido en este proyecto desde el 2.016, que me surgió la idea después de leer varias páginas de Internet, donde explicaban cómo hacer proyectos de vehículos con Arduino, donde explicaban más o menos, tanto el proceso de construcción de la parte exterior del vehículo, como el programa de control con Arduino, pero a todas las paginas les falta algo por explicar, quizás esa última y definitiva, actualización del proyecto.
Pero yo no sabía, que a todas las paginas les faltaba la última actualización para que el proyecto funcionase como es debido, a esa conclusión he llegado a base de iniciar proyectos y no poder terminarlos, por falta de un ultimo empujón, aclarando los pormenores de los “errores”, o problemas de programación.
Lo primero que he hecho siempre, es informarme como funciona cualquier sensor, o parte del proyecto utilizado, por separado, y después de tener éxito en el funcionamiento de ese código solo para el funcionamiento de ese componente en concreto, lo he juntado al código de control del ROV, con el resto de instrucciones que funcionaban juntas.
Le cuento todo esto, para explicarle, que no he iniciado un código de 700 líneas, de inicio, si no que he llegado a esas 700 líneas poco a poco, sumando códigos que funcionaban.
Hasta que he llegado al punto, en que no entiendo, porque si el código solo funciona, y he adjuntado todas las líneas al código de control, este código de control, no funciona tan bien como funciona solo. He llegado a la conclusión de que estaba forzando las posibilidades del Arduino Mega 2560, pero esta conclusión se queda sin consistencia, cuando descubrí los códigos de las impresoras 3D, con más de 5.000 líneas de código, eso sí es llegar al límite de las posibilidades de Arduino, y no lo que yo estoy haciendo.
Otro de los problemas más importantes que he tenido, es que me he registrado en varios foros de construcción de modelos similares a mi proyecto, en los que hay verdaderos artistas y “manitas”, en la construcción de modelos, pero no he encontrado a ningún programador experimentado que de verdad, que supiera realmente lo que estaba aconsejándome, y en vez de ayudarme a arreglar el código, lo hemos terminado de estropear.
Por ejemplo hay una línea que me han dicho de quitar varias veces, porque estaba leyendo la estructura del programa 5 veces, y estorbaba en el código, es esta:
for (int i = 0; i < 5; i++) {}
Cuando de verdad lo que hace esta línea, es ayudar a la librería EasyTransfer, en la comunicación de los dos Arduinos, alternando cada 5 segundos, el estado de Arduino, entre la Lectura de datos, y el envió de datos.
Hasta ahora la explicación que tiene más sentido, es la suya, no la que me han dado otros con la intención de ayudar. Y posiblemente ese sea unos de los errores de programación, que impiden que el programa funcione bien.
En cuanto a los problemas de PIO con Atom, ya he leído en este foro, que casi nadie utiliza Atom, todos utilizan otro entorno, lo que me ha llevado a pensar en cambiar de plataforma en este momento, antes de aprender a utilizar algo que no me va a ser de utilidad, por lo tanto voy a cambiar inmediatamente Atom, por VSCode.
Y en cuanto a los problemas de Arduino con PIO, también he leído en este foro que causa bastantes quebraderos de cabeza solucionar algunos problemas de programación, y hay que utilizar parches o comandos de compatibilidad, que no entiendo, y no soy capaz de adoptar.
Ya he comprado y estoy esperando que me lleguen próximamente, unas placas ESP32, con las que será más fácil depurar los programas, sin perder la compatibilidad con Arduino.
Algo que verdaderamente me preocupa, es su comentario sobre el mando de PS2, que no sé cómo debo interpretar esto
“también tendría que simular la entrada de PSX, lo cual no es realmente factible en su caso específico.”
Usted me quiere decir que no voy a poder usar el mando de PS2 con PIO, de ninguna manera, aunque use otro tipo de placa.
O me quiere decir que no puedo usar el mando con Arduino en PIO, con la configuración que tengo ahora mismo.
De no poder usar este tipo de mando PSX, ¿Qué otro tipo de mando para control puedo utilizar para sustituirlo?
Por supuesto que tengo cruzados los pines TX y RX de un Arduino con el otro, es uno de los primeros errores que se cometen, y que ya solucione hace tiempo, pero gracias por su observación al respecto.
En su último párrafo no sé lo que me quiere decir, entiendo que me está diciendo que se realizan demasiadas tareas en el programa, y que tendría que dividirlo en varias funciones o archivos.
¿Cómo?
Mientras usted me contesta, voy a intentar averiguar algo sobre esto en Internet, pero dado mi experiencia en otras dudas, creo que solo voy a conseguir confundirme más de lo que ya estoy, pero aun así, voy a intentarlo, aunque solo voy a adoptar los consejos que usted me diga.
Muchas gracias por sus consejos y observaciones.
Espero que no se desanime con mis comentarios tan extensos, y siga ayudándome, muchas gracias.
Un saludo
Good afternoon.
The first thing I have to do is thank you for your time and for your directions, which are undoubtedly of great value to me.
It is very difficult to ask for help on a project, if not explained in any way, and it is also very difficult to explain a project of more than 4 years of research, in very few lines. So I apologize for the extension of my comments. But if I need your help, I also need to explain all my problems from the beginning.
I tell you a little bit about my story, to put you in the background, and clarify several things about me, and about my project.
I have been involved in this project since 2.016, which came up with the idea after reading several pages of the Internet, where they explained how to do vehicle projects with Arduino, where they explained more or less, both the process of construction of the outside of the vehicle, and the control program with Arduino, but all the pages are missing something to explain , perhaps that last and definitive, project update.
But I did not know, that all the pages lacked the last update for the project to work as it should, that conclusion I have come to start projects and not be able to finish them, for lack of a last push, clarifying the details of the “errors”, or programming problems.
The first thing I have always done is to inform myself how any sensor, or part of the project used, works, separately, and after succeeding in the operation of that code just for the operation of that particular component, I have put it together to the ROV control code, with the rest of instructions that worked together.
I tell you all this, to explain, that I have not started a code of 700 lines, starting, but that I have reached those 700 lines gradually, adding codes that worked.
Until I’ve reached the point, where I don’t understand, because if the code only works, and I’ve attached all the lines to the control code, this control code, doesn’t work as well as it works alone. I have come to the conclusion that I was forcing the possibilities of the Arduino Mega 2560, but this conclusion runs out of consistency, when I discovered the codes of 3D printers, with more than 5,000 lines of code, that is to reach the limit of Arduino’s possibilities, and not what I am doing.
Another of the most important problems that I have had, is that I have registered in several forums of construction of models similar to my project, in which there are real artists and “handymen”, in the construction of models, but I have not found any experienced programmers who really, who really knew what was advising me, and instead of helping me fix the code, we have finished spoiling it.
For example there is a line that I have been told to remove several times, because I was reading the structure of the program 5 times, and I was in the way in the code, it is this:
for (int i = 0; i < 5; i++) {}
When what this line really does, is to help the EasyTransfer library, in the communication of the two Arduinos, alternating every 5 seconds, the state of Arduino, between Data Reading, and data sending.
So far the explanation that makes the most sense is yours, not the one given to me by others with the intention of helping. And possibly that’s some of the programming errors, which prevent the program from working well.
As for the problems of PIO with Atom, I have already read in this forum, that almost no one uses Atom, everyone uses another environment, which has led me to think about changing platforms at this time, before learning to use something that will not be useful to me, therefore I will immediately change Atom, by VSCode.
And as for the problems of Arduino with PIO, I have also read in this forum that causes quite a few headaches to fix some programming problems, and you have to use patches or compatibility commands, which I do not understand, and I am not able to adopt.
I have already purchased and am waiting for to arrive soon, ESP32 boards, with which it will be easier to debug the programs, without losing compatibility with Arduino.
One thing that really worries me is your comment on the PS2 command, which I don’t know how I should interpret this
“you would also have to simulate PSX input, which is not really feasible in your specific case.”
You want to tell me that I won’t be able to use the PS2 controller with PIO, in any way, even if I use another type of board.
Or it means that I can’t use the controller with Arduino in PIO, with the settings I have right now.
If I can’t use this type of PSX controller, what other type of control controller can I use to replace it?
Of course I have crossed the TX and RX pins of one Arduino with the other, it is one of the first mistakes that are made, and that already solved a long time ago, but thank you for your observation about it.
In your last paragraph I don’t know what you mean, I understand that you’re telling me that too many tasks are done in the program, and that I would have to divide it into various functions or files.
How?
While you answer me, I’m going to try to find out something about this on the Internet, but given my experience in other doubts, I think I’m only going to get more confused than I already am, but I’m still going to try, even though I’m just going to adopt the advice you tell me.
Thank you very much for your advice and observations.
I hope you will not be discouraged by my very extensive comments, and continue to help me, thank you very much.
A greeting