This topic has 16 replies, 3 voices, and was last updated 6 years ago by SuperDroid.

  • Author
    Posts
  • #5606
     Dave
    Participant

    Hello,
    I’m trying to figure out the best way to control the SDC2130s that I bought and wanted to try controlling them via PWM since RS232 is going to require ordering a new cable. I have a Micro Maestro 6-Channel USB Servo Controller (Pololu item #: 1350) and I was able to connect SDC2130s’ DB15 P4 data and P5 GND (SDC2130 manual pg 7) to Maestro servo 0 single and ground. This allowed me to control the motor via SDC2130 after putting PWM first in the SDC2130 order. However, I noticed in the Roborun utility that it was showing nearly identical values for both digital channels 1 and 2 even though nothing is connected to digital channel 2. (see attached pictures) I don’t know how important this is, but my end goal is to use digital channel 3 for PWM input and digital channel 1&2 for the encoder inputs.

    Thanks for your help,
    Dave

    Attachments:
    You must be logged in to view attached files.
    #5609
     SuperDroid
    Keymaster

    Hey Dave,

    Do you have the encoder channels enabled? The reason I’m asking is ENC1A and ENC1B share the same pins as RC1 and RC2. Therefore, Encoder 1 and PIn1/PIn2 should never be enabled at the same time.

    At the top of Roborun you can find a “View Pinout…” button. From this you’ll see that RC5 and RC6 also share the same pins as ENC2A and ENC2B. So if you plan on using both encoder channels, your only pulse read options will be PIn3 (RC3) and PIn4 (RC4).

    Also, I feel it’s important to note that interfacing with RoboteQ motor controllers through USB is the best alternative to RS-232 (even better in some cases). USB interfacing will allow you to access/poll data such as voltage levels, current draw, encoder values, and many other data points that prove to be useful feedback. Just pointing this out since it seems you have a serial port available.

    Let us know if you have anymore questions.

    #5610
     Dave
    Participant

    Hello,
    Yes, both encoders are disabled. I had enabled them and then disabled them earlier today. Please see the attached picture.
    Is it possible to use the encoders and then use digital channel 3+ for the PWM input?
    Regarding interfacing with RoboteQ motor controllers through USB, do you have any more information on how to do this? It’s not practical to use the Roborun+ utility. THe plan is to use a computer running Ubuntu to control the motors with encoder feedback for closed loop operation with the SDC2130.

    Thanks again for your help.

    Attachments:
    You must be logged in to view attached files.
    #5612
     Dave
    Participant

    Attached are the Digital pin input configurations

    Attachments:
    You must be logged in to view attached files.
    #5614
     SuperDroid
    Keymaster

    If you’re saying digital channel 3 is PIn3, then yes. When using encoders, please keep PIn1, PIn2, PIn5, and PIn6 disabled. Your PWM signals should be connected to pins 11 and 12 which translate to PIn3 and PIn4 in the Roborun utility.

    For a USB connection there’s no need to use the Roborun utility. This is just a convenience provided by RoboteQ. Since you’re using a Ubuntu machine it will be very similar to RS-232 actually. In fact, RoboteQ provides a Linux API just for this purpose. You can download it here: https://www.roboteq.com/index.php/support/downloads

    I would definitely recommend this if you’re familiar with C++.

    #5615
     Dave
    Participant

    So the good news is that D2 is no longer putting out a PW value. The bad news is that I don’t know why it stopped and can’t repeat the bug.

    #5616
     Dave
    Participant

    When using encoders, please keep PIn1, PIn2, PIn5, and PIn6 disabled.

    Thank you. I connected everything for one motor and I am able to control the motor using PWM (Digital P3) and read the encoder. (Please see attached pictures.) However, I’m still unsure if the Encoders should be selected as “Command” or “Feedback” to make sure the motor maintains a constant rpm. I tried holding the motor shaft to slow it down, but the gearing is too high. Can you please let me know what the correct setting is for the encoders?

    I’ll look into the API you sent in a bit. Thank you very much.

    Dave

    Attachments:
    You must be logged in to view attached files.
    #5628
     SuperDroid
    Keymaster

    The encoders should be configured for Feedback. Once you set the motor operating mode to “Closed Loop Speed” you can plot the loop error in the run tab. This will useful when tuning the PID parameters. Also, make sure the “Max Speed” and “Pulses/Rev” parameters accurately reflect what your motor and encoder are capable of.

    Also, make sure your RoboteQ MC firmware is up to date before testing and tuning the speed control. The firmware was updated earlier this year to fix a bug which caused the output to stick on max negative motor power in closed loop speed mode. This can be a dangerous bug depending on the application.

    #5630
     Dave
    Participant

    Thank you, that’s especially good to know about the software update to fix that bug. That could have been bad.

    I’ve updated the software after downloading the files from RoboteQ’s SDC21xx website and then set my motor operation to “Closed Loop Speed” (please see attached). Do you have any suggestions on how to tune the PID and the other settings like “Max Speed”, “Acceleration”, “Deceleration”, Turns Min to Max”, etc.? I’m using one of your “IG42 24VDC 078 RPM Gear Motor with Encoder” on my desk without a wheel attached to it for testing.

    I tried just running with the default values and the motor very rapidly/ violently went forward and reverse with a small PWM value of 1456 (just ~50 off from center ie. no movement). One other disconcerting observation was that even after I turned off the PWM single the motor still continued to rapidly move forward and reverse unlike before in direct control mode where turning off the PWM single caused the motor to stop because the controller had switched to Serial input which was set at no movement (sliders centered in the Roborun+ utility). I had to press the “Emergency Stop” in the Roborun+ Utility to stop the motor.

    Thank you

    Attachments:
    You must be logged in to view attached files.
    #5632
     SuperDroid
    Keymaster

    Max speed should just be the max RPM of your motor. By default the acceleration and deceleration are both twice the max speed. So you could go ahead and scale these values with your max speed and leave them alone for the time being. Typically, having these values inflated will cause faster wear and tear on the mechanical components of your system but it depends on the application. Your pulses/rev will need to be measured and entered into the encoders section. I would definitely take care of these parameters before tuning the PID.

    For the PID, I recommend plotting the loop error in the run tab while accelerating/decelerating and adjusting the parameters accordingly. If you’re unfamiliar with the parameters of a PID algorithm, I would do some research beforehand. The wiki page has a pretty decent overview on manual PID tuning: https://en.wikipedia.org/wiki/PID_controller#Loop_tuning

    The behavior you’re seeing is probably a result of one (or all) of two things:
    – The RoboteQ is set to use the wrong encoder input for speed calculations. Motor command 1 will use Encoder 1 values to make speed calculations and corrections. Verify the wiring matches your configuration. Encoder 1 can be setup to use values from ENC2A and ENC2B by setting “Use” to “Feedback(2)”.
    – Positive motor command results in decreasing encoder counts. For speed control to work, the count and command polarity have to match. Otherwise, the PID will be making corrections in the wrong direction.

    Hope this helps.

    #5633
     Dave
    Participant

    Hello, thank you for the information. I have two quick questions of clarification:
    1.”max RPM of your motor” do you mean the geared output or the motor shaft that’s connected to the encoder? I think you mean the motor shaft connected to the encoder. From the datasheet of the motor should I use Max RPM of 5600 or no load max RPM 7000 (please see attached)
    2.”pulses/rev will need to be measured” I assume you mean pulses per revolution of the geared shaft output, not the motor shaft which is 5PPR (please see attached)

    Thank you again for your help

    Attachments:
    You must be logged in to view attached files.
    #5636
     SuperDroid
    Keymaster

    Usually you want to use the final geared output for both parameters. So in your case it would be 78 RPM for max speed. Then observe the encoder counts as the geared shaft approaches one revolution. This is going to give you a very high encoder count resolution for speed calculations.

    You can fudge these numbers if you need higher that 1 RPM precision in your control. Just keep in mind these two parameters have an inverse relationship.

    #5637
     Dave
    Participant

    Ok, I thought I could calculate the PPR by 84 (gear reduction) * 5 (PPR)= 420 PPR on the geared motor output shaft, but when I tested it, the counter in the RoboteQ showed ~1,600. (attached) Any idea why my calculation and reality were so far off?

    Continuing, I entered 1600 in Encoder 1, Pulses/Rev and the motor this time slowly sped up until it was turning at full speed and did not rock back and forth like earlier (I haven’t changed the hardware set-up). But, the motor just goes to full speed and changing the PWM value doesn’t slow the motor down, reverse, or stop with the PWM is shut off like it does in direct control mode. It seams like the controller reads the PWM value once to decide which direction to turn the motor and then never looks back.

    Attachments:
    You must be logged in to view attached files.
    #5639
     Dave
    Participant

    Ok, so I think it’s working now. It’s now providing a constant speed under different loads to the motor gear output shaft. :)

    I spent some more time reading through that huge document “Roboteq Controllers User Manual v18” and on pg 123 found some “strt-up steps for closed loop speed control (attached). Following those instructions I saw that the when the feedback (Counter 1) should have been positive, it was negative. I then followed the next step in the attached doc and switched the encoder channels A and B. (I also tried switching the positive and negative going to the motors, but that didn’t seem to allow the motors to turn which is odd since they’re brushed and can go in forward and reverse)

    Now I’m able to control the motor on my desk using either the RoboteQ Utility (sliders) or via PWM, slow the motor to a craw, put a load on the motor and it still turns at a steady rate and I don’t see the error where the controller doesn’t respond after the 1st command, even turning off the PWM single which is very odd.

    I’ll reevaluate the tuning of the PID once the robot is built and in testing conditions. Attached is the configuration page with the values I used. Please notice that I still don’t know if the Pulses/Rev should be 420 as I calculated (84*5=420) or should be ~1,600 as measured. (see lingering question below, and above post)

    Thanks again for helping with this, can you please let me know your thought on my other threads/questions?

    Dave

    Lingering question:

    I thought I could calculate the PPR by 84 (gear reduction) * 5 (PPR)= 420 PPR on the geared motor output shaft, but when I tested it, the counter in the RoboteQ showed ~1,600. Any idea why my calculation and reality were so far off?

    Attachments:
    You must be logged in to view attached files.
    #5642
     SuperDroid
    Keymaster

    Search the blog for posts on encoders, we have a lot of posts on this topic. This one should help you with your calculation. https://sdrobots.com/tech-thursday-029-encoder-cpr-resisted/

Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic.

Login Register

©2024 SDRobots.com | All rights reserved.

Log in with your credentials

or    

Forgot your details?

Create Account