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




Bookmarks