stop count early

Roy Spiller

New Member
Hi I have enclosed a part of the program I am using to spool tape off one spool to another spool. It is working fine it stops just before the end and then move on to rewind. I would like to change it slightly I would like to stop and reverse at a point I select. At the moment the count is about 11600 pulses from each encoder on each spool when they meet they stop and reverse. D.1 and b.1 are my counters I have added the extra 3 to w11 to make sure the two counts don’t meet at the start. I would like to stop at about 30 pulses short of the finish I can’t add a number to w10 before it starts because it will stop when it reaches that number. So I’m stuck.


brake:
high b.6
pause 150
low c.5
w10 = 0 ;supply motor pulse
w11 = 3 ;takeup motor pulse
low a.6 ;c.1 motor brake off
low b.6 ;c.2 motor brake off
low b.3 ;supply motor dir
low b.7 ;takeup motor dir
pwmout c.1, 199, 630
pwmout c.2, 199, 300
do
If pinD.1 <> bit0 Then
bit0 = bit0 ^ 1
w10 = w10 + 1
End If
If pinB.1 <> bit1 Then
bit1 = bit1 ^ 1
w11 = w11 + 1
End If
if w10 = w11 then high b.6 high a.6 goto rewind ; brakes on and led on
end if
loop

any help would be a Appreciated
Best regards
Roy
 

hippy

Ex-Staff (retired)
W10 and w11 are counts of pulses for each spool so you should be able to stop when one or the other reaches the pulse count you want. For example ...

If w10 >= 11570 Or w11 >= 11570 Or w10 = w11 Then
 

Roy Spiller

New Member
Hi hippy
Once again thanks for replying so quickly. There is another problem I forgot to mention the tapes vary in length and the count could go over or under the count I quoted. The system I&#8217;m using working fine but occasionally I get a loose wound tape which messes up the count and it will spin off (go too far) the tape is then damaged. I think what I am looking for is a way to add an extra value to w10 so it could catch-up earlier. I hope this makes sense it is difficult to explain.
Regards
Roy
 

premelec

Senior Member
@Roy perhaps you will need to put an idler with codewheel under some tension to count tape lengths aside from any spool condition... or perhaps a tension measuring switch loaded onto the tapes to maintain tension [additon of feed friction implied...]
 

hippy

Ex-Staff (retired)
The main problem is trying to predict the outcome of an unknown. There is no way to know how long a tape is or how loosely wound but you could perhaps predict both by noting the counts and specifically over time. You could then slow the spooling down towards the expected end to minimise any damage done and a tension cut-out as premelec suggests would probably help.

What is the nature of the tapes ? If they have transparent lead-out you could add an optical cut-out.

You could perhaps extend that tension detection to being a tape reservoir which holds tape taken from one spool before it is placed on the other, which is how high-speed mag tape machines used to handle things, though more to keep constant velocity over the tape heads.

As an aside, many moons ago I worked for a company where the development computer only had slow punched tape output which would be spooled into a bucket before feeding it into a lightning fast electrostatic tape reader for the computer which had a printer attached. That was a fun task, blipping the button to keep the process running smoothly. It's strange how things come round full circle.
 

AllyCat

Senior Member
Hi Roy,

If the spools and encoders are identical (same reel diameter and pulses/rev), what you might be able to do is count the number of revolutions of the takeup spool until the reels are rotating at exactly the same speed (the centre of the tape). Then start counting the feed spool and continue until it has rotated by a few percent less than the takeup had rotated to the centre. Ideally, also use the PWM to slow the motor(s) to reduce damage if it does over-run.

It should be possible to determine the centre because the pulses from the feed spool are then faster than from the takeup, i.e. when you get two consecutive pulses from the feed without one (or more) from the takeup inbetween. Of course that won't work perfectly if the tape is wound more loosely on one spool relative to the other, so you might need a "mechanical" solution (as described above) to fix that.

Cheers, Alan.
 

Roy Spiller

New Member
Hi thanks for some great ideas i think that premelec's idea is good however the drive chassis I am using is small and compact and would be very difficult to modify, and as these tapes are data tapes i have to try not to touch the tape. There is one other thing i forgot to mention each spool has three sensors set at 120 degree's i am only using one on each to do the counting perhaps one or more of these could be used?
Cheers Roy
 

hippy

Ex-Staff (retired)
each spool has three sensors set at 120 degree's i am only using one on each to do the counting perhaps one or more of these could be used?
Using the other sensors may increase the resolution of measuring how far the spools have turned but won't likely do anything to improve the outcome of the algorithm being used.
 

Roy Spiller

New Member
Hi Allycat
I studied your idea and it sound like it could be a solution to my problem. would it be possible for you to write out the basic code. I don't understand how to measure the length of the pulse's.
cheer's Roy
 

AllyCat

Senior Member
Hi Roy,

I'm not going to attempt to write any detailed code yet as there are still far too many "unknowns".

First, we must know the (approximate) maximum and minimum pulse rates. The minimum is also important because a command like PULSIN may have a "timeout" of less than 100 ms if running the clock at 32 MHz (which may be needed because PICaxe Basic is so "slow"). There may be issues with factors such as contact bounce or timing jitter (i.e. inconsistency). Also, are the "pulses" reliably 50% duty cycle (or some other fixed ratio) or nearer "constant width"; what is the pulse polarity and which PICaxe chip are you using (or hope to use)?

A further complication is that it's (probably) necessary to measure the pulses from both spools at the same time. The mechanical nature of the spool diameters gradually changing means that sometimes pulses from the two spools will occur at the same time, so we need a strategy to handle that. The PICaxe M2's "Multitasking" feature is unlikely to help because it really just "hides" from the user, the fundamentally sequential processing.

My personal solution would probably involve some combination of the on-chip Capture/Compare Latches, the S/R Flip-Flop, the Timer1 Gate and/or Interrupts, etc.. But that's quite "advanced" programming, dependent on the specific PIC used and POKESFR commands, etc.. Alternatively, I suspect hippy might recommend using two (or three) separate PICaxe chips. ;)

However, ignoring what happens when the spools are turning slowly (or stopped), it might be possible to devise code which counts only the revolutions of the SLOWER turning spool. Very basically, something like the following pseudocode:

Code:
DO
  PULSIN feedpulsepin,polarity,w2
  INC w1      ; Approximately determines the revolutions of the slower reel
  PULSIN  takeuppulsepin,polarity,w3
LOOP  UNTIL  w2 < w3      ; feed spool is now rotating faster than takeup spool
;   Half Way !
DO         ; Use the same code structure as before to equalise timing
  PULSIN feedpulsepin,polarity,w2
  DEC w1      ; Revolutions of the slower reel
  PULSIN  takeuppulsepin,polarity,w3
LOOP UNTIL w1 < 10      ; Make some allowance for slowing down
;  Apply brakes and/or reduce PWM duty cycle
Cheers, Alan.
 

Roy Spiller

New Member
Hi
I have sorted the problem I run the both motors as normal for a set period or count and then reset both counters. the supply motor reel will be slightly smaller and counting faster and the take up reel slightly larger and counting slower. therefore I can stop the wind anywhere I wish which is what I was after. Thank for all your help and idea's. Much appreciated
Cheers
Roy
 
Top