1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  3. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  4. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

DATA FROM SIMTOOL TO ARDUINO

Discussion in 'SimTools DIY Version' started by kingh3, Apr 30, 2016.

  1. TFOU57

    TFOU57 Member

    Joined:
    Mar 30, 2009
    Messages:
    164
    Location:
    Thionville - France
    Balance:
    5,723Coins
    Ratings:
    +16 / 1 / -0
    My Motion Simulator:
    2DOF, AC motor, Arduino
    @BlazinH
    You were right, everything was not clear in my mind about it.Thank you for your valuable precision

    You mean the Arduino must be a waiting time before receiving data from Game Engine: It has the Arduino has completed these calculations and ordered the PID output pins before any reading of the serial link.

    Equal PID execution or less than 1 ms?Glupps .... !How to check if there are collisions of data between the PID calculation + OutPut pine Controls and reception of a new frame set engines?

    I start asking myself some serious questions that will make some joke! ...How Arduino treats his execution code?
    I thought to single file: lines one after the otherIf treatment is line by line through all sub programs, there is no possible interference.
    It may nevertheless have a saturation in view of the processing power of the Arduino if packet rate of Game Engine is too low.
    What is happening in this case if the packet rate of Game Engine is too low?
    When the Arduino treats his reading program the serial port sends frames SimTools taking account of the Arduino backlog?
    If Game Engine sends these packets more quickly than the Arduino can read and process (processing code line by line, I'm not talking about the speed of the Com port) if he spends excess data?

    How can we detect a packet rate setting too low?
    Can we predict an alert at Arduino?

    Is it possible to considered having led a "USB Saturation Alert" at the Arduino (Led13 or another output)?
    How to detect Serial.available ( )> 0 incoming data are present on the serial port too soon ?
    By putting IF (Serial.available ( )> 0) ....... a number of key places of the Arduino code ?


    @BlazinH
    I believe you are getting confused with the differences between the telemetry rate (at FPS rate), the packet rate, and the PID rate.[/QUOTE]
    Vous aviez raison, tout n’était pas clair dans mon esprit à ce sujet.
    Merci de vous précieuse précision

    Vous voulez dire que l’Arduino doit avoir un temps d’attente avant toute réception de données provenant de Game Engine : Il faut que l’Arduino a terminé ces calculs de PID et commandé les pins de sortie avant tout lecture de la liaison série.

    Exécution du PID égal ou inférieur à 1 ms ?
    Glupps …. !
    Comment vérifier s’il y a collisions des données entre le calcul du PID + Commandes des pins OutPut et une réception d’une nouvelle trame de consigne moteurs ?

    Je commence à me poser de sérieuses questions qui vont faire rigoler certains ! …
    Comment l’Arduino traite son code d’exécution ?
    Je pensais à la queue leu leu : lignes l’une après l’autres
    Si le traitement est ligne par lignes en passant par tous les sous programmes, il n’y a pas d’interférence possible.
    Il peut néanmoins avoir une saturation au vue de la puissance de traitement de l’Arduino si Packet Rate de Game Engine est trop faible.
    Que se passe-t-il dans ce cas si le Packet Rate de Game Engine est trop faible ?
    Quand l’Arduino traite son programme de lecture du port série, SimTools envoie des trames prenant compte du retard de traitement de l’Arduino ?
    Si Game Engine envoie ces paquets plus vite que l’Arduino puissent les lire et les traiter (traitement du code ligne par ligne, je ne parle pas de la vitesse du port Com) que se passe-t-il des données en excès ?

    Comment peut-on déceler un paramétrage Packet Rate trop faible ?
    Peut-on prévoir une alerte au niveau Arduino ?

    Est-il possible d’envisagé d’avoir une led « Alerte Saturation USB » au niveau de l’arduino (Led13 ou sur une autre sortie) ?
    Comment déceler Serial.available() > 0 : des données entrantes sont présentes sur le port série trop tôt ?
    En mettant des IF (Serial.available() > 0)……. à plusieurs endroit clés du code Arduino ?
    Last edited: May 6, 2016
  2. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,613Coins
    Ratings:
    +1,835 / 32 / -1
    I don’t know if I understand all of what you ask but I’ll try to explain.

    First, if you don’t know what PID stands for, a PID controller is an algorithm used to control your simulators motors with https://en.wikipedia.org/wiki/PID_controller .

    In short,
    By using a regular motor, a potentiometer and a PID controller, you in essence can make your own servo motor. You want a very fast PID rate because, the faster you can read the pots, the faster you give updated information to the PID controllers algorithms to act upon, and the better the control of your servos will be.

    How it works is the PID is the main program on your arduino, say running a 1ms loop. Then, in order to find out if there is any new data on the serial line, you poll if serial.available is true every few milliseconds from within the PID loop. If it is true you would then run a subroutine to read and process the latest telemetry data in order to calculate what the new setpoints are for the motors. If its not true then the PID loop just keeps running in order to get and hold the motors at their current setpoints.

    If a packet rate is too slow you will feel it in the quality of the motion. If it is to fast you will waste resources which could possibly slow down your PID rate due to the clearing of extra unused packets from the buffer.

    I hope that’s helpful.
    • Informative Informative x 3
    • Useful Useful x 1
    Last edited: May 6, 2016
  3. TFOU57

    TFOU57 Member

    Joined:
    Mar 30, 2009
    Messages:
    164
    Location:
    Thionville - France
    Balance:
    5,723Coins
    Ratings:
    +16 / 1 / -0
    My Motion Simulator:
    2DOF, AC motor, Arduino
    Thank you all very well formulated explanations

    In the header of PID loop or between reading feedback and PID calculations of correction?

    So Feedback + Serial + Calculation of corrections = 1ms loop (target runtime)?

    For feedback, some programs use the average of several consecutive readings in order to smooth the value of Feedback
    What do you think of this solution?

    How do you solve the little unstable read feedback values?

    cursor capacitor and ground? It appears that the filter R / C slows playback.

    What potentiometer value and what kind do you recommend?
    I use a 20kΩ 360°
    http://www.conrad.fr/ce/fr/product/...conducteur-Vishay-357-20K-mono-1-W-20-k-1-pcs


    Merci de toutes explications très bien formulées

    En entête de boucle PID ou entre la lecture du feedback et les calculs PID de correction ?

    Donc Feedback + Serial + Calcul de corrections = Boucle de 1ms (objectif de temps d’exécution) ?

    Pour le Feedback , certains programmes utilisent la moyenne de plusieurs lectures consécutives afin de lisser la valeur du Feedback
    Qu’en pensez-vous de cette solution ?
    Comment résolvez-vous la petite instabilité des valeurs de Feedback lues ?
    Condensateur en curseur et la masse ? Il parait que le filtre R/C ralentit la lecture.

    Quelle valeur de potentiomètre et quel type conseillez-vous ?
    J’utilise un 20kΩ 360°
    http://www.conrad.fr/ce/fr/product/...conducteur-Vishay-357-20K-mono-1-W-20-k-1-pcs
  4. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,613Coins
    Ratings:
    +1,835 / 32 / -1
    I made an error. You don't want to poll serial from within the PID loop but outside. PID timing is critical to the D term so I don't think you can do it in the PID loop.

    Here's some code from the smc3 sketch you can decipher. He put the serial polling at the end of the main loop once it completes. The line, "checkserial0();" runs a subroutine that checks for and processes new input. The PID loop runs at .25ms.

    If you want to see and learn more download the smc3 sketch.

    Btw, I use hall pots but I mostly see 10k pots being used.
    • Informative Informative x 2
    • Agree Agree x 1
    Last edited: May 9, 2016
  5. TFOU57

    TFOU57 Member

    Joined:
    Mar 30, 2009
    Messages:
    164
    Location:
    Thionville - France
    Balance:
    5,723Coins
    Ratings:
    +16 / 1 / -0
    My Motion Simulator:
    2DOF, AC motor, Arduino
    Can you tell me what time the PID is the real: 1 or 25 ms?


    Pouvez-vous me préciser quel temps d'éxécution du PIDest le véritable : 1 ou 25 ms ?
  6. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,236
    Location:
    Marseille - FRANCE
    Balance:
    20,962Coins
    Ratings:
    +2,089 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    with Arduino, 10k pots are preferred

    http://forum.arduino.cc/index.php?topic=14852.msg109078#msg109078
    • Agree Agree x 1
  7. TFOU57

    TFOU57 Member

    Joined:
    Mar 30, 2009
    Messages:
    164
    Location:
    Thionville - France
    Balance:
    5,723Coins
    Ratings:
    +16 / 1 / -0
    My Motion Simulator:
    2DOF, AC motor, Arduino
    @RacingMat
    Merci pour votre information et votre lien à propos de la valeur du potentiomètre
    A l’origine, j’avais commandé de 10kΩ 360°
    Ils m’ont livré des 20kΩ avec un mot signalant que les 10kΩ étaient indisponibles.
    Paiement en eCarte Bleue , pas de recrédit possible . J’ai tardé , je ne voulais pas avoir d’avoir …
    Bref j’ai des 20kΩ
    @RacingMat
    Thank you for your information and links about the value of potentiometer
    Originally, I had ordered 10 k ohms to 360 °
    They delivered me 20kΩ with a word indicating that the 10 k ohms were unavailable.
    ECard payment Bleue, no possible crediting. I delayed, I do not want to have to have ...
    In short I have 20kΩ
  8. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,613Coins
    Ratings:
    +1,835 / 32 / -1
    If you recall I stated 1ms or less is best for the pid loop. The smc3 sketch uses cycle saving methods that allows it to run a .25ms loop.
  9. TFOU57

    TFOU57 Member

    Joined:
    Mar 30, 2009
    Messages:
    164
    Location:
    Thionville - France
    Balance:
    5,723Coins
    Ratings:
    +16 / 1 / -0
    My Motion Simulator:
    2DOF, AC motor, Arduino
    :blushSorry, I had not seen the point to 25ms.
    With SMC3 is 0.25ms (1/4 ms)
    I read 25ms, damn. he sees quasiement not!:grin
    Sorry again !:cheers

    Désolé , je n'avais vu le point devant 25ms .
    Avec SMC3 c'est 0,25ms (1/4 de ms)
    Je lisais 25ms , satané . il se voit quasiement pas !
    Encore désolé !
  10. Rodrigo Baornio

    Rodrigo Baornio New Member

    Joined:
    Oct 22, 2016
    Messages:
    18
    Location:
    Brazil
    Balance:
    - 285Coins
    Ratings:
    +6 / 0 / -0
    i have a 2 dof dc motor with arduino, and i notice the motor works only with 2 and 2 %. is that because i use 8 bits? i need more resolution?
  11. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    21,030
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    147,878Coins
    Ratings:
    +10,880 / 54 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    You need to start your own thread and ask your question there.

    Before you do please read the SimTools documentation: http://www.xsimulator.net/simtools-complete-documentation/

    You also need to detail what code is being used with your Arduino, as there are a number of code options: https://www.xsimulator.net/community/faq/arduino-code-for-use-with-various-hardware-and-simtools.31/