• 沒有找到結果。

Chapter 4 Implementation

4.1 Architecture

The whole architecture of the treadmill can be shown in Fig 4.1. The whole architecture can be briefly described as follows. In the treadmill system, the user can use the treadmill through the 15 inch touch screen. The controller of the touch screen to communicate with the target board PCM-9575 is through USB interface. The connection between the desktop pc using to develop the application and the target embedded development board PCM-9575 is through the RS-232 interface, and we need the software ActiveSync to make the connection valid.

The development board PCM-9575 communicates with the Inverter EI-8001 through the RS-232 interface to control the AC induction motor. We can play the music or sound with the help of stereo speaker, and download music file through the Ethernet.

4.2 Communication between PCM-9575 and Inverter EI 8001

There are two choices to control the Inverter EI-8001: terminal control, and serial communication control.

.

4.2.1 Terminal control

Most treadmills use the terminal control to control the speed of the motor, figure is the graph of the terminal, and table is the function of each pin. The pin AI1 controls the voltage to control the speed. The pin LI1, LI2, LI3, LI4 can be programmed to the required function such as free run.

4.2.2 Serial communication control

EI-8001 adopts RS-232, half-duplex, 9600 baud rate, no parity, and 8 data bits. The communication between the development board PCM-9575 and the inverter is:

PCM-9575->Inverter (command)

2Fh Drv.-No. Cmd. Log-Adr. Data Sum

Inverter->PCM-9575 (answer)

2Fh Drv.-No. Cmd. Log-Adr. Data Sum

Inverter->PCM-9575 (wrong message)

Data 4Eh,6Eh

Drv.-No.

2Fh Sum

The following are the meanings of each block:

2Fh (‘/’) [1 byte]: Heading byte

Drv.-No. [1byte]: When the value of the Drv.-No. matches the internal drive number, the command will execute, the default value is 0

CMD [1 byte]: 52h (‘R’): RAM data read. Reads the important parameters from the inverter.

57h (‘W’): EEPROM/RAM data write. Writes data to both EEPROM and RAM.

50h (‘P’): RAM data write. Writes data to RAM only.

Log.-Adr. [2 bytes]: Logical address DATA [2 bytes]: Data to write SUM [1 byte]: Check sum

The PCM-9575 sends command to the inverter, if the inverter receives the correct command, it returns the answer else it returns wrong message, the data in the wrong message stream is the error code, and the following is the meaning of each error code.

Error code

0000h: can’t execute the command.

0001h: error data (out of range) 0002h: error register address 0004h: Checksum Error No answer: error format

When using the Inverter EI-8001 to drive the motor, there are several important register addresses that provide the useful function. The important register address is shown in table 4.1

The logical address of FA00 is the line command register; the table 4.2 is the communication command word bit structure.

4.2.3 Acceleration time, deceleration time

The range of the acceleration time and the deceleration time is 0.1~3600

sec, its scale factor is 0.1, and the definition is based on the supplying power frequency.

For example:

Power freq. =60 Hz

Acceleration time (t1) =10 s

t1 t (sec)

f (Hz) 60

In this case, the power frequency is 60 Hz, and the setting of the

acceleration time is 10 sec, so increasing the frequency from 0 Hz to 30 Hz will spend 5 sec.

The acceleration time and deceleration time we use in the treadmill is 15.6 second; it can stop the machine from 3.2 km/hr to 0 km/hr in 5 second.

4.2.4 Terminal control v.s serial communication control

Most of treadmills use terminal control, because the program that previously controls the DC motor can be used directly to control the inverter, but the terminal control provides less function than the serial communication control,

and it may restrict the function when programming. So we adopt serial communication control to control the inverter.

4.2.5 The process of start and stop

The process of start and stop is important to the treadmill; the appropriate design will make the user exercise in the safety condition and prevent the occurrence of injury.

Start:

The process of start is shown as follows:

(1) Lower the incline to 0%

(2) Count down 3 second with the warning sound.

Stop:

There are four kinds of stop type, all of which can be described as follows:

Cool down:

This type is used when the user presses the stop button, the standard process is: (1) Lower the incline to 0%. (2) According to the recent speed, if the speed is slower than 3.2 km/hr, then stops the treadmill in 5 sec, else if the speed is faster than 3.2 km/hr, decreasing the speed at the rate of 0.2 km/hr per second until reaching the speed of 3.2 km/hr, in this period, if the user presses the fast button, the treadmill will hold the present speed.

Else if the speed is smaller than 3.2 km/hr, the treadmill will stop in 5 second.

Pause:

This type is used when the user presses the pause button, and the

treadmill will stop according to the deceleration time.

Emergency Stop:

This type is used when the emergency condition occurs, and the treadmill will stop depends on the inertia and the braking ability of the drive.

End of course:

This type occurs when the course or program ends, and the treadmill will stop the same as the Cool Down type.

4.3 The Function of the treadmill

There are many functions in the treadmill, and the rough program flow is shown in Figure 4.2. When the power of the treadmill is on, it gets into the Main layer; the picture of Main is shown in Figure 4.3. We can set the parameters in Data Setting; the picture is shown in Figure 4.4; we can play music in the Music Mode, the picture is shown in Figure 4.5.

4.3.1 Mode of the treadmill

Basic Mode:

This mode is designed for the user who wants to use the basic function of the treadmill, and the user can run or walk at the speed between 0.5 km/hr to 20 km/hr or adjust the incline to climb at the range of 0 % to 15%. At this mode, we can adjust the speed by use of “Fast” and “Slow” button, which can adjust 0.1

km/hr when pressing the button each time. Using “hot key” is another way to adjust the speed quickly, hot key is the button used to adjust the speed quickly, and there are many “hot key” buttons: 2, 4, 6, 8, 10, 12, 14, 16, 18 km/hr. And the “Up”, “Down” button can adjust the incline 1%/press. Figure 4.6 is the picture of Basic Mode.

SET

This mode can be divided into three parts:

(1) Set Time

This mode provides the user to set the desired exercising time; the range of the time setting is between 1 minute to 98 minute, and the adjustment unit is minute. At the end of the count down, the screen will display “End”, and the treadmill will cool down. Figure 4.7 is the picture of Set Time.

(2) Set Distance

This mode provides the user to set the desired exercising distances;

the range of distance setting is between 1 km to 50 km, and the adjustment unit is km. At the end of the count down, the screen will display “End”, and the treadmill will cool down.

(3) Set Calories

This mode provides the users to set the desired consuming calories;

the range of setting is between 40 cal to 990 cal, and the adjustment unit is 10 cal. At the end of the count down, the screen will display “End”, and the treadmill will cool down.

Program

There are three different kinds of programs the users can choose to exercise: Walking, Running, Interval, each course has ten sections, and each

section takes one minute. When the tenth section is through, it returns to the first section and continue the course. The incline is fixed, and the speed can be adjusted by the user. The range of the speed is between 0.5~20 km/hr.

The incline of each course and level can be shown in Table 4.3~Table 4.5.

Figure 4.8 is the figure of Walking Course.

Course

There are four different kinds of courses the user can choose to exercise:

(1) Cardio 20 Min:

There are seven sections in the course, and the first section is the warm up section, and the last section is the cool down section; the second to sixth section is the cardio section. The speed and incline of the first and last section are not open to the user; it will run by the default value. At the cardio section, there also have default values of incline and speed, but the value can be changed by the user. At the end of one cardio section, the value of speed and incline will return to the next section’s default value.

There are three minutes in the warm up section, the speed of the first minute is 3.2 km/hr, and the second minute is 4.0 km/hr, and the third minute is 4.8 km/hr. There are two minutes at the cool down section; the speed slows at the rate of 0.2 kph/ 15 sec until 3.2 km/hr and then stops the treadmill in five second. The Table of cardio course is shown in Table 4.6. The figure 4.9 is the picture of CARDIO 20 Min.

(2) Interval 25 Min:

There are eleven sections in the course, and the first section is the warm up section, and the last section is the cool down section; the second to tenth section is the interval section. The speed and incline of the first

and last section are not open to the user; it will run by the default value.

At the Interval section, there also have default values of incline and speed, but the value can be changed by the user. At the end of one interval section, the value of speed and incline will return to the next section’s default value.

There are three minutes in the warm up section, the speed of the first minute is 3.2 km/hr, and the second minute is 4.0 km/hr, and the third minute is 4.8 km/hr. There are two minutes at the cool down section; the speed slows at the rate of 0.2 kph/ 15 second until 3.2 km/hr and then stops the treadmill in five second. The data of interval course is shown in Table 4.7.

(3) Fat Burn 30 Min:

There are thirteen sections in the course, and the first section is the warm up section, and the last section is the cool down section; the second to twelve section is the Fat Burn section. The speed and incline of the first and last section are not open to the user; it will run by the default value.

At the Fat Burn section, there also have default values of incline and speed, but the value can be changed by the user. At the end of one Fat Burn section, the values of speed and incline will return to the next section’s default value.

There are three minutes in the warm up section, the speed of the first minute is 3.2 km/hr, and the second minute is 4.0 km/hr, and the third minute is 4.8 km/hr. There are two minutes at the cool down section; the speed slows at the rate of 0.2 kph/ 15 second until 3.2 km/hr and then stops the treadmill in five second. The data of Fat Burn course is shown in Table 4.8.

(4) Endurance 35 Min:

There are fifteenth sections in the course, and the first section is the warm up section, and the last section is the cool down section; the second to fourteenth section is the Endurance section. The speed and incline of the first and last section are not open to the user; it will run by the default value. At the Endurance section, there also have default values of incline and speed, but the value can be changed by the user. At the end of one section, the value of speed and incline will return to its default value.

There are three minutes in the warm up section, the speed of the first minute is 3.2 km/hr, and the second minute is 4.0 km/hr, and the third minute is 4.8 km/hr. There are two minutes at the cool down section; the speed slows at the rate of 0.2 kph/ 15 second until 3.2 km/hr and then stops the treadmill in five second. The data of Endurance course is shown in Table 4.9.

Race Mode

In this mode, the user has a contest with an opponent. And there are many racing distance the user can choose: 400m, 800m, 1600m, 3000m, and 5000m. There are three levels the user can choose: Easy, Normal, and Professional. In the different level, the opponent will have different speed.

In the level “Easy”, the opponent has the speed at the range between 3 km/hr~9 km/hr. In the level “Normal”, the opponent has the speed at the range between 6 km/hr~12 km/hr. In the level “Pro.”, the opponent has the speed at the range between 9 km/hr~15 km/hr. In each level, the opponent changes their speed every five second. At the end of the race, the panel will show the racing result. The figure 4.10 is the picture of RACE mode.

4.3.2 The importance of the Warm Up and Cool Down

Warm Up

First several minutes of a workout should be devoted to warm up. The warm up will limber your muscles and prepare them for more strenuous exercise. Warm up on the treadmill by walking at slow speed.

Cool Down

A cool down period allows the heart to readjust to the decreased demand.

Use a slow speed setting during the cool down to gradually the heart rate.

4.4 HTTP communication [14]

HTTP provides a simple and powerful communications mechanism for mobile applications. In cases where large amounts of data need to be transferred or data is more efficiently transferred in binary form (such as MP3s or bitmaps), it may be more efficient to take direct control of the HTTP communications process. This is especially true for mobile applications that are often faced with low bandwidth connectivity or communication billing rates based on the number of megabytes transferred. In these situations, operational performance and costs can be improved by transferring only the core application data.

The .NET Compact Framework provides two HTTP communications classes: HttpWebRequest and HttpWebResponse. Together, these classes provide the necessary functionality to both send an HTTP request (HttpWebRequest) to a web server and receive a response (HttpWebResponse) back from that server.

In the other aspect, if we want to use the download program; we need a

virtual directory on a server running IIS. And from the HTTP communication, we can download the file from the IIS server.

4.5 Play the wave file format [15]

In the treadmill system, we want to play music or sound on the treadmill.

The audio data we want to play is the wave file format, using the P/Invoke to implement the mechanism. The following functions and structure are used to play waveform audio:

waveOutGetNumDevs ( ): Determines the number of audio drivers available for output.

waveOutOpen ( ): Creates an instance of the specified audio device for output.

waveOutGetVolume ( ): Returns the volume of the specified output device.

waveOutSetVolume ( ): Sets the volume of the specified output device.

waveOutPrepareHeader ( ): Prepares a WAVEHDR and data block for output.

waveOutUnprepareHeader ( ): Releases a previously prepared WAVEHDR and data block.

waveOutWrite ( ): Starts playing the queued buffer.

waveOutClose ( ): Closes the specified instance of the audio device.

waveOutReset ( ): Stops playing and empties the queue.

waveOutPause ( ): Pauses playback.

waveOutRestart ( ): Resumes paused playback.

4.5.1 The Wave File Format

The Waveform Audio Interface provides a mechanism for playing and recording raw uncompressed pulse code modulated (PCM) data. The .wav file format consists of some header information followed by the raw data. This format is shown in Figure 4.11.

To reduce memory use, we can first specify a buffer size. And the audio file will be streamed using two audio buffers, each being half of the specified total size. The streaming mechanism is maintained by loading one buffer while the other plays. Therefore it is important to always have a second buffer queued before the first ends. The Figure 4.12 briefly describes the method.

The application must then wait for a message from the audio system indicating that an audio block has finished, at which point it will determine what to do next. If the audio block is the last one then playback is stopped and resources are cleaned up, otherwise, the buffer is reused to load the next block while the other buffer is playing.

The general process for creating an instance of WaveOut and playing the .wav file is as follows:

(6) Write the headers to the audio device (put them in the queue for playback)

4.6 GDI

Due to the resource constraints, there is no full GDI support in the .NET Compact Framework. The services of GDI fall into the following three broad categories:

(1) 2-D vector graphics (2) Imaging

(3) Typography

Of the 2-D Vector Graphics in the .NET Compact Framework, only the core drawing primitives like Ellipse, Line, Image, Polygon, Rectangle, String, Fill Ellipse, Fill Polygon, Fill Rectangle, and Fill Region are supported by the Graphics object.

In the user interface of the treadmill, we use the technique to draw the playground and the incline graph and make the image buttons [16] to implement the graphic.

Chapter 5 Conclusion

From the implementation of the treadmill, we may do some improvement compared to the traditional treadmill such as user interface and the play of the audio sound and the connection to the internet. It’s the advantage of using embedded system as the electric control system, but there are still some functions that haven’t implement yet. Such as saving the files of some parameters in the memory, and the interface of Emergency Stop; in the traditional treadmill, the interface of Emergency Stop is done by hardware. But in our treadmill, we implement it by the software emulation. It’s not a safety way by doing so. And the measurement of the Heart Rate is another function that we should implement.

In the other aspect, the use of the embedded OS, WinCE.NET has some topics for discussion: The embedded system is used for the specified purpose, and the hardware is differ from each other according to the manufacturer, so the driver for the hardware may not open to the public, and it may increases the cost.

Building the WinCE.NET OS needs the driver. We should take this into consideration.

In the aspect of playing music, the format we use now is the PCM data, and it is uncompressed format. It takes much memory space, and it is improper to the embedded system; it can be improved by using the compressed format. In the aspect of drawing the playground and incline graphic, we use the basic geometric graph to form the drawing; it’s better than the traditional LED display but still can be improving.

Reference

[1]ANTHONY J.PANSINI,”Basics of Electric Motors”, PRENTICE HALL, 1989.

[2]Denis O’Kelly, “Performance and control of Electrical Machines”, McGraw-Hill, 1991.

[3]P.C. Sen, “Principles of Electric Machines and Power Electronics”, John Wiley & Sons, 1997.

[4]劉昌煥,"電機機械 ", 東華,民國 91 年.

[5]劉昌煥,"交流電機控制-向量控制與直接轉矩控制原理",東華,民國

[5]劉昌煥,"交流電機控制-向量控制與直接轉矩控制原理",東華,民國

相關文件