Using Motor Recovery Function in AM9BE
Some of voice toys with motors may have such a function that when power on, the motor starts to rotate until it reaches to a particular position and then stops. After the voice playing is completed, motor will continue to rotate to the particular position and then stops. This function is named as the Motor Recovery function.
Previously, this function is realized by programming. But now this function can be realized by using AM9BE. In the following description, we introduce how to realize this function by using AM9BE.
How to identify the particular position by AM9BE?
In general, a motor structure consists of two parts. One part is fixed, and the other part can rotate. Between these two parts, a touching point is set as the particular position, which can be identified by AM9BE. When this point is touched, it means that the motor rotates to the particular position.
To produce this position, for example, we can first install a switch at the fixed part and make a little raised part at the rotated part respectively. When the motor rotates to the particular position, the little raised part can press the switch. In this way, the switch will be closed. While if the little raised part leaves, the switch will be off.
Then connect the two ends of switch to the IO3 (Motor Recovery input port) and the anode of power respectively. This connecting create a function that when the switch is off, the IO3 is in low level as it is internally set with a pull-down resistor. While if the switch is on, the IO3 will be in high level. Thereby, AM9BE identifies that the motor has rotated to a particular position and then stop motor rotating.
Motor Recovery Function Realization
Case Functions:
1. Do Motor Recovery when power on.
2. Do Motor Recovery for OKY when toggle OFF.
3. Sequentially play two voices with IO actions (produced by PowerIO). The IO actions are used to drive bi-directional motor.
4. Do Motor Recovery after the playing is over.
Steps
1. Produce two voices with IO actions, which are used for driving motor when playing voice.
2. Produce a short mute with IO actions, which are used to drive motor to do Motor Recovery. See the figure 1, the mute only lasts 10ms. The SYNC1 (in blue) is in high level, and the SYNC2 is in low level. This is used to drive bi-directional motor to rotate.

Figure 1
- Create an EzSpeech project file, and fill in the client name and related info in the Information page.
- In Function page, select Input in IO3 and select Motor Recovery. Then set PowerIO as the output type for IO1 & IO2 and set the PIO Init as Low (high level drives motor). See the figure 2.

Figure 2
- Add voice files in VoiceSections page. In figure 3, two voices (S01.amp, S02 amp) and a mute (t01 amp) to drive motor are added.
In addition, add two Mute onlys. One lasts 5 seconds, and the other lasts 8 ms.

Figure 3
- Set playing list in Subtables column. See the figure 4.

Figure 4
In figure 4, Subtable3 first plays a short mute with IO actions, which is used to drive motor to rotate. Then it plays a mute (5 sec). Since the MtyRvy of these two mutes are set as ‘Yes’, the Motor Recovery function is valid during two mutes playing. Thus, the motor will keep rotating until the IO3 goes to high level. Then it executes Subtable4 or the mute (5 sec) playing is over and enters into End.
For the IO3 Subtable setting, the ‘4’ is selected. It means that the IO3 Subtable4 will be executed when the switch is closed and the IO3 goes to high level during Motor Recovery process. Since Subtable4 plays a very short mute, it quickly enter into End and stops motor rotating.
To sequentially play two voice (S01.amp & S02.amp) and start to play Subtable from Subtable1 for OKY, we should select Subtable1- Subtable2 for OKY Sequential setting. These two voices are placed in Subtable1 and Subtable2 respectively. As the Motor Recovery function is not allowed during voices playing, you should set ‘-“ for MtrRvy column but not ‘Yes”.
After the sequential playing of Subtable1 and Subtable2 is over, do Motor Recovery. Therefore, the ‘Jump Step002’ should be set in Instruction column for both Subtable1 and Subtable2, that is, jump to Subtable3. In this way, the motor is driven and Motor Recovery function is executed.
For the POP Subtable setting, the Subtable3 is selected. It means that when power on, play the short mute with IO actions and drive motor.
- After filling in the table, save the project file and compile. Then download it to AM9BA_Romter or AM9BA_DB for test.
Notes:
1. You should set IO3 as Input first before using Motor Recovery function. After you select Motor Recovery, the KeyReleaseJump is compelled to select and in gray. This is in order to jump to the Subtable with Motor Recovery function and thereby execute Motor Recovery when Toggle off.
2. Only if you select ‘Yes’ in MtrRvy column for Subtable, the Motor Recovery function is valid and the IO3 goes to high level to execute IO3 Subtable. Otherwise, the IO3 Subtable is not executed.
3. Only when toggle off and the MtrRvy is set as ‘Yes’, the Jump instruction in Instruction column can be executed. As shown in figure 3, it jumps to Step002 and execute Motor Recovery when Toggle OFF.
4. During the process of Motor Recovery, all input ports will be masked and the trigger keys are invalid until IO3 goes to high level or Motor Recovery enters into End within limited time.
5. To avoid damaging the touch point, which may result in motor limitless rotating, we add a 5 sec mute in this example for restricting the Motor Recovery time. If the time exceeds the limit, it will enter into End and resume to initial state at the same time. Certainly you can adjust the mute time for restriction by yourself.