Файл: Advanced Robotics with the Toddler (Paralax, student guide, v1.3, 2004).pdf

ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 12.06.2025

Просмотров: 1931

Скачиваний: 0

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

Page 204 · Advanced Robotics with the Toddler

IF (currentTilt < newTilt) THEN

' start tilt calculations

currentTilt = currentTilt + TiltStep

' from right tilt = increment

PULSIN Yout,1,Incline

'DEBUG "Incline = ", DEC Incline, CR

IF Incline < YAxisLfLimit THEN

Counter = Counter + 1

'DEBUG "Counter = ", DEC Counter, CR

ENDIF

IF Counter > escVal THEN

newTilt = currentTilt

' at limit of tilt, move no more

ENDIF

IF currentTilt >= newTilt THEN

currentTilt = newTilt

' correct if overshot tilt

doneTiltFlag = 1 Counter = 0

ENDIF ELSE

currentTilt = currentTilt - TiltStep

' from left tilt = decrement

PULSIN Yout,1,Incline

'DEBUG "Incline = ", DEC Incline, CR IF Incline > YAxisRtLimit THEN

Counter = Counter + 1

'DEBUG "Counter = ", DEC Counter, CR ENDIF

IF Counter > escVal THEN newTilt = currentTilt IF currentTilt <= newTilt THEN

currentTilt = newTilt

' stop at limit of tilt

doneTiltFlag = 1

Counter = 0

ENDIF

ENDIF

ENDIF

Move_Stride:

IF (currentStride < newStride) THEN currentStride = currentStride + StrideStep

' from right stride = increment

IF (currentStride >= newStride) THEN currentStride = newStride

IF (doneTiltFlag = 1) THEN doneMoveFlag = 1

' uses doneMoveFlag to increment ' states

ENDIF ELSE

currentStride = currentStride - StrideStep

' from left stride = decrement IF (currentStride <= newStride) THEN' jump if still moving

currentStride = newStride


IF (doneTiltFlag = 1) THEN doneMoveFlag = 1
' uses doneMoveFlag to increment ENDIF ' states
ENDIF
Move_It:
PULSOUT TiltServo, currentTilt PULSOUT StrideServo, currentStride RETURN
Do_Movement is the big change here. The tilt section kept the limits for the servo pulse width but opened the values out to their full range. Measuring the tilt sensor was integrated with the tilt movement.
If you recall, the program from the last experiment just managed to get the servo pulses out at 20 ms intervals. Now we just added a measurement that takes around 5 ms and some more calculations. When the tilt is ramping, the servo refresh is 30 ms. Not as good as it can be! A quick and dirty fix was to check up front if the tilt is already where it is supposed to be. If it is, we set the flag and skip the tilt sensing altogether. Since that would run at 19 ms servo refresh, a 1 ms PAUSE was added. When we have to do the tilt measurements, the refresh time goes back to 30 ms. It works like that but any changes to this program could cause the servo movements to get rough. As it is, the same step values for tilt are slower for tilting.
Where’s the Problem?
The whole issue is the need to keep pulsing the servos every 20 ms. Toddler really doesn’t need to use its vision and check the bumpers every 20 ms. You could set up the state machines for vision and bumpers to run every other time. On one pass through the main DO...LOOP, do the IR, the next the bumpers. That trick will minimize the maximum time between servo pulses and get smoother performance back. The big question now becomes – “How do I measure the servo pulse cycle times?” Actually, if you have an oscilloscope, it is easy. But many people don’t have one so that brings us back to the problem.
Co-processor: Another Solution
Tuning a processor to get the absolute maximum performance out of it is an interesting and challenging exercise. It can also be a big pain and require lots of time spent with an

Chapter #9: Acceleration-Based Motion · Page 205

Page 206 · Advanced Robotics with the Toddler

oscilloscope trying to find a quicker way of executing your code. If your goal is to try out new and fun behaviors, or sensors, or whatever, on your Toddler, there is another way. Since the whole problem was the servos and their need for regular updates you can use a “Co-Processor” that is specially programmed to handle the servos. There are two major distinctions in “servo controller” Co-Processors. One type is given the new servo position and it sends the servo to that position at full speed. It then gives the same pulse widths every 20 ms to the servo until you send a new value. That type is better suited for wheeled robots with modified servo motors. They aren’t very helpful in a walking robot. The issue with a walker is that it is constantly changing the value of the servo output pulse in a ramped fashion. As you recall, that is what the StrideStep and TiltStep were used for in the Do_Movement subroutine. Happily, there is another type. A “ramping” servo controller remembers where each servo is and ramps (adds constant steps like Do_Movement did) to get to the new position. It essentially executes the Do_Movement subroutine for you. Many Co-Processors have more than just servo controllers in them. One we recommended is from Blue Bell Design Inc. (www.bluebelldesign.com). It has 8 ramping servo controllers, 5 analog to digital converter inputs (10-bit), and extra inputs and outputs. Best of all, it will be available on a compatibly sized PC board for easy installation on your Toddler! The Blue Bell Design Co-Processor is discussed in Appendix C.

CHALLENGES

In Do_Movement, the PULSIN command reads the value of the Memsic 2125 accelerometer. Since we know the code is too slow to keep up with 20 ms refresh on the servos, and there is plenty of code space left, is there some way you can use the current state of the accelerometer signal to pick up an average of 1.5 ms in the worst case? What is the worst case state of Yout? Why is it the worst case? Hint: What do you know about how PULSIN works that makes a difference?

Tune the timing of your Toddler for optimal speeds, tilt, and stride. How good can you get it to be?

You know that Toddler really doesn’t need to use its vision and check the bumpers every 20 ms. Can you think of ways to make the state machines in vision and bumpers run on alternate cycles? What happens to the evenness of the servo steps if the duration between servo pulses changes cycle to cycle?.


Appendix A: Parts Listing and Sources · Page 207

Appendix A: Parts Listing and Sources

All parts used in the Toddler kit are available individually from the Parallax Component Shop at www.parallax.com. If you can’t readily find the component you are looking for in the Component Shop enter the name of it in the on-line search box using the stock code.

The Toddler Kit comes in two flavors:

Gold Anodized Toddler Kit - 27310

Blue Anodized Toddler Kit - 27311

Toddler Kit Bill of Materials

Parts and quantities subject to change without notice

Parallax Part #

Description

Qty/Kit

Electronic Components

150-02210

220 Ohm resistors ¼ watt 5% tolerance

4

200-01040

0.1 uF capacitor

2

200-01031

0.01 uF capacitor

2

350-00001

Green LED

2

350-00003

Infrared LEDs

4

350-00007

Yellow LED

2

350-00009

Photoresistors

2

350-00014

Infrared detector

4

350-90000

LED standoffs

4

350-90001

LED light shields

4

550-00020

Toddler Printed Circuit Board with BASIC Stamp 2

1

753-00001

Battery Pack with Tinned Wires

1

800-00016

Jumper wires (bag of 10)

1

900-00001

Piezospeaker

1

900-00010

Parallax Toddler Servo (Toddler Mini F BB)

2

Metal Parts

720-00001

Toddler Top Plate - Gold Anodized

1

720-00002

Toddler Top Plate - Blue Anodized

1

720-00003

Toddler Body - Gold Anodized

1

720-00004

Toddler Body - Blue Anodized

1

720-00005

Toddler Foot - Left Gold Anodized

1


Page 208 · Advanced Robotics with the Toddler

720-00006

Toddler Foot - Left Blue Anodized

1

720-00007

Toddler Foot - Right Gold Anodized

1

720-00008

Toddler Foot - Right Blue Anodized

1

720-00009

Toddler Ankle

2

720-00010

Toddler Legs

4

Hardware

700-00002

3/8" 4/40 machine screw – panhead

10

700-00003

4/40 nut

14

700-00016

3/8” 4/40 machine screw – flathead

6

700-00028

1/4" 4/40 machine screw – panhead

12

700-00060

1” 4/40 aluminum standoffs female/female

4

710-00100

3/16” long 4/40 socket head cap screw – stainless steel

4

712-00001

1/2" outer diameter flat round plastic washer

4

725-00002

3” long 3/16" outer diameter stainless steel rod

2

725-00003

1/16" ball joints with 2/56 thread (nut, ball joint, cup)

4

5.4" long stainless steel rod with 2/56 0.5" thread on each

725-00004

end

2

725-00005

3/32" hex L-key

1

725-00006

3/32" E/Z adjust plastic horn bracket for 4-40 screw

1

725-00007

.072” brass servo horn connector (brass fitting, rubber

holder and small screw) – in a package

1

725-00008

.072” diameter “L” shaped 2” wire

2

726-00001

3/16" collars (4), set screw and wrench

1

Miscellaneous

122-00001

Advanced Robotics with the Toddler Manual

1

123-00001

Toddler Printed Insert

1

800-00003

Serial cable

1

900-00007

The Plastic Box

1

700-00064

Parallax Screwdriver

1

Additional Recommended Hardware

Parallax Part #

Description

27312

Toddler Toes Kit for Chapter 8

28017

Memsic 2125 Accelerometer for Chapter 9