Speed regulator for sewing machine


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Dec 2013
    Posts
    8

    Default Speed regulator for sewing machine

    Hope to get some help or advice.
    I am new to programing and trying to learn. This is also my first post.
    I am trying to design a speed regulator for a sewing machine used for quilting. The sewing machine is on an X, Y table and I need to keep a constant number of stitches regardless whether sewing machine moves X or Y or diagonally. My encoders on the tacks give me 55 pulses per inch of travel and I feed these signals into the inputs of the Pic. I take the pulse width of each encoder convert the value back to hertz. I took these values of X and Y and do a hypotenuse calculation on them and take the value and feed a PWM output. The Pic works on the bench using signal generators etc but in practice it has problems. There is far too much time delay during acceleration and deceleration. I.e. it takes .65 second to sense a 0 pulse in. This circuit uses a 4 MHz crystal. I tried 20 mHz and it improved but causes other problem. Thanks
    Code:
    ' PULSIN Command
    ' 16F88
    ' Serial Pulse Width Meter
            Include "modedefs.bas"          ' Include serial modes
            
            DEFINE OSC 4
            
            
           
    SO      VAR PORTB.5                       'Define serial out pin
    FI      VAR PORTB.4                       'Define frequency input pin X1
    FI2     VAR PORTB.2                       'DEFINE FREQUENCY INPUT PIN Y1
    W0      var WORD
    W1      VAR WORD
    W2      VAR word
    W3      VAR WORD
    W4      VAR WORD
    TRISB = %00010100
              #CONFIG __config _CONFIG1, _HS_OSC & _WDT_ON & _LVP_OFF & _CP_OFF & _CCPMX_RB3 & _CCP1_RB3
              #ENDCONFIG
    
     displayloop:
             Pulsin FI,1,W0               ' Measure pulse (in 10 uSec)
             Pulsin FI2,1,W1              ' Measure pulse (in 10 uSec)
     
             W2 = 50000 / W0
             W3 = 50000 / W1
             W4 = (W2 HYP W3)               'HYPOTENUSE CALCULATION
            
            If W4 = 0 Then disp             ' If non-zero, display
            Serout SO,N2400,[#W4]
    disp:   Serout SO,N2400,[" Hertz",13,10]        ' Display trailer
     HPWM 1,W4,1500                          
            Goto DISPLAYLOOP                 ' Forever
    Last edited by Archangel; - 25th December 2013 at 01:26.

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default Re: Speed regulator for sewing machine

    What if you tweak PULSIN_MAX?

    (See PBP manual for PULSIN)

    If you can't speed up the oscillator, I'd decrease the maximum waiting time for a pulse.

    Robert

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Speed regulator for sewing machine

    So you are using the encoders for speed calc instead of distance . . . have you tried using comparators to shape the pulses for you?
    Last edited by Archangel; - 25th December 2013 at 04:46.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4
    Join Date
    Dec 2013
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: Speed regulator for sewing machine

    Hi Arhangel. Thanks for the reply. Maybe you might be right. the encoders that I have put out very good defined square wave pulses at 55 pules an inch. I expect my maximum travel speed to be 2 inches per second. As I accelerate the PWM output should increase smoothly and it isn't. I am not sure how using comparators would help me? Other people I've talked to have suggested using linear encoders i.e 0 to 5 volts out with increase in speed and feeding the output into the A to D convertors. Just anothe Idea for me to try. Thanks

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: Speed regulator for sewing machine

    Hi,
    I Think it's just a matter of time, so to speak....
    If your top speed is 2"/sec I'm going to guess that a typical slow speed is something like 0.05"/sec. At that speed, with 55 pulses per inch, the signals period time is 1/(55*0.05)=363ms, then you're doing that on two "channels" (no, they are not measuring the two pulses simultanously).

    There's really not much the software can do about that, it can't update the output of it doesn't get any input and the input is only updated ~1.5 times per second at such slow speed.

    Using tachometers is better since they are continous output devices but you may need some preamplifier to boost the output voltage at slow speed - it all depends. And you're going to need a precision rectifier or an external ADC that can measure both positve and negative voltages since the polarity of the output changes with direction of rotation. Changing to higher resolution encoder is another option.

    /Henrik.

  6. #6
    Join Date
    Dec 2013
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: Speed regulator for sewing machine

    Hi Henrik
    Thanks for the feedback. I started this project a number of months ago and just getting back into it. The reason I picked 55 pulses per inch was that the maximum number that the hypotenuse calculation on X and Y was about 127 before it would go into overflow. I am using a 16F88 and I purchased an 18F2550 to give me a larger number to work with. I only have the student version of PBP so that’s why the choices. I haven’t tried the 18F2550 yet as I’m a beginner it looks very complicated.

    I don’t know why there is not a smooth rise or fall on the output of the PWM but maybe using the PULSIN is not the way to go.
    Using the ADC convertors may be faster responding.

    I have lots of options to try. The encoders can put out a maximum of 2048 pulses per revolution or about 1500 pulses per inch. I can also feed them into a DAC chip to give me a voltage out.
    You can buy these speed controllers commercially so it can be done but they are a bit too much money for me. May someone out there has one that they can reverse enginner for me?
    Thank Jan

  7. #7
    Join Date
    Dec 2013
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: Speed regulator for sewing machine

    Hi Demon
    Thanks for the reply. I have played with the PULSIN_MAX but as I decrease the value I loose slow speed response. As A beginner I realy don'y understand what is happening. I assume the PULSIN measures the first pulse width and puts that value into a var. I then divide it into 50000 and the do a hypotenuse calculation on the two values of X and Y. I'm guessing it should take 20 or so clock cycles for all this to happen. Does the PULSIN take the next pulse in or maybe the third pulse in and repeat the calculation? I have an LED across the PWM output and I can see a step in brightness as I increase the pulses in where it should be a smooth increase in brightness.
    Thanks

Similar Threads

  1. Replies: 0
    Last Post: - 7th August 2008, 09:02
  2. State machine programming
    By tjstevens in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th April 2007, 22:45
  3. Help - ID a 3.0V regulator (SOT23-5)
    By badcock in forum Off Topic
    Replies: 0
    Last Post: - 8th June 2006, 15:00
  4. voltage regulator help - ot
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 17th May 2006, 00:37
  5. Help with a Parallel I/O to Machine Interface?
    By john meiers in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 16th September 2005, 18:50

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts