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. kingh3

    kingh3 Member

    Joined:
    Sep 26, 2013
    Messages:
    42
    Balance:
    256Coins
    Ratings:
    +10 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SimAxe, Arduino, JRK, Motion platform
    Could you tell me about data from simtool to arduino? (what is it? It include what imformation, 3 bit or 8 bit, hexa or dinary ....). Could you tell me your knowledge about it. Thank you so much. hug:
  2. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,574Coins
    Ratings:
    +1,831 / 32 / -1
    Setting a Serial Interface.
    Once you have selected Ser from the Output Type box you will be given a screen that looks like this:

    [​IMG]



    To explain all the areas:

    • ComPort – Is the Com port the device is connected on.
    • BitsPerSec – Is the Baud Rate at which the interface needs to communicate at.
    • Databits – as it states is the data bits that are needed by this interface.
    • Parity – as it states is the parity that is needed by this interface.
    • Stop Bits – as it states is the Stop Bits that is needed by this interface.
    • Output – Bit Range – as it states is the range of values SimTools will send.
    • Output – Type – Is the format for the value needed by the interface.
    • Startup – Output – If your Interface needs a specific set of commands to set it up. Plus on the end of this you can set a pause for the Interface to do its start up in time before any other command is sent to it – HW Start. IE the time it takes to centre or calibrate itself.
    • Interfaces – Output – Will be the format that SimTools will send Axis movements to the selected interface, and an axis is represented as <Axis1> and so on. Again on the end of this there is another setting for setting the time needed for the interface to cycle through the command before it receives another Command – Packet Rate.
    • ShutDown – Output – If your interface needs specific commands to shutdown enter them here, as well again we have another setting on the end to allow the interface time to successfully shut down – HW Stop.
    • Informative Informative x 3
    • Like Like x 2
  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
    Hello,
    The SimTools using GameEngine chapter "Setting a Serial Interface" is also very précisieuse.
    http://www.xsimulator.net/simtools-game-engine/
    :thumbsFécilitations their editors for using this quality:grin

    But I also have a question on this subject "Output - Type" that the format of the value required by the interface.

    I am also interested to Arduino interface among the BIN, DEC, HEX, which is more interesting to use an execution time code Arduino fastest.? What format is the fastest at runtime.

    I see how to run a frame BIN or HEX from SimTools but how to decode a frame DEC by the Arduino code?
    Have you sample code to provide an example? (Regardless of the number of DOF, I have only the principle of treatment of frame DEC)


    Bonjour,
    L'aide SimTools de GameEngine au chapitre "Setting a Serial Interface" est également trés précisieuse.
    http://www.xsimulator.net/simtools-game-engine/
    Fécilitations à leurs rédacteurs pour une aide de cette qualité

    J'ai néanmoins une question également sur le sujet "Output – Type" qui le format de la valeur requise par l'interface.

    Je m'interesse également à une interface Arduino, parmi les formats BIN , DEC, HEX, lequel est le plus interessant à utiliser afin un temps d'éxécution du code Arduino le plus rapide.? Quel format est le plus rapide à l'éxécution.

    Je vois comment gérer une trame BIN ou HEX provenant de SimTools mais comment décoder une trame DEC par le code Arduino ?
    Avez-vous un exemple de code à fournir en exemple ? (peut importe le nombre de DOF, j'ai uniquement pour le principe de traitement de la trame DEC)
  4. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,574Coins
    Ratings:
    +1,831 / 32 / -1
    Speed depends on more than just the data type, e.g. the baud rate, and bit range. But when considering at the same baud rate, for an 8 bit interface I would say BIN is fastest, for more than 8 bits, BIN and HEX should be about the same and DEC would be at least half as fast and maybe even slower. But considering you really only need to output at 10ms intervals, it really doesn’t make much difference unless possibly the sketch can’t keep up when inputting a few extra bytes with DEC.

    And if I understand your question about decoding DEC, you must input it as a string and then convert it into numbers. I don't have an example handy though, sorry.
    • Like Like x 1
    • Informative Informative x 1
  5. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,162
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    48,171Coins
    Ratings:
    +5,036 / 16 / -0
    I believe that hex would be the fastest sending string as it would be the shortest. (smallest amount of char's sent)
    But how much work does the interface (arduino in this case) have to do to decode the input?
    So there are a lot of factors going into it as @BlazinH pointed out.
    I'm not sure there is a definite answer, as it depends on the hardware also.
  6. 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
    @yobuddy, @BlazinH thank you for your response to my question.
    I work with an Arduino Due to 84Mhz and 12-bit

    To see what was passing through the USB link between Game Engine and the Arduino Due Serial_Port_Monitor I used a software 30-day trial period.

    BitsPerSec: 115200 bauds
    Data Bits: 8 bits
    Output - Bit Range: 12 bits
    Interface - Output: XL <Axis1> CXR <Axis2> C
    Packet Rate 1 ms

    For example for a matching set SimTools XL2047CXR2507C
    Here are frames received below
    (I'll 'have added a space between each byte in each letter in bold for ease of understanding)
    Output – Type : Binaire
    01011000 01001100 00000111 11111111 01000011 01011000 01010010 00001001 11001011 01000011

    Output – Type : Décimal
    01011000 01001100 00110010 00110000 00110100 00110111 01000011 01011000 01010010 00110010 00110101 00110000 00110111 01000011

    Output – Type : Hexa
    01011000 01001100 00110111 01000110 01000110 01000011 01011000 01010010 00111001 01000011 01000010 01000011

    Comments following these trials

    The Hexa frame is not the shorter 12-bit
    In addition to the Hexa frame, use the Arduino code conversion function Hex to Decimal

    The bit frame is the shortest in 12 bits.
    Is Binary frame necessarily the fastest?

    Decimal frame is longer.
    How to interpret the Decimal frame in the Arduino code?


    La trame Décimale nécessite–t-elle une conversion du style de la conversion de la trame Hexa ?
    Avez-vous un extrait de code dans lequel on voit un exemple de cette conversion nécessaire avec une trame Décimale
    @yobuddy, @BlazinH merci pour vos réponse à mon interrogation.
    Je travaille avec une Arduino Due à 84Mhz et travaillant en 12 bits
    Pour voir ce qui transitait par la liaison USB entre Game Engine et l’Arduino Due j’avais utilisé un logiciel Serial_Port_Monitor en période d’essai de 30 jours.
    BitsPerSec : 115200 bauds
    Data Bits :8 bits
    Output – Bit Range : 12 bits
    Interface – Output : XL<Axis1>CXR<Axis2>C
    Packet Rate 1 ms


    Par exemple pour une consigne SimTools correspondant à XL2047CXR2507C
    Voici les trames reçues ci-dessus
    (Je vous ’ai rajouté un espace entre chaque octet en mis en gras chaque lettre pour faciliter la compréhension)

    Observations à la suite de ces essais
    La trame Hexa n’est pas la plus courte en 12 bits
    En plus avec la trame Hexa, il faut utiliser dans le code Arduino une fonction de conversion Hexa vers Décimal

    La trame Binaire est la plus courte en 12 bits.
    La trame Binaire est-elle forcement la plus rapide ?

    La trame Décimale est la plus longue.
    Comment l’interpréter la trame Décimale dans le code Arduino ?
  7. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,162
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    48,171Coins
    Ratings:
    +5,036 / 16 / -0
    All of the captured outputs you show above are in binary thou?

    I believe your Arduino will be looking for data in the Bin format.
    But maybe take a look at some of the other firmware's available, and it may give you some clues.
    yobuddy
  8. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,574Coins
    Ratings:
    +1,831 / 32 / -1
    There are several factors involved that determine the overall execution time of a packet (frame) as stated earlier. But for now lets just consider the data type used.

    The DECimal data type is not a number, so you don’t convert it the same as you do with BIN or HEX. So let’s start by converting those.

    With the BIN data type, you can store a value up to 255 in one byte. With HEX though, you can only store a value up to 15 per byte. Since both the axis numbers in your packet example are larger than 15, the HEX output required an additional byte over BIN for each value (It takes two HEX digits or bytes to represent a number between 16 and 255 but only one for BIN to represent from 0 to 255).

    So from your example above, lets use the number 2507 and convert to it. In BIN it is represented as 00001001 and 11001011 or the equivalent of 9 and 203. To find the number that represents you multiply 9 x 256 = 2304 + 203 = 2507. In HEX it is represented as 00111001, 01000011, and 01000010 or the equivalent of 9, C, and B. To find the number that represents you multiply 9 x 256 = 2304 + C (or 12) x 16 = 192 + B (or 11) = 2507.

    With DEC though, each byte represents a character not a number. So 00110010, 00110101, 00110000, and 00110111 represents decimals 50, 53, 48, and 55. Get out your ascii table and 50 = 2, 53 = 5, 48 = 0, and 55 = 7 or 2507. The problem though is that 2507 is still a text representation of a number, not an actual number. In order to use it you must extract the correct digits from the string and then convert the characters into a number.

    https://www.arduino.cc/en/Tutorial/StringSubstring
    https://www.arduino.cc/en/Tutorial/StringToIntExample
    • Winner Winner x 3
    • Like Like x 1
    Last edited: May 4, 2016
  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
    @yobuddy
    I understand the connections through the serial / USB port are in binary
    o_OI think do not understand your answer (? Google translation?):think
    You speak of firmware!
    - This is the firmware of the Arduino Due card? I do not understand the relationship ...?
    - This is changing version of the Arduino IDE? Explain me the benefit of always seeking the latest version when everything works fine?
    - This is the uploaded code in the Arduino Due? : The Ino file. It is certain that it is him who is responsible for reading and processing data from the USB cable

    @yobuddy
    Je crois savoir que les liaisons par le port série / USB se font en binaire
    Je crois ne pas comprendre votre réponse ( ? Traduction Google ?)
    Vous me parlez de firmware !
    • Il s’agit du firmware de la carte Arduino Due ? Je ne comprends pas le rapport … ?
    • Il s’agit de changer de version de l’IDE Arduino ? Expliquez moi l’intérêt de toujours chercher la dernière version quand tout fonctionne correctement ?
    • Il s’agit du code téléversé dans l’Arduino Due ? : Le fichier Ino. Il est certain que c’est bien lui qui est chargé de lire et de traiter les données provenant de SimTools par le cable USB
  10. 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
    Thank you for these detailed explanations and step by step about the BIN and HEX frames!I've already figured out how to reach the decimal value exploitable by the Arduino but a review with other words do not hurt.

    Output – Type DEC
    « The problem though is that 2507 is still a text representation of a number, not an actual number.
    In order to use it you must extract the correct digits from the string and then convert the charters into a number. »

    The Game Engine frame SimTools (Output - Type) or Dec or Bin Hex are many continuous frames without skipping lines.The function you tell me seems to find a line break.

    Excerpt from link
    https://www.arduino.cc/en/Tutorial/StringToIntExample
    String to Int Function
    The toInt() function allows you to convert a String to an integer number.
    The Arduino reads a serial input string until it sees a newline, then converts the string to a number if the characters are digits.
    After reading the December frame, your code Arduino automatically inserts a line break to use the toInt () function?


    @BlazinH
    Merci pour ces explications détaillées et pas à pas à propos des trames BIN et HEXA !
    J’ai déjà compris comment aboutir à la valeur décimale exploitable par l’Arduino mais une révision avec d’autres mots ne fait pas de mal.
    Output – Type DEC
    « Le problème est que 2507 n’est pas un nombre réel mais encore une représentation textuelle d'un nombre.
    Pour l'utiliser, vous devez extraire les chiffres corrects de la chaîne, puis convertir les nombres ASCII décimaux en un nombre décimal. »

    La trame Game Engine de SimTools (Output – Type) Bin ou Dec ou Hex sont bien des trames continues sans saut de ligne.
    La fonction que vous m’indiquer semble rechercher un saut de ligne.

    Extrait du lien
    https://www.arduino.cc/en/Tutorial/StringToIntExample
    La fonction toInt () vous permet de convertir une chaîne à un nombre entier.

    L’Arduino lit une chaîne d'entrée série jusqu'à ce qu'il voit un saut de ligne, puis convertit la chaîne à un nombre si les caractères sont des chiffres.
    Après lecture de la trame DEC , votre code Arduino insère automatiquement un saut de ligne pour utiliser la fonction toInt () ?
  11. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,574Coins
    Ratings:
    +1,831 / 32 / -1
    You don’t have to use newline (\n) as the delimiter, you can use anything you want other than a number (digit). They just used newline for their example.

    My Example (2 Axis): *compiles but untested*

    In Simtools DEC output interface: <Axis1>a<Axis2>b

    On Arduino:
    String inString = ""; // string to hold input
    int Axis1 = 0; // integer to hold axis1
    int Axis2 = 0; // integer to hold axis2

    void setup() {
    // Open serial communications and wait for port to open:
    Serial.begin(38400);
    while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
    }
    }

    void loop() {
    // Read serial input:
    while (Serial.available() > 0) {
    int inChar = Serial.read();
    if (isDigit(inChar)) {
    // convert the incoming byte to a char
    // and add it to the string:
    inString += (char)inChar;
    }

    // if you get a character other than a Digit, convert the string to an integer and save to the appropriate axis

    if (inChar == 'a') {
    Axis1 = (inString.toInt());
    // clear the string for new input:
    inString = "";
    }

    if (inChar == 'b') {
    Axis2 = (inString.toInt());
    // clear the string for new input:
    inString = "";
    }
    }
    }
    • Winner Winner x 2
    • Informative Informative x 2
    • Like Like x 1
    Last edited: May 4, 2016
  12. 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
    Thank you for taking your time to your insightful explanations and especially for the clarity of explanation.:thumbs

    I take the dialogue on the serial link between SimTools and Arduino to ask a subject close to my heart.

    I understand that the April Atmel microcontrollers have 2% to 3% error when reading the serial port.
    I do not know the error rate of SAM 3x8E processor Arduino Due that I use. I guess it must be almost similar.
    I hear about checksum.
    I do not understand how it works:think
    - Average data from multiple consecutive readings?
    - After multiple consecutive readings, rejecting a reading too different from others?

    :nerdCan you popularize the checksum operation?

    How to perform a checksum with an Arduino code as simple as possible?

    A 115200 bauds and a "packet rate" 1 ms for "Interfaces - Output", this is not a slowing factor for setpoint processing axes?
    Should we neglect the possibility of misreading the serial port because the instructions are repeated at least once every 1 ms ?("packet rate" 1 ms)

    Even if you can overlook this misreading the serial port, I would be anxious to know better the checksumand how to apply at the Arduino code


    @ BlazinH
    Merci de prendre de votre temps pour vos judicieuses explications et surtout pour la clarté des explications

    Je profite du dialogue sur la liaison série entre SimTools et Arduino pour vous poser un sujet qui me tient à cœur

    Je crois savoir que les microcontrôleurs Atmel AVR ont 2% à 3% d’erreur lors de la lecture du port série
    Je ne connais pas le taux d’erreur du processeur SAM 3x8E de l’Arduino Due que j’utilise. Je suppose que cela doit être quasiment similaire.
    J’entends parler de Checksum

    Je ne comprends pas comment cela fonctionne
    • Moyenne des données de multiples lectures consécutives ?
    • Après de multiples lectures consécutives, rejet d’une lecture trop différente des autres ?
    Pouvez- vous vulgariser le fonctionnement du Checksum ?

    Comment réaliser un Checksum avec un code Arduino le plus simple possible ?

    A 115200 bauds et avec un « Packet Rate » à 1 ms pour « Interfaces – Output », cela n’est pas un facteur de ralentissement pour le traitement de la consigne des axes ?
    Doit-on négliger la possibilité erreur de lecture du port série parce que les consignes sont répétées au maximum tous les 1 ms ? (« Packet Rate » à 1 ms)

    Même si on peut négliger cette erreur de lecture du port série , je serais soucieux de connaitre mieux le Checksum et comment l’appliquer au niveau du code Arduino
  13. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,162
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    48,171Coins
    Ratings:
    +5,036 / 16 / -0
    @TFOU57,
    I believe you would take a lot of speed away from the main loop, if you add a bunch of checksums.
    Or used multiple sends in order to set a target.
    Speed is the number one thing we want here.
    So the smaller the code the better for the main loop.

    I would think if it was really a problem, you would see checksums in other firmware.
    But I have never seen any in any firmware's.

    Remember, you are looking for a 'a' and a 'b', and the b acts as a trailing char, so honestly I believe you are fine without error checking.
    The speed advantage is much better IMO.
    But that just my two cents.
    yobuddy
    • Like Like x 2
    • Agree Agree x 1
    • Informative Informative x 1
  14. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,574Coins
    Ratings:
    +1,831 / 32 / -1
    I agree with yobuddy. Using a checksum would require Simtools to use an algorithm on its output in order to calculate a checksum to send too. Simtools does not currently have this feature but there are other and probably better ways to do it anyway.

    But you do need an error handler of some sort imo to see if the frame received was as expected or not. But from my experiences, once a frame goes bad, the rest of the frame will be bad too. So you can use that to your advantage. You need to use some creativity though because there are a lot of different ways of doing it.

    For example, what I would do without sending out any additional bytes from Simtools would be to test to make sure that the last axis identifier expected in the string was received; such as, did you receive a ‘b’?. Or you could see if you got both an ‘a’ and ‘b’. And while it would take several additional bytes, you could also send the axis data out twice and then compare the two values to make sure they are the same such as <Axis1>a<Axis2>b<Axis1>c<Axis2>d. Does the ‘a’ value match the ‘c’ value and does the ‘b’ value match the ‘d’ value?
    • Agree Agree x 1
  15. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,574Coins
    Ratings:
    +1,831 / 32 / -1
    Imo using a 1ms packet rate is more of a speed killer than anything though. When a game is running at 100fps for example, the arduino is processing the exact same information 10 times when it only needs to do it once or twice if you wanted to test using my last example above.
    • Winner Winner x 1
    Last edited: May 5, 2016
  16. 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
    @ yobuddy
    I do not think checksums risk so disrupted the execution speed of the Loop and whatever the type of output (BIN, HEX, DEC):thumbs
    Your opinion is supported by BlazinH
    It is true that if one seeks for example 'a' and 'b' in the frame and there is none, it is also a kind of checksum not penalizing the speed of the Arduino code to share the addition in the IF test looking for 'a' and 'b' ELSE rejecting a previous reading and performs a new play.
    I do not understand the "IMO" abbreviation you use, BlazinH also uses the abbreviation "IMO"
    It should not therefore be a mistake.
    o_OWhat does "IMO"?
    Interface - ? - Output?

    @ yobuddy
    Je ne pensais pas que les checksums risque de perturbaient tellement la vitesse d’exécution de la boucle Loop et quel que soit le type de sortie (BIN , HEX , DEC)
    Votre avis est conforté par BlazinH
    Il est vrai que si l’on cherche par exemple un 'a' et 'b' dans la trame et qu’il n’y en a pas, cela fait également un genre de checksum ne pénalisant pas la vitesse du code Arduino à part le rajout dans le test IF recherchant les 'a' et 'b' un ELSE qui rejette la lecture précédente et qui effectue une nouvelle lecture.
    Je n’arrive pas à comprendre l’abréviation « IMO » que vous utilisez, BlazinH utilise également l’abréviation « IMO »
    Cela ne doit donc pas être une erreur de frappe.
    Que signifie « IMO » ?
    Interface - ?- Output ?
  17. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,234
    Location:
    Marseille - FRANCE
    Balance:
    20,890Coins
    Ratings:
    +2,083 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    IMO in my opinion ;)
  18. 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
    OK thanks
    Sorry I did not know that!:blush
  19. 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 for this valuable information, because I was totally wrong.!

    I did not know that the telemetry from the game was generated in step with the on-screen display
    I thought that was totally independent!

    Am I right?
    - More Game of the PC processor is powerful and that the graphics card is powerful, the pace of updating of telemetry is high because the number of fps will be.
    - A maximum resolution with a PC somewhat limit deteriorates the update of the telemetry of the game.
    - An Arduino board 16 MHz or 84 MHz as the Arduino Due does not affect the packet rate that one must choose. Only internal calculations are speed and reading the Feedback

    Merci pour ces informations précieuses, car j’étais totalement dans l’erreur.
    Je ne savais pas que la télémétrie provenant du jeu étais généré au rythme de l’affichage à l’écran
    Je pensais que c’était totalement indépendant !
    Ai-je bien compris ?
    • Plus le processeur du PC de Jeu est puissant et plus que la carte graphique est puissante, plus le rythme de la mise à jour de la télémétrie est élevée car le nombre de fps sera élevé.
    • Une résolution maximum avec un PC un peu limite détériore la mise à jour de la télémétrie du jeu.
    • Une carte Arduino 16 Mhz ou 84 Mhz comme l’Arduino Due n’influe pas sur le Packet Rate que l’on doit choisir. Seuls les calculs internes sont accélérer ainsi que la lecture du Feedback
  20. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,574Coins
    Ratings:
    +1,831 / 32 / -1
    Correct!

    I believe you are getting confused with the differences between the telemetry rate (at FPS rate), the packet rate, and the PID rate. While the PID is dependent upon receiving a packet and a packet is dependent upon receiving telemetry, their rates are all driven independently.

    So the packet rate can be faster than the received telemetry (although there is nothing gained by doing so) and the PID rate (running on the arduino) can, and should, be faster than the packet rate.

    So while a packet rate is acceptable when running at say 7 to 10ms, the PID rate should run as fast as possible. So 1ms or less would be best.



    Updated 2 axis DEC example with error handling (It tests if all axis delimiters are received before processing the packet) Again, compiles but untested.

    // Process Simtools DEC Output Example with Error Handling (2 axis but can be expanded)
    // Sketch tests for good packet data on axis 'a' and 'b' before processing

    // Simtools DEC Output: <Axis1>a<Axis2>b

    String inString = ""; // string to hold input
    int Axis1 = 0; // integer to hold axis1
    int Axis2 = 0; // integer to hold axis2
    int Temp_Axis1 = 0;
    int Temp_Axis2 = 0;
    int Flag_Axis1 = 0;
    int Flag_Axis2 = 0;


    void setup() {
    // Open serial communications and wait for port to open:
    Serial.begin(38400);
    while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
    }
    }

    void loop() {
    while (Serial.available() > 0) { // Read serial input
    int inChar = Serial.read();
    if (isDigit(inChar)) { // if char is a digit convert the incoming byte to a char
    inString += (char)inChar; // and add it to the string:
    }

    // once you get a char other than a Digit, convert the string to an integer and save to the appropriate temporary axis if value appears to be valid

    if (inChar == 'a') {
    Temp_Axis1 = (inString.toInt());
    Flag_Axis1 = 1;
    inString = ""; // Clear the string for new input}

    if (inChar == 'b') {
    Temp_Axis2 = (inString.toInt());
    Flag_Axis2 = 1;
    inString = ""; // Clear the string for new input }


    } // Loop until entire packet is read then test for errors

    if (Flag_Axis1 == 1 and Flag_Axis2 == 1) { //Good Packet - Process and reset flags
    Axis1 = Temp_Axis1;
    Axis2 = Temp_Axis2;
    Flag_Axis1 = 0;
    Flag_Axis2 = 0;
    }
    else //Bad Packet - Ignore entire packet and reset flags
    {
    Flag_Axis1 = 0;
    Flag_Axis2 = 0;
    }
    }
    • Like Like x 1
    • Informative Informative x 1
    Last edited: May 6, 2016