Mike's SCARA Robot

That’s some amazing work and progress. I’m rooting for ultimate success and impressed with what you have done so far. I’ve made a couple PCBs, a couple including some degree of SMDs. But nothing as detailed as what you are doing. I love it.

Thank you so much! I feel like a complete newbie who got pretty lucky on his first try. Sort of a "It works and I don't know why" kind of thing :)

I was thinking today, and short of the entire robot being broken, I've gotten about as unlucky with this retrofit as I could have gotten (probably not, but that is how it feels!). Still having a blast and really hoping I am getting close to having working motors. Thanks so much for following along.
 
Quick update:

I got a small 5V supply in the mail which I added to my test setup. This is now powering all the encoders in the robot rather than trying to pull the power from the servo drives. The reason this is necessary is that the robot manufacturer tied all the encoder power wires together in parallel. The drives cannot combine their 5V outputs in parallel, and a single drive cannot supply enough current for all 4 encoders. The drive power supply powers only the logic chips on my custom PCB.

I finished testing all the combinations of motor power wiring. I still don't know how to interpret the results, but hopefully something will make sense the more I think about it. The notes below are really for my benefit.

The power connector on the drive is labeled U V W and it connects to the motor power wires with colors BRN BLK BLU. The hall effect commutation inputs on the drive are labeled S1, S2, S3 and connect to wires labeled S1 S2 S3. The tests below are listed as the wire number/color attached to the drive terminal inputs U, V, W, S1, S2, S3 in that order

The following combinations yielded successful hookup tests:
  • BLK, BRN, BLU, S1, S3, S2: Poor motor control, stalls after 2-3 revolutions
  • BLK, BRN, BLU, S2, S1, S3: Poor motor control, stalls after 2-3 revolutions
  • BLK, BRN, BLU, S2, S3, S1: Somewhat better control, stalls after 2-3 revolutions
  • BLK, BRN, BLU, S3, S1, S2: Very poor motor control, runaway motor, motor overspeed fault
  • BLK, BRN, BLU, S1, S2, S3: Poor motor control, runaway motor, motor overspeed fault
  • BLU, BLK, BRN, S3, S2, S1: Poor motor control, Failed to Autotune, runaway motor, motor overspeed fault
  • BLU, BLK, BRN, S1, S2, S3: Somewhat better control, stalls after 5-6 revolutions
All other 29 combinations yielded a "Motor Feedback Signal Error" and a failed hookup test. The tests that failed caused the shaft to snap roughly 60 degrees at the start of the test while the ones that passed started smoothly.

All tests that passed rotated in the clockwise direction when viewing the motor shaft. All tests were completed with the feedback polarity set to "Positive".

When a hookup test was passed, the motor was immediately tuned with the following parameters: Travel Limit - 36000 degrees, Speed - 3600 deg/s, Torque - 100% rated, Direction - Forward Bidirectional, Damping Factor - 0.8

Movement was tested by issuing a Motion Servo On (MSO) command followed by a Motion Axis Move (MAM) command with the following parameters: Incremental, Distance - 360 deg, Speed - 360 deg/s, Acc/Dec - 1000 deg/s/s. The motion was repeated until the axis faulted.

Common trends and puzzling discoveries:
  • All successful tests rotated the motor shaft CW when viewed from the motor face
  • Motor control is pretty good when first turned on, however it gets worse each time the motor moves a revolution from the starting position
  • Eventually, the motor stalls and produces no useful torque
  • Some successful tests resulted in a runaway motor condition triggering a motor overspeed fault
  • When motor control gets poor (after a couple revolutions), I can manually rotate the motor shaft and get it to cog to a new position.
  • There are an odd number of successful tests (weird)
  • The combination BLK, BRN, BLU was successful in 5/6 combinations of hall effect commutation signals
  • The combination BLU, BLK, BRN was successful in 2/6 combinations of hall effect commutation signals
  • All tests that were successful and didn't cause a runaway motor resulted in diminishing motor control the further the motor traveled
I think the biggest issue I need to look into is the diminishing torque. It almost seems like there is a mismatch between the number of motor poles somewhere in hardware/software. I have a few people I know at work who are pretty smart with this kind of stuff and should be able to point me in the right direction.

-Mike
 
Talked with a guy I consider to be an expert in our motion control products at work about my issues. He agreed about the motor behavior being related to drift in the commutation angle. Apparently the motor mechanical and electrical angles can differ by as much as 30 electrical degrees without a significant loss of motor control, however current draw increases quite a bit as waste heat. The loss of controllability, motor oscillations, and runaway are all symptoms of incorrect commutation. Neither of us could make sense of the weird way that the hookup tests passed.

He had a couple things for me to try:

1) Measure the motor Back EMF using the oscilloscope and match it to the hall effect signals. The drive expects the signals to appear in the following order (RST is UVW and ABC is S1, S2, S3):

1.png

2) In the motor CMF file, there is a line entry for "Motor Polarity". Default is "0". Since Rockwell winds their motors such that positive rotation is CW when viewed from the motor face and Yaskawa winds theirs CCW, I think I might have needed to set this equal to "1". After scoping the motor, I will repeat the hookup tests with this value inverted. In order for the motor to function, the mechanical direction, the winding direction, the commutation signal direction, and the feedback direction must all match or be compensated for in software configuration.

He also reassured me that as long as my circuit is correctly generating the commutation waveforms, there is no reason the drive shouldn't be able to run my motors.
 
Last edited:
After work today I spent an hour or so running the Back EMF tests on the Z axis motor. I'll attach a bunch of pictures here and discuss at the bottom.

Common to all tests: Probe A (Red) measures from Motor terminal "U" (BRN) to motor Terminal "V" (BLK). Probe B (Blue) measures from motor terminal "V" (BLK) to motor terminal "W" (BLU). Probe C (BLK) measures from motor terminal "W" (BLU) to motor terminal "U" (BRN). Motor was rotated at a relatively constant velocity with a cordless drill at a slow speed. Motor was rotated in the clockwise direction when viewed from the motor face. Channel D (Green) was changed between tests.

Test 1: Channel D measures PCB output "S1"
IMAGE040.jpg

Test 2: Channel D measures PCB output "S2"
IMAGE044.jpg

Test 3: Channel D measures PCB output "S3"
IMAGE048.jpg

Test 4: Channel D measures PCB output "Z". Cursors are sitting on top of the index pulses.
IMAGE053.jpg

Results: As expected, when the motor is spun clockwise, the back EMF signals appear to be going backwards WVU. This was expected since this excerpt from the SGM manual indicates motor direction. As a note, the motor wire colors are BRN = RED, BLK = WHT, BLU = BLU. I used servo cable I had on hand which didn't have colors to match the Yaskawa convention.

1593649976249.png

The hall effect signals seem to increment S3, S2, S1 which is somewhat expected as again the motor is rotating in the opposite direction. What is curious is that the image in the post above provided by my colleague shows the halls transitioning at the 0V crossing of the measured Back EMF signal, while the halls I measured are shown transitioning at the intersection crossing between the waveforms. I believe this means the hall tracks natively etched into the encoder disk on the motor are out of phase with the windings (for the particular way Allen Bradley drives expect to see the commutation signals).

If this is true, then the signals should be able to be corrected by applying a negative 30 [electrical] degree commutation offset to the motor. This can either be done from the CMF file (currently set to 0.0) or through a SERCOS IDN message - an instruction in the PLC which sends a command to reconfigure the drive settings over the SERCOS fiber optic network.

The description of this message is the following: "This IDN is the synchronous motor commutation offset. This is set to zero for asynchronous motors. The two bytes contain absolute position at the defined commutation vector U+, V+, W-. U leads V leads W for clockwise rotation from the shaft end. The units are electrical radians from the defined null position."

If the commutation angle is really off by 30 electrical degrees, then I am right at the limit of motor controllability according to my colleague.

I also have a feeling that I will need to set the "MotorPolarity" in the CMF file to "1" since the phases occur in the opposite order compared to what the drive expects.

One last thing is the 4th tests shows that 4 electrical cycles occur between index pulses, and that the index pulse occurs at the peak of the VW BEMF waveform. There are 4 complete signal periods between the index pulses confirming that there are 4 pole pairs or 8 magnetic poles on the motor.

I'll probably play with these settings tomorrow! Have a great 4th of July weekend everyone :)
 
Last edited:
One additional thing. You can see numerous glitches on the commutation output channel (Probe D - Green). These are a real issue with my custom PCB and I think I have the issue figured out.

IMAGE050.jpg

The issue comes about due to the encoder signal (asynchronous) being sampled into a clocked circuit. The very first thing that happens to the signals when they enter my board is that they are "synchronized" by a pair of flip flops. A flip flop is a edge triggered memory element where the value at the input "D" is latched to the output "Q" when the clock "CLK" rises from low to high.

1593654304698.png

There is a minimum amount of time that the input "D" must be stable both before and after the rising edge of the clock. This is called the setup and hold time. These are specified in the chip datasheet, for example this Texas Instruments CD74AC175 (Quad D-Type Flip-Flop):

1593654572824.png

If the input signal violates the setup or hold time, metastability can occur. Metastability is a state when the flip flop can get temporarily stuck between states or rapidly oscillate until it resolves to either high or low. The issue is this result is completely random and nondeterministic.

This graphic below shows many samples of the green signal become metastable and how they can take many paths and either settle high or low (before eventually being corrected near the far right edge on the next clock pulse)

1593654858522.png

The clock that sequences the logic oscillates at a very stable 8.0000MHz. Since there is no way for me to guarantee when the input signal will change, there is a pure probabilistic chance that any given input transition will happen at the same time as the clock edge and become metastable. This is dependent on the circuit clock frequency, the signal frequency, and the proportion of time in which a setup or hold time violation could occur. This calculates to *on average* 240,000 metastable events per second when the motor is running at max speed. But not to worry! We contain this unstable signal between a pair of flip flops called a 2FF synchronizer. This forces a 1 clock cycle delay for the metastable signal to settle and assures a very very high likelihood that there will be no metastability after the synchronizer. Since the value randomly lands high or low, there is a 50% chance that the signal change is delayed by 1 clock cycle into the circuit, this is perfectly acceptable.

In the graphic below, "Din" represents the input to my circuit. CLK-A is the clock in the encoder (of which I have no control over) and CLK-B is the 8.0000MHz clock in my circuit. Each blue box represents the flip flop circuit shown above. You can see the "Din" signal rises at the same time as CLK-B. This causes the output "Ds" to become metastable, however this value settles well before the next clock pulse on "CLK-B". Notice the output "Dout" transitions very cleanly because the metastability has settled at the expense of 2 clock cycles of delay from the input signal "Din".

This synchronization is only needed when a signal is brought in from another clock source or the outside world. Once you are inside the circuit, there is no risk of metastability unless poorly designed.

1593654810921.png

But hey! I have 2FF synchronizers on all my inputs... Why do I still have glitches?

Well, the key is that each signal randomly settles to a value when metastability occurs. In my signal, 2 inputs can change at the same time (big problem). There is some finite probability that both inputs will go metastable at the same time (actually pretty likely since they transition at the same time and all flip-flops see the same clock). If both do metastable, there is a 25% chance they resolve to the correct values, 25% chance they resolve to old (but valid) values, and a 50% chance that they resolve to one of two illegal value combinations. This 50% chance of an illegal input combination after metastability is what causes the glitches.

1593656535044.png

If the glitch registers on the first sample of a new input combination, then the error is corrected on the next sample, however if the error occurs on the last sample before an input transition, then the glitch gets latched into memory until the encoder moves 3 more counts in the forward direction so the input sample can be corrected. These are the larger glitches shown in some of my earlier scope traces.

There is not a good solution that completely preserves data integrity without additional handshaking signals, however I realized I have an option that isn't available to most people designing circuits - it is acceptable for me to discard input samples. Since it is impossible to know if a flip-flop is metastable, I assume that the first sample after any input transition is bad and I discard it. If the next sample matched the previous, then we know the sample was good and it is OK to use the data. If the next sample doesn't match the previous, then metastability and data corruption occurred and we throw away a second sample and check the 3rd. In this way we trade a small amount of additional delay (100-200ns) for guaranteed signal integrity.

Here is my circuit modification to the input section of my circuit accomplish this. It adds 3 additional chips (3 channel 2-input XNOR gate, 3 channel 3-input AND gate, and 3 channel 2:1 multiplexer). Unfortunately I'll have to re-order PCBs, but I am going to try to rework my test board first to prove the concept before spending the money on another potentially faulty PCB.

1593656560590.png
 
Worked on the commutation issues and CMF file last week. I modified the "Motor Polarity", "Commutation Offset", and "Factory Aligned" parameters, however there was not any significant change in motor performance. I also set up a message to change the commutation offset on the fly. Changing this by 30 degrees at a time did not find any value which properly operated the motor. Additionally, the motor polarity did not seem to be changed either.

I need to think more on what is going on here. I have a buddy at work who was interested in taking a look at it, so I might see if he has anything to add to this conversation.

Hope everyone had a great 4th of July.
 
I have not solved the issues related to motor commutation, however I do feel that I will be able to, so I am not letting that stop me from working on other aspects of this project.

The big update right now is that I have created a Version 2.0 of the interface PCB that demultiplexes the encoders on the robot.

1594648035220.png

1594647595256.png

1594647969870.png

The new PCB is a bit longer than before due to the addition of 3 new IC's as well as "wings" on the outside of the connectors to allow me to silkscreen the pinouts on the top as well as the bottom. It was a pain to have to flip back and forth between the two sides while wiring it.

The 3 new integrated circuits modify the input sampling circuitry to block the first sample after an input state transition from entering the circuit. Only when two consecutive samples are the same can the circuit evaluate new outputs. This should prevent glitches from occurring due to sampling the signals into a clocked circuit and make it more robust against noise (at the expense of an occasional 125ns added delay to the outputs).

The power circuitry has been updated to include reverse polarity protection on the power inputs. The LED resistors have been changed from 85 ohm to 200 ohm to make them a bit dimmer. All the components have been packed more tightly together to save space. I also manually routed all the power circuits before running the auto-router to make sure it branches nicely and all chips properly engage their decoupling capacitors. I opted not to bother adding ESD protection to the inputs and outputs. All the chips come with 2kV protection built in. This isn't the best, but I'll just try to be careful with them. The cost keeps climbing every time I add new features.

The bottom row of IC's has been shifted up to make room for a thick polygon pour on the bottom edge. This is a path to land cable shield connections and pass them through into the servo drive. Without this, I couldn't land any shielded cables. I also changed the one side of terminals from 10 to 12 to add 2 locations to land the cable shield.

I feel kind of bad for the PCB company. This little board needs almost 300 0.20mm holes drilled in it for all the interconnections.

The board is fully routed, but I still need to do a wire by wire verification of the design against the simulation and fix up the silkscreen.

-Mike
 
Last edited:
I feel kind of bad for the PCB company. This little board needs almost 300 0.20mm holes drilled in it for all the interconnections.

No reason to feel bad ....they should simply know their capability limits: hole size, aspect ratio(hole size vs board thickness), line widths, plating, layer alignment, etc. and charge you accordingly. You likely have no blind or buried VIAs, no buried capacitance or resistance, no exotic plating, etc.

Sure it looks complex to you and me, but their robots won't care!

How many layers is it?

-brino
 
No reason to feel bad ....they should simply know their capability limits: hole size, aspect ratio(hole size vs board thickness), line widths, plating, layer alignment, etc. and charge you accordingly. You likely have no blind or buried VIAs, no buried capacitance or resistance, no exotic plating, etc.

Sure it looks complex to you and me, but their robots won't care!

How many layers is it?

-brino

Honestly from a PCB manufacturer's perspective, this is as easy as it gets. 2 Layer, 1oz copper, 10/10 mil trace space, 1.6mm thick. No blind, buried, laser drilled, or filled vias. No via in pad. Hot air solder leveling and black solder mask. That's how I managed to get 25 of them for $12.

Just me as a machinist, I'd be ticked off if I needed to drill 300 0.2mm holes in each board.
 
I'd be ticked off if I needed to drill 300 0.2mm holes in each board.

Absolutely, me too!
I hate to think of how many spare drill bits I'd need due to breakage......and how many scrap boards there would be with broken bits in them.
Unless you could use broken drill bits as "plated-thru VIAs". :)

-brino
 
Back
Top