0% found this document useful (0 votes)
36 views45 pages

Ga Matroni X

Uploaded by

long đặng
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
36 views45 pages

Ga Matroni X

Uploaded by

long đặng
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
B samatronix Gamoto-1 User’s Manual Gamatronix Motor Controller Integrated PID Servo Motor Controller/Driver User's Manual: Rev U Documents the following versions: Firmware through rev 21 MotoView Software v. 1.0.14 and later PCB Hardware rev. E, F Gamoto TABLE OF CONTENTS: WARRANTY DISCLAIMERS. COPYRIGHT... 1. OVERVIEW LL TECHNICAL SPECIFICATIONS Ll TYPICAL APPLICATION.. OPERATIONAL MODE: 2.1 Position Mops 7 22 PowER Move. 7 23° VeLocrry Mone, 7 24 TRAIECTORY MODE... 8 24 Trajectory Stop. s 25 HOMING MoDE 8 2.6 MorioxDowe ENaaLe 8 2.7 SERIALSHARE ENABLE, 9 28 115200 BAUDRATE.... 9 29 STEP DIRECTION PULSE INPUTS : son st 2.10 ANALOG FEEDBACK MODE 9 2.11 RIC Putse Input Move 10 2.12 PWM-Mones. i 2421 Sign-Magnitude son vo ov ven 22.2 Locked Anti-Phase ai a esac ictioaiia 3. BRAKING BEHAVIOR wrsnmsenensniniennnn 4. THEORY OF OPERATION vvssnsnsnnneenn 4.1 Trarectory ConrRoL 4.2. UNTTS OF MEASUREMENT. 4.20 42. 423 Example Torque Caleulation. Velocity Equations. Acceleration Equations. INTERNAL REGISTERS. COMMAND REGISTERS. REGISTER MEMORY MA? ANALOG REGISTERS scr MOTION TRAJECTORY REGISTERS... 5.3 MoDe REGISTER 5.6 MODE? RECISTER COMMUNICATION PROTOCOLS .. s 6.1 DPSWICHSETTNes, 26 6.2 __ COMMUNICATION PROTOCOLS: SERIAL.. 26 6.2.1 Example Write $1234 to Kp Register 27 6.22 Example Write Response 27 6.23 Example Read from Kp Register. 27 6.24 — Example Read Response. 27 63 COMMUNICATION PROTOCOLS: FC... 27 63.1 Example 2-byte Write to Kp register 2 6.3.2 Example 2-byte Read from Kp register. 2005 Gamatronix Page 2 of 45 Gamoio Gamoto 64 COMMUNICATION PROTOCOLS: CRICKET BUS won se ae 29 64.1 The Cricket Command Word 30 642 RW/ Address Byte 30 O43 RegNum 30 644 — Data. 30 64.5 Cricket Logo Example: Reading and W 7. MECHANICAL SPECIFICATIONS sess 8. ELECTRICAL CONSIDERATIONS 9. CONNECTOR PINOUTS ing Registers . 31 paces 9.1 LED INDICATORS. 33 92 FUSES. a sana 34 93 M:aANALOGIN@UTS 34 9.4 12: MotoR POWER INPUT AND OUTPUT. 35 9.5 13: CRICKET BUS CONNECTOR, 35 9.6 14: LIMIT SWITCH INPUTS AND RESET... 36 9.738: SERIAL INTERFACE . . enum 37 9.8 16: ENCODER INPUTS. 7 99 TH EC TERA CE ciccnioniaancnancsncncanmanstaaa canine saST 9.10 18: Locic POWER INU 39 10. SCHEMATIC DIAGRAM., 11, APPENDIX A: FACTORY DEFAULT VALUES.. 12, APPENDIX B: IC SUBROUTINES FOR PIC ASSEMBLY 13, APPENDIX C: FAQS. 2005 Gamatronix Page 3 of 45 Gamoio Gamoto Warranty The software libraries and tools are provided “as is" without warranty. The entire risk for the results and performance of these libraries and tools is assumed by the purchaser. Gamatronix does not warrant, guarantee or make any representation regarding the use of this product. No other warranties are made, expressly or implied, including, but not limited to, the implied warranties of merchantability and suitability of products for a particular purpose. In no event will Gamatronix be held liable for additional damages, including lost profits, lost savings or other incidental or consequential damages arising from the use or inability to use Gamatronix’s products or the products resold by Gamatronix. Disclaimers Gamatronix reserves the right to make changes without notice, to any product, to improve reliabilty, performance, capabilities, design or ease of use, or to reduve size or cost. Gamatronix products may not be used as components in life support devices of any description, Copyright Al the source code and documentation is covered under a Creative Commons license by Aitbution. The fulltext of the license can be found at [Link], 2005 Gamatronix Page 4 of 45 Gamoio Gamoto B camatronne Gamoto Integrated PID Servo Motor Controller / Driver Gamoto Feature Summary: 12-55 VDC Motor Voltage 7 = 16 VDC Logic Voltage input Integrated 3A continuous / 6A peak H- Bridge motor driver + Trapezoidal Trajectory processing, for precise control of position, velocity, and acceleration * Step + Direction pulse inputs, to work with stepper motor driver software * RIC Pulse input, to work with Remote Control radios, hobby servo systems 1X and 4X quacrature encoder decoding I°C slave interface, for motor control by an external I°C. Serial interface, 9600, 19200, or 115200 baud Cricket Bus interface, for use with Handy Cricket control bus products Removable motor power fuse, with fuse fail indicator On-board flash memory to store parameters. Analog reading of real-time motor current Limit switch interface to add optional upper limit, lower limit, and home switch inputs Expansion port with four analog input pins available for general purpose analog readings. 1. Overview The Gamatronix Gamoto is an integrated module that includes a PID (Proportional, Integral, and Derivative) control chip, a motor driver, and quadrature encoder interface / conditioning circuitry, step/direction pulse input circuit, and an RIC Pulse capture circuit. A complete motor control system would include the Gamoto, a motor, power supply, and a quadrature encoder or analog potentiometer for position feedback. The Gamoto can also be used in direct power mode (open loop), in which case the position feedback is not necessary. The host processor can communicate with the Gamoto in any one of three ways: Serial, V°C, of Cricket Bus. Serial communication uses a simple binary-based protocol with a header and checksum, to reduce errors. As an I°C slave device, the Gamoto accepts read and write commands to its internal registers, as well as some special commands, allowing full control over the Gamoto, Maximum speed is 400 kHz, The third communication option is the Cricket Bus. This is a one-wire serial type of 2005 Gamatronix Page 5 of 45 Gamoto Gamoto interface, similar to I°C, but using only one signal line, plus power and ground. This bus is designed with Handy Cricket devices ([Link]/cricket), but since it is an ‘open protocol, any hast controller can implement this bus and use it to communicate with the Gamoto. 1.1 Technical Specifications Processor H-Bridge Motor Voltage input Motor Current output Logic Voltage input Position Registers PID Constant Registers PWM Resolution PWM Frequency Trajectory Storage ‘Analog inputs Digital inputs (Over-current protection (Over-temp protection Encoder inputs Parameter storage Serial Interface 12C Interface PIC16F876, 20 MHz LM118200 DMOS Quad H-Bridge 42-55 VDC 3A continuous, 6A peak 7-16 VOC 32-bit signed, with &-bit fraction ‘16-bit signed 10-bit resolution 19.54 kHz 6 trajectories storable in non-volatile flash 4 user analog inputs, 10-bit resolution + + for motor current Upper limit, Lower limit switches, interlocks motion 5A replaceable fuse, with LED indication of failure Over-temp LED, auto-shutdown H-bridge Filtered, up to 254,000 counts/sec Key parameters stored in non-volatile flash {9600 of 19200 baud, serial command protocol Operates as an I2C slave, with command protocol Cricket Bus interface ‘Complies with Cricket device bus for use with Handy Cricket RIC Pulse Capture (0-3ms pulse width, with configurable hilow set points ‘Step + Direction inpuls ‘BV Digital pulse capture, triggers on positive edge of Step pulse signal. 2005 Gamatronix Page 6 of 45 Gamoio Gamoto 1.1 Typical Application ‘Shown below is a block diagram of a typical application. Encoder Host | Serial or | Motor ( C l2C or Gamoto. CricketBus Sone Power Host MAX PC 232 APC can connect using sorial COM port and a serial level-shifter. such as the Maxim MAX232 2. Operational Modes ‘The Gamoto can be operated in any of several operational modes. The mode setting can be changed “on-the-fy,” by the host, during operation, or the power-on default mode can be customized, allowing it to always power up in the desired mode. For details of the actual Mode registers, see section xx. The various modes are outlined below. 2.1 Position Mode Mode Register = 00000001 (0x01) This is the default mode, in which the motor drives to the set position (stored in the setPosition register). On power-up, the setPosition is 0, and actual position (mPosition) is 0, s0 the motor will not move. However, fits disturbed or pushed one way, it will drive to return to the target position. The PID algorithm (see Theory of Operation section) determines the power sent to the motor. In the windows control software, there is an interactive mode that demonstrates position control based on mouse movements. 2.2 Power Mode Mode Register = 00010001 (0x11) Enabled by setting PwrMode bit of Mode register. This mode is the simplest to use and to Understand. In this mode, a raw motor power number is sent to the Gamoto, as a percentage of power desired to send to the motor. This register, mPower, isa signed &-bit fhumber, and can range from ~128 to +127. (0 = 0% power, 127 = 100% forward, -128 = 100% backwards). In this mode the encoders are ignored, so in fact encoders are not necessary. However, it encoders are connected, then the current position and velocity can be read from the internal registers while the motor is running. 2.3 Velocity Mode Mode Register = 0000101 (0x05) Enabled by setting the VelMode bit of the Mode register. This mode allows easy control of 2005 Gamatronix Page 7 of 45 Gamoio Gamoto motor velocity, while still tracking the absolute position. When this mode is set, the value in register SetVelocity is used as a velocity target. Sotting SetVelocity = 0 causes the motor to stop. SetVelocity is a signed 16-bit register, and the lowest 8 bits are fractional. The actual value to use for a given velocity depends upon your encoder resolution, so this must be found by trial and error. The actual algorithm for this mode is as follows: SetVelocity is added to the target setPosition register every control cycle. This means the target position is always changing, but at a constant rate, laading to a constant average velocity, Be aware that ifthe motor is slowed by an obstacle, and then freed, it may temporarily speed up to “catch up" to the moving position target. This leads to an’accurate average velocity, but not always the most stable instantaneous velocity 2.4 Trajectory Mode Mode Register = 0000011 (0x03) Enabled by setting the TrajMode bit of the Mode register. This mode causes the Gamoto to immediately begin following the pre-set trajectory that has been stored in the trajectory registers. 2.4.1 Trajectory Stop Mode Register = 0001011 (0x0B) Enabled by setting the StopGrace bit of the Mode register, this allows the host to prematurely stop a trajactory in progress, but rather than suddenly stopping the motor, the motor is gracefully decelerated at the rate specified by the original trajectory. This is useful when the distance to travel is not known ahead of time, or an event triggers a necessary, but not urgent, stop. Note this requires Trajectory Mode to be enabled, and Velocity Mode disabled. If there is no trajectory currently active, setting this mode will have no effect 2.5 Homing Mode Mode2 Register 10000004 (0x01) This mode is normally disabled. Enabled by setting bit 0 of the Mode2 register, this mode allows an external home switch to clear the position register and stop the motor automatically. It changes two of the analog pins to digital pins (Analog pins 2 and 4), and Uses Analog channel 4 (Connector J1, pin A4) as a home switch input. Normally high (you need to supply a pull-up resistor of 1K-50K), when pulled low while in Velocity mode, the position registers are cieared, Velocity is set to 0, and the mode will change to Position mode, stopping the motor. The second converted digital channel, A2, is not used for this homing feature, and will stil read analog values, even though it is configured as a digital pin. 2.6 MotionDone Enable Mode2 Register = 00000010 (0x02) This option is normaly disabled. Enabled by setting bit 1 of the Mode? register, this option turns one of the analog pins (A2) into an output, and uses it fo signal when @ motion profile has been completed (A2 goes high). This can be used as an interrupt to an extemal MCU of other control system, in place of polling the Mode register to detect when a motion is 2005 Gamatronix Page 8 of 45 Gamoio Gamoto complete. As with the Homing mode, pin A4 becomes a digital pin, but is still able to read analog input voltages. 2.7 SerialShare Enable Mode? Register = 00000100 (0x04) This option is normally disabled. It allows you to connect up to 8 Gamotos to the same serial TX and RX lines, with no additional hardware other than a 10K pull-up resistor, which may be needed in some cases. When this bit is set, the Gamoto allows the TX ine to float when it's not being used. Since each Gamoto only replies to messages addressed to it (by the correct header/DIP switch combination), then only the proper Gamoto will reply. Since the TX line is floating when not in use, a 10K pull-up resistor is recommend, if not already included in your serial transceiver or MCU. 2.8 115200 Baud Rate Mode2 Register = 00001000 (0x08) This option enables serial communication at 115200 baud, regardless of the dip switch settings for baud rate (9600/19200) Note that if you set this mode bit via a serial command, the response will come back at the current baud rate - it will not change to 1118200 until you reset the Gamoto, either manually or with a reset command, 2.9 Step + Direction Pulse Inputs Mode2 Register = 00010000 (0x10) This option enables command of the motor via Step and Direction signals, similar to a stepper motor driver. This allows you to use existing stepper motor driver’ software, for example in CNC applications, to control your DC servo motor. The Step signal connects to J4 Pin 2 (Normally the Lower Limit switch input) and the Direction signal connects to J4 pin 3 (Normally the Upper Limit switch input). The limit switches are of course disabled while in this mode If the Direction signal is high, then each rising edge of the Step signal wil jog the motor one count forward (setPosition gets incremented). If the direction signal is low, the setPosition register gets decremented, StepSize Register (Address = 0xB3, or 179 decimal) If you want each step pulse to jog more than one count, use the StepSize register to set the step size to something larger than 1. For example, if StepSize = 10, then each incoming step pulse will jog the motor to (mPosition + 10), 2.10 Analog Feedback Mode Mode? Register = 00100000 (0x20) This mode allows Analog Channel 1 to be used as the position feedback, rather than quadrature encoder signals. This makes it easier to convert a simple motor to a servo, without the need for a costly quadrature encoder. The 0-1023 signal is fed directly to the mPosttion register, and the encoder inputs are ignored. 2005 Gamatronix Page 9 of 45 Gamoio Gamoto 2.11 RIC Pulse Input Mode Mode2 Register = 01000000 (0x40) This mode allows the Gamoto to accept standard R/C (Remote Control) input pulses to command the moter set point. These R/C pulses ate generally in the range of 1ms — 2ms wide pulses, repeated every 20ms. The Gamoto accepts any pulse in the range of 0.2ms to 3ms, and the repeat rate is not important. To configure the low and high pulse range and low and high desired set points, use the MotoView RIC Pulse configuration dialog, under the Tools menu. This dialog also shows. the real-time pulse width being received, so i's handy for debugging your R/C equipment. RIC Pulse Timing Requirements: 1: Minimum pulse width is 0.2ms. Any smaller pulses wil be rejected as noise. 2: Normal pulse range is 0.2ms to 3.0ms. Max and min are settable via MotoView. 3: Time between pulses must be at least 20 usec (0.020ms). There is no maximum. If the signal is lost, the set point will remain at the set point given by the last valid signal Note that in the current firmware version, when using RIC Pulse mode, you must also enable Analog Feedback mode. To set up this feature, you need to set the following key parameters: RCPmin, RCPmax, SPmin, and SPmax. These parameters are described by the diagram below. Any RIC. Pulse that is shorter than the RCPmin value (but greater than 0.2ms) will be result in a set point of SPmin. Similarly, a pulse larger than RCPmax will result in 2 set point of SPmax. RCPmin RcPmax 0 15000 Oms 3ms 0 1023 ‘SPmin ‘sPmax If we take an example, let's say you connect your RIC radio receiver to the Gamoto, open 2005 Gamatronix Page 10 of 45 Gamoio Gamoto the MotoView RIC config dialog, and look at the Raw R/C pulse counts. If you're getting values from say 4412 to 9762, then you could set RCPmin to 4800, and RCmax to 9700, Values outside of this range will get clipped to the max and min values. Now you need to look at your potentiometer, and see what values you get for feedback. If your analog’ channel is showing values from 8 to 1019, then you could set SPmin to 10 and SPmax to 1015. You wouldn't want to set the minimax values outside of your actual range, or else you could reach the mechanical limit of your motor motion, and the motor Would stil be trying to drive. 2.12 PWM Modes There are two available modes for controling the power to the motor. Both use Pulse Width Modulation (PWM), which is a digital way of delivering a range of power to a device. Depending upon the motor design and application, it may be desirable to use one mode over another. 2.12.1 Sign-Magnitude Sign-Magnitude is the default mode. This method requires that two signals be sent to the H-bridge: direction (Sign), and Magnitude. The Magnitude is always positive, and the direction changes depending on which way the motor is to be driven. The Magnitude signal is a square wave with a fixed base frequency of 19.2 kHz, and varying duty cycle, from 0 to 100%, corresponding to 0 and 100% power delivered to the motor. The Sign, or direction signal, is a digital high for clockwise rotation, and low for counter clockwise motion. 2.12.2 Locked Anti-Phase To enable Locked Anti-Phase (LAP) mode, set the LAP PWM bit in the Mode byte. Any time you change this bit, you need to save to Flash, then power cycle before it takes effect. In LAP mode, ditection and magnitude are combined into one signal. The “zero power" condition is represented by a 50% duty cycle. Full forward is 100% duty cycle, and full backward is 0% duty cycle. The reason for this behavior is that this pin is connected to the Direction input of the H-bridge, so that at 50% power, the motor is actually reversing direction constantly, which averages out to zero net power. The other pin on the H-bridge that is normally used for PWM input is now used to enable or disable the motor. ‘The advantages and disadvantages of these PWM modes have been much debated in the motor control community. If you don't have an opinion, use the default Sign Magnitude mode. If you have a very free-spinning motor and would like more of a braking effect when slow or stopped, then you should try LAP mode. 3. Braking beha' ‘The LMD18200 Dual H-Bridge chip has a braking feature that, in the case of the Gamoto, is controlled by one bit (the "Brake" bit) in the Mode byte. When the Brake bit is set, the Brake pin on the bridge goes high. When the Brake bit is clear, the Brake pin goes low. r The first confusing point is that this type of ‘braking’ usually does not stop a motor. and is sometimes a barely noticeable effect. It works by effectively shorting the motor coll leads 2005 Gamatronix Page 11 of 45 Gamoio Gamoto together. With some motors this causes a strong resistance to spinning, and other motors just seem sluggish. It's best to think of it as a way to reduce the amount of “coasting” or free-wheeling after a controlled move. The second confusing part of the braking behavior is the way that the H-Bridge has implemented the brake. ‘The data sheet states that to assert the brake, you not only need to set the Brake pin high, but also set the PWM input high. The PWM input normally tells, the motor to turn on! So in the case of the Gamoto, you would need to turn on the Brake bit of the Mode byte, then command the motor to go at full power (set PwrMode of Mode byte, then set mPower=127), in order to activate the brake. This actually works ~ the motor does not tum, and has a noticeable resistance to tuming in this condition. But there is a better way. The third confusing part of the behavior actually allows a more convenient way to use the brake. According to the H-bridge datasheet, if the brake pin is Low (disabled) while the PWM pin is low (no command for power), then the braking is actually ON. This means that during normal operation, when you signal zero power to the motor, the braking is activated, This actually makes sense, because if you want zero power, you generally want to stop. If, for some reason, you want to stop and coast, then you ask for zero power, and then tun (ON the Brake bit. Note that as long as the Brake bit is on, it cannot be controlled by the Gamoto, so if it sips away from its setPosition, it will not drive back to set point until the Brake bit is tumed off, Bottom line: Don't worry about the Brake. For most cases, you won't ever need to set it or read it or understand it. The one exception is the case where you really want to free-spin your motor with no power. In this case, send zero power and turn on the brake bit. 4. Theory of Operation The Gamoto motor controller uses a PID (Proportional, Integral, and Derivative) algorithm to calculate how much power to deliver to the motor, and in which direction. This is not a new technique. It was developed in the 1960's, and is stil the accepted standard today for fast, accurate motion control, as well as most other types of control systems. The main equation has three major components, the sum of which equals the power to be delivered to the motor. The inputs to the equation are the set point ('setPosition” register), the actual position (‘mPosition® register), and the three key constants, Kp, Ki, and Kd, the proportional, integral, and derivative constants, respectively. We can calculate the error, “u,” by subtracting the set point from the actual position: (1) u=mPosition - setPosition The Proportional component is straightforward: 2) Kpxu The Integral component is calculated based on the integral over time of the error: (3) Ki x fudt The Derivative component is caloulated based on the differential the actual position over time, which in the case of motor control, is the same as the velocity (‘mVelocity” register): (4) Kd x mVelocity 2005 Gamatronix Page 12 of 45 Gamoio Gamoto So the resulting equation is: mPower = Kpxu+ Kix udt + Kd x mVelocity ‘One more final scaling is performed, to allow the use of motors that cannot handle the full voltage of the power supply. For example, if you are using a six volt motor with a 12 Volt battery, you can set pwrLimit = 50% power, or 127. The final equation then, is mPower = [Kpxu+ Kix ludt + Kd x mVelocity ] x [ pwrLimit / 255 ] 4.1 Trajectory Control ‘As mentioned in the velocity mode section, velocity is controlled by continuously adding to the position set point. In the same manner, adding to the velocity set point can cause a constant acceleration. These techniques are combined, along with distance planning and deceleration, to create a Trajectory Move. The diagram below shows a normal trajectory move. CN Velocity, v \, Acceleration, a >» x Diistanee, x Given a desired distance, velocity, and acceleration, a move can be completed smoothly and accurately. You can create and test these trajectories easily, using MotoView. Once you decide a few trajectories that you will use in your application, you can store up to seven of them in flash. Or you can create them and run them on the fy. To run a trajectory, the following steps are necessary: + Write to the desired X, V, and A trajectory registers + Write the corresponding trajectory number to the TrajNum register + Set Mode to 0x03 to run the trajectory + To determine when it's complete, you can poll the Trajectory Mode bit in the Mode byte. Or you can turn on MotionDone Enable (by setting Mode2, bit 1), and monitor pin A2 (on J1), This pin is normally low, and will go high when the motion is complete. + The distance value is always a relative distance, to be added to the current position. ‘When using trajectories, i's @ good idea to follow these guidelines’ + For negative moves, use a negative x or negative v, but never use a negative acceleration. + va should be an integer, especially for large values of v andlor a. For example, if v=5000 and a=1000, then after 5 cycles, v will become 5000, and will stop increasing. But if a=1100, then after 4 cycles, it will be 4400, and after 5 cycles, will overshoot to 2005 Gamatronix Page 13 of 45 Gamoio Gamoto 5500, and then stop increasing. In the extreme case of v close to the maximum value (32767) and large values of a, then the velocity can roll over to a negative value. + Ifthe maximum v is not fast enough, decrease dS. + Ifthe minimum v is not slow enough, increase dS. + Reminder: Changing dS will also affect the strength of the Kal term, in a linear fashion. Maximum values for trajectory variables: Var Length Range x 3 bytes, signed integer _-8388608 to 6388607 v 2 bytes, signed integer _| -32768 to 32767 a 2 bytes, signed integer__| 0 to 32767 Special case: Short Trajectory In the event that the distance specified is short, and acceleration is small, then the velocity may never be achieved. This is not a problem for the Gamoto, but it is good to be aware of this possibilty. A diagram showing this situation is shown here: Target Velocity, v Detecting the end of the trajectory: This diagram shows a trajectory move, and how the Mode byte changes and the MotionDone pin signals the end of the trajectory, if MotionDone is enabled in the Mode byte: Motor Spee \ Pin 82.1 sono” pin NOTE: It's important to note that by “Trajectory Done” it means that the position setpoint (setPosition) has reached its target value, not that the actual position has reached the 2005 Gamatronix Page 14 of 45 Gamoio Gamoto target value. There are several reasons for this. The main reason is that there is no good way to tall if the position has been reached, i.e. what if it reaches it briefly, but then overshoots the position? What if it comes close, but due to the P,1.D settings, there is some steady-state error? How long should it “settie” at the destination before deciaring it has arrived? If it never reaches, what should the timeout behavior be? All of these questions will have very different answers depending on the application, so we have left it to the user to decide. The idea is the user would implement this kind of use case: ‘+ Distance is set to 10000 (default) + Velocity is set to 5000 (default) + Acc set to 10 (default) + TrajMods is set to 1 * SetPosition increases ‘+ Host program polls “Trajectory Done" bit, until it changes to 0 (now we know setPosition = 10000) ‘* Host position polls “Error” register (u0) until Error = 0, or [Error] < AcceptableLevel ‘© © Now we know we have arrived at the destination 4.2 Units of Measurement ‘The units used to control and calculate the position, velocity, and acceleration are different than typical “real-world” units. To aid in the conversion to meaningful units, this section, describes how to do the conversions ‘Some basic definitions: CPR = Counts per revolution (counts/rev). This is how many encoder counts for every complete revolution of your output shaft or wheel. To measure this value, run MotoView and show the Register View window. Display Position. Tum your output shaft one turn, and note how many counts have passed. ORD = One Revolution Distance (inchestrev, feetirev, ete.). This is the distance your device moves in one revolution, in the distance units of your choice. In the case of a ‘wheel, i's the circumference of the wheel, To = Period of Gamoto PID loop. This is a fixed constant, equal to 0.00051 seconds. dS = Number of PID cycles to skip when updating velocity, Kd, and profile information. The factory default value is 10, but this is changeable by the user. V = Velocity. This can be represented in many units, as shown below. The basic unit is the internal Gamoto units, which are in relation to the PID loop of the Gamoto, 2005 Gamatronix Page 15 of 45 Gamoio Gamoto 4.2.1 Velocity Equations v ‘V (counts/sec) = 256" To * dS V (inches/sec) = V (counts/sec) * (ORDICPR) (assuming ORD isin inches/rev) V (miles/hour) = (Vin inchesisec) * (5/88) Example calculation: We have a robot with 3° diameter wheels, driven by a motor with 19:1 gear reduction. The encoders have 250 counts/rev, and are attached to the motor, before the gear reduction. First, the CPR of the output shaft = 250 * 19 = The ORD = circumference of the wheel, or pi * D, of 3.14159°3 = 750 countsirev. .42 inches/rev When using MotoView, we enter a set velocity = 8000, and dS=10. How fast is the motor going? V = 8000 / (256°0.00051"10) = 6127.5 counts/sec V=\ (counts/sec) * (ORD/CPR) = 6127.5 * (9.42/4750) = 12.4 V = (Vin inches/sec) * (5/88) = 12.15 * (5/68) = 0.69 miles/hour 4.2.2 Acceleration Equations a A (ents/see) 256° (To * dS)? A (inches/sec?) = A (cnts/sec?) * (ORDICPR) A (relative to gravitational constant g) = A (inches/sec”) | (12 * 32.2) Example calculation: If we continue the above example, let's find out how fast an acceleration setting of 20 will cause the robot to accelerate: A (enta/sec*) = 20 / (256 * (.00081 * 10)" ) = 20 * 150.18 = 3003.65 ents/sec* A (inches/seo”) = 3003.65 * (9.42 / 4750) = 5.96 inches/sec A (relative to g) = 5.96 /(12 * 322) = 0.015 g 4.2.3. Example Torque Calculation Let's assume we are powering our robot with two motors capable of 20 oz-in of torque. What value should we use for the Gamoto acceleration setting? Assume our robot weighs 4'lbs, or 64oz. 2005 Gamatronix Page 16 of 45 Gamoio Gamoto First, since we have two wheels, we have 2 x 20 = 40 oz-in of torque available. Now, the definition of torque is force times distance: Torque = 40 o2-in = (Force) x (Wheel Radius), so, solving for Force, F = Tir Force = (40 02-in) / (1.5 inches) = 26.7 02 = 1.67 Ibf So now we know the Force we want. How does this relate to acceleration? F=ma (Newton's Law), so a= Fim First we need to know the mass in om, which is equal to its weight divided by g m =4 Ibf = (4/32.2) = a= (1.67 Ibf) / (0.124 Ibm) a= (13.44 ftlseo”) x (12 in/ft) = 161.3 in! sec? 1.124 Ibm = 13.44 fY sec* Now we know the acceleration in in/sec” that we are shooting for. To summarize all of the above calculations, we can use this condensed expression: 24.15 A fin/soe?) = : wer Where T = Total Torque in oz-in, W = Weight in pounds, and r = wheel radius in inches. Now we need to use the acceleration equations backwards to deduce what we should use for our A setting AA (incles/sec?) * 256 * (To * dS )?* CPR A= ORD 56 * (0.00051* 10 )2* 4750 A- 9.42 So now we know the maximum setting possible for use in our trajectories. Setting any value higher than this will exceed the capacity of our motors, and will result in high errors and overshoot. Keep in mind that when using trajectories, the velocity you choose should be an even multiple of the acceleration. In this example, valid velocities include 6420, 8130, 11382, tc. Any even multiple of 542, that is within the bounds of valid velocities (-32768 to +32767). 2005 Gamatronix Page 17 of 45 Gamoio Gamoto 5. Internal Registers The host controls the Gamoto by writing to and reading from various internal registers. Each section below describes the name, address, and purpose of each intemal register Where applicable, an R, W, or R/W is shown, indicating whether the register is Read-only, Write-only, or ReadWrite, respectively. Note that registers in locations 34 - 44 can be changed and stored to fiash, to allow different power-on conditions. 5.1 Command Registers ‘Almost everything you need to do to control the Gamoto can be done by reading or writing to the internal registers. However, there are a few special cases of standalone commands, listed below, that require different treatment. Writing to any of these registers will execute the command. The data that is written is not important; in fact you dont need to write any data at all. Any write command to these registers will activate the command 2005 Gamatronix Page 18 of 45 Gamoto Gamoto 5.2 Register Memory Map Note: All registers are stored with the LSB fist, MSB at the highest address. Where noted, some registers have a fractional component. DEC HEX Register Len Description $00 FactoryRst 1 |Writing to this special command register will cause all Key registers (34 ~ 44) to be reset to factory default values. See Appendix A for {factory default values. WARNING: This command takes about 300 ims to execute. If you execute this command during a trajectory move or while in valocity mode, you may notice a slight jerk or hesitation in motion. tis best not to issue this command while in Wvelocity or trajectory mode. ‘$01 SaveParms |Writing to this special command register will save all key registers to Iiash. After this operation, these values will survive a power cycle. The key registers are locations 34 — 44, and all motion trajectory values. WARNING: This command takes about 300 ms to execute. It lyou execute this command during a trajectory move or while in velocity mode, you may notice a slight jerk or hesitation in motion. It is best not to issue this command while in velocity or trajectory mode. $02 Reset |Writing to this special command register will reset the Gamoto, just las if it were power-cycled. As with all command registers, any |dummy byte can be written to activate the command. $03 ‘SetHome |Writing to this special command register will set the mPosition and setPosition registers to zero, effectively making the current position “Home”. The current Mode is not changed 822 Kp Kp isthe proportional constant register, used fo scale the overall response of the system. Kp is multiplied by the position error. ‘Signed 16-bit number. Can range from ~32768 to + 32767, but negative numbers should not be used for this register. 36 324 Ki Kis the intagral constant register, used compensate for steady-state lerror in the system. Ki is multiplied by the integral of the position lerror. Signed 16-bit number. Can range from ~32768 to + 32767, but negative numbers should not be used for this register. 38 $26 Ka Kd is the derivative constant register, used to compensate for lovershoot in the system. Kd is multiplied by the derivative of the position error. Signed 16-bit number. Can range from -32768 to + 32767. 2 328 Limit iL (integration Limit is used fo limit the maximum build-up of integral error. Prevents ‘integral windup” problems, when a long-lasting steady-state error causes excessive build-up of the integral term. ‘Signed 16-bit number. Can range from ~32768 to + 32767, but negative numbers should not be used for this register. az 32K es {Unsigned 8-bit number. Can range from 1 to 255. Setting this 10 0 has the effect of setting dS = 258. Number of cycles over which average velocity is calculated. For higher resolution encoders, this number should be lower, to prevent overrun of actual motor velocity register (mVelocity). For low resolution encoders, increase this number. This is also used to trigger the update of the trajectory Wvariables. A lower number updates more often. cry S28 Mode '&-bit number. Each bit enables or disables various modes. Fora complete description, refer to section 3.1, Made Register. 2005 Gamatronix Page 19 of 45 Gamoio Gamoto ‘S20 wLimit [&-bit number to limit maximum power delivered to the motor. Set to 0 {tor zero power to motor, 127 for 50% power, and 255 for 100% power. Normally set to 255. Use this to limit max voltage when lusing a lower-voltage rated motor. For example, using a 12V battery Iwith a 6V motor, set this to 127, and the motor will never see more than the equivalent of 6 volts & 82D Modez is-bit number. Each bit enables or disables modes. For complete \description, see section 3.2, Mode? Register. a ‘S2F seiPosition [24-bit signed integer. Can range from -8, 388,608 to 6,388,607. Thi is the target position. The error term is the difference between ‘setPosition and mPosition. BI $33 mPosition '24-bit signed integer. Can range from -8 388,608 to 6,388,607. This is the actual motor position. The error term is the difference between ‘setPosition and mPosition $36 ‘setVelocity 16-bit signad integer, specifying desired velocity. This number, \divided by 256, is added to the target position, setPosition, every dS period. For example, if dS=10, then every 10” control cycle, setVelocity/256 is added to setPosition. a7 $39 mivelocity ‘This is @ signed 16-bit number that represents the actual motor velocity, totaled over several (dS) cycles. The velocity is calculated jas the change in encoder counts in a given time period. To change ithe scaling of this number, dS can be adjusted. miVelocity is also the multiplier for Kd, used to calculate the derivative term for the control loop, so changing dS will have a direct effect on the strength of the \derivative term, Ey 38 trajectory The trajectory register is used to choose which trajectory you would like to run. To run a given trajectory, first store the desired distance, velocity, and acceleration in one of the 7 trajectory register sets [Then specify which trajectory register set you want to run by writing to trajectory. Then turn on trajactory mode by writing the proper mode command to the Mode register. 60 530 mPower (Motor power. Signed 8-bit number. Used normally in open-loop ‘mode (without encoders), or when you want manual control over actual voltage delivered to the motor. Setting mPower = 0 will cause motor to stop. Setting mPower = 64 will cause 50% forward power. ‘Setting mPower = 127 will cause full forward power, setting mPower= 128 (128) will cause full reverse power. A setting of ~64 (192) will cause 50% reverse power. 90 SA RCPraw Raw RIC pulse counts. 5000 counts = ims. This holds the length of ithe last RIC pulse received. Only used while in RIC mode. 7 361 wo [Error term. Signed 24-bit number. This is the difference between the {target position (setPosition) and actual motor position (mPosition), Read this value to detect if an obstacle or friction is causing a large \difference between the goal and actual position, or velocity 178 $82 version Firmware version number. Integer from 1 to 255. Read only 179 $B3 StepSize ‘Number of steps to ‘jog when step/dir input is enabled, and Gamoto receives a stop pulse. 226 SEZ ‘SPmin setPosition Minimum. This is the minimum value that will be set by an incoming RIC pulse. Refer to the R/C mode description. 228 SE4 SPmax ‘setPosition Maximum. This is the maximum value that will be sat by lan incoming R/C pulse. Refer to the R/C mode description 230 SEG ROPmin IRIC Pulse minimum. This is the minimum pulse length accepted by ithe Gamoto. Shorter lengths will be clipped to this length. The units are in raw counts, 5000 counts = 1 ms. 2005 Gamatronix Page 20 of 45 Gamoio Gamoto 232 | SEB | RCPmax | 2 |RIC Pulse maximum. This is the maximum pulse length accepted by tthe Gamoto. Longer lengths will be clipped to this length. The units lare in raw counts, 5000 counts = 1 ms. 2005 Gamatronix Page 21 of 45 Gamoio Gamoto 5.3 DEC: 160 162 164 166 168 Analog Registers These registers are all two byte (16-bit) memory locations, but there is only 10 bits of resolution. The data is right-justified to the LSB, that is, the LSB is the first byte, and it contains the lower 8 bits, and the next byte contains the upper two bits of the analog value. The upper remaining bits are padded with zeros. Example of register mapping for Analog0 register: MsB LsB ‘ 110/1/1/0]4 Off |o\4 161 (SA1) 160 (SAO) This table shows the addresses for all of the analog registers. Note that Analog0 is a special case: itis tied to the motor current output signal from the H-Bridge. HEX! Register | Len Description $A0 AnalogO 2 This is wired directly to the H-Bridge, and provides a reading proportional to Motor current. Reading translates to ‘approximately 186 counts / amp, with max reading of 1023 counts = 5.5 Amps $A2 Analog! | 2 Analog input 1. Soale is 0-5V, with 10-bit resolution, making the register minimum = 0, maximum = 1023. SA4 Analog2 2—_Analog input 2. Seale is 0-5V, with 10-bit resolution, making the register minimum = 0, maximum = 1023. $A6 Anaiog3 | 2—_Analog input 3. Scale is 0-5V, with 10-bit resolution, making the register minimum = 0, maximum = 1023. $A8 Analog’ | 2 Analog input 4. Scale is 0-5V, with 10-bit resolution, making the register minimum = 0, maximum = 1023. 2005 Gamatronix Page 22 of 45 Gamoio Gamoto 5.4 Motion Trajectory Registers The motion trajectory registers are shown below. The all begin with LSB first as with all registers. The distance register is three bytes (24-bits), and the others are 2 bytes (16- bits). "You can store up to six motion trajectories in this memory space, and they can be saved in non-volatile flash memory if desired (see the SaveParms command) To calculate the address of a motion profile register (where n = 0 to 5) X(n) = 180 + n*7 Vin) = 183 + n*7 A(n) = 185 + 147 DEC HEX Length | Register Description 180 $B4 3 XO _ Relative distance for motion trajectory 183 $B7 2 VO Velocity for motion trajectory 185 $892 ‘AO Acceleration for motion trajectory 187 SBB 3. X1__ Relative distance for motion trajectory 190 SBE 2 V1 Velocity for motion trajectory 192 sco 2 'A1__ Acceleration for motion trajectory tea $c2_ 3. X2___ Relative distance for motion trajectory 197 $C5 2 V2 Velocity for motion trajectory 199 SC? 2 ‘A2 Acceleration for motion trajectory 201 sco 3 X3__ Relative distance for motion trajectory 204 $cc 2 V3 Velocity for motion trajectory 208 SCE 2 ‘3 Acceleration for motion trajectory 208 $003 X4 Relative distance for motion trajectory 211 $032 V4 Velocity for motion trajectory 2138052 ‘Aé_Acceleration for motion trajectory 215 S073 X5__ Relative distance for motion trajectory 218 SDA 2 V5. Velocity for motion trajectory 220/02 AS Acceleration for motion trajectory 2005 Gamatronix Page 23 of 45 Gamoio Gamoto 5.5 Mode Register The mode register is shown below. It is a one-byte register, and each bit serves a different function, as shown. Care must be taken to avoid setting incompatible bits, as not every combination is allowed. The allowable modes and combinations are described in the paragraphs below. Register Name: MODE (Address 0x2B) RWO RO RWwOo RWO RMWO RWO RWO RWO LAP PvIM —Overtema | Baka ——=|~PrMade—StapGrace | VelMede | TraiMode _MpwiON Bit7 6 5 4 3 2 1 Bit bit? Locked Ant-Phase PWM mode 1= LAP mode 0 = Sign-Magnitude PWM mode NOTE: To change PWM mode, you must frst seUclear the bit, then save to Flash, then ppower-cycle the motor controller. ‘This only required for ths particular Mode bit bité —_Over-temperature concition (READ-ONLY signal from H-bridge) 11 = Over-emp signa is active ftom H-Bridge.. Motor is disabled, and setPosition Is set to ‘Postion, 50 when condition clears, motor wil not jump 0 = Normal condition bitS Brake On 41 = Brake signal s being sent to H-Bridge 0 = Normal conattion bid PwrMode 0 = Power Mode is Disabled. In this state, the PID loop operates normally, and the mPower register i lgnored 1 = Power Mode is Enabled. n this state, the PID loop is bypassed, and the motor power 's taken diecly from the mPower register. Encoder positon is tracked but ignored bts StopGrace 0= Disabled Enabled. When tis bt is set during a traletory move, the Gamoto immediately stats decelerating, until completely stopped, using the deceleration rate that is stored in the trajectory. This is only vad when TrajMode is set bt2 —_VelMode 0= Disabled 112 Enabled, When this bits set, the SetVelocty register is used as a velocty set point. Use this when you want to contro the velocity, ratner than absolute postion. The PID loop wil continually adé this value to the Position target register. This ‘moving target’ position value causes a constant average veloily. This is ony valid when TrajMode is disabled. bit TralMode 0= Disabled 1 Enabled. When this bit is set, the Gamoto immediately begins folowing the pre- Toaded trajectory. When the trajectory has been completed, this bit is automatically cleared. Pol ths bt to find out when the move nas been completed. DIO MpwiON 0 = Disabled. Motor will not receive power without this bt se Enabled, When tis bit fs set, the enable pin on the [Link] I set, allowing power to flow to the motor. This bit Is Independent of all other mode. settings 2005 Gamatronix Page 24 of 45 Gamoio Gamoto 5.6 Mode2 Register The Mode2 register is shown below. It is a one-byte register, and each bit serves a different function, as shown. Care must be taken to avoid setting incompatible bits, as not every combination is allowed. The allowable modes and combinations are described in the paragraphs below. Register Name: MODE2 (Address 0x2D) RwO RWO RWO RWO RWO RWO RWO RWO RIC Pulse | Analog | Step+ | 115200 | Serishere | MotonDone | Hom reseed Enable Feedback Direction baud -—_—SavslShere | MotionDone Homing Bit7 6 5 4 3 2 1 Bit bit7 Reserved for future use bité RIC Pulse Input Enable 1 = enabled 0= disabled bitS Analog Feedback Enable enabled isabled bit4 __Step+Direction Pulse Input Enable enabled isabled bits 118200 Baud Rate Enable enabled 0= disabled bit2 _SerialShare Enable ‘Serial Share enabled SerialShare disabied bit _MotionDone Enable enabled isabled bito Homing Mode foming Mode enabled (0 Homing Mode disabled 6. Communication Protocols There are three ways to communicate with the Gamoto: Serial, IAC bus, or Cricket Bus. All of them require settingichecking the dipswitch settings for configuration, 2005 Gamatronix Page 25 of 45 Gamoio Gamoto 6.1 Dip Switch Settings The table below shows the dip switen assignments, and the purpose of each of the switches. Before attempting to use the Gamoto, make sure the switches are set appropriately. The factory default position is all switches in the OFF position Dip Switch Assignments ‘Switch | OFF ON | Description 1 Cricket Bus FC | Bus selection 2 19200 baud | 9600 baud Serial baud rate 3 0 1 ‘A2 Address bit 4 0 1 ‘AM Address bit 5 0 1 AO Address bit Note that the user must choose either I7C or Cricket bus, because they share the same (0 pins on the controller. The setial port uses different pins, and can be used regardless of the bus selection position. However, itis not advisable to use the serial port while data is being sentreceived on the Cricket or I*C bus, because some of the same internal registers. may conflict in this case. Tho AO, A1, and A2 address switches are used to set the Gamoto Address to a value from 0 to 7. The °C, Cricket Bus, and Serial protocols use this address to determine which Gamoto is being addressed. The table for setting this address is shown in the I°C protocol section. 6.2 Commu ation Protocols: Serial The normal connection method for serial communications is to have one host connected to one Gamoto. However, the Gamoto is addressable, to allow for a multi-drop communication connection. To connect more than one Gamoto to_a single host (PC or MCU), you can simply connect the TX lines in parallel with the other TX lines, and connect the RX lines to the other RX lines. For more detailed instructions on this, refer to this guide available on the Gamatronix website: bit www. [Link]/gamoto/examples/Serial%20Share%[Link] On the protocol level, allowing mutiple Gamotos requires that you specify which Gamoto you are speaking to (Gamoto Address). This is specifigd by setting the cipswitehas, as with the I°C and Cricket protocols. Please refer to the I°C communication section to see how to set the Gamoto Address (0-7). This Address is added to hex value SAA, and becomes the header byte of the packet. Examples of the different types of transactions are shown below. For the most common case of RS-232 Serial, with only one Gamoto, simply leave the dipswitch set to the factory positions, and use a header value of SAA. The checksum is @ single unsigned byte, and is calculated by using a simple sum of the preceding bytes, excluding the header and the checksum byte itself. In the case of the checksum totaling more than 255, it rolls over (wraps) as necessary. An example of the formula in Visual Basic is: CShyte = (bytel + byte? + byte3 + byted) mod 2005 Gamatronix Page 26 of 45 Gamoio Gamoto 6.2.1 Example Write $1234 to Kp Register Header = § «= LEN. = RegNum = Data(LSB) Data(MSB) CHECKSUM. SAA + (0107) 803 $22 $34 812 XX The serial protocol is binary-coded, with @ header and checksum to help ensure reliable data transfer. The example diagram above shows a two-byte write to the Kp register. The Header byte, which is dependent on the dipswitch setting, is followed by the RW / Length byte. The high bit of this byte is O for Writes, 1 for Reads. The lower nibble indicates the length of information to follow, excluding the Checksum byte. The next byte is the targe! register address, followed by data bytes, and then a checksum. The checksum does not include the header, or the checksum byte itself. The number of data bytes is flexible, up to a maximum total massage size of 8 bytes. This, means the maximum continuous bytes you can write to a register location is 4 bytes. This allows you to access any register with a single transaction. 6.2.2. Example Write Response ACK CHECKSUM $41 841 The reply from the Gamoto is shown above. In place of the header is an ACK byte, which should always be = $41. If this is diferent, then there was some internal error. 6.2.3 Example Read from Kp Register Node LEN RegNum NumBytes CHECKSUM SAA + (010 7) $82 $22 $02 SAG The read is same in structure as the write, with the main difference in the high bit of the RWiLen byte. The high bit is one, indicating a read, and the data following the register number is the number of bytes we want to read. In this case we are requesting two bytes back, and the result is $1234 hex. 6.2.4 Example Read Response ACK Data (LSB) Data (MSB) CHECKSUM Sat $34 $12 $87 ‘Checksum ~ 6.3 Communication Protocols: IC To communicate with the Gamoto using 1°C, the first step is to enable I°C. Turning ON 2005 Gamatronix Page 27 of 45 Gamoio Gamoto dipswitch 1 enables this mode. It should be in the ON position for I°C communication. The next step is to set the address bits (dipswitches 3, 4, and 5). If you only have one Gamoto controller, you can leave it at the factory seting of 000 (switches 3.45 all OFF). However, if you plan to place more than one Gamoto on the same °C bus, it will be necessary to set each controller to a different address, ‘The complete I°C address is constructed from three components: the I7C device type (fixed at "1001", with the exception of the broadcast case), the Gamoto address (sot by dipswitches 3,4,5), and the Read Write bit (0=Write, 1=Read) VC Slave Address Byte 1 o 0 1 A2 At AO RW FC Device Type Gamato Address ReadWrite Use the folowing table to find the desired address. A maximum of 8 controllers can be in Use on the same bus, dus to this I°C addressing limitation. Note that the address used is different, depending on whether you are reading or writing Gamoto | Gamoto | CWrite | fC Read ‘eo, An any Address Address Address Addross (Binary) (Decimal) OFF OFF OFF (00 0 0x90 0x94 OFF OFF | ON 001 1 0x92 0x93, OFF ON OFF 010 2 0x94 0x95 OFF ON ON ont 3 0x96 0x97 ON OFF OFF 100 4 0x98 0x99 ON OFF ON 101 5 OxA x98 ON ON OFF 110 8 oxac xsd, ON ON ON M1 7 Ox9E Ox9F All All All All Broadcast 0x00 NA Bold row represents the factory default configuration, (One the address byte is known (sometimes called the Slave ID), you ean begin writing routines to control the Gamoto over the IC bus. The last row is the “Broadcast” address, or “General Cal”, which can be used to send commands to all Gamoto boards simultaneously. This is convenient for starting two or motors at the same time. Keep in mind, however, that it can only be used for commands (writing), not for reading, since you wouldn't want two or more Gamotos responding at the same time. 6.3.1 Example 2-byte Write to Kp register The basic sequence for a 2-byte write to a register is as follows (shown here, setting register Kp = 0x1234): 7 12C Example: 2-byte write to Kp register ; Written in PIC Assembly. 12C subroutines not shown. call I2cStart novlw SLAVEID + Send control byte (Ww) call 12CWrite movlw 0x22 + RegAddress = Kp call I2cWrite 2005 Gamatronix Page 28 of 45 Gamoio Gamoto moviw 0x34 7 Low byte of data to write call T2cWrite movlw 0x12 + High byte of data to write call 12cwrite call 12¢Stop 7 Send 12¢ Stop condition ‘See Appendix B for the IC library routines. Additional bytes can be added before the stop condition. They will be written in the next sequential memory location. There is no limit on the quantity of bytes that can be written at one time. 6.3.2 Example 2-byte Read from Kp register A two-byte register read is as follows: } I2c Example: 2-byte vead from Kp vegister ; Written in PIC Assembly. 12C subroutines not shown. call 12cstart movlw SLAVEID call I2cwrite moviw 0x22 7 Set pointer to Kp register call I2cwrite send control byte (w) + Send control byte (R) call 12CWrite call I2cReadwAck } First read is with ACK noyf 120Data,w wi RegdatalSB + Store LSB resu: call 12cRead 7 Read without ACK ls last read movt 12CData,w novwi RegDataMsB + Store MB result call 12catep ‘See Appendix B for the °C library routines. Note that the master should not ACK the last road. This signals the end of the read operation. To perform a one-byte read, the one and only read should not be with an ACK, since its the last read, : Cricket Bus 6.4 Communication Protocol: Bofore using the Cricket Bus, make sure the bus is enabled, by checking the dip switch settings. if you will be using more than one Gamoto on the same bus, then you also need to set each address differently, so they don't confi. ‘The Cricket communication protocol format is shown below. All Cricket messages start with a special 9-bit Cricket Command code. The next byte is the RW/Address byte that tolls if the operation is a Read or a Write, and includes the 3-bit unit address of that particular Gamoto controller. The 3 bits allow for up to seven Gamotos on the same Cricket bus. The next byte is the RegNum, or register number, that specifies which register is the target of the read or write. In the case of a write, #Bytes to Write, and Data to be written follows. Cricket READ format: 2005 Gamatronix Page 29 of 45 Gamoio Gamoto 4 CrktCMD RW / Address RegNum {datat, data2, Cricket WRITE format 1 CrKICMD RW / Address RegNum | #Bytes toWrite ( datat, data2, ...) 6.4.1 The Cricket Command Word 1 0 0 1 0 0 1 0 CMD bit Cricket “Class ID" (Always = $11 for Gamoto devices) The best way to think of the Cricket Command Word is that it is always written as $100 + $11 for the Gamoto devices. The $100 signals a command, and the $11 is the Cricket “Class ID” that has been assigned to Gamoto devices. That's all you need to know to use the Gamoto with Crickets. Ifyou are implementing a Cricket Bus yourself, using a non-cricket controller, then you may need to understand more of the protocol details. Please refer to the Handy Cricket website for more details on the cricket bus. 6.4.2 RW/ Address Byte RW o oo) 0 a2 A AO Road = 4 Broad | Dipswitch | Dipswitch Dipswiteh Write = 0 a cast 3 4 5 The high bit of the RW/Address byte is set to 0 for Writing, 4 for Reading. The lower 3 bits are set to the unit address of that particular Gamoto controller, and must match the dipswitch settings for the unit address. Broadcast Address To send a command simultaneously to all Gamotos on the bus, set the broadcast bit. This, is the same as using a device address of 8, rather than the usual 0to 7. This is convenient for starting two motors at the same time (ie. two wheels on a robot). Note that the broadcast address only works for WRITE operations. Read operations would cause conflicting responses. 6.4.3 RegNum The register number corresponds to the starting address of the register you wish to wiitelread to/from. Please note that many registers have fractional components, so you need to pay close attention to the register map to make sure you are accessing the correct starting point of the register. 6.4.4 Data The data following a write command can be a maximum of four bytes. After each byte is written, the internal pointer is incremented, allowing sequential writes to a range of register 2005 Gamatronix Page 30 of 45 Gamoio Gamoto bytes. When reading using the cricket bus, a dummy data byte must be sent in order to read each byte. So to read a three-byte register, you must send the CricketCMD byte, RWiAddress byte, RegNum, then a dummy data byte. Read the first byte. Send a second dummy byte, then read the next byte. Send a third dummy byte, then read the final byte. 6.4.5 Cricket Logo Example: Reading and Writing Registers Using the Handy Cricket to control the Gamoto is very easy. Below is an example of using Cricket Logo to read and write to 8-bit Gamoto registers. The command to send a byte out the Cricket bus is bsend, and to read a byte is bsr. Every bsr command must be followed by a dummy data byte, which is used to trigger the read operation, The Gamoto has been assigned the Cricket “Class ID" of 17, or $11 hex. All Gamotos. respond to the class ID. The first byte to send is the command bit ($100) + $11 = S111 Then they look at the next byte, the ‘adr’ or address, to see if the command is for them, This number must match the address set by the dipswitches on the Gamoto. } Write to an s-bit Gamote register to gxzSetReg3 :reg :val :adr bsend $111 send :adz bsend tzeg bsend low-byte :val end 7 Read! from an 8=bit| Ganoto register to gzReadReg® :reg :adr bsend $111 bsend tadr + 128 bend :reg output ber 1 end A full set of Cricket library routines for controlling the Gamoto is available at the Gamatronix web site. By pasting these routines into your Cricket program, you can be controling the Gamoto in no time! 2005 Gamatronix Page 31 of 45 Gamoto Gamoto 7. Mechanical Specifications The dimensions of the Gamoto board mounting holes are shown in the figure below. Be careful when mounting the board to protect the bottom of the board from contact with metal surfaces that could short out the signals. The board itself measures 2.75 in. x 2.075 in. The mounting holes are 0.15 inch diameter, large enough for 4-40 or 6-40 screws. 1.775 in 245i 8. Electrical Considerations When designing your control system, one of the first considerations is the power supply design. In general itis desirable to separate digital control power from noisy, high-current motor power. The Gamoto board allows this separation by having two separate connectors. JB is for logic power input, and J2 is for Motor power connection. However, these supplies are isolated on the board by a voltage regulator, s0 itis also possible to use one power connector for both, and tie them together using jumper JP4 Separated power inputs When using two separate power inputs, you can take advantage of higher motor voltages, from 12V up to 55V for your motor. You can also shut off or disconnect motor power without resetting the logic side of the motor board. In this configuration the logic power can be from 7.5V to 16V DC. Combined power inputs To combine power inputs, install jumper JP1. With JP4 installed, only one connector (J2) must be used to supply power. DO NOT INSTALL JP1 WITH POWER CONNECTED TO BOTH CONNECTORS! When combining the power inputs, you are limited to a more narrow range of allowable voltages. The acceptable range for combined power input is 12V - 16V. Tho advantage is a simpler cabling/connector design, and one switch can control the whole system. REV E BOARDS ONLY: Ons note about the fuse: The fuse is only connected to the J2 connector: so if you are using a single power connection, use J2, not J8. Rev F and later boards do not have this problem. Current Draw The typical standby current flow of the logic circuits is 4OmA without encoders connected. Depending on the type of encoders used, this wil increase to 80 to 140mA. Note that with 2005 Gamatronix Page 32 of 45 Gamoio Gamoto high-current encoders and high logic voltage supply (i.e. 16VDC), the 5V regulator will get guite warm and a heat-sink is highly recommended. Current draw for the motor side of the circuit is entirely dependent on the motor col resistance and the torque applied on the motor shaft. An easy way to estimate current is to measure the motor winding resistance, and divide this into the motor voltage you plan to Use. Make sure the estimated current is less than 3 Amps before connecting it to the Gamoto. An example calculation is as follows: Motor winding resistance measures 6 ohms, and you plan to use a 12V battery. Since batteries usually charge higher than their nominal voltage, let's assume 13 volts for the caloulation. So current = 13/6 = 2.17 Amps. This is less than 3 A, so it should work fine with the Gamoto. 9. Connector Pinouts This soction shows connector pin assignments and electrical details required for interfacing the Gamoto to your application. The connectors are labeled JP1 to JP10, as printed on the PC board's silkscreen. Over-temp LED JB <— Fuse Blown LED Power LED —> + J2 4 5 9.1 LED Indicators ‘The Gamoto board has three LED indicators. A green power LED (D4) lights when logic power is present. A yellow Over-Temp LED (D3) lights when the H-Bridge indicates itis in temperature shutdown mode. A red “Fuse Blown’ LED (D2) lights when the fuse is removed or blown. 2005 Gamatronix Page 33 of 45 Gamoto Gamoto 9.2 Fuses There is one removable fuse on the Gamoto, labeled FS1, in the upper right corner of the board. If this fuse is damaged or removed, the red fuse LED will light. The Gamoto ships with 5A fuse in this position, but you can change this value if you like. The ordering information for additional fuses is shown here: Fuse Type ikey PIN 1,0. Amp, Fast-acting _ WK3048BK-ND 4.25 Amp, Fast-acting WK3050BK-ND 1.6 Amp, Fast-acting _ WK3053BK-ND 2.0 Amp, Fast-acting _ WK3057BK-ND 2.5. Amp, Fastacting __ WK3058BK-ND 3.15 Amp, Fastacting WK3024BK-ND 4.0 Amp, Fast-acting _ WK3062BK-ND 5.0 Amp, Fast-acting WK3063BK-ND 9.3 Jumpers 9.3.1 JP1 Motor Power Jumper This jumper bridges the Motor Power supply with the Logic Power supply. See section 8 (Electrical Considerations) for details and precautions about using this jumper. 9.3.2 JP2 Cricket Power jumper This jumper bridges the logic power for the Gamoto to the power on the Handy Cricket, if you have a Cricket connected to the cricket cable. This allows you to use either only the Handy Cricket's power supply, or only the Gamoto power supply. Care should be take not to use the jumper when both supplies are present. 9.3.3 JP3 Encoder 1X/4X Setting (Rev F and later boards only) This jumper selects between 1X and 4X encoding for the quadrature encoders. A setting of 4X allows a 500 count encoder to have 2000 pulses per revolution, by triggering on the pulse edges, rather than each complete pulse cycle. This feature is only available on rev F and later boards, 9.4 J1: Analog Inputs 4 Row | Analog Inputs G1 Ground V+ 2 5 VDC output. Can be used to supply power to extemal sensor. A 3. Analog voltage input, 0 - VDC This connector Is used to connect up to four analog inputs. For each of the four channels (At ~ Ad), a separate power and ground pin is available, making it easy to keep cabling simple, and to provide power to an analog sensor, such as the Sharp GP2D12 sensor. NOTE: Analog Channel 4 (pin Ad) can be used to connect a Home Switch, if the Homing mode is enabled (see Homing Mode description) 2005 Gamatronix Page 34 of 45 Gamoio Gamoto NOTE: Analog Channel 2 (pin A2) can be used as an interrupt output, or "MotionDone’ pin, if this is enabled by configuring Mode2. In this case, it becomes a normally high output pin, and goes low during a trajectory and high when a trajectory is finished, NOTE: Analog Channel 1 connector can be used for the Analog Feedback feature. This allows the use of a potentiometer or analog voltage in place of a quadrature encoder. NOTE: Analog Channel 0 is not available on this connector, because it is dedicated to reading motor current. It is connected to the H-bridge on the Gamoto board. 9.5. J2: Motor Power Input and Output J2_| Pin | Motor Power Input. This supplies power for the Motor. M+ 1 Output to Motor winding. Reverse these fo change motor direction M- 2 Output to Motor winding. Reverse these fo change motor direction V+ 3 #42—55 VDC" input. Current consumption up to 3A continuous, 6A peak G4 Ground * Maximum motor input voltage will be limited to 16 volts if jumper JP1 is used, tying together the logic and motor voltage inputs This connector is used both fo supply motor power and to distribute power to the motor. G and V+ should be connected to a battery or other high-current voltage source. Pins M+ land M- should be connected to the motor windings. The polarity of these terminals is usually determined by trial and error. If the motor operates in the wrong direction, reverse these leads. IMPORTANT NOTE: MOTOR POWER MUST BE AT LEAST 12 VOLTS FOR THE H- BRIDGE TO WORK PROPERLY. LOWER VOLTAGES WILL CAUSE STRANGE BEHAVIOR THAT IS DIFFICULT TO TROUBLESHOOT, SO ALWAYS CONFIRM MOTOR VOLTAGE IN CASE OF ODD BEHAVIOR. If you do not want to use 12V or more because your motor is rated for a lower voltage, then. refer to the register descriptions on pwrLimit. This will allow you to use a lower voltage motor 9.6 J3: Cricket Bus connector J3_| Pin | Cricket Bus Connector. G1 Ground Vec | 2 Regulated SVDC power supply. Use jumper JP 12 to disconnect this, Bus 3. Bus data line. This is normally high, low when active, or during init signal V+_| 4 Unregulated voltage supply 2005 Gamatronix Page 35 of 45 Gamoto Gamoto Handy Cricket Bus Jack — Unregulated power output — Bus signat — Loci power ouput — ond This port can used to connect the Gamoto to a Handy Cricket or other Cricket Bus-enabled device. A second optional ‘pigtail’ connector is hooked in parallel to this one, for easy daisy-chaining of bus devices. For more details on the Cricket Bus connector and protocol, see hitou/wn handyboard,com/crickevtech/bus. shtml 9.7 J4: Limit Switch Inputs and Reset J4~ Pin | Limit Switch Inputs and Reset line G1 Ground LL 2 Lower Limit switch input / Step signal input UL 3 Upper Limit switch input / Direction signal input / RIC pulse input Reset 4 Resel line for Gamoto processor. Momentarily pull this line low to reset Gamoto. This connector is used to add limit-switch interlocks to your control system. By pulling the Lower Limit input low, clockwise mation of the motor will be disabled; until the line is released (there Is an internal pull-up resistor in the Gamoto). If the Upper Limit input is pulled iow, counter-clockwise motion will be disabled, until the line is released. This allows a mechanism of preventing travel beyond a mechanical limit, by adding limit switches at ‘each end of the travel. When in Step * Direction mode, pins 2 and 3 are used for Step + Direction, respectively. When in RIC Pulse mode, pin 3 is used for the RIC pulse input, which allows connection of the standard RIC cable pin-out (Gnd, 5V, signal) on pins 1,2,3. Connecting +5V to pin 2 is not needed, but has na ill effect, and is convenient for this mode of operation (see warning below). NOTE: When connecting an RIC signal cable to J4, remember that all pins have a 5V maximum. if your servo cable carries more than 5V on the middle pin (pin 2, LL), it will damage the Gamoto, so you must not connect this pin. In this case it would be better to remove the pin or wire for this signal, and connect only GND and the 5V RIC pulse signal. There is also a reset pin available to allow an extemal processor to electrically reset the Gamoto, by pulling the reset line low momentarily 2005 Gamatronix Page 36 of 45 Gamoto Gamoto 9.8 J5: Serial Interface JS Pin Serial Interface connector. 1 G_ Signal Ground 2 Vreg Regulated 5 Volt supply output, available to power a serial level adapter 3. RX _ Sefial Receive line, 5V logic levels 4 TX __ Sotial Transmit line, SV logic levels This connector is used for controlling the Gamoto from a serial host, such as a microcontroller (MCU) or PC. When communicating using this port, use the serial protocol {as described in communication section of this manual, NOTE: You cannot directly connect a PC serial port to this connector, because the logic levels are 5V levels, not RS-232 or RS-485 levels. A serial transceiver chip, such as the Maxim MAX232 must be used in this, case. Either RS-232 or RS-485 transosivers may be used, depending on the application. If RS-485 is chosen, you must use a transceiver capable of automatically enabling the driver upon transmission ("AutoDirection’ feature or similar name). Two examples of this type of chip are the Maxim MAX13487E and MAX13488E devices. See the Gamatronix website (wwe [Link]) for sources for off-the-shelf serial adapter cables, to allow easy connection to a PC. 9.9 J6: Encoder Inputs J6 | Pin | Quadrature Encoder inputs G1 Ground Vreg 2 Regulated § VDC output. Supplies power to LED for encoder. ‘A_3 Quadrature Encoder input signal, Phase A B__4 Quadrature Encoder input signal, Phase B This connector is used to power the encoders and to receive the encoder input signals. The two inputs, A and B, should be out of phase with each other, to indicate motor direction, as shown below: Encoder A, Encoder B | Please note that if a normal LED is connected directly to this power supply, a current- limiting resistor must be used, to avoid damaging the LED. Most commercial encoder modules have these resistors included, and some LEDs have current limiting builtin Check the encoder or LED datasheet to be sure. 9.10 J7: ’C Interface J7 Pins | \“¢ Communication Interface SDA 1,2 FC Data signal. This is an open-collector 5V logic signal, with pull-up resistor. 2005 Gamatronix Page 37 of 45 Gamoio Gamoto CLK 3.4 FC Clock signal. This is an open-collector SV logic signal, with pull-up resistor. G56 Ground This connector is used to control the Gamoto from an IC Master device, such as a microcontroller (MCU). The olock (CLK) and data (SDA) lines are held high by pull-up resistors on the board, and are pulled low when active. Note that the two connectors are wired in parallel, for easy daisy-chaining of I'C devices, 2005 Gamatronix Page 38 of 45 Gamoio Gamoto 9.11 J8: Logic Power Input J8 | Pin | Logic Power Input. This supplies power for the digital components. G1 Ground V2 47.5~16 VDC. Typical current consumption is 40 mA @ 12V G3 Ground Although this is a three-position connector, only one ground connection is necessary. The third pin has been added to help provent accidentally reversing the input power. We recommend using a three-pin connector for power, because it allows the user to connect in either orientation without risk of damaging the board. WARNING: There is NO internal protection against reverse-polarity, so if power is connected backwards, the 5V Tegulator WILL be permanently damaged. The good news is that this is a commonly available part, and not too dificult to replace if you have a solder iron and some electronic. experience. The Digikey part number is LM340T-5.0-ND, but many substitutes can be Used, such as the LM7805. 2005 Gamatronix Page 39 of 45 Gamoto Gamoto 10. Schematic Diagram T77 aa] GZGSTED b00e702/ TT OU) 4 ‘euep Fury Aq uoNeUeD 103 23 rasqunny WwawN>0g) tow UI JBIJOUOD JO}OW C}OWES + age, Gamoto Page 40 of 45 2005 Gamatronix Gamoto 11. Appendix A: Factory Default values Below are the factory defaults ofthe flash registers, These values can be restored at any time by writing to the command register, FactoryRst. Register Factory Default Value Kp 500 Ki 3 Ka 200 iLimit 5000 dS 10 Mode 1 pwrLimit 255 Mode2 o To change the value that these registers will have at power-up, simply set them to the desired values, and then write to the command register SaveParms to save them to flash memory. Now, every time you power up, the values you programmed will be set. To revert back to the original factory values at any time, write to the FactoryRst command register. 2005 Gamatronix Page 41 of 45 Gamoto Gamoto 12. Appendix B: I?C Subroutines for PIC Assembly The following routines can be used with a PIC microcontroller to implement an I°C Master. The sample code is for a 20MHz clock, but can easily be adapted to other clock speeds. Note that for communicating with the Gamoto, 400 kHz is the maximum I°C speed that should be used. jslave SDBFINE SLAVEID 0x91 device to we are talkin: this for your device (set if you 2005 Gamatronix Page 42 of 45 Gamoio Gamoto \c_WET: movi SSPCON2“0x80,4 i Check all busy bics skipz goto 12¢ Wr itset SSESTAT“Ox80,R W goto $- 1 ~ Banko “call 12¢aitforidle bank sf SSPCON2"Dx80, SEN ; Initiate start panko r2cRepstart: ‘call T2cwaitoridle pankL Bef SSPCON2“0xe0, RSEN j initia panko Repeated start sc8tep: (call 12cwaitforzdle sr SSPCON2~0xe0, PEN ; Initiate stop bank Read: call T2cwaitoridle bankL bef SSPCON2” 0x80, RCEN } Initiate receive anko Gal: r20waiteostale move SSP2UF,W movee 12CData call T2cwaitroridle anki bef SSPCON2"0x80,AcKDT j Don't send an ACK (EEPROM doesn's require it sf SSPCON2"0x20,ACKEN c panko ate ACK sequence z2cReadwack } Same a3 12CRead, mut we send an ACK this time Gall i2cwsiteoriale anki bef SSPCON2“0xE0, RCEN j Initiate receive panko call I2cwaitoridle nevi SSPS0F, w= call [2¢eaiveoridle Eanel bof SSPCON2~0x80,ACRDT } Send an ACK this time sf SSPCON2"0x0,ACKEN jan ACK sequence 2005 Gamatronix Page 43 of 45 Gamoio Gamoto 2005 Gamatronix Page 44 of 45 Gamoto Gamoto 13. Appendix C: FAQs Frequently Asked Questions 4. What if my motor doesn’t have encoders, or | don’t want to use encoders? No problem. Set the mode to Power mode, and use the mPower register to manually control power to the motor. 2. want to use a 6-volt motor, but the spec sheet says minimum 12 volts. Am | out of luck? Not Just sot the max power to 50%, and there will never be more than 6V of power to your motor, even though you are running off a 12 Volt battery. Similar power limiting can be done for any combination of battery levels and motor limitations. 3. My Gamoto was working fine, but now the motors won't run. What's wrong? Most likely your battery has run down to less than 12 Volts, Double check the voltage and make sure it reads at least 12V under load. 4. My Gamoto board is dead. The green power light does not light when power is connected. What's wrong? Most likely, the 5V regulator has been damaged, either by reversed polarity or a short of some kind. Replace the SV regulator. 5. Is the Gamoto firmware field-upgradeable? Yes, itis. Please contact us at sales@[Link] for details to upgrade your Gamoto firmware 6. Ared LED is lit on the board. My Gamoto is communicating, but the motors are dead. I've checked the voltage levels and they're fine. What's wrong? Your fuse has blown or is missing. Remove and check it for continuity. See the section in the User's Manual on fuses to find ordering information. 7. Where can | ask more questions, and share experiences with other users? Join the Gamatronix Yahoo forum. The web page is at: htips/[Link]/group/gamatronix 2005 Gamatronix Page 45 of 45 Gamoto

You might also like