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

4Dof-Controller code for arduino mega for AASD-15A and similar driver

Discussion in 'SimTools compatible interfaces' started by cubexxx, Mar 19, 2020.

  1. cubexxx

    cubexxx Member

    Joined:
    Oct 4, 2019
    Messages:
    69
    Balance:
    537Coins
    Ratings:
    +41 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, 4DOF
    That is correct, you need to connect DIR and STEP (called "pulse" in the code), I don't control ENA from the code, you can do one of 2 things:
    1.) Put +5V (you can take that from the arduino) on pin 9 and 0V (Ground) to pin 6 of the db25 connector. You can use a switch as an E-Stop to break one of of these connections.
    2.) Permanently enable the drive by setting Pn003 to 1. Of course you'll have no E-Stop then.
  2. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    484
    Balance:
    2,872Coins
    Ratings:
    +178 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    Thank you!

    Still cant make it work right though. just spins and dont respond to mover
    I got 5v on p9, ground p6. Pulse 12 to db p3 and Dir 30 to db 4. If no ground on p5 10 14 Nothing will happen.

    If i now connect the ground wire that is connected to p5 10 44 on DB25 it will start to spin fast/slow/random one way and all the time. If i permanently enable it will just spin and if i remove the p5 p10 p14 ground it will start spinning fast. Its a bit odd. If i pull either or both pulse/dir there's no change. Enable does work as it stops when i pull the 5v/ground Maybe this mega clone isnt all correct
    Last edited: Jul 15, 2020
  3. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    484
    Balance:
    2,872Coins
    Ratings:
    +178 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    It feels more and more like a dud. I have just reuploaded the sketch a couple of times and now the motor will move up when it starts and do the same motion the other way on disconnect. When i move sliders it will just move -40 and 40 about 7-8mm change on the motor shaft keeway when i whack the sliders all the way over. If i move the slider for actuator nr 3 off center the slider for actuator 1 works normally. Could be a mover issue, dont know but its making knocking noises as slider 3 passes center so its definitively related.



    All the settings are like shown on the first post.
    Last edited: Jul 15, 2020
  4. cubexxx

    cubexxx Member

    Joined:
    Oct 4, 2019
    Messages:
    69
    Balance:
    537Coins
    Ratings:
    +41 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, 4DOF
    Well that means that it is basically working correctly, should move up to center on connect and all way down when disconnecting. Pin 5, 10 and 14 of the DB25 have to be connected to GND. The rest of what you described sounds like there's something wrong with the mover setup, maybe I could tell if you if you post a screenshot of your settings
    Last edited: Jul 15, 2020
  5. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    484
    Balance:
    2,872Coins
    Ratings:
    +178 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    Im rather sure its something to do with the Ardunio. Its acting very random. 1 and 3 will work but the second will just go randomly back and forth. It worked fine 1 and 3 for a while but now it dont. If i pull dir pin

    Another example nr 3 same speed back and forth if nr 2 is connected on DB. If i disconnect it, then nr 3 will work full speed one way. 1/10 the other. 5v and grounds are wired in parallell.

    M2 is always random when its connected to and i cant find any fault in the wiring

    Sometimes moving m2 slider moves m3...

    Not really sure where the issue is. on Leo/sfx nr 3 moves random. Not your job to troubleshoot but any help is appreciated if you got the time
    Last edited: Jul 15, 2020
  6. cubexxx

    cubexxx Member

    Joined:
    Oct 4, 2019
    Messages:
    69
    Balance:
    537Coins
    Ratings:
    +41 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, 4DOF
    Well most of the time the problem is with cabling/connections, but you'll probably know that already. Other than that it sometimes helps to reset the arduino (there is a button on the board) or reconnect the usb and than connect again in mover. Be aware that after a reset the code assumes that the actuators are in the lowest position.
  7. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    484
    Balance:
    2,872Coins
    Ratings:
    +178 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    Yup and Yup. Gonna redo all the wiring and check again. Going to make real sure there are no issues before i install it
  8. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    484
    Balance:
    2,872Coins
    Ratings:
    +178 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    Ok so i redid the wiring. In the SFX software everything is running as it should. Everything is identical.

    On the Mega motor 2 still fails and ive tested different wires and checked that its not the servo controller itself. It doesnt just run randomly anymore but Ive also put the pins from motor 2 to 4 and i have the same issue.

    Connected Leo and checked again, no issues. Reconnected Mega. Only motor 1 works right. restarted and it just runs the motors randomly until i reset. If i restart my comp again it does the same om first Mover connect. Cant really imagine it being anything but the Mega at this point.

    Here's my settings.
    troubleshoot sfx.png
    Last edited: Jul 15, 2020
  9. cubexxx

    cubexxx Member

    Joined:
    Oct 4, 2019
    Messages:
    69
    Balance:
    537Coins
    Ratings:
    +41 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, 4DOF
    Ok I see the problem now: You're using only 3 actuator values in the serial output string, you need 4 values here. You don't have to use the 4th output, but you need to put a value there because the code expects always 4 values. You can put a constant zero like this: "<255><255><a1><a2><a3><0><0>" (you need 2 zeros because its 2 bytes)
  10. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    484
    Balance:
    2,872Coins
    Ratings:
    +178 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    Thanks. That seems to have solved it. Should have posted them settings they first time you asked ay :p Did have wire issues though.

    I have everything finished and ready to rock but there is one issue though. After a board reset the motors start quickly and the go into their normal start routine. If i start and stop the serial connect and then enable and start again it works fine so there is a workaround but important to remember



    Another question i have. You have updated to aprox 140 throw. Is that your exact throw or do you keep 1cm safety?. I have a 150mm throw on mine. Hopefully Mover can be updated to allow us to move the center/range a bit.
    Last edited: Jul 16, 2020
  11. cubexxx

    cubexxx Member

    Joined:
    Oct 4, 2019
    Messages:
    69
    Balance:
    537Coins
    Ratings:
    +41 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, 4DOF
    Glad you got it working! I have almost exactly 140mm, so far no problems. As for the video, I don't know exactly what your're doing here, but you shouldn't reset the board while it's still connected to mover.
  12. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    484
    Balance:
    2,872Coins
    Ratings:
    +178 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    The video was for demonstration purpose only. As mentioned if for some reason the board resets you need to connect to the board in mover then disconnect without power to the motors. If you turn on the motors and connect to the board without doing that initial connect/disconnect the motors will start like they do in the video.

    So upon reset. Disable the motors. Connect and disconnect serial in Mover and you should be good to go for your next connect.
  13. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    484
    Balance:
    2,872Coins
    Ratings:
    +178 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    Been using it for a little while now and its was easy to modify for 150mm throw with the latest changes you made. The motion feels very very good but of course i dont have anything to compare with :) The actuators was worth every penny and then some though!

    Cant thank you enough for this sketch!
  14. imagebuff

    imagebuff New Member

    Joined:
    May 17, 2017
    Messages:
    26
    Location:
    Tomball TX
    Balance:
    269Coins
    Ratings:
    +8 / 0 / -0
    Hi cubexxx. I know your using Pn98 = 10 which theoretically should give you more actuator resolution and possibly a smoother feeling. I've come from SFX and am now on Thanos. Does your board / code actually make it feel any different? Would you mind describing that difference? Is there a downside to the higher resolution?
    On another note you mentioned modding your SFX-100 actuators to 140. It sounds like you may have modified the ballscrew and other internals maybe? Just curious as to how you accomplished this. Thanks much!

    Chris
  15. cubexxx

    cubexxx Member

    Joined:
    Oct 4, 2019
    Messages:
    69
    Balance:
    537Coins
    Ratings:
    +41 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, 4DOF
    I have started with the sfx Leonardo controller. Now with this controller and the simfeedback software it is almost impossible to have a smooth slow movement. In my opinion that is necessary if you want to do some kind of washout, i.e. you need motion that is so slow and smooth that it cannot be felt. I then tried the free Thanos so-called "open hardware" controller. While it is possible to have smooth motion with that controller, it has in my opinion a serious flaw: it doesn't generate the pulses for all servos simultaneously but serially, i.e. it first sends all the pulses for motor 1, then for motor 2, etc. Now that means if you want for example to move simultaneously all 4 actuators (in my case) as fast as possible up it will generate a noticeable delay between the servos, a definite no-go in my opinion, for me the main reason not to use this controller. I could definitely feel this delay in certain situations with my settings. I think with my solution I can have both, slow smooth unnoticeable movements and as fast as possible large movements, each when needed. As for the increase in resolution it's the maximum that's possible with the mega while still having the maximal speed. The felt difference in smoothness is at times noticeable, but is rather on the subtle side, not a night and day difference, still a little better than the other two known options. Also it allows me to use more aggressive control loop parameters in the drivers (for parameters see also this post https://www.xsimulator.net/community/threads/dirtys-6dof-aasd-servos.14621/page-3#post-202201)
    I'm not aware of any downside to using the higher resolution.
    As for my modification of the actuators: I just printed a spacer to put between the aluminum extrusion and the linear bearing mount that allows me to mount the linear bearing the other way round so that it doesn't extend into the aluminium extrusion. No change of ballscrew necessary, the only other thing needed is longer screws for the linear bearing mount. I gain about 28mm stroke by that, originally it had 114mm, so now its ca. 142mm, more is not possible with my ballscrew, the nut would fall off.

    Attached Files:

    • Informative Informative x 3
  16. SeatTime

    SeatTime Well-Known Member

    Joined:
    Dec 27, 2013
    Messages:
    2,573
    Occupation:
    Retired
    Location:
    Brisbane Australia
    Balance:
    28,370Coins
    Ratings:
    +2,844 / 39 / -0
    My Motion Simulator:
    AC motor, Motion platform
    I gave this software a try and it works exactly as detailed. Excellent work @cubexxx
  17. wingert

    wingert Active Member

    Joined:
    Aug 10, 2020
    Messages:
    112
    Balance:
    642Coins
    Ratings:
    +89 / 0 / -0
    My Motion Simulator:
    4DOF
    Gains this software a solution for surge movement, there the longitudinal acceleration value is mapped to a rig position , so in that situation the driver can not feel the acceleration only the position changing, means in telemetry the changing of acceleration, feeling a second wrong direction jerk?
  18. cubexxx

    cubexxx Member

    Joined:
    Oct 4, 2019
    Messages:
    69
    Balance:
    537Coins
    Ratings:
    +41 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, 4DOF
    Not sure what you mean exactly, but your question seems more related to motion cueing, i.e. how to generate the position commands, for that you should look into FlyPT mover thread. My code is not concerned with this, but only with translating the positioning commands from mover (or other cueing software) as best as possible to pulses for the driver.
  19. wingert

    wingert Active Member

    Joined:
    Aug 10, 2020
    Messages:
    112
    Balance:
    642Coins
    Ratings:
    +89 / 0 / -0
    My Motion Simulator:
    4DOF
    thanks, that means filtering and telemetry processing must be done in FlyPT.
  20. wingert

    wingert Active Member

    Joined:
    Aug 10, 2020
    Messages:
    112
    Balance:
    642Coins
    Ratings:
    +89 / 0 / -0
    My Motion Simulator:
    4DOF
    I have tested your program it works fine.
    In combination with FLYPT (thanks for that great software), creating two independent mover for each direction forward,backward with filtering (crop/HP/crop/LP) and combine it in the Rig.
    Thus I could get proper solution suppressing the second jerk, if mapping longitudinal acceleration to position. (surge movement) flypt1.PNG 77784 77785

    Attached Files: