Pioneer Module Mobile manual Programming the Digital I/O Ports, Programming the A/D Ports

Page 22

Experimenter’s Module

5.2 Programming the Digital I/O Ports

Use the sfCOMDIGOUT PSOS command and the related Saphira convenience command to manage the various digital output ports. They are described in detail in the previous chapter. (PAI and P-LOGO support similar commands, too.)

For example, to turn the right LED on, use:

sfRobotCom2Bytes(sfCOMDIGOUT, sfRIGHTLEDBIT, sfRIGHTLEDBIT)

Or alternatively, specify the state of an LED:

void sfGripperSetLed(int which, int state)

for which=sfLEFT or sfRIGHT, and state=sfON or sfOFF.

5.3 Programming the A/D Ports

The eight analog-to-digital (A/D) ports on the Experimenter’s Module (AN0-7) are multiplexed from a single A/D port on the Pioneer 1 microcontroller. Hence, only one port may be read at a time, although all eight ports may connect to individual sources.

Each AN port accepts a 0-5VDC analog input and outputs a proportionally related,

single byte value 0-255. Use the digital output ports OD5-7 to address which port PSOS will read and return as the A/D value in the Server Information Packet (section 3.2, PSOS Server Information Packet).

For example, the following Saphira command addresses the AN4 port by masking the OD5-7 ports, setting OD7, and resetting OD5 and OD6: (remaining output ports remain untouched:

sfRobotCom2Bytes(sfCOMDIGOUT, 0xE0, 0x80)

5.4 Programming the Speaker

The latest PSOS implements a new command called SAY, which plays a sequence of up to 20 notes through the Experimenter’s Module speaker. Now your Pioneer will be humming a different tune!

The SAY command (number 15) has two arguments: a string up to 40 bytes long, and the integer number of actual bytes in the string:

sfRobotComStrn(sfCOMSAY, str, n)

The string is comprised of duration and tone pairs; the duration byte is the number of

20 millisecond increments the following tone value half-cycle times—in 150 microsecond increments—should be played through the speaker.

For example, to play two short, high beeps using the Saphira equivalent command:

void sfPlayToneString ("\010\002\010\000\010\002", 6)

18

Image 22
Contents Gripper Experimenter’s Module Manual Gripper & Experimenter’s Module Contents Maintenance & Repair Package Components IntroductionGripper and Experimenter’s Package User Supplied ComponentsGripper & Experimenter’s Module Basic Pioneer PlatformGripper Description Pioneer Gripper side view Experimenter’s Module Description Pioneer 1 Experimenter’s ModulePioneer Web Software Archive Additional ResourcesPioneer and Saphira Newsgroups Support Pioneer-support@rwii.comRemove the Console InstallationRemove Microcontroller from Console Installation ReplaceConnect Cables Reattach Microcontroller to ConsoleRemove Nose Attach Gripper/Experimenter’s Module to PioneerRe-Attach the Console Cables Test the AssemblyRe-Attach the Console Gripper Self Test Gripper Operation and ProgrammingPsos Server Information Packet Gripper Programming Gripper I/ODirect Control via Digital Ports SfRobotCom2BytessfCOMDIGOUT, 0x2 SfRobotCom2BytessfCOMDIGOUT, 0x20SfRobotCom2BytessfCOMDIGOUT, 0x3 Int sfGripperGetState voidGripper functions Experimenter’s Module I/O PortsExperimenter’s Module Digin BREAK, Boot to r EturnDigin Self-Test To skip Vv.vVProgramming the A/D Ports Programming the Digital I/O PortsProgramming the Speaker Drive Lubrication Maintenance & RepairGripper Belt Adjustments Factory RepairsAppendix a Example C Program Demonstrates Gripper and Speaker FunctionsGripper & Experimenter’s Module Momentary switch, 0 is pressed Gripper & Experimenter’s Module Appendix B Pioneer Server Information PacketIndex ComsayMore, Grinnell Gripper & Experimenter’s Module Warranty & Liabilities