barcode scanner sdk vb.net program 26-6 Distance Moved Tied to the Position of a Potentiometer in Software

Drawer QR Code in Software program 26-6 Distance Moved Tied to the Position of a Potentiometer

program 26-6 Distance Moved Tied to the Position of a Potentiometer
Quick Response Code Recognizer In None
Using Barcode Control SDK for Software Control to generate, create, read, scan barcode image in Software applications.
QR Code Encoder In None
Using Barcode creator for Software Control to generate, create QR Code image in Software applications.
{{10 Sep 09 Harprit Sandhu StepperDistPot.spin Propeller Tool Ver 1.2.6 26 Program 6 (continued)
Quick Response Code Scanner In None
Using Barcode recognizer for Software Control to read, scan read, scan image in Software applications.
Generate Quick Response Code In C#.NET
Using Barcode generation for .NET framework Control to generate, create QR Code image in Visual Studio .NET applications.
Running a SteppeR MotoR: BipolaR, FouR-WiRe MotoRS
Quick Response Code Creation In Visual Studio .NET
Using Barcode generation for ASP.NET Control to generate, create QR Code ISO/IEC18004 image in ASP.NET applications.
QR Code Encoder In .NET Framework
Using Barcode creator for .NET Control to generate, create Quick Response Code image in Visual Studio .NET applications.
program 26-6
Drawing Denso QR Bar Code In VB.NET
Using Barcode maker for .NET Control to generate, create QR Code image in Visual Studio .NET applications.
Drawing EAN13 In None
Using Barcode maker for Software Control to generate, create GS1 - 13 image in Software applications.
Distance Moved Tied to the Position of a Potentiometer (continued)
Generate Bar Code In None
Using Barcode creator for Software Control to generate, create barcode image in Software applications.
Create USS Code 128 In None
Using Barcode drawer for Software Control to generate, create Code 128B image in Software applications.
RUNNING A STEPPER MOTOR FROM A POTENTIOMETER STEPPER position FOLLOWS POT position This program allows you to control the speed of a STEPPER motor from a potentiometer and run motor back and forth. Xavien amplifier lines are Coil #1 Brake is on line P2 PWM is on line P3 Direction is on line P4 Coil #2 Brake is on line P5 Direction is on line P6 PWM is on line P7 }} CON _CLKMODE=XTAL1+ PLL2X _XINFREQ = 5_000_000 Brk1=2 Pwm1=Brk1+1 Dir1=Brk1+2 Dir2=Brk1+3 Brk2=Brk1+4 Pwm2=Brk1+5 VAR long long byte word byte
UPC A Maker In None
Using Barcode maker for Software Control to generate, create UPCA image in Software applications.
EAN128 Maker In None
Using Barcode generator for Software Control to generate, create UCC - 12 image in Software applications.
of the propeller of the propeller of the propeller of the Propeller of the Propeller of the propeller
UPC Case Code Creator In None
Using Barcode creator for Software Control to generate, create ITF-14 image in Software applications.
Creating Bar Code In None
Using Barcode creator for Font Control to generate, create barcode image in Font applications.
'The system clock spec 'line assignments
Encoding USS Code 128 In VS .NET
Using Barcode maker for Reporting Service Control to generate, create Code 128 image in Reporting Service applications.
Painting Bar Code In Visual Basic .NET
Using Barcode generator for VS .NET Control to generate, create barcode image in Visual Studio .NET applications.
stack2[35] stack3[35] Pcount divider servopos
Encoding Matrix 2D Barcode In VB.NET
Using Barcode printer for .NET Control to generate, create 2D Barcode image in Visual Studio .NET applications.
ANSI/AIM Code 39 Decoder In None
Using Barcode scanner for Software Control to read, scan read, scan image in Software applications.
'these are the variables we will use. 'space for Cog_LCD 'space for Cog MoveStepper 'potentiometer reading. 'divides clkfreq for delays 'servo position 'These are the methods we will need 'for the LCD methods 'for general methods 'main Cog 'start a new Cog for the LCD 'any non 0 OK 'this main Cog's main loop 'get the pot reading from the utilities 'do 8 at a time to speed things up 'move motor (continued)
Make Data Matrix ECC200 In Java
Using Barcode printer for BIRT Control to generate, create DataMatrix image in Eclipse BIRT applications.
Encode Code-39 In None
Using Barcode encoder for Microsoft Word Control to generate, create Code 3 of 9 image in Office Word applications.
OBJ LCD : "LCDRoutines4" UTIL : "Utilities"
PUB Go Cognew(MoveStepper,@Stack3) Cognew(cog_LCD, @stack2) servopos:=32 repeat pcount:=UTIL.Read3202_0/16 repeat 8 MoveStepper
the SoFtWaRe
program 26-6
Distance Moved Tied to the Position of a Potentiometer (continued)
Pub Cog_LCD 'set up and run the LCD LCD.INITIALIZE_LCD 'initialize the LCD repeat 'LCD loop LCD.POSITION (2,1) 'Go to 2nd line 1st space LCD.PRINT(STRING("Target =" )) 'Potentiometer position ID LCD.PRINT_DEC(pcount) 'print the pot reading LCD.SPACE(5) 'erase over old data LCD.POSITION (1,1) 'Go to 1st line 1st space LCD.PRINT(STRING("Position=" )) 'Potentiometer position ID LCD.PRINT_DEC(servoPos) 'print the pot reading LCD.SPACE(5) 'erase over old data Pub MoveStepper 'stepper move routine dira[Brk1..Pwm2]~~ 'set at outputs outa[Brk1..Pwm2]~~ 'set high divider:=750 'max acceptable divider case servopos-pcount 'this is the error in the position -1..-255: 'neg error move to + direction outa[Brk1..Pwm2]:=%011_010 'on off waitcnt(clkfreq/divider+cnt) ' outa[Brk1..Pwm2]:=%100_101 'off on waitcnt(clkfreq/divider+cnt) ' outa[Brk1..Pwm2]:=%010_010 'rev off waitcnt(clkfreq/divider+cnt) ' outa[Brk1..Pwm2]:=%100_001 'off rev waitcnt(clkfreq/divider+cnt) ' servoPos:=servoPos+1 0: 'no error so do nothing 1..255: 'pos error so move in- direction outa[Brk1..Pwm2]:=%011_010 'on off waitcnt(clkfreq/divider+cnt) ' outa[Brk1..Pwm2]:=%100_001 'off rev waitcnt(clkfreq/divider+cnt) ' outa[Brk1..Pwm2]:=%010_010 'rev off waitcnt(clkfreq/divider+cnt) ' outa[Brk1..Pwm2]:=%100_101 'off on waitcnt(clkfreq/divider+cnt) ' servoPos:=servoPos-1
In Program 26-6, we have to slow the servo stepping time down and then reduce the range of the potentiometer values to give us an approximately 16-revolution movement of the servo from one extreme to the other. Manipulate these factors to see what happens so you can understand why these compromises have to be made. One often-used stepper scheme moves a motor back and forth constantly to perform a repetitive task. An example of this would be the movement of a printer head back and forth across the paper to access an entire page. We will develop the code to do this
Running a SteppeR MotoR: BipolaR, FouR-WiRe MotoRS
in the Program 26-8. We will fix the extent of the movement to about 16 revolutions, and adjust the speed with the potentiometer to see what happens. A very interesting phenomenon becomes evident when you have to reverse the motor and start from zero speed again and again: Although the motor can run at a high speed if we ramp up to the speed, it cannot start at a high speed setting. In other words, we have to ramp up every time. Program 26-8 uses the code segment from Program 26-7 to control the ramp up.
program 26-7 Program Segment to Ramp Up Stepper Speed
PUB MoveStepper dira[BRK..DIR]~~ outa[BRK..DIR]~~ divider:=divstt '' 'divider start setting, a constant repeat 'the outside loop for fwd and back repeat pcount 'the forward part of the outer loop divider:=divider*divstt/(divstt-20) 'increase speed in each loop if divider>divmax' 'check that you don't exceed maximum divider:=divmax 'clamp at max speed outa[2..7]:=%011_010 'on off waitcnt(clkfreq/divider+cnt) ' outa[2..7]:=%100_101 'off on waitcnt(clkfreq/divider+cnt) ' outa[2..7]:=%010_010 'rev off waitcnt(clkfreq/divider+cnt) ' outa[2..7]:=%100_001 'off rev waitcnt(clkfreq/divider+cnt) ' divider:=divstt 'reset the divider waitcnt(clkfreq/2+cnt) 'pause to look at LCD
In this program segment, the divider divides the system clock by a number to determine the time between stepper moves. Each time through the loop of four moves, the value of the divider is increased, thus decreasing the time between moves. This could have been done between each move to act even faster, but I chose not to, to keep the code simple and more compact. The program then checks to make sure we have not made the time too short by clamping the divider to divmax. Both divstt and divmax are constants set at the top of the program. Play with these to see what happens and then figure out what to do about it. The numbers for your stepper, most probably, will be different from the numbers I have used in the sample programs. The code that demonstrates this is given in Program 26-8.
program 26-8 Move a Stepper Motor Back and Forth with Distance and Motor Speed Controlled by Potentiometers
Copyright © OnBarcode.com . All rights reserved.