ServoPAL (#28824): Servo Pulser and Timer

Similar documents
Web Site: Forums: forums.parallax.com Sales: Technical:

Special Lecture. Basic Stamp 2 Programming. (Presented on popular demand)

Chapter 4: Pulse Width Modulation

MODULE BOUSSOLE ÉLECTRONIQUE CMPS03 Référence :

CHAPTER 11: Flip Flops

SD21-21 Channel Servo Driver Module Power Servo's

Web Site: Forums: forums.parallax.com Sales: Technical:

Digital To Analog Converter with Sine Wave Output

Web Site: Forums: forums.parallax.com Sales: Technical:

Experiment #26: Stepper Motor Control

Pulse Width Modulation Applications

Parallax Serial LCD 2 rows x 16 characters Non-backlit (#27976) 2 rows x 16 characters Backlit (#27977) 4 rows x 20 characters Backlit (#27979)

Gripper Kit for the Boe-Bot Robot (#28202)

Servo Motors (SensorDAQ only) Evaluation copy. Vernier Digital Control Unit (DCU) LabQuest or LabPro power supply

Bluetooth + USB 16 Servo Controller [RKI-1005 & RKI-1205]

Web Site: Forums: forums.parallax.com Sales: Technical:

Scan a Keypad with the BS2 For Pushbutton User Input

TEK 1 Applications V TEKVOX, Inc San Antonio, TX 78232

Software Manual RS232 Laser Merge Module. Document # SU Rev A

FLORIDA INTERNATIONAL UNIVERSITY. Miami, Florida ADAPTIVE FAULT-TOLERANT TELEOPERATION. A dissertation submitted in partial fulfillment of the

DC Motor control Reversing

UPS PIco. to be used with. Raspberry Pi B+, A+, B, and A. HAT Compliant. Raspberry Pi is a trademark of the Raspberry Pi Foundation

etape Continuous Fluid Level Sensor Operating Instructions and Application Notes

EasyC. Programming Tips

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

Robotics with the Boe-Bot Student Guide

Designing VM2 Application Boards

STWD100. Watchdog timer circuit. Description. Features. Applications

Table 1 Comparison of DC, Uni-Polar and Bi-polar Stepper Motors

Allen-Bradley/Rockwell

NTE2053 Integrated Circuit 8 Bit MPU Compatible A/D Converter

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

BLOCK OCCUPANCY DETECTOR WITH SEMAPHORE OPERATION BOD1/DAP4-BR

Lab 3 Microcontroller programming Interfacing to Sensors and Actuators with irobot

Web Site: Forums: forums.parallax.com Sales: Technical:

WA Manager Alarming System Management Software Windows 98, NT, XP, 2000 User Guide

OPERATING MANUAL. Table of contents. 2 Phase Stepping Motor Driver 2M542. Rev. A. Introduction page 2. Specifications page 2 Timing chart page 3

Display Board Pulse Width Modulation (PWM) Power/Speed Controller Module

AN141 SMBUS COMMUNICATION FOR SMALL FORM FACTOR DEVICE FAMILIES. 1. Introduction. 2. Overview of the SMBus Specification. 2.1.

SumoBot Mini-Sumo Robotics Assembly Documentation and Programming

Page 1. Description

Application Unit, MDRC AB/S 1.1, GH Q R0111

Advanced LED Controller (LED Chaser)

Eric Mitchell April 2, 2012 Application Note: Control of a 180 Servo Motor with Arduino UNO Development Board

UPiS - Uninterruptible Power intelligent Supply

Allows the user to protect against inadvertent write operations. Device select and address bytes are Acknowledged Data Bytes are not Acknowledged

M25P05-A. 512-Kbit, serial flash memory, 50 MHz SPI bus interface. Features

LG Air Conditioning Multi F(DX) Fault Codes Sheet. Multi Split Units

ARM Thumb Microcontrollers. Application Note. Software ISO 7816 I/O Line Implementation. Features. Introduction

AN : Using Wago CANOpen IO

XBee USB Adapter Board (#32400)

Application Note AN-1187

Microcontroller Based Low Cost Portable PC Mouse and Keyboard Tester

ABB Drives. User s Manual HTL Encoder Interface FEN-31

cs281: Introduction to Computer Systems Lab08 Interrupt Handling and Stepper Motor Controller

Massachusetts Institute of Technology

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

Work with Arduino Hardware

The Basics of Robot Mazes Teacher Notes

DS Wire Digital Thermometer and Thermostat

How To Program An Nxt Mindstorms On A Computer Or Tablet Computer

[F/T] [5] [KHz] [AMP] [3] [V] 4 ) To set DC offset to -2.5V press the following keys [OFS] [+/-] [2] [.] [5] [V]

Flow Charts and Servomotors (background to Lab #2) Things to learn about: flow charts for design. MECH Lecture #2 flow charts & servos rev2

Easy Step 1000 Stepper Driver Module

PNSPO! Modbus Solution CP1H / CP1L / CJ1 / CJ2 / CS1. Version /18/2009

GLOLAB Two Wire Stepper Motor Positioner

Controlling a Dot Matrix LED Display with a Microcontroller

MicroMag3 3-Axis Magnetic Sensor Module

understanding sensors

mdm-mp3 minidirector with MP3 Player

- 35mA Standby, mA Speaking pre-defined phrases with up to 1925 total characters.

An Introduction to MPLAB Integrated Development Environment

ROBOTC Software Inspection Guide with Additional Help Documentation

Rethinking the First Year Programming Course

Series /16 DIN Multi-Mode Bar Graph Display Timer TIMERS PRODUCT HIGHLIGHTS

DS18B20 Programmable Resolution 1-Wire Digital Thermometer

LOVELINK III- Process Monitoring, Logging, Graphing, & Configuration

PROGRAMMABLE LOGIC CONTROL

PLL frequency synthesizer

Using your LED Plus keypad

Pmod peripheral modules are powered by the host via the interface s power and ground pins.

RS - SPM. Serial parallel translator module

ARRL Morse Code Oscillator, How It Works By: Mark Spencer, WA8SME

Three Axis TB6560 CNC Driver Users Manual

Digital and Analog I/O

S4000TH HART. HART Communication Manual

JTAG-HS2 Programming Cable for Xilinx FPGAs. Overview. Revised January 22, 2015 This manual applies to the HTAG-HS2 rev. A

SenseLink TM. End-Point Controller. Addendum

Digital Systems Based on Principles and Applications of Electrical Engineering/Rizzoni (McGraw Hill

ETEC Digital Controls PIC Lab 10 Pulse Width Modulation

Flexible Active Shutter Control Interface using the MC1323x

A Practical Guide to Free Energy Devices

Servo Info and Centering

Chapter 9 Latches, Flip-Flops, and Timers

Design and Verification of Nine port Network Router

Introduction to programming moway

Smart Sensing Solutions Since 1954

HANDLING SUSPEND MODE ON A USB MOUSE

Transcription:

Web Site: www.parallax.com Forums: forums.parallax.com Sales: sales@parallax.com Technical: support@parallax.com Office: (916) 624-8333 Fax: (916) 624-8003 Sales: (888) 512-1024 Tech Support: (888) 997-8267 ServoPAL (#28824): Servo Pulser and Timer General Description The ServoPAL is a tiny module that plugs in between your BASIC Stamp and two servo motors to pulse the motors so your PBASIC program doesn t have to. In addition, it provides an alarm clock function to perform timing in the background while the BASIC Stamp is busy with other tasks. Features Plugs in between servo headers and servos: no wiring necessary. Simplifies PBASIC programming for both standard and continuous-rotation servos. Pulses two servos continuously based on single pulses received from the BASIC Stamp. Provides an alarm output (200mS to 30 min delay), which can be set by a single pulse. All interfacing is done by pulsing: no serial protocols to learn. Runs from the servo s power (up to 6.5VDC): no additional power source needed. Compact size: stackable side-to-side with additional units on 0.1 servo headers. What s Included What You Need to Provide ServoPAL module BASIC Stamp and carrier board (such as the BOE). One or two servo motors. Installation Installation of the ServoPAL is a simple: 1. Unplug the servo connectors from the servo headers. 2. Plug the ServoPAL into the servo headers. (See diagram below.) 3. Plug the servo connectors into the ServoPAL. Parallax, Inc. ServoPAL (2007.10.30) Page 1 of 9

To Servo 1 To Servo 1 Alarm Alarm Top View Servo Header Everything Connected Below is a photo of the ServoPAL installed on a BOE-Bot s P12/P13 servo header. The wheel servo motor cables are plugged into the ServoPAL. In this case, the input pin is P12, the Alarm output pin is P13, the right servo is, and the left servo is Servo 1. Hardware Interface and Initialization Interface to the ServoPAL is realized through its input and Alarm output. When the ServoPAL powers up, both lines are configured as normally-high inputs, pulled up to a nominal +5V through internal 20K to 50K resistances. Commands to the ServoPAL are sent as negative pulses to the pin. If the alarm feature is not used, the BASIC Stamp can use the Alarm pin for any other purpose. If this is done, however, you must be careful not to trigger an alarm inadvertently, or else a bus conflict may occur. The ServoPAL runs autonomously on power obtained from the servo headers. Therefore, it does not reset when the BASIC Stamp resets, and continues to send out pulses during and after reset if it was sending them out before. But it can be reset, nonetheless, by sending a pulse of 100mS duration to the pin. Here s the recommended initialization sequence for the ServoPAL in PBASIC: Parallax, Inc. ServoPAL (2007.10.30) Page 2 of 9

{$STAMP BS2} {$PBASIC 2.5} ninp PIN 12 Define the input pin. Alarm PIN 13 Define the alarm pin. Restart: INPUT ninp DO UNTIL ninp LOOP Make sure ninp isnt being driven. Wait for ServoPAL to power up. LOW ninp Set pin to an output and hold it low PAUSE 100 for 100mS. HIGH ninp Raise the pin. This sequence accomplishes a couple things: 1. In systems, like the BOE-Bot, where the servo power is switched on after the BASIC Stamp powers up, it will wait for the ServoPAL to be turned on. It does this by setting the ninp line to an input and waiting for that line to go high, signifying not only that that the ServoPAL has powered up, but that it has come out of reset and engaged its internal pull-ups. 2. In case the ServoPAL was already running, it then sends a long reset pulse to terminate any servo pulses, to abort any pending alarm, and to ready the ServoPAL for further commands. Programming Servo Pulses Servo pulses are programmed in much the same way you d send pulses directly to a servo motor, using the PBASIC PULSOUT command. The only differences are that the pulses are negative-going instead of positive and that both servos are programmed from the same pin. Here s an example that will cause the output to begin pulsing with 1.5mS pulses. These pulses are automatically repeated every 10-15mS without further intervention from the BASIC Stamp. PULSOUT ninp, 750 Notice that this is identical to the statement that would have been used, had the servo been connected directly to the BASIC Stamp. Once the initialization code is executed, your program is primed for negative-going pulses, and you don t need to do anything special to send them. Here s what the waveforms look like that result from the above example: But what about Servo 1? There s only one pin, so how does it get programmed? That s easy: just send another pulse within 1mS of the first one, and that one will be assigned to Servo 1: PULSOUT ninp, 750 PULSOUT ninp, 1000 The preceding code will program with a pulse width of 1.5mS and Servo 1 with a pulse width of 2.0mS. Here s what the waveforms will look like: Parallax, Inc. ServoPAL (2007.10.30) Page 3 of 9

Servo 1 To terminate a sequence of pulses on, just wait at least 2mS before sending another pulse. This signals the ServoPAL that the next pulse is intended for. Now, what if you want to program only Servo 1 and leave alone? That s easy, as well. Just send a very short pulse (4 100µS) for first, then a pulse for Servo 1. The ServoPAL will interpret the short pulse as indicating that you don t want to change s pulse stream, if one has already been programmed. Here s an example: PULSOUT ninp, 2 PULSOUT ninp, 500 Here s what the resulting waveforms look like: Servo 1 Note: Do not send the ServoPAL any pulses less than 4µS in duration. It could easily become confused, as it might miss them entirely. And finally, what if you want to terminate a servo s pulse stream? The ServoPAL will only send pulses to a servo that are between approximately 0.5 and 2.5mS. If it encounters a request for pulses well outside this range, it will cease sending pulses to the affected servo. Here s how you can use this to stop sending pulses to a servo: PULSOUT ninp, 2000 Send a 4mS pulse to. Here s the result: Servo 1 To summarize, here s a table showing the various pulse durations and what they mean: 4-100µS Skip this servo. (Don t change its output.) 0.5-2.5mS Program this pulse width into the affected servo. Parallax, Inc. ServoPAL (2007.10.30) Page 4 of 9

4 30mS Kill the servo s output. 100mS or more Reset the ServoPAL. Pulse widths outside the individual ranges shown may have unpredictable effects. Programming the Alarm Function In addition to servo control, the ServoPAL has an alarm clock (timer) function. You can set an alarm to occur anywhere from 200mS to 30 minutes after it s set (triggered). For programming purposes, the timer is treated by the ServoPAL as a third servo: i.e. after sending pulses for and Servo 1, you send a pulse for the timer. As soon as such a pulse is received, the Alarm output is pulled low. It will remain low until the programmed time elapses, whereupon it will again float and be pulled high by means of the internal pullup resistor. The relation between the pulse width sent by the BASIC Stamp and the actual time programmed into the timer is Programmed time = Pulse width * 50000 (approximately) So a pulse width of 4µS yields a timeout of 200mS, and a pulse width of 36000µS yields a timeout of 30 minutes. In terms of PULSOUT units, here s the timing for various BASIC Stamps: Time per PULSOUT unit Maximum PULSOUT units BS1 BS2 BS2e BS2sx BS2p BS2pe BS2px 500mS 100mS 100mS 40mS 40mS 100mS 40mS 3600 18000 18000 45000 45000 18000 45000 Here s a BS2 program fragment that sets the timeout period to 5 minutes: PULSOUT ninp, 4 Skip. PULSOUT ninp, 4 Skip Servo 1. PULSOUT ninp, 3000 Set timeout to 300 seconds. And here s the output waveform: Alarm 6mS 300000mS = 5 min. One additional thing to note about the timer is that it s retriggerable. What this means is that if you set it before a previous setting has timed out, it will start over with the new timeout value. This feature makes the ServoPAL useful as a watchdog timer for the BS2p, BS2pe, and BS2px, which support automatic polling. As long as you keep resetting the watchdog timer, the Alarm output will stay low. But if your program hangs up somewhere, the timer will eventually time out and the rising edge on Alarm can be used to (re)start the program specified by POLLRUN. Parallax, Inc. ServoPAL (2007.10.30) Page 5 of 9

Simple Example Program Here s a simple-minded BS2 program that moves a BOE-Bot forward for 5 seconds, then in reverse for five seconds, using the Alarm output as a timer: ========================================================================= File... ServoPAL_Simple_Demo.bs2 Purpose... Demonstrate ServoPAL capabilites on a BOE-Bot Author... Parallax, Inc. E-mail... support@parallax.com Started... 2007.05.01 Updated... 2007.10.29 {$STAMP BS2} {$PBASIC 2.5} ========================================================================= -----[ Program Description ]--------------------------------------------- This simple demo of the ServoPAL, when used with a BOE-Bot, will move the robot forward for five seconds, then in reverse for five seconds. -----[ I/O Definitions ]------------------------------------------------- ninp PIN 12 Define the input pin. Alarm PIN 13 Define the alarm pin. -----[ Initialization ]-------------------------------------------------- INPUT ninp DO : LOOP UNTIL ninp Make sure ninp isnt being driven. Wait for ServoPAL to power up. LOW ninp Set pin to an output and hold it low PAUSE 100 for 100mS to reset ServoPAL. HIGH ninp Raise the pin. PAUSE 100 -----[ Program Code ]---------------------------------------------------- PULSOUT ninp, 500 PULSOUT ninp, 1000 PULSOUT ninp, 50 DO : LOOP UNTIL Alarm PULSOUT ninp, 1000 PULSOUT ninp, 500 PULSOUT ninp, 50 DO : LOOP UNTIL Alarm PULSOUT ninp, 2000 PULSOUT ninp, 2000 DO:LOOP Program right servo for full forward. Program left servo for full forward. Program alarm for 5 seconds. Wait for Alarm. Program right servo for full reverse. Program left servo fro full reverse. Program alarm for 5 seconds. Wait for Alarm. Turn right servo off. Turn left servo off. IR Roaming Program The next example is an IR roaming program for the BOE-Bot. To use this program, you should connect the IR emitters and sensors as shown in Parallax s Robotics with the Boe-Bot, figure 7-4 (copied below). Parallax, Inc. ServoPAL (2007.10.30) Page 6 of 9

The program works like this: 1. Start the BOE-Bot moving forward. 2. Keep checking for obstacles until one is found. 3. If obstacle is on left or right, begin turning in opposite direction. 4. If obstacle is in front, back up for one second, then begin turning right for at least ½ second. 5. Continue evasive action until clear of obstacles AND any timed motion has completed. 6. Go to step 1. Here s the program: ========================================================================= File... ServoPAL_IR_Roaming.bs2 Purpose... BOE-Bot IR Roaming Program using ServoPAL Author... Parallax, Inc. E-mail... support@parallax.com Started... 2007.10.29 Updated... {$STAMP BS2} {$PBASIC 2.5} ========================================================================= -----[ Program Description ]--------------------------------------------- This program uses the ServoPAL in conjuction with IR emitters and detectors to steer the BOE-Bot past obstacles in encounters in its path. -----[ I/O Definitions ]------------------------------------------------- IRDetR PIN 0 Righthand IR detector. IREmtR PIN 2 Righthand IR emitter. IREmtL PIN 8 Lefthand IR Emitter. IRDetL PIN 9 Lefthand IR detector. ninp PIN 12 ServoPAL input pin. Alarm PIN 13 ServoPAL alarm pin. -----[ Constants ]------------------------------------------------------- NONE CON 0 RIGHT CON 1 LEFT CON 2 Parallax, Inc. ServoPAL (2007.10.30) Page 7 of 9

BOTH CON 3 BKWD CON 0 FWD CON 3 -----[ Variables ]------------------------------------------------------- Obstacle VAR Nib Reading from IR detectors. Move VAR Nib Motor command. Time VAR Word -----[ Initialization ]-------------------------------------------------- INPUT ninp DO : LOOP UNTIL ninp Make sure ninp isnt being driven. Wait for ServoPAL to power up. LOW ninp Set pin to an output and hold it low PAUSE 100 for 100mS to reset ServoPAL. HIGH ninp Raise the pin. PAUSE 100 -----[ Program Code ]---------------------------------------------------- DO Move = FWD Start BOE-Bot moving forward, GOSUB DoMotor using the DoMotor routine. DO GOSUB ReadIR Read obstacle detectors, LOOP UNTIL Obstacle until an obstacle is found. IF (Obstacle = LEFT) THEN Obstacle on the left? Move = RIGHT Yes: Start rotating right. GOSUB DoMotor ELSEIF (Obstacle = RIGHT) THEN On the right? Move = LEFT Yes: Start rotating left. GOSUB DoMotor ELSEIF (Obstacle = BOTH) THEN In front? Move = BKWD Yes: Start backing up, Time = 10 and set alarm for 1 sec. GOSUB DoMotor DO UNTIL Alarm : LOOP Wait for alarm to time out. Move = RIGHT Then start rotating right, Time = 5 setting alarm for 1/2 sec. GOSUB DoMotor ENDIF DO Evasive action is being taken. GOSUB ReadIR Read the obstacle detectors. LOOP UNTIL Obstacle = NONE AND Alarm Continue (timed) evasive maneuver, until clear AND time is up. LOOP -----[ Subroutines ]----------------------------------------------------- ------[ ReadIR ]---------------------------------------------------------- Read both IR sensors. Put inverted values into position in Obstacle. ReadIR: FREQOUT IREmtR, 1, 38500 Obstacle.BIT0 = ~IRDetR FREQOUT IREmtL, 1, 38500 Activate the right IR emitter. Read the right IR sensor (and invert). Activate the left IR emitter. Parallax, Inc. ServoPAL (2007.10.30) Page 8 of 9

Obstacle.BIT1 = ~IRdetL RETURN Read the left IR sensor (and invert). ------[ DoMotor ]--------------------------------------------------------- Start motors turning to move BOE-Bot in direction indicated. If Time > 0, then set alarm and clear Time to zero. DoMotor: IF (Move = BKWD) THEN PULSOUT ninp, 900 PULSOUT ninp, 600 ELSEIF (Move = LEFT) THEN PULSOUT ninp, 600 PULSOUT ninp, 600 ELSEIF (Move = RIGHT) THEN PULSOUT ninp, 900 PULSOUT ninp, 900 ELSE PULSOUT ninp, 600 PULSOUT ninp, 900 ENDIF IF (Time) THEN PULSOUT ninp, Time Time = 0 ENDIF RETURN Parallax, Inc. ServoPAL (2007.10.30) Page 9 of 9