phase shifting

Hi Bro

what burns my mind is when i do the first cut manually in the middle of the hole then i give a cutting distance as an input (eg 10cm) starting from the middle of the previously cutted hole as the start of counting
the length of the cutted pieace is 10cm (-/+2mm) but the cut is not in the middle of the the hole even that the distance between hole is 1cm
the holes width is 5mm
if the cutt is not exacly in the middle that is exactable (just cut the hole between its width)) and that's what am not gatting


If the machine moves exactly the commanded distance of 10CM then it did what it was asked to do; regardless of where the holes are. Your drawing shows a distance of 1CM from center of the hole to the center of the hole so if the machine cuts exactly 10CM away that has to be in the center of a hole.



Please give more detail of the system, Peter has already asked but I will ask them again:
General information:

  • Does the machine stop to perform the cutting or is it on the fly?
  • Are you cutting every hole? If not, are you cutting the same distance repeatedly, every machine setup?
  • How is the machine setup to start the cutting process, is it like you said, manually positioned in the center of the hole and then commanded to cut at a distance from that point?
  • Is there any sensor used in the process for any reason and if yes what does it do.
Hardware information:

  • What is are the specs of your encoder:
    • PPR
    • Is it two phase? (form your question I would say it is, but good to know for sure)
    • How is it mounted to the machine?
  • What PLC are you using:
    • I assume it is Siemens, which one and which firmware?
    • How is the encoder connected to the PLC, A and B?
Programming information:

  • Which TIA version?
  • Are your encoder inputs configured for HSC?
  • What are the setting in your configuration?
  • Are you using hardware interrupt for any reason?
  • How is the distance entered processed, converted or otherwise used to initiated the cutting? Meaning, you entered 10CM then how is that number used to position the product?
  • How are you using the HSC counter value to determine cutting position, what are you comparing, with what and where in the program?
Note: The old system has been removed so trying to figure out how it worked is purely academic now and may very well be irrelevant to the current system. But, those switches may have been used in many different way and one of them is as an encoder.
 
Hi Bro
in the old system when s1=1 means that the cutter blade is in the middle of the hole, also and somehow s1 is included in the measurement cause when removing one of the sensors you won't get a good results


What did you change, what do you mean by systems?
Did you change just those two switches with and encoder and are using everything else including the existing code or what?
 
I still do not fully understand how the old system works, so I will make a guess.

  • The holes in the coil material are 1cm apart.
  • The width of the gaps and of the teeth on the pinion gear represent 1cm movement of the coil material.
  • The S1 and S2 sensors never have the same value, so if S1 is 1, then S2 is 0, and if S1 is 0 then S2 is 0.
    • This means that if S1 is detecting a tooth, then S2 is detecting a gap (no tooth), and vice versa
    • This also means that, if S1 sees a rising edge (0 to 1, gap to tooth, transition), then S2 has a falling edge (1 to 0, tooth to gap, transition), and vice versa
  • When starting a series of cuts of the same length of some integral number of cm,
    • 1) The machine is stopped
    • 2) The operator manually aligns the system so it will cut in the middle of a hole
    • 3) The operator makes the cut at that first (zero-th;)) hole
    • 4) The operator adjusts the sensors so S1 is at the start of a gap and S2 is at the start of a tooth
      • So
        • after 1cm of total movement, S1 will have a rising edge
        • after 2cm of total movement, S2 will have a rising edge
        • after 3cm, S1 will have a rising edge
        • after 4cm, S2 will have a rising edge
        • etc.
      • Perhaps S1 and S2 are on a jig that keeps the distance between them fixed i.e. a distance of 1cm of the material
    • 5) The operator selects the length of subsequent cuts as an integral number of cm
    • 6) The operator starts the machine,
    • 7) The machine uses a single counter to count the rising edges (transitions) of either S1 and S2,
      • Since S1 and S2 are 1cm apart in "phase," only one of those transitions will happens on every single cm, which is why two sensors are needed i.e. to handle odd (1, 3, 5, ...) integral lengths in cm
Am I closer to understanding the process?


If yes, can you give the details of the physical encoder setup: coil drive wheel diameter; gearing between encoder and coil wheel if the encoder is on a different shaft; [A] encoder pulses per revolution (PPR; assume B PPR are the same); speed; whether the process stops to make each cut; was a PLC used for the old system; is a PLC used for the new system; etc.
 
Last edited:
I still do not fully understand how the old system works, so I will make a guess.

  • The holes in the coil material are 1cm apart.
  • The width of the gaps and of the teeth on the pinion gear represent 1cm movement of the coil material.
  • The S1 and S2 sensors never have the same value, so if S1 is 1, then S2 is 0, and if S1 is 0 then S2 is 0.
    • This means that if S1 is detecting a tooth, then S2 is detecting a gap (no tooth), and vice versa
    • This also means that, if S1 sees a rising edge (0 to 1, gap to tooth, transition), then S2 has a falling edge (1 to 0, tooth to gap, transition), and vice versa
  • When starting a series of cuts of the same length of some integral number of cm,
    • 1) The machine is stopped
    • 2) The operator manually aligns the system so it will cut in the middle of a hole
    • 3) The operator makes the cut at that first (zero-th;)) hole
    • 4) The operator adjusts the sensors so S1 is at the start of a gap and S2 is at the start of a tooth
      • So
        • after 1cm of total movement, S1 will have a rising edge
        • after 2cm of total movement, S2 will have a rising edge
        • after 3cm, S1 will have a rising edge
        • after 4cm, S2 will have a rising edge
        • etc.
      • Perhaps S1 and S2 are on a jig that keeps the distance between them fixed i.e. a distance of 1cm of the material
    • 5) The operator selects the length of subsequent cuts as an integral number of cm
    • 6) The operator starts the machine,
    • 7) The machine uses a single counter to count the rising edges (transitions) of either S1 and S2,
      • Since S1 and S2 are 1cm apart in "phase," only one of those transitions will happens on every single cm, which is why two sensors are needed i.e. to handle odd (1, 3, 5, ...) integral lengths in cm
Am I closer to understanding the process?


If yes, can you give the details of the physical encoder setup: coil drive wheel diameter; gearing between encoder and coil wheel if the encoder is on a different shaft; [A] encoder pulses per revolution (PPR; assume B PPR are the same); speed; whether the process stops to make each cut; was a PLC used for the old system; is a PLC used for the new system; etc.
Hi bro
in this video i have explained how the machine works
https://www.youtube.com/watch?v=h4WRjM74ru0
the wheel revolution(360 degree)goves coil lenght of 256mm
 
If the machine moves exactly the commanded distance of 10CM then it did what it was asked to do; regardless of where the holes are. Your drawing shows a distance of 1CM from center of the hole to the center of the hole so if the machine cuts exactly 10CM away that has to be in the center of a hole.



Please give more detail of the system, Peter has already asked but I will ask them again:
General information:

  • Does the machine stop to perform the cutting or is it on the fly?
  • Are you cutting every hole? If not, are you cutting the same distance repeatedly, every machine setup?
  • How is the machine setup to start the cutting process, is it like you said, manually positioned in the center of the hole and then commanded to cut at a distance from that point?
  • Is there any sensor used in the process for any reason and if yes what does it do.
Hardware information:

  • What is are the specs of your encoder:
    • PPR
    • Is it two phase? (form your question I would say it is, but good to know for sure)
    • How is it mounted to the machine?
  • What PLC are you using:
    • I assume it is Siemens, which one and which firmware?
    • How is the encoder connected to the PLC, A and B?
Programming information:

  • Which TIA version?
  • Are your encoder inputs configured for HSC?
  • What are the setting in your configuration?
  • Are you using hardware interrupt for any reason?
  • How is the distance entered processed, converted or otherwise used to initiated the cutting? Meaning, you entered 10CM then how is that number used to position the product?
  • How are you using the HSC counter value to determine cutting position, what are you comparing, with what and where in the program?
Note: The old system has been removed so trying to figure out how it worked is purely academic now and may very well be irrelevant to the current system. But, those switches may have been used in many different way and one of them is as an encoder.

Hi bro
in this video i have explained how the machine works
https://www.youtube.com/watch?v=h4WRjM74ru0
the wheel revolution(360 degree)gives coil length of 256mm
 
How many teeth on the pinion?


How fast does the pinion turn (RPM, radian/s, encoder pulses/s, whatever) when the clutch is engaged?


In the old system, how is the cut implemented i.e.


  • is the brake engaged to stop the wheel-pinion shaft, in response to the state of S1 and/or S2, and the cut is made
  • OR
  • is the cut made while the wheel-pinion shaft is still moving?
In the old system, does S2 have the state of 0 for very brief times, i.e. when the pinion wheel is positioned such that S2 is halfway between two pinion teeth, and S2 has a state of 1 otherwise?


In the old system, is the wheel-pinion system, and the position of the cutter, designed such that S2 is 0 when the cutter is exactly in the center of the hole?
 
How many teeth on the pinion?


How fast does the pinion turn (RPM, radian/s, encoder pulses/s, whatever) when the clutch is engaged?


In the old system, how is the cut implemented i.e.


  • is the brake engaged to stop the wheel-pinion shaft, in response to the state of S1 and/or S2, and the cut is made
  • OR
  • is the cut made while the wheel-pinion shaft is still moving?
In the old system, does S2 have the state of 0 for very brief times, i.e. when the pinion wheel is positioned such that S2 is halfway between two pinion teeth, and S2 has a state of 1 otherwise?


In the old system, is the wheel-pinion system, and the position of the cutter, designed such that S2 is 0 when the cutter is exactly in the center of the hole?

for every motor revolution 360degree= 4000pulse==256mm(coil length)
in the old system the wheel breaks then the cut is made, that's also what i did in the new system
the sensors S1and S2 when the lower sensor is 0 the other is 1 and vice versa, and when the lower sensor is 0 means that the cutter is in the middle off the hole
but if we say let's forget the old system ,for the new system when you reach the specified length starting from the middle of the hole ,break then cut it's simple process but the results are not good ,today another problem appears
the first piece is 2cm more other ones are +/-4 to 6mm
i put a mark in the wheel to see if it return to the same place for every motor revolution (256==4000puls ==360 degree) i noticed that the mark does not return to the same place, in the program am not using the HSC interrupt it's just comparison (pic),i think the scan cycle has something to do with this problem

cutter.PNG
 
if 1 Revolution = 360° = 4000 encoder pulses = 256mm, then the encoder resolution is 64µm of coil per pulse, or just under 16 pulses per mm of coil.

How fast is the motor running?

Is it possible the new encoder has 4096PPR, not 4000PPR?

How long (in pulses) does it take the brake to stop the shaft? Can you record the first pulse value (".".mul_length) that is greater than or equal to "."."1ST_length" in the program (e.g. see below)? That way you might be able to see if the scan cycle time is a problem, and also how much the encoder moves after the trigger event.
cutter.png
 
Last edited:
If the variation is ±2mm, that is a 4mm range, or 4mm * (1revolution ÷ 256mm) = 1/64 of a revolution of variation.

If we assume the scan cycle time is 1ms and the cause of, and therefore equivalent to, that variation, then the motor speed is (1/64 revolution) ÷ 0.001s × (60s/1minute) ~ 940RPM.

So if the motor speed is around 1kRPM, that accounts for the variation, but not the error.
 
I finally got around to watching your video which was quite informative. Thanks for that.


I was not very clear on whether the machine stops to cut because the term "breaking" was used to mean different things, but I will assume the machine does stop which is achieved by disengaging a clutch that couples a motor to a gear.


One issue that has to be made clear is the distance cut. I do not care whether it cuts in a hole or not. If you command the machine to move 2cm and it does in fact move 2cm then it did what it is programmed to do and did it very well. Where the holes are located is an entirely different problem.


So I will assume the following unless you state otherwise:
1- The machine stops to perform the cut.
3- It is not skipping teeth and is otherwise mechanically sound.

2- The machine does *not* move the distance it is commanded.
3- There's a button to start cutting.


Your code in another thread uses the legacy HSC instruction; I suggest you use the newer instruction CTRL_HSC_EXT specifically to take advantage of its "Capture" feature but it is not the end of the world, you can always use a hardware interrupt to grab the counter current value.



  1. Configure HSC for A/B counter fourfold.
  2. Configure the input of the button that initiates the cutting to capture HSC current value which is done in HSC section of hardware configuration. (or alternatively configure a hardware interrupt for that input).
  3. Under Event Configuration check hardware interrupt for "counter value equal to referencevalue0" ( I know it's confusing, one is referencevlaue0 and the other is NewReference1)
  4. Set digital input filters for A and B encoder inputs to 0.1 microsec ( you can change that later if needed.
  5. Now comes the logic:
    1. Do not convert distance units to encoder counts, instead, move the machine to the center of the hole and via HMI or your engineering laptop, grab the counter current value. Then move the machine to the center of the next hole and grab that counter value, then move to another hole and grab the counter value. The idea is you want to get the average of those counter values to figure out the number of counts per move, meaning the number of counts from hole to hole. This value will be your number of counts from hole to hole which you will use to calculate the target counter value.
    2. A side note: I usually have code and HMI controls to do that at commission or set-up time and sometimes if needed, it is done on the fly using sensors to capture start and target values and do all the calculations.
    3. From here on you will use this value (number of counts equal to distance from hole to hole) to determine the number of counts needed for a move. I you want to move 10cm which is equal to 10 moves you multiply the counter value of hole to hole by 10.
    4. You may calculate the number of counts per cm to display on HMI or for the operator to enter the required distance which is hopefully in whole numbers. 12 CM = 12 moves.
    5. Do not reset the counter value, let it rollover.
    6. Use HSC to do the comparison independently of scan cycle. The steps are simple:
      1. Assume we want a distance of 12cm(12 moves). To do that you position the machine over the center of the first hole.
      2. Then Capture the current counter value, whatever it is and in whichever way you want.
      3. The target value where we want the machine to stop and cut is equal to the 12 x number of counts from hole to hole + current counter value.
      4. Load HSC NewReference1 with the target value we calculated in the last step.
      5. When the target value is reached the hardware interrupt you configured earlier will execute and in that block you will have code to stop the machine and start the cutting process.
    7. Stopping the machine is straight forward, add a RESET instruction to reset the output that controls the motor/clutch. Use :p to address the output with immediate effect. %Q0.5:p.
    8. Starting the cutting process involves more care, usually anyway. The difference is that with a machine like what you described there's no safety or functional risk to stopping the machine with consideration to any code but starting a cut could very well be risky and may cause damage to product or the machine itself if other conditions are not evaluated. Safety of human beings is outsider the scope of this post as it involves entirely different hardware and design considerations.
    9. So if you know it is OK to turn on the output to start cutting without validating any conditions then go ahead and use the same method above with a SET instruction and ":p" if not then have a look at the project I posted earlier which calls the block responsible for cutting. It should verify whatever conditions required to initiate the cut.
    10. Note: Addressing the output with a SET or RESET instructions need to be followed with updating those outputs and the coder controlling the in the rest of the program.
    11. Now that we got the first cut we need to prepare for the next one:
      1. In the same hardware interrupt, for counter value equal to reference value, we want to grab the current counter and we want to do that in the hardware interrupt so that we have the most accurate value.
      2. Then somewhere in regular scan cycle we will calculate the next target value the same way we did earlier and load that into NewReference1 yet again.
      3. The reason we do not do the calculation in the interrupt is that you want to interrupt execution to be as short as possible to maximize accuracy.
      4. And so on, the process keeps repeating for as long as the distance is the same.
 
Here's another archive with no block call in the interrupt for faster execution and more suitable for your application which is unlikely to be moving that fast. I assumed the conditions necessary to stop the motor and start cutting will have been ready by the time the interrupt is triggered.
Also assumed that both stopping of motor and starting of cutting may occur simultaneously.
 
Here's another archive with no block call in the interrupt for faster execution and more suitable for your application which is unlikely to be moving that fast. I assumed the conditions necessary to stop the motor and start cutting will have been ready by the time the interrupt is triggered.
Also assumed that both stopping of motor and starting of cutting may occur simultaneously.


This is buggy, do not use it. I won't get around to fixing it till tomorrow or Monday.
 
Fixed both versions with preference to use the first version.



The issue with using interrupts is that as the name implies they interrupt the process at any point, between rungs or between instructions. So you have to use a lot of imagination and/or spend hours creating tests to cover all possible and impossible scenarios.


As you may see, if I haven't lost you yet, my comments in version2 in one of the rungs explains what would happen if the interrupt is triggered between those two rungs and how I mitigate it; not pretty which is why I prefer version1; but I know many people find it confusing.
 
Fixed both versions with preference to use the first version.



The issue with using interrupts is that as the name implies they interrupt the process at any point, between rungs or between instructions. So you have to use a lot of imagination and/or spend hours creating tests to cover all possible and impossible scenarios.


As you may see, if I haven't lost you yet, my comments in version2 in one of the rungs explains what would happen if the interrupt is triggered between those two rungs and how I mitigate it; not pretty which is why I prefer version1; but I know many people find it confusing.
Hi Bro
the last update i did on the machine is that i removed the encoder and tried with only one lower sensor and use it as single phase encoder and also with CTU (count up instruction)
with CTU (no HSC is configured) ,a rising edge detection will count when ever one of the pinion 25 teeth is detected , my motor RPM is 1300 but there a gear is used to reduce the RPM so all teeth's are detectable, I put a mark on the pinion and program it to stop after 1 REV or 25 teeth (used 25 teeth),i noticed that after 25 count the motor stops but in the CTU CV it reads 26 means there is a displacement of 1 teeth
in this case i assumed that the breaking mechanism is not doing well,i tried the same code in another motor and mechanism with a pinion of 18 teeth i did a mark and asked for 1REV=18 teeth the result was good the pinion returns to it's start point exactly after 18 teeth (am not sure if both motors have the same RPM and gear boxes) ,i will change the mechanisms and see if it works ,if so i will keep with CTU no need for HSC and it's complexity

IMG20220817132727.jpg IMG20220817132745.jpg IMG20220817132759.jpg IMG20220817132804.jpg IMG20220817132856.jpg
 

Similar Topics

What would happen if you ran a 60Hz Single Phase Motor on 50Hz supply?
Replies
6
Views
469
Hi all, I am having a problem with a powerflex 753 we have on site and keep getting input phase loss. The drive has been running for a long...
Replies
7
Views
1,267
We have an existing VSD where a three phase circuit breaker feeds the drive, and two phases also tee off to a contactor, which is energised to...
Replies
12
Views
1,455
Hello all... I'm looking for a 480v 3ø 25+ amp Solid State Relay to replace a mechanical one beating itself to death keeping temp in a heating...
Replies
15
Views
1,885
Hello. We have a Powerflex 700s phase II firmware 4.002, but the encoder card is burned. We want to disable it to use the Drive without motion...
Replies
0
Views
443
Back
Top Bottom