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

My spin on an interface

Discussion in 'SimTools compatible interfaces' started by wimpo`, Aug 21, 2022.

  1. wimpo`

    wimpo` Member

    Joined:
    Jul 27, 2008
    Messages:
    89
    Occupation:
    metselaar
    Location:
    nederland, twente, vroomshoop
    Balance:
    178Coins
    Ratings:
    +5 / 0 / -0
    Hello I wanted to share my project with you guys. it's a 2dof solution based of an esp32 programmed with the arduino environment, and processing for the software interface (tuning pid etc..). It's semi functional but there is always room for improvement and adding functions or safety off course. I however can't find the time at the moment to push this project further. I'm sure I will pick it up again in the future but for now it isn't really possible to put the time in.

    I'm not by any means an expert in programming or electrical engineering, however I am someone who is heavily interested and invested these topics.

    For the hardware side of things I used an esp32 dualcore. The serial communication is done on core 1 so that it doesn't interfere with the pid calculations etc which run on core 0. For feedback I use 2 continuous potentiometers, but I will be using incremental encoders when I find the time for continuing this project. The motor drivers I use are ibt-2's.

    I cant provide schematics at the time due to not having enough time for it.

    for testing/debugging purposes i'm using 2 serial connections. but it will work with one off course. Wifi/udp is possible but i havent tried this myself yet.
    IMG_20220821_210150.jpg

    IMG_20220821_210750.jpg

    For the software side of things I've used processing language an ide for the gui. I tried to copy as much functions from smc3 as possible for obvious reasons.
    osmx.jpg
    Stuff that's working:

    Selecting com port and stopping serial connection. baud speed is set "fixed" to 500000.
    Udp connection for communication between simtools and osmxsimulator.

    Motor on/off toggles.

    Try mode for tuning.
    In try mode:
    Setting up pid.
    Setting pwm minimum and pwm maximum output.
    Setup a deadzone.
    Setup range for the potentiometer.
    Setup pwm reverse.
    and setup pwm frequency.

    Reset for resetting to previous settings.
    Save function for saving settings.
    Inverse feedback from potentiometer.
    Inverse direction for motor.
    Setting ms for time between pid calculations.
    link toggle for settings for both motors.
    Save all setting which include all settings.
    Clipping slider which sets a limit for the input and when the feedback overshoots will reverse the motors until it's within limits.
    A hard limit slider which when the motor crosses this line will stop the motors.
    A output and direction indicator.
    A continuous graph for each motor.
    buttons and slider for changing setpoint.

    Stuff that isn't implemented yet.
    Saving tunings to esp32 in eeprom.
    Automatically generate setpoint movements for tuning purposes.
    General settings for choosing 2 or 3 dof. (not yet sure if it's possible with io pins available on esp32.)
    Choosing between potentiometers or incremental encoders. The idea is to use the potentiometers for a fixed position and then use the incremental encoders for dynamic positioning.
    Choosing/settings for different kind of motor drivers.

    Code wise it isn't the prettiest, but i hope the readability is good enough.
    There is some to a lot of code duplication. I've not cracked the method for solving that problem.

    The serial communication isn't optimized yet, but I've not yet felt the need to do so. Because it runs on it's own core.

    There's still a lot to be done, but a lot is also ready to go. I've called it osmxsimulator (Open Source Motion Xsimulator) however it's not a fixed name or anything. It's the best I could come up with, that's all.

    Here is a rar with everything I've build so far.
    http://jwpost.nl/osmxsimulator.rar

    The library's needed for the arduino ide are: (arduino ide 1.8.19) https://www.arduino.cc/en/software
    https://github.com/br3ttb/Arduino-PID-Library
    https://github.com/madhephaestus/ESP32Encoder

    The library's needed for the processing ide are: (processing ide 3.5.4) https://processing.org/download
    https://github.com/sojamo/controlp5
    http://multiply.org/processing/
    http://ubaa.net/shared/processing/udp/

    These libraries can be added from within the ide's with there builtin library managers.

    The esp32 board i use is esp32 devkit v1. This board has the dual core on it, but there are alternatives with the same processor. The pinout could differ.

    For now this concludes my post, maybe it's useful for anyone who wants to build a 2dof (or more just use extra esp32's for the extra dof's) for now and likes the idea of it being open source so that everything about it is changeable. All I ask is that if anyone wants to pick this up, and add to or improve it. That it's made available for this community as is. Completely open source. And hopefully easy enough coded to be adapted or changed without a higher skill in programming.

    I myself will continue this project also, but I'm not sure when this will be.
    In the meantime I thought it would be a shame to hold it until finished/polished. Maybe it's helpfull for those starting out in programming, or for someone who's looking for a different kind of solution. And this way the hours put in are not for nothing I hope.

    Best regards, and talk to you later.
    • Like Like x 1
    • Creative Creative x 1