.net barcode scanner sdk Program 28-1 Rudimentary Holding the Motor on Position Program in Software

Generate QR Code in Software Program 28-1 Rudimentary Holding the Motor on Position Program

Program 28-1 Rudimentary Holding the Motor on Position Program
Decode QR In None
Using Barcode Control SDK for Software Control to generate, create, read, scan barcode image in Software applications.
Quick Response Code Creation In None
Using Barcode printer for Software Control to generate, create QR image in Software applications.
{{4 Sep 09 Harprit Sandhu MotorHoldPos.Spin Propeller Tool Version 1.2.6 28 Programs 01, 02, 03 depending on gain algorithm in use This program holds an encoded motor at the starting position. If you disturb the motor it will return to its initial position. You may have to adjust the gain variable for your particular motor. You adjust it with POT1. Low values are needed or the motor oscillates. Connections are Amplifier brake Amplifier PWM Amplifier direction
QR Code ISO/IEC18004 Reader In None
Using Barcode decoder for Software Control to read, scan read, scan image in Software applications.
Make QR Code 2d Barcode In Visual C#
Using Barcode generation for .NET Control to generate, create QR image in Visual Studio .NET applications.
P2 P3 P4
QR Code Generator In Visual Studio .NET
Using Barcode creator for ASP.NET Control to generate, create QR Code image in ASP.NET applications.
Encode QR Code In VS .NET
Using Barcode drawer for .NET Control to generate, create Quick Response Code image in .NET framework applications.
Potentiometer read through MCP3202 at P19..P22 LCD on the usual Revisions OCT 29 08 DEC 24 09 P12..P18 standard. Set Up.
Draw Denso QR Bar Code In VB.NET
Using Barcode creation for VS .NET Control to generate, create QR Code ISO/IEC18004 image in .NET applications.
Printing Code-128 In None
Using Barcode drawer for Software Control to generate, create Code 128C image in Software applications.
Revisions to make variable universal added software runaway IF on motor direction Changed to 3202 pots. Uses PotOne
ECC200 Generation In None
Using Barcode creation for Software Control to generate, create ECC200 image in Software applications.
Barcode Creator In None
Using Barcode generation for Software Control to generate, create bar code image in Software applications.
}} OBJ Encoder : "Quadrature Encoder" 'for encoder readings LCD : "LCDRoutines4" 'for the LCD methods UTIL : "Utilities" 'for general methods (continued)
Printing Bar Code In None
Using Barcode creator for Software Control to generate, create barcode image in Software applications.
Make EAN128 In None
Using Barcode generation for Software Control to generate, create UCC.EAN - 128 image in Software applications.
holDing the MotoR Position
Create Intelligent Mail In None
Using Barcode generation for Software Control to generate, create USPS Intelligent Mail image in Software applications.
Barcode Encoder In None
Using Barcode creator for Excel Control to generate, create barcode image in Excel applications.
Program 28-1
UPC Code Encoder In Visual Basic .NET
Using Barcode printer for .NET Control to generate, create GS1 - 12 image in .NET framework applications.
EAN / UCC - 13 Printer In None
Using Barcode maker for Office Excel Control to generate, create UPC - 13 image in Microsoft Excel applications.
Rudimentary Holding the Motor on Position Program (continued)
Painting Code 128 Code Set A In Visual Studio .NET
Using Barcode drawer for ASP.NET Control to generate, create Code 128 image in ASP.NET applications.
Data Matrix ECC200 Reader In C#.NET
Using Barcode decoder for .NET framework Control to read, scan read, scan image in VS .NET applications.
CON _CLKMODE=XTAL1 + PLL2X 'The system clock spec _XINFREQ = 5_000_000 MotorRev =1 'set this to 0 to reverse a runaway motor 'set to 1 for normal operations. 'You can also fix this runaway by reversing 'the encoder leads S1 and S2. BRK =2 'Connections to the amplifier PWM =BRK+1 'next line DIR =BRK+2 'next line VAR long long long long long long long long long long long long long word word
Making Code 3 Of 9 In .NET Framework
Using Barcode generation for Reporting Service Control to generate, create Code 39 Full ASCII image in Reporting Service applications.
Code-39 Reader In Visual Basic .NET
Using Barcode recognizer for .NET Control to read, scan read, scan image in Visual Studio .NET applications.
Pos[3] stack2[25] stack3[25] stack4[25] stack5[25] Pulswidth PresPosition TargetPosition PositionError MinGain Gain MaxGain Index Integ PotOne
'Create buffer for encoder 'space for Cog_LCD 'space for Cog_SetMotorPower 'space for Cog_RunMotor 'space for Cog_FigureGain 'pulse width 'Present Position 'Target Position 'Positional error 'Minimum gain 'Actual gain used 'Maxim gain permitted 'Counting index 'Integration value 'Potentiometer reading
PUB Go cognew(Cog_LCD, @stack2) cognew(Cog_SetMotPower, @stack3) cognew(Cog_RunMotor(PWM), @Stack4) cognew(Cog_FigGain, @stack5) Encoder.Start(0, 1, 0, @Pos) 'Read the encoder position MaxGain:=2000 'Maxim gain MinGain:=100 'Minimum gain repeat PotOne:=UTIL.Read3202_0 'Read pot PRI cog_LCD LCD.INITIALIZE_LCD repeat LCD.POSITION (1,1) LCD.PRINT(STRING("Err=" )) LCD.PRINT_DEC(PositionError) 'manage the LCD 'initialize the LCD 'LCD loop 'Go to 1st line 1st space 'Error id 'print error (continued)
Running DC MotoRs with AttACheD inCReMentAl enCoDeRs
Program 28-1
Rudimentary Holding the Motor on Position Program (continued)
LCD.SPACE(2) LCD.POSITION (2,1) LCD.PRINT(STRING("Gain=" )) LCD.PRINT_DEC(gain) LCD.SPACE(2) LCD.POSITION (1,11) LCD.PRINT(STRING("Integ")) LCD.SPACE(1) LCD.POSITION (2,11) LCD.PRINT_DEC(Integ) LCD.SPACE(2)
'erase over old data 'Go to 2nd line 1st space 'Potentiometer 'print the gain 'erase over old data 'Go to 1st line 11th space 'integrated value 'set position for cursor 'Go to 2nd line 11th space 'print the integ 'erase over old data
PUB Cog_SetMotPower dira[BRK..DIR]~~ 'These pins control the motor amp TargetPosition:=0 'we want to stay where we are outa[BRK]~ 'turn off the amp brake repeat 'loop PresPosition:=pos[0] 'reads the encoder position PositionError:=TargetPosition-PresPosition case PositionError 'decision variable -1_000_000..-1: 'range if MotorRev 'negative range outa[DIR]~~ 'move positive else 'decide outa[DIR]~ 'move negative PULSWIDTH:=gain*244/10 'set gain -0..0 : 'range for stopping PULSWIDTH:=0 'gain is set to 0 1..1_000_000: 'range if MotorRev 'positive range outa[DIR]~ 'move negative else 'decide outa[DIR]~~ 'move positive PULSWIDTH:=gain*244/10 'set gain PUB Cog_RunMotor(Pin)|WaveLength,period ' toggle the output line dira[BRK..DIR]~~ ' the three amplifier lines ctra[30..26]:=%00100 'Set this cog's "A Counter" to run PWM ctra[5..0]:=Pin 'Set "A pin" to Pin# frqa:=1 'Set this counter's frqa value to 1 PulsWidth:=0 'Start with pulsewidth=0 WaveLength:=clkfreq/100 ' time for the pulse width to 10 ms period:=cnt 'Store the current value of the counter repeat 'power PWM routine. phsa:=-PulsWidth ' high pulse for Pulsewidth counts (continued)
holDing the MotoR Position
Program 28-1
Rudimentary Holding the Motor on Position Program (continued)
period:=period+WaveLength waitcnt(period) PRI Cog_FigGain repeat gain:=PotOne
'Calculate wave length 'Wait for the wavelength 'The Cog we are playing with 'loop 'how we define gain here
{{EXERCISE: Play with the equation on the last line to see what happens to the motor response. Turn power to motor off and then turn motor by hand and watch what the LCD shows and look at PWM line P3 to see what the power to the motor does while you turn POT1. We will be using this set up repeatedly so leave it all hooked up. }}
The gain is controlled in the three-line PRI Cog_FigGain method. In the next step, let s add some proportionality to this value. Change the PRI Cog_FigGain to what s shown in Program 28-2 and see how the system response changes.
Copyright © OnBarcode.com . All rights reserved.