当前位置:文档之家› Purposeful mobility for relaying and surveillance in mobile ad hoc sensor networks

Purposeful mobility for relaying and surveillance in mobile ad hoc sensor networks

Purposeful mobility for relaying and surveillance in mobile ad hoc sensor networks
Purposeful mobility for relaying and surveillance in mobile ad hoc sensor networks

Purposeful mobility for relaying and surveillance in mobile

ad-hoc sensor networks

R.Rao and G.Kesidis??

October30,2004

Abstract

In this paper,we consider a mobile ad-hoc sensor network.The mobility of the sensor nodes is designed with the cost of communication and mobility in mind along with consid-

eration of the possible scanning tasks of the nodes.Our mobility algorithm is developed

in the context of a distributed system where,for any single mobile node,only local infor-

mation about associated energy costs is known.We use a distributed simulated annealing

framework to govern the motion of the nodes and prove that,in a limiting sense,a global

objective function comprising mobility and communication energy costs will be minimized.

This paper concludes with a simulation study focusing on mobile sensors with dual roles of

scanning and relaying higher priority tracking tra?c from tracking nodes.

keywords:sensor networks,MANET,mobility strategy,communication,Energy-aware

systems

1Introduction

Traditional mobile ad hoc networks(MANETs)typically treat node mobility as an uncontrolled factor.In sensor MANETs,the nodes have a communal surveillance(tracking/scanning)mission and mobility in some cases can be designed to help achieve the mission.In addition,mobility can be used to provide logistical support by,for example,facilitating network connectivity and achieving better communication,in general,between the sensors and data repository(cache or larger database)or,in a real-time setting,the command-and-control entities of the network. Also,node mobility makes the network more robust against node failure events.

We consider the real-time,command-and-control context of a sensor MANET deployed in battle?eld environment to perform surveillance tasks.Each node is a robot carrying one or more sensors.These sensors collect information and transmit it to a data sink:base-station(satellite up-link)or command-and-control center.The nodes are required to track any hostile targets they sense,perform local scans(explore local surrounding that are not covered by any other nodes) and forward data from neighboring nodes towards the base station.

The speci?c goal of communal-mission-oriented(i.e.,“purposeful”)mobility is to decide where

2

to move a node so that it can perform any one or all the tasks better.We assume that a node at any given time can be a tracking node or a scanning node.The data generated by the tracking nodes is considered latency-critical since we are looking to provide detailed information on tracked targets in real time.The scanning node generates lower volume,non-latency-critical data about its local surroundings.The scanning node also relays tra?c,i.e.it forwards,in particular,latency-critical data towards the base station node.Other kinds of communication are possible in such a sensor MANET including that required for coordination of target tracking and overhead for communication route establishment and maintenance.In the somewhat more simpli?ed setting of this paper,we target a single network“time-scale”and focus on scanning nodes moving to scan a new area and/or reduce the total transmission power used by the network for high-priority tracking tra?c.We are interested in distributed mobility algorithms relying only on information local to the node.

For terrestrial vehicles(nodes),the cost of mobility may be high depending on their weight and on the environmental conditions(terrain).If we consider unmanned aerial vehicles(UAVs), there is a roughly?xed power cost to keep the UAV airborne.The power cost of motion for scanning and relaying(the focus of this paper)would the additional cost needed to maneuver the UAV in the necessary directions.This cost may be relatively low compared to that required to keep the UAV airborne.For unmanned underwater vehicles(UUVs),the cost of motion may be signi?cantly lower than that of terrestrial vehicles in certain environments.If there is a?xed power cost for necessary mobility,we can include it together with that of computation and communication-reception under one?xed costπ.The available energy of a node at any time

3

t>0will then be

E t=E0?πt?M t?C t

where M t is the cumulative energy required for additional motion and C t is the cumulative energy required for communication-transmission.

Two cases are considered in this paper both assuming statically positioned tracking nodes generating latency critical data that is forwarded by mobile“intermediate”nodes to the single data sink.In the?rst case,the intermediate nodes only relay the tracking information to the sink.The intermediate nodes move so that the total transmission power is reduced.For example if a node is relaying a large volume of data between two nodes,it will obviously save energy in transmission if it is closer to them.The cost of motion to a chosen location will be amortized against the savings in communication energy at that location as predicted by the node(again, using only local information).To this optimization problem,we can apply a greedy approach to select the optimum position of nodes.This may result in a optimal solution locally,but could potentially give rise to sub-optimal placement globally.To prevent this,we employ simulated annealing wherein a node,with a positive probability,accepts a“bad move”locally because the move could bene?t the network globally in the longer run.This is explained in greater detail in Section3.Note how the use of“randomized”motion is,at least in part,motivated by the distributed nature of the problem we have formulated.Alternative motivations for random motion of sensor nodes were articulated in[8].

In the second case,the intermediate nodes are assigned both scanning and relaying tasks.To reiterate,we assume that data volume generated by intermediate nodes is of lower priority and of

4

negligible volume compared to the data from the tracking nodes.The goal here is to?nd optimal node paths to conserve power and to cover areas not explored by any nodes.An intermediate node could move either to save communication energy or to perform local scans.This mobility strategy is explained in greater detail in Section4.

The remainder of the paper is organized as follows.A survey of related literature is given in Section2.In Section5,our simulation study is described.The paper concludes with a summary and discussion of future work in Section6.

2Related Work

Issues of surveillance coverage and communication connectivity for random static positioning of sensors were explored in[5]and,more recently,in[13].In[13],the nodes are active with certain probability with a given sensing and communication radius.They have derived results to prove connectivity and coverage is maintained even if the probability of a node being active and communication radius are low.This may give the communication radius for coverage and connectivity but only for a static network.It is not possible to extend this framework to include mobility as the nodes are assumed to be uniformly arranged.

Clearly,a basic motivation of node mobility is that the nodes are not deployed with su?cient density in the region under surveillance to make mobility of the nodes unnecessary.In this paper, we assume that the sensors deployed are somewhat sophisticated and costly so that very dense deployment is infeasible.

In[11],the e?ect of mobility on a position detection algorithm was considered.They suggested

5

the use of hop-counts from reference nodes to?nd relative positions of all nodes.Nodes are moved to neighborhoods where accurate information is not available.Mobility helps to increase accuracy of information regarding node positions but does not help to?nd best position for coverage or connectivity.

Flocking properties of platoons of UAVs were studied in[14].Speci?cally,they explored local mobility laws that keep formation(velocity and heading).

In[8],the authors evaluate the distribution of the time until detection of a point-target under purely random(di?usion)mobility per node.Given an associated Bessel process describing the distance between any two given nodes,there also exist expressions for the distribution of the time between successive contact of any two nodes assuming each of their communication ranges is bounded,see p.297of[1].

In[10],the authors look at navigating across a vehicle across a sensor grid.The nodes in the sensor interacts with the vehicle giving it local information about the terrain.The vehicle then decides where to move next.

In[16],the authors consider a scenario where mobility assists the nodes in sensor deployment. The goal is to maximize coverage while not compromising connectivity by intuitively enacting local repulsion of nodes(to minimize redundancy of coverage)along with long-range attraction of nodes so as not to compromise network connectivity.[17]and[6]also consider virtual forces between the nodes for sensor deployment.Again,the mobility assists only in the deployment of a static network.

Finally,simulated annealing mechanisms have been proposed in the past for other networking

6

purposes.For example,in[15],a(centralized)simulated annealing algorithm was used for clusterhead selection based on weights assigned to nodes.

3Deterministic and random mobility for relay network-ing

In this section we assume a single task per node.For example,in response to target detection, certain nodes(proximal to the target)are assigned logistical target-tracking tasks while others are assigned tasks supporting communication.We focus herein on mobility for the latter category of nodes and,for those nodes,state that a goal of node mobility is to maximize the life-time of the MANET and,at the same time,perform the required relaying tasks satisfactorily.Our speci?c objective is to incrementally?nd the node positions that minimize the total required transmission power for all the active?ows in the MANET while suitably“penalizing”for the energy cost of motion in order to?nd these positions.

For a node to move from one position to another,there must be a signi?cant resulting reduc-tion in communication power compared to the power consumed for motion.This would vary signi?cantly depending on the environment of the moving vehicle operates in.For example,the relative cost for UAVs will be signi?cantly less than UUVs which will be signi?cantly less that terrestrial vehicles.In the following,we assume that nodes make such decisions based only on local information(tra?c and neighbor positions)as appropriate for a highly decentralized and distributed sensor MANET.We will devise a distributed mobility strategy based on the simu-

7

lated annealing algorithm,see,e.g.,[9].The randomness introduced in the strategy will allow the sensor MANET to avoid positions that are suboptimal local minima of its objective.

3.1Basic network model assumptions and a“greedy”mobility strat-

egy

We need to de?ne the following terms for our problem formulation:

?N is the number of intermediate relay nodes;

?F is the number of?ows each of constant rateλpackets/s(?xed length packets assumed herein);

?x is a vector of the positions of the intermediate relay nodes(so,in3-dimensions,x is actually an N×3matrix);

?r is the set of F routes(each assigned to one?ow)where a route through the network is determined by a series of nodes beginning with a source and ending with a data sink;

?V(x,r)is the total power required from the network to transmit the F?ows using routes r when the intermediate nodes are in positions x;the optimal choice of routes at position x is

R(x)≡arg min

V(x,r)

r∈R(x)

where R(x)is the set of feasible routes connecting those nodes when in positions x.

8

The quantity R(x)is the objective of a distributed routing algorithm(like Bellman-Ford[2]) and its determination is assumed to occur on a much faster time-scale than that of the mobility of the nodes.Further assume that all nodes have an associated clock cycling every T seconds (clocks are not necessarily synchronized).Once every cycle,a node decides with probability p whether it should attempt to move.Under a deterministic“greedy”mobility strategy,node k at position x k will move to position z that minimizes

V((x?k;z),R(x))?V(x,R(x))+c|z?x k|/T(1)

≡?k V(x,z)+c|z?x k|/T

where(x?k;z)represents the vector x with x k replaced by z,and c|z?x k|represents the amount of energy required for the move that we have chosen to amortize over a clock cycle-time(c is a ?xed parameter of the assumed“constant”terrain).Movement according to(1)may be velocity v constrained,i.e.,

|z?x k|≤vT.

For a simple illustrative example,consider a relay node k that forwards two?ows from its tributary nodes i and j to node l.Suppose that the power required to transmit over distance d(again,at rateλpackets/s)is given by KdαWatts where K is a constant andα≥2is a transmission attenuation factor[4].So,for this example,

?k V(x,z)=K[|z?x i|α+|z?x j|α+2|z?x l|α

?|x k?x i|α?|x k?x j|α?2|x k?x l|α].(2)

9

A basic assumption herein is that the quantity in(1)is computable by node k requiring,in par-ticular,knowledge of the location of its neighbors[12].Note that what makes this“distributed”computation of?k V(x,z)is the fact that V is an additive function of the transmission power required at each node.The existing routes(at x)are used in the term V((x?k;z),R(x))because, in this distributed setting,the node k does not know the consequences its move will have on the routes.When multiple nodes can move simultaneously,the uncertainty in the bene?t of a move is signi?cantly larger;to reduce the likelihood of this,one may set p=1/N for this case of static sources and sinks.

3.2Mobility by distributed annealing

This greedy method may converge to a“suboptimal”solution because:V(x,R(x))may have local minima;simultaneous motion of multiple nodes;and/or suboptimal local movement,i.e.,

?k V(x,z)+c|z?x k|/T≥

min

z

min

V((x?k;z),R((x?k;z)))

z

?V(x,R(x))+c|z?x k|/T.

So,we propose a randomized motion on a lattice resulting in a kind of distributed simulated annealing algorithm.Motion is restricted to a lattice and a node k(currently at x k)selects a neighboring position z at random and accepts the move to z according to a“heat bath”probability(c.f.,(5)).Many other kinds of motion randomization could be used[8]but we chose annealing on a lattice because it is tractable in the following sense:Assuming no simultaneous

10

motion of nodes,we show in the following theorem that limit of this annealing motion tends to the(assumed unique)state x that minimizes

U(x)≡V(x,R(x))+cT?1

N

k=1

|x k|(3)

≡V(x,R(x))+cT?1||x||.(4) In this function,we clearly see the total cost of transmission power combined with the amortized cost of motion to positions x from the origin over a constant terrain.

Consider the framework of,e.g.,[9]with potential function(Hamiltonian)U(x)given by(3) over all states x∈D where D is a lattice.We can de?ne a time-reversible discrete-time annealing Markov chain on D with associated transition-probability matrix(TPM)P and stationary distri-butionπ.More speci?cally,consider an aperiodic,irreducible and time-reversible Markov chain with TPM Q and stationary distributionμ,i.e.,detailed balance holds:μx Q x,y=μy Q y,x for all states x,y∈D and Q x,y>0implies that x and y are neighboring points in D,e.g.,y=(x?k,z) for some k and z as above.De?ne the annealing chain using the heat bath acceptance probability rule:for states x=y,

P x,y≡Q x,y min{1,exp(?β(U(y)?U(x)))}

whereβ>0is interpreted as inverse temperature and,for our purposes herein,a constant.So, the TPM P inherits aperiodicity and irreducibility from Q.The TPM is also time-reversible with Gibbs stationary distribution:

πx=

μx e?βU(x)

where Zβis the normalizing constant(partition function).

Now de?ne a TPM for the distributed annealing process:

?P

x,y

≡Q x,y min{1,

exp(?β[V(y,R(x))?V(x,R(x))

+c||y?x||/T])}.(5) The TPM?P continues to be irreducible and aperiodic,thereby yielding a unique stationary distribution?π[3],but is no longer time-reversible.

Lemma1P x,y≥?P x,y for all x=y,and P x,x≤?P x,x for all x.

Proof:By the de?nition of R and the triangle inequality,

V(y,R(x))?V(x,R(x))+c||y?x||/T

≥V(y,R(y))+c||y||/T?[V(x,R(x))+c||x||/T]

=U(y)?U(x).

The?rst statement of the lemma directly follows from the de?nitions of P and?P.The second statement is an immediate corollary of the?rst because both P and?P are row-stochastic matrices. Now,sinceπis Gibbs,

lim β→∞πx(β)=0for all x∈?≡arg min

x∈D

U(x)(6)

12

where we have explicitly shown the dependence ofπonβ(β→∞is interpreted as“cool-ing”).The following result states that the distributed annealing chain,?P,also has a stationary distribution with this“Gibbs like”property.

Theorem1If?is a singleton set,i.e.,?≡{x?},then

?π(β)=1x?

lim

β→∞

where1x?

=0if y=x?and1x?x?=1.

y

Proof:First note that

[(1x?)′?P(β)]y=?P x?,y(β).

If y=x?then by Lemma1,

?P

(β)≤P x?,y(β)→0asβ→∞.

x?,y

Otherwise,if y=x?then again by Lemma1,

?P

x?,x?(β)≥P x?,x?(β)→1asβ→∞.

Therefore,

(1x?)′?P(β)=(1x?)′.(7)

lim

β→∞

Now recall that?π(β)is the unique solution to

?π(β)′(I??P(β))=0

and?π(β)′1D=1

13

where1D is a vector all of whose entries are1.Let?V(β)be the matrix obtained by replacing a column of I??P(β),say column n,by1D.Thus?π(β)is the unique solution to

?π(β)′?V(β)=(1n)′.

Uniqueness implies that the null space of?V(β)must be just the zero vector;this,in turn,implies that?V(β)is nonsingular giving,for allβ>0:

?π(β)′=(1n)′[?V(β)]?1.

Beginning with(7)and using the same argument,

(1n)′[?V(β)]?1=(1x?)′.

lim

β→∞

The theorem statement follows from the last two equations.

A straight-forward extension to this theorem(using condition(6))follows for optimal sets?in which no two states are directly connected by the TPM Q.

In summary,we have demonstrated that randomized annealing motion of the sensor nodes, distributed in the sense that only local information is used,nevertheless retains a Gibbs-like property,i.e.,a natural composite utility of communication and mobility costs(3)is minimized as the temperatureβ?1cools.

14

4Dual tasking:scanning and relaying

In this section we look at combining the two tasks of scanning and relaying for the intermediate nodes in greater detail.The goal of the scanning task is to move to a location in the surveillance area not visited before or not visited by a scanning node in a long time.To quantify this,we partition the surveillance area with a grid.A node selects a“scanning move”with probability p s and“relaying move”with probability p r=p?p s where0

A simple method of scanning involves maintenance of a“taboo list”of,say,the last10points visited by the node.When considering a scanning move,points on the taboo list are excluded and the remaining choices are chosen uniformly at random.Alternatively,the taboo list can also maintain the time of the last visit so that the list could be implemented as a sliding time-window. For both of the approaches above,the taboo lists or lists of time-stamps can be exchanged by neighboring nodes and merged to create a more up-to-date table(at each node),where we note that the latter will require some kind of time time-synchronization among the nodes.

5Simulation Study

We considered a MANET with seven nodes,including four mobile relays,operating within a 40m×40m square area(for the following simulations,the units of distance can be scaled-up by suitable modi?cation of the following mobility and communication parameters).We assumed there are two stationary(immobile)source(tracking)nodes and a single stationary data-sink (base station)node.Source nodes generated data at a constant bit rate of100kbps with50-byte

15

packets.

We chose the following communication and mobility parameters for our simulation study.The relative motion constant c of the global utility function(3)was assumed to be determined by the?gure50mJ/m;i.e.,a node weighing1kg required about5mJ to move a distance of0.1m. The value of the parameter K from Equation(2),determining communication power required to transmit a packet over a distance of1m,was assumed to be1mW.Also for this equation, the communication attenuation parameter was assumed to beα=2.5.Finally,the intermediate nodes involved in forwarding tra?c from sources to sink made a movement decision every T=10 seconds.

Initially,the positions x(0)of the nodes are chosen independently and uniformly at random in the area under consideration.In the simulation,we also assume all active relay nodes move at all times,i.e.,p=1instead of p=1/N as advised in the end of section3.1.

A transmission power-based(distributed Bellman-Ford with dαas metric)routing algorithm was assumed to be in e?ect determining the routes R(x)at node-positions x(again,assumed to operate at a time-scale much faster than that of node movement,T).As we are using power based routing algorithm,we assume nodes can communicate with all nodes in the given region.

A node wishing to communicate with a farther node can do so by increasing its transmission power.

Finally,from each set of simulation trials we determined an empirical mean and95%con?dence interval;in the following graphs,the con?dence interval is indicated by a vertical bar centered at the mean.

16

5.1Single task per node

In this set of simulations,we assumed that the intermediate nodes have a single task,i.e.,that of relaying source-node tracking-data transmissions to the sink-node.That is,the relay nodes did not generate any scanning data of their own.

Figure1:Total transmission power over time for di?erent?xedβ

In Figure1we plot the total transmission power of the network over time for di?erent values of theβparameter in the annealing algorithm(i.e.,the inverse temperature).Note thatβwas a ?xed constant for each simulation run.Asβincreased(temperature decreased or cooled),note that the variance in total transmission power decreased.For lower values ofβ,the nodes accepted “bad”moves with higher probability,hence the higher variance in total transmission power.The increased variance at the beginning of each set of simulation trials was due to the randomly chosen initial positions for each simulation run.This variance reduces as the nodes move closer to the optimal position.Since we average over di?erent initial positions,the reduction in total transmission power might not appear signi?cant.But for cases where nodes have a bad initial position,we observed a reduction in total transmission power by as much as a factor of3.Theβ

17

value also controls the rate of convergence.For largerβ,the nodes move to an optimal position more quickly.We note this di?erence in the total transmission plot forβ=50andβ=500. Forβ=50the total transmission power reaches the optimal value after700s and continues to change around the optimal value.Forβ=500,the total transmission power reaches the optimal value after450s and remains relatively unaltered.

Figure2:Total transmission power whenβincreased dynamically(cooling)

In Figure2,we“cooled”the temperature during each simulation run in order to trap the nodes into optimal positions from the perspective of communication power.More speci?cally, every10s,βwas increased in increments of20from an initial value of200.As theβincreases, the variance in the transmission power predictably decreased.Such a cooling schedule makes sense in the context of constant bit-rate and stationary source nodes,stationary data sinks,and with no scanning motion,but would not make sense in a more dynamic networking environment, c.f.,Sections5.2and6.

Figure3shows the initial and?nal position of the intermediate nodes of a representative sample path of a single simulation run.Note how the relay nodes have basically formed a line

18

Figure3:Inital and?nal node positions

between the sources and sink to reduce transmission distance.

Figure4:Mobility and transmission energy

Figure4shows the transmission energy saved compared to the energy spent in moving from the initial node-positions,for di?erent values ofβ.The energy saved in transmission was on the order of a few tens of Joules while the energy spent in moving the nodes was of the order of few hundred mJ clearly demonstrating the worth of mobility in the context of our selected parameters.

For largeβ,mobility is typically restricted to moves that deterministically reduce transmission

19

energy.The result is both a reduction of transmission energy and a small amount of energy is spent on mobility,but poor local minimas may occur.Under the annealing policy,as the value of βdecreases,the nodes have greater freedom to move.This ultimately reduces the energy saved in transmisson because poor local minima are avoided as the nodes make more“bad”moves to better explore the space of relay node-positions(i.e.,a greater breadth of search).

5.2Dual tasking per node

In this set of simulations,we assumed that the intermediate nodes had both a scanning and relaying function,as described in Section4.The simple method involving a taboo list of the last10points visited by the node was simulated.Taboo lists of neighboring nodes were not exchanged.Finally,we assumed that the transmission energy for scanning(passive surveillance) tra?c was negligible compared to that of the tracking tra?c and the former was not accounted for.

Figure5:Total transmission power over time

For two values of the scanning-decision probability parameter,p s∈{0.4,0.6},the commu-

20

表情符号大全

表情符号大全 ?new news?new news? ???????????● ?●?????????????????♂♀????????⊙◎?????????????????????◇?????の★☆→あぃ£Ю〓§???¤????????≈???.. ..????? ???????? ~.~??-????【】┱┲?????????????????????????????????★☆??⊙????????╬『』∴? .??????????☆∷﹌の★◎??????

??????↘??▄█▌????????????????の☆→ ?ぃ£?????????????????????????????????????????????????????????????????????????????????????*????????????????????????o(?\'\'\'?)o?べò????????????べ?????????:基本符号?.1 ⊙●○①⊕◎Θ⊙¤㊣★☆♀◆◇◣◢◥▲▼△▽⊿◤◥?.2▆▇█ █ ■ ▓ 回□ 〓≡ ╝╚╔

╗╬ ═ ╓ ╩ ┠┨┯┷┏?.3┓┗┛┳⊥『』┌ ┐└ ┘∟「」↑↓→←↘↙♀♂┇┅﹉﹊﹍﹎╭?.4╮╰╯*^_^* ^*^ ^-^ ^_^ ^(^ ∵∴‖||︴﹏﹋﹌()〔〕?.5【】〖〗@:!/ " _ < > `,·。≈{}~ ~() _ -『』√ $ @ * & # ※?.6卐々∞Ψ ∪∩∈∏ の℡ぁ§∮”〃ミ灬ξ№∑⌒ξζω*?.7.·°∴☆..·°?Yesterday ?.·°?.8?KicaZ宝贝o(╥﹏╥)o ??じ☆ve 【??????】*°^_^.......???.9 ┢┦aΡpy ?^_^??????ぜ长ヤ乷?????Cool Friends??????.10【】—一▄【┻┳═一▄【┳一▄【┻═┳一▄【┳-一?.11 ▄【┻═

延时子程序计算方法

学习MCS-51单片机,如果用软件延时实现时钟,会接触到如下形式的延时子程序:delay:mov R5,#data1 d1:mov R6,#data2 d2:mov R7,#data3 d3:djnz R7,d3 djnz R6,d2 djnz R5,d1 Ret 其精确延时时间公式:t=(2*R5*R6*R7+3*R5*R6+3*R5+3)*T (“*”表示乘法,T表示一个机器周期的时间)近似延时时间公式:t=2*R5*R6*R7 *T 假如data1,data2,data3分别为50,40,248,并假定单片机晶振为12M,一个机器周期为10-6S,则10分钟后,时钟超前量超过1.11秒,24小时后时钟超前159.876秒(约2分40秒)。这都是data1,data2,data3三个数字造成的,精度比较差,建议C描述。

上表中e=-1的行(共11行)满足(2*R5*R6*R7+3*R5*R6+3*R5+3)=999,999 e=1的行(共2行)满足(2*R5*R6*R7+3*R5*R6+3*R5+3)=1,000,001 假如单片机晶振为12M,一个机器周期为10-6S,若要得到精确的延时一秒的子程序,则可以在之程序的Ret返回指令之前加一个机器周期为1的指令(比如nop指令), data1,data2,data3选择e=-1的行。比如选择第一个e=-1行,则精确的延时一秒的子程序可以写成: delay:mov R5,#167 d1:mov R6,#171 d2:mov R7,#16 d3:djnz R7,d3 djnz R6,d2

djnz R5,d1 nop ;注意不要遗漏这一句 Ret 附: #include"iostReam.h" #include"math.h" int x=1,y=1,z=1,a,b,c,d,e(999989),f(0),g(0),i,j,k; void main() { foR(i=1;i<255;i++) { foR(j=1;j<255;j++) { foR(k=1;k<255;k++) { d=x*y*z*2+3*x*y+3*x+3-1000000; if(d==-1) { e=d;a=x;b=y;c=z; f++; cout<<"e="<

批处理命令行for语句

for语句可以在命令行提示符中使用,也可以在批处理文件中使用。这两种情况下唯一的区别是%和%%,参加下文说明。 一、for语句的格式: for [参数] 变量in (集合) do 命令[命令的参数] 二、for语句的作用:对集合内的元素逐一执行后面的命令。 1、如:for %%i in (你好) do echo %%i 将在屏幕上显示“你好”2个字。这里集合是“你好”,执行的命令是“echo”。由于集合中只有1个元素,因此循环只运行一次。 如果改成for %%i in (你好朋友) do echo %%i 将会显示2行文字,第一行为“你好”,第二行为“朋友”。因为2个词之间有空格,因此集合中就有了2个元素,循环将运行2次。 2、注意:以上for语句的运行方式是新建一个批处理文件,即扩展名为“.bat”的文件,内容为上面的命令,然后运行。为了批处理执行完不退出,可在最后加上一条pause>null命令,这样能看到执行的结果。要想通过cmd命令行执行的话,必须将%%换成%,即去掉一个%,如下: for %i in (你好) do echo %i 3、以下所有例子都是这样,若要在命令行提示符下执行,请将所有的%%改成一个%。 三、for语句详细说明: 上面语句格式中有的加了中括号[],表示这个语句元素不是必须的,只在需要时使用。像刚才显示“你好”的命令中就没有使用[参数]这

个语句元素。所有语句元素间用空格隔开。 各语句元素的写法:for、in、do这3个符号是固定不变的 1、[参数]的种类:只有4种,分别是/d、/r、/l、/f(即目录Directory、递归recursion、序列list、文件file),他们用于对后面的集合的含义做出解释,请与下面的集合解释结合来看。这4个参数不区分大小写,可以联合使用,即一条for语句可以出现多个参数。 2、变量:除10个数字外(0-9)的所有符号(因为0-9往往作为形参使用,为了与此区别),变量名一般用单个字母表示即可,而且变量名区分大小写,即A和a是两个不同的变量。变量名前面必须是%,当在命令提示符下执行时,只用一个%;而在批处理程序中,必须用%%。 一行语句中,一般只需定义一个变量。使用/f参数中的tokens 选项可以将集合中的元素分解成多个值,并自动定义新的变量对应这些值。这时语句中可以使用多个变量,通常按字母顺序命名,即第一个是%%a,那么后一个就用%%b。如果第一个是%%i,后一个就用%%j。依此类推。具体看后面的相关内容。 变量可以直接在do后面的命令中使用。每次使用的变量总数不超过52个。 3、集合:集合必须放在括号里。集合是一行文本,这行文本可能有几种类型,如“你好”只是一串字符;“c:\boot.ini”是一个文件;“dir /b”是一个命令。 (1)如果for语句中没有使用任何参数,对待集合文本的处理方式是:

批处理命令for语句基本用法

批处理命令for语句的基本用法 [系列教程]批处理for语句从入门到精通[20101225更新] ____________________________版主提醒 ____________________________ 文档来自于网络搜索 为了避免影响技术讨论、提高看帖的舒适性,请大家不要在此帖下跟 无实质内容的口水帖,特别是纯顶、纯支持、纯感谢、路过之类的帖子, 管理人员将不定期清理此类回帖,请大家多参与讨论少灌水,与人方便, 终将给自己带来方便,谢谢合作。 ________________________________________________________________ 文档来自于网络搜索 批处理是一门简单的脚本语言,虽然不能独当一面,但是,若作为工作中的辅助工具,绝对会让大家有随用随写、称心如意的畅快感。 文档来自于网络搜索 和其他语言相比,批处理语言有其先天性的优势: 1、系统自带,无需另行安装; 2、命令少,语句简洁,上手非常快; 3、编写出来的脚本小巧玲珑,随写随用; 但是,因为它以命令行方式工作,操作多有不便,在图形界面大行其道的windows世界里,多多少少会让大众望而却步;就算是对命令行有好感的新手,面对微软有如天书的帮助文件,很多人也会败下阵来,因此,论坛里很多会员也发出了编写系统的批处理教程的呼声。

文档来自于网络搜索 编写系统的批处理新手教程,一直是论坛管理层讨论的热点问题,但是,各位管理人员大多都有工作在身,而系统的教程涉及的面是如此之广,面对如此浩大的工程,仅凭一两个人的力量,是难以做好的,因此,本人退而求其次,此次发布的教程,以专题的形式编写,日后人手渐多之后,再考虑组织人力编写全面的教程。 文档来自于网络搜索之所以选择最难的for,一是觉得for最为强大,是大多数人最希望掌握的;二是若写其他命令教程,如果没有for的基础,展开来讲解会无从下手;三是for也是批处理中最复杂最难掌握的语句,把它攻克了,批处理的学习将会一片坦途。 文档来自于网络搜索 这次的for语句系列教程,打算按照for语句的5种句式逐一展开,在讲解for/f的时候,会穿插讲解批处理中一个最为关键、也是新手最容易犯错的概念:变量延迟,大纲如下: 文档来自于网络搜索一前言 二for语句的基本用法 三for /f(含变量延迟) 四for /r 五for /d 六for /l 遵照yibantiaokuan的建议,在顶楼放出此教程的txt版本、word版本和pdf版本,以方便那些离线浏览的会员。 文档来自于网络搜索[本帖最后由namejm于2010-12-26 02:36编辑]

表情符号,~~~非常有用网络常用表情符号大集合哦~~~

全形顏文字 得意<( ̄︶ ̄)> 乾杯[]~( ̄▽ ̄)~*滿足( ̄ˇ ̄) 沒睡醒( ̄﹏ ̄) 狡猾(‵﹏′) 被打一巴掌( ̄ε(# ̄)無言( ̄. ̄) 無奈╮( ̄▽ ̄)╭ 裝傻( ̄▽ ̄)~* 驚訝(⊙?⊙) 發現( ̄. ̄)+ 驚嚇Σ( ° ?°|||)︴冷( ̄▽ ̄)" 沒辦法╮(╯▽╰)╭貓咪臉(= ̄ω ̄=) 疑惑( ̄3 ̄)a 阿達( ̄0  ̄)y 重創(。_。) 不(>﹏<) 懷疑(→_→) 睏( ̄o ̄) . z Z 崇拜m( __ )m 我想想(ˇ?ˇ)

生氣<( ̄﹌ ̄)> 就是你<( ̄﹌ ̄)@m Orz 挫折系列顏文字 這是經典... 大頭Orz 小頭orz 翹XXXXX Or2 放大版○| ̄|_ 雙手撐地ORZ 有表情囧rz 變化形OTL 換邊STO 換邊(小) _no 動物顏文字豬頭( ˉ(∞)ˉ ) 蝸牛"\@ 章魚(:?)≡ 蟑螂((( ●< 毛毛蟲(??)nnn 蝌蚪(: )~ 顏文字組合 使用時可加( ) 例:˙﹏˙ →(˙﹏˙) ˙?˙˙0˙˙︿˙˙ε˙˙ 3˙˙ω˙˙﹏˙˙?˙˙▽˙小眼睛

⊙?⊙⊙0⊙⊙︿⊙ ̄ε ̄ ̄3 ̄⊙ω⊙⊙﹏⊙⊙?⊙⊙▽⊙大眼睛  ̄? ̄ ̄0 ̄ ̄︿ ̄ ̄ε ̄ ̄3 ̄ ̄ω ̄ ̄﹏ ̄ ̄? ̄ ̄▽ ̄瞇瞇眼 ∩?∩∩0∩∩︿∩∩ε∩∩3∩∩ω∩∩﹏∩∩?∩∩▽∩微笑眼 ∪?∪∪0∪∪︿∪∪ε∪∪3∪∪ω∪∪﹏∪∪?∪∪▽∪悲傷眼 ˋ?ˊˋ0ˊˋ︿ˊˋεˊˋ3ˊˋωˊˋ﹏ˊˋ?ˊˋ▽ˊ生氣眼 >?<>0<>︿<>ε<>3<>ω<>﹏<>?<>▽<緊閉眼ˇ?ˇˇ0ˇˇ︿ˇˇεˇˇ 3ˇˇωˇˇ﹏ˇˇ?ˇˇ▽ˇ不爽眼 ╯?╰╯0╰╯︿╰╯ε╰╯3╰╯ω╰╯﹏╰╯?╰╯▽╰無奈眼 ≧?≦≧0≦≧︿≦≧ε≦≧3≦≧ω≦≧﹏≦≧?≦≧▽≦嬉皮眼 ????0??︿??ε??3??ω??﹏??△??▽?鬥雞眼 ????0??︿??ε??3??ω??﹏??△??▽?金魚眼 ●?●●0●●︿●●ε●● 3●●ω●●﹏●●?●●▽●外星人 +?++0++︿++ε++3++ω++﹏++?++▽+小丑眼 日系顏文字精選 (????)(??`ω′?)(?(?)?)(σ`?д?)σ(o?ω?o) 小眼睛 (???)(???*)(p?_q)(〃?o?〃)(*^?_?) (。???。) (*?0?)(?ε?●)(??ω?)(。?д?。)(???)(/??、)(?□?、*)(?-?。) (?▽?。)(?_?。) (?O?。)(ノ??。)(@???)(*??*)人(?ε?;) (?o ?)(?ェ?o)(′???『) 瞇瞇眼 (*  ̄ー ̄)( ̄ー ̄〃)(@ ̄ー ̄@)(*  ̄︿ ̄)(* ̄? ̄*)<(??*)> ( ̄(●●) ̄)( ̄?? ̄)(ー?ー)( ̄o ̄)( ̄、 ̄)(* ̄? ̄*)( ̄へ ̄)( ̄□ ̄) ( ̄~ ̄;)(。-?-。)( ̄ε ̄;)( ̄┬ ̄;)( ̄? ̄)(ノへ ̄、)(* ̄ro ̄)(ー人ー)(* ̄m ̄) 日系小眼睛 (′▽`〃)(′o`)(′ェ`)(′ε` )(=′ー`) ( ′θ`)(′○` )( ′-`)(′?`=)(*′▽`) (*′ノ0`)( ′ロ` )(′~`;)(′︿`)(*′?`*) (′m`)(′0ノ`*)(@。ε。@) (=′?`=)(●′ω`●) (′~`●)(′へ`、)(〃′o`)(;′⌒`) 日系大眼睛 (ΘΘ)(Θ~Θ〃)(ΘoΘ)(ΘェΘ)(Θ?Θ#)(ΘдΘ;)(Θ皿Θメ)(ΘーΘ*)(Θ0Θ●)(Θ▽Θ)(ΘεΘ?)(Θ?Θ。)(ΘへΘ)(Θ?Θ=)(Θ、Θ)(Θ?Θ@)(Θ3Θ) 圓珠眼 (°ー°〃)(#°Д°) (。□。) (*。?。) (*。?^*)(* ^ー。) (@。ー。@)(。?^?)(o。?。) (。▽。) (#。ε。#) (。?^d)(。?。;)(。皿。メ)(* 。3^) (〃。o。〃) ( °?°)(。?。) (°□°;) (ロ)。。(。Д。;)(*。ノO。)(;。。) 緊閉眼 (><)(;><)(>_<)(>.<)(>o<)(>▽<)(>O<)(o>▽<)(>?< ) (>▽<)(;>?<)( >з<)(o>ェ<)(>д<)(>皿<)(>_<、)(/_<。)(>。;)(>。ヘ)(ノ_<)(>。?)(>y<;)

实用批处理(bat)教程

目录 第一章批处理基础 第一节常用批处理内部命令简介 1、REM 和:: 2、ECHO 和@ 3、PAUSE 4、ERRORLEVEL 5、TITLE 6、COLOR 7、mode 配置系统设备 8、GOTO 和: 9、FIND 10、START 11、assoc 和ftype 12、pushd 和popd 13、CALL 14、shift 15、IF 16、setlocal 与变量延迟(ENABLEDELAYEDEXPANSION / DISABLEDELAYEDEXPANSION 启动或停用延缓环境变量扩展名。) 17、ATTRIB显示或更改文件属性 第二节常用特殊符号 1、@命令行回显屏蔽符 2、%批处理变量引导符 3、> 重定向符 4、>>重定向符 5、<、>、<& 重定向符 6、|命令管道符 7、^转义字符 8、组合命令 9、& 组合命令 10、||组合命令 11、\"\"字符串界定符 12、, 逗号 13、; 分号 14、() 括号 15、! 感叹号 第二章FOR命令详解 一、基本格式 二、参数/d仅为目录 三、参数/R递归(文件名) 四、参数/L迭代数值范围 五、参数/F迭代及文件解析 第三章FOR命令中的变量

一、~I- 删除任何引号(\"),扩展%I 二、%~fI- 将%I 扩展到一个完全合格的路径名 三、%~dI- 仅将%I 扩展到一个驱动器号 四、%~pI- 仅将%I 扩展到一个路径 五、%~nI- 仅将%I 扩展到一个文件名 六、%~xI- 仅将%I 扩展到一个文件扩展名 七、%~sI- 扩展的路径只含有短名 八、%~aI- 将%I 扩展到文件的文件属性 九、%~tI- 将%I 扩展到文件的日期/时间 十、%~zI- 将%I 扩展到文件的大小 十一、%~$PATH:I 第四章批处理中的变量 一、系统变量 二、自定义变量 第五章set命令详解 一、用set命令设置自定义变量 二、用set命令进行简单计算 三、用set命令进行字符串处理 1、字符串替换 2、字符串截取 第六章if命令讲解 第一种用法:IF [NOT] ERRORLEVEL number command 第二种用法:IF [NOT] string1==string2 command 第三种用法:IF [NOT] EXIST filename command 第四种用法:IF增强的用法 第七章DOS编程高级技巧 一、界面设计 二、if…else…条件语句 三、循环语句 四、子程序 五、用ftp命令实现自动下载 六、用7-ZIP实现命令行压缩和解压功能 七、调用VBScript程序 八、将批处理转化为可执行文件 九、时间延迟 1、利用ping命令延时 2、利用for命令延时 3、利用vbs延迟函数,精确度毫秒,误差1000毫秒内 4、仅用批处理命令实现任意时间延迟,精确度10毫秒,误差50毫秒内 十、模拟进度条 十一、特殊字符的输入及应用 十二、随机数(%random%)的应用技巧 十三、变量嵌套与命令嵌套 1、更正了所有的错别字,适当排版,增加条理性。

单片机C延时时间怎样计算

C程序中可使用不同类型的变量来进行延时设计。经实验测试,使用unsigned char类型具有比unsigned int更优化的代码,在使用时 应该使用unsigned char作为延时变量。以某晶振为12MHz的单片 机为例,晶振为12M H z即一个机器周期为1u s。一. 500ms延时子程序 程序: void delay500ms(void) { unsigned char i,j,k; for(i=15;i>0;i--) for(j=202;j>0;j--) for(k=81;k>0;k--); } 计算分析: 程序共有三层循环 一层循环n:R5*2 = 81*2 = 162us DJNZ 2us 二层循环m:R6*(n+3) = 202*165 = 33330us DJNZ 2us + R5赋值 1us = 3us 三层循环: R7*(m+3) = 15*33333 = 499995us DJNZ 2us + R6赋值 1us = 3us

循环外: 5us 子程序调用 2us + 子程序返回2us + R7赋值 1us = 5us 延时总时间 = 三层循环 + 循环外 = 499995+5 = 500000us =500ms 计算公式:延时时间=[(2*R5+3)*R6+3]*R7+5 二. 200ms延时子程序 程序: void delay200ms(void) { unsigned char i,j,k; for(i=5;i>0;i--) for(j=132;j>0;j--) for(k=150;k>0;k--); } 三. 10ms延时子程序 程序: void delay10ms(void) { unsigned char i,j,k; for(i=5;i>0;i--) for(j=4;j>0;j--) for(k=248;k>0;k--);

51单片机延时时间计算和延时程序设计

一、关于单片机周期的几个概念 ●时钟周期 时钟周期也称为振荡周期,定义为时钟脉冲的倒数(可以这样来理解,时钟周期就是单片机外接晶振的倒数,例如12MHz的晶振,它的时间周期就是1/12 us),是计算机中最基本的、最小的时间单位。 在一个时钟周期内,CPU仅完成一个最基本的动作。 ●机器周期 完成一个基本操作所需要的时间称为机器周期。 以51为例,晶振12M,时钟周期(晶振周期)就是(1/12)μs,一个机器周期包 执行一条指令所需要的时间,一般由若干个机器周期组成。指令不同,所需的机器周期也不同。 对于一些简单的的单字节指令,在取指令周期中,指令取出到指令寄存器后,立即译码执行,不再需要其它的机器周期。对于一些比较复杂的指令,例如转移指令、乘法指令,则需要两个或者两个以上的机器周期。 1.指令含义 DJNZ:减1条件转移指令 这是一组把减1与条件转移两种功能结合在一起的指令,共2条。 DJNZ Rn,rel ;Rn←(Rn)-1 ;若(Rn)=0,则PC←(PC)+2 ;顺序执行 ;若(Rn)≠0,则PC←(PC)+2+rel,转移到rel所在位置DJNZ direct,rel ;direct←(direct)-1 ;若(direct)= 0,则PC←(PC)+3;顺序执行 ;若(direct)≠0,则PC←(PC)+3+rel,转移到rel 所在位置 2.DJNZ Rn,rel指令详解 例:

MOV R7,#5 DEL:DJNZ R7,DEL; rel在本例中指标号DEL 1.单层循环 由上例可知,当Rn赋值为几,循环就执行几次,上例执行5次,因此本例执行的机器周期个数=1(MOV R7,#5)+2(DJNZ R7,DEL)×5=11,以12MHz的晶振为例,执行时间(延时时间)=机器周期个数×1μs=11μs,当设定立即数为0时,循环程序最多执行256次,即延时时间最多256μs。 2.双层循环 1)格式: DELL:MOV R7,#bb DELL1:MOV R6,#aa DELL2:DJNZ R6,DELL2; rel在本句中指标号DELL2 DJNZ R7,DELL1; rel在本句中指标号DELL1 注意:循环的格式,写错很容易变成死循环,格式中的Rn和标号可随意指定。 2)执行过程

批处理命令格式

批处理命令格式.txt人永远不知道谁哪次不经意的跟你说了再见之后就真的再也不见了。一分钟有多长?这要看你是蹲在厕所里面,还是等在厕所外面……echo 表示显示此命令后的字符 echo off 表示在此语句后所有运行的命令都不显示命令行本身 @与echo off相象,但它是加在每个命令行的最前面,表示运行时不显示这一行的命令行(只能影响当前行)。 call 调用另一个批处理文件(如果不用call而直接调用别的批处理文件,那么执行完那个批处理文件后将无法返回当前文件并执行当前文件的后续命令)。 pause 运行此句会暂停批处理的执行并在屏幕上显示Press any key to continue...的提示,等待用户按任意键后继续 rem 表示此命令后的字符为解释行(注释),不执行,只是给自己今后参考用的(相当于程序中的注释)。 例1:用edit编辑a.bat文件,输入下列内容后存盘为c: a.bat,执行该批处理文件后可实现:将根目录中所有文件写入 a.txt中,启动UCDOS,进入WPS等功能。 批处理文件的内容为: 命令注释: @echo off 不显示后续命令行及当前命令行 dir c: *.* >a.txt 将c盘文件列表写入a.txt call c: ucdos ucdos.bat 调用ucdos echo 你好显示"你好" pause 暂停,等待按键继续 rem 准备运行wps 注释:准备运行wps cd ucdos 进入ucdos目录 wps 运行wps 批处理文件的参数 批处理文件还可以像C语言的函数一样使用参数(相当于DOS命令的命令行参数),这需要用到一个参数表示符“%”。 %[1-9]表示参数,参数是指在运行批处理文件时在文件名后加的以空格(或者Tab)分隔的字符串。变量可以从%0到%9,%0表示批处理命令本身,其它参数字符串用%1到%9顺序表示。例2:C:根目录下有一批处理文件名为f.bat,内容为: @echo off format %1 如果执行C: >f a: 那么在执行f.bat时,%1就表示a:,这样format %1就相当于format a:,于是上面的命令运行时实际执行的是format a: 例3:C:根目录下一批处理文件名为t.bat,内容为: @echo off type %1 type %2 那么运行C: >t a.txt b.txt %1 : 表示a.txt %2 : 表示b.txt 于是上面的命令将顺序地显示a.txt和b.txt文件的内容。 特殊命令 if goto choice for是批处理文件中比较高级的命令,如果这几个你用得很熟练,你就是批

批处理基础知识

批处理文件基础知识 一、单符号message指定让MS-DOS在屏幕上显示的正文 ~ ①在for中表示使用增强的变量扩展。 ②在%var:~n,m%中表示使用扩展环境变量指定位置的字符串。 ③在set/a中表示一元运算符,将操作数按位取反。 ! ①在set /a中一元运算符,表示逻辑非。比如set /a a=!0,这时a就表示逻辑1。 @ ①隐藏命令行本身的回显,常用于批处理中。 % ①在set /a中的二元运算符,表示算术取余。 ②命令行环境下,在for命令in前,后面接一个字符(可以是字母、数字或者一些特定字符),表示指定一个循环或者遍历指标变量。 ③批处理中,后接一个数字表示引用本批处理当前执行时的指定的参数。 ④其它情况下,%将会被脱去(批处理)或保留(命令行) ^ ①取消特定字符的转义作用,比如& | > < ! "等,但不包括%。比如要在屏幕显示一些特殊的字符,比如> >> | ^ &等符号时,就可以在其前面加一个^符号来显示这个^后面的字符了,^^就是显示一个^,^|就是显示一个|字符了; ②在set/a中的二元运算符,表示按位异或。 ③在findstr/r的[]中表示不匹配指定的字符集。 & ①命令连接字符。比如我要在一行文本上同时执行两个命令,就可以用&命令连接这两个命令。 ②在set/a中是按位与。 : ①标签定位符,表示其后的字符串为以标签,可以作为goto命令的作用对象。比如在批处理文件里面定义了一个":begin"标签,用"goto begin"命令就可以转到":begin"标签后面来执行批处理命令了。 ②在%var:string1=string2%中分隔变量名和被替换字串关系。 | ①管道符,就是将上一个命令的输出,作为下一个命令的输入."dir /a/b |more"就可以逐屏的显示dir命令所输出的信息。 ②在set/a中的二元运算符,表示按位或。 ③在帮助文档中表示其前后两个开关、选项或参数是二选一的。 / ①表示其后的字符(串)是命令的功能开关(选项)。比如"dir /s/b/a-d"表示"dir"命令指定的不同的参数。 ②在set/a中表示除法。 > ①命令重定向符,将其前面的命令的输出结果重新定向到其后面的设备中去,后面的设备中的内容被覆盖。比如可以用"dir > lxmxn.txt"将"dir"命令的结果输出到"lxmxn.txt"这个文本文件中去。 ②在findstr/r中表示匹配单词的右边界,需要配合转义字符\使用。 < ①将其后面的文件的内容作为其前面命令的输入。 ②在findstr/r中表示匹配单词的左边界,需要配合转义字符\使用。 . ①在路径的\后紧跟或者单独出现时:

特殊符号大全(表情符号)

囧???⊕?Θ?¤㈱㊣??????▕??▓?▔⊿??▂▃▄▅▆▇██■?回□』∵╝╚╔╗╬═╓╩┠┨┯┷┏┓┗┛┳?》「┌┐└┘∟〉《′?″?↘↙??┇┅﹉﹊﹍﹎╭╮╰╯*^_^* ^*^ ^-^ ^_^ ^(^ ∮?‖||︴﹏﹋﹌()【】」『〒〓@:!/\ " _ < > `,?。?{}~ ~() _ -》「?$ @ * & # ?卐??Χ∪∩‵?の℡〔§?"?ミ灬μ??~μδω* ㄚ??+-??+-a/=∫???∧∨??‖※??∶∷?<>じ?veve′?????■?》「Χ?″??㊣?~〒〓@μδω□?』??ぷ?卐」『??∩¤????∽ㄚ∵↘↙┗┛╰?╮∽??????????≈???≌?????≒????????丨丩丬丶丷丿乀乙乂乄乆乛亅亠亻冂冫冖凵刂讠辶釒钅阝飠牜饣卩卪厸厶厽孓宀川巜彳廴三彐彳忄扌攵氵灬爫犭病癶礻糹纟罒冈耂艹虍言西 兦亼亽亖亗盲凸凹卝卍卐匸皕旡玊尐开木囘囙囚四囜囝回囟因女团団囤亢囦囧囨云囱囫囬园化囯困囱囲図围抡囶囷正囹固囻囼国图囿圀圁圂圃吾圅圆囵圈幸青国圌围园圏圐圑员圆圔圕图圗团圙圚圛圈圝圞 一般常用特殊符号 ,、。.?!~$%@&#*? ;?…¨,??? ‘’“”"?`?〃′??″↖↗↙↘㊣???⊕?????????□■▔▓§?〒????? 贴图符号大全 A、希腊字母大写ΑΒΓΓΔΕΖΘΗΚ∧ΜΝΞΟ?Ρ?ΤΥΦΦΧΨ B、希腊字母小写αβγδεδεζηθικλμνπξζηυθχψω C、俄文字母大写АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ D、俄文字母小写абвгде?жзийклмнопрстуфхцчшщъыьэюя E、注音符号??ㄅㄌㄐㄔㄘ?ー??ㄆㄉㄙㄍㄑㄕ?ヽ??ㄇㄊㄚㄎㄒㄖ???ㄈㄋㄛㄏㄓㄗ F、拼音o?ǎ-、ōμǒ′、±?°?ˉ、?3ǐ2、ū?ǔ·、ǖǘǚǜ1 G、日文平假名〔ぃぅぇぉかきくけこんさしすせそたちつってとゐなにぬねのはひふへほゑまみむめもゃゅょゎを H、日文片假名?ィゥヴェォカヵキクケヶコサシスセソタチツッテトヰンナニヌネノハヒフヘホヱマミムメモャュョヮヲ

DOS批处理命令大全

写批处理 扩展名是bat(在nt/2000/xp/2003下也可以是cmd)的文件就是批处理文件。 ==== willsort 编注======================================= .bat是dos下的批处理文件 .cmd是nt内核命令行环境的另一种批处理文件 从更广义的角度来看,unix的shell脚本以及其它操作系统甚至应用程序中由外壳进行解释执行的文本,都具有与批处理文件十分相似的作用,而且同样是由专用解释器以行为单位解释执行,这种文本形式更通用的称谓是脚本语言。所以从某个程度分析,batch, unix shell, awk, basic, perl 等脚本语言都是一样的,只不过应用的范围和解释的平台各有不同而已。甚至有些应用程序仍然沿用批处理这一称呼,而其内容和扩展名与dos的批处理却又完全不同。 =================================== 首先批处理文件是一个文本文件,这个文件的每一行都是一条DOS命令(大部分时候就好象我们在DOS 提示符下执行的命令行一样),你可以使用DOS下的Edit或者Windows的记事本(notepad)等任何文本文件编辑工具创建和修改批处理文件。 ==== willsort 题注=================== 批处理文件中完全可以使用非dos命令,甚至可以使用不具有可执行特性的普通数据性文件,这缘于wind ows系统这个新型解释平台的涉入,使得批处理的应用越来越"边缘化"。所以我们讨论的批处理应该限定在dos环境或者命令行环境中,否则很多观念和设定都需要做比较大的变动。 ======================== 其次,批处理文件是一种简单的程序,可以通过条件语句(if)和流程控制语句(goto)来控制命令运行的流程,在批处理中也可以使用循环语句(for)来循环执行一条命令。当然,批处理文件的编程能力与C语言等编程语句比起来是十分有限的,也是十分不规范的。批处理的程序语句就是一条条的DOS命令(包括内部命令和外部命令),而批处理的能力主要取决于你所使用的命令。 ==== willsort 编注================== 批处理文件(batch file)也可以称之为批处理程序(batch program),这一点与编译型语言有所不同,就c语言来说,扩展名为c或者cpp的文件可以称之为c语言文件或者c语言源代码,但只有编译连接后的exe 文件才可以称之为c语言程序。因为批处理文件本身既具有文本的可读性,又具有程序的可执行性,这些称谓的界限是比较模糊的。 =========================== 第三,每个编写好的批处理文件都相当于一个DOS的外部命令,你可以把它所在的目录放到你的DOS搜索路径(path)中来使得它可以在任意位置运行。一个良好的习惯是在硬盘上建立一个bat或者batch目录(例如C:\BATCH),然后将所有你编写的批处理文件放到该目录中,这样只要在path中设置上c:\batch,你就可以在任意位置运行所有你编写的批处理程序。 ==== willsort 编注===== 纯以dos系统而言,可执行程序大约可以细分为五类,依照执行优先级由高到低排列分别是:DOSKEY宏命令(预先驻留内存),https://www.doczj.com/doc/a63949844.html,中的内部命令(根据内存的环境随时进驻内存),以com为扩

各种表情符号大全。。。

≡(▔﹏▔)≡⊙﹏⊙∥∣°ˋ︿ˊ﹀-# ╯︿╰﹀ (=‵′=) <(‵^′)> (-__-)b  ̄□ ̄||-----\\(˙<>˙)/----- <("""O"""> (O ^ ~ ^ O) (*^︹^*︺( /。\ ) ( ' – ' ) ( ^3^ )╱~~ (;°○° ) ( > c < ) <( ̄︶ ̄)> <( ̄︶ ̄)/ b( ̄▽ ̄)d 汗( ̄口 ̄)!! ╮( ̄▽ ̄)╭╰( ̄▽ ̄)╭╮( ̄﹏ ̄)╭ ( ̄▽ ̄@) ○( ̄﹏ ̄)○ <( ̄oo, ̄)/ ╮( ̄▽ ̄"╭︿( ̄︶ ̄)︿ 凶手!凶手就是你! <( ̄﹌ ̄)@m 我..我..是大猪头╭(﹊∩∩﹊#)╮来嘛!╮(╯◇╰)╭口禾火~口禾火~…(⊙_⊙;)…○圭~○列~怎么酱? <( ̄oo, ̄)/猪头不是一天造成的! ˋ(′o‵")ˊ这个你问我也不知道~ 有火星人~ \("▔□▔)/\("▔□▔)/ 不要以为我不知道咩!┌(‵▽′)╭<( ̄ c ̄)y▂ξ真烦,来哈根草吧~ 叔叔~这样很冷耶! (#-.-)/ 我是优质大帅哥一枚. \( ̄▽ ̄)♂♀( ̄▽ ̄)/ 我是优质大美女一枚. ┐(─__─)┌你说我有啥米办法咧~ 吃饱饱,睡好好! ○(* ̄︶ ̄*)○有没有被猪揍过啊? ○(#‵︿′#)○ε(┬┬_┬┬)3 我真命苦 .. 拆屋┴┴︵╰(‵□′)╯︵┴┴≡ ̄﹏ ̄≡冷到不行.. <(‵^′)> 我看你还是回火星去好了! <( ̄oo, ̄)/ 没看过猪哥吗??... <( ̄︶ ̄)/ 喜欢吗?把拔买给你~︿( ̄︶ ̄)︿这学期欧趴欧趴啦~无影脚升级版 <(  ̄^ ̄)︵θ︵θ︵θ︵θ︵θ︵θ︵θ︵θ︵θ☆( >_<)~啊! 恶魔集团o(‵▽′)ψ( ̄︶ ̄)ψ( ̄︶ ̄)ψψ(╰_╯)σ☆咒 嘟着嘴 ( ̄)︿( ̄) \(~__~)/ 要抱抱啦... 满意.满足 <( ̄︶ ̄)> []~( ̄▽ ̄)~* ( ̄﹏ ̄) ( ̄ˇ ̄) \( ̄︶ ̄)> <( ̄︶ ̄)/ (‵﹏′) ╮(‵▽′)╭\(‵▽′)/ =============================================

目前为止最全的批处理教程

目录 第一章 批处理基础 第一节 常用批处理内部命令简介 1、REM 和 :: 2、ECHO 和 @ 3、PAUSE 4、ERRORLEVEL 5、TITLE 6、COLOR 7、mode 配置系统设备 8、GOTO 和 : 9、FIND 10、START 11、assoc 和 ftype 12、pushd 和 popd 13、CALL 14、shift 15、IF 16、setlocal 与 变量延迟(ENABLEDELAYEDEXPANSION / DISABLEDELAYEDEXPANSION 启动或停用延缓环境变量扩展名。) 17、ATTRIB显示或更改文件属性 第二节 常用特殊符号

1、@命令行回显屏蔽符 2、%批处理变量引导符 3、> 重定向符 4、>>重定向符 5、<、>、<& 重定向符 6、|命令管道符 7、^转义字符 8、组合命令 9、& 组合命令 10、||组合命令 11、\"\"字符串界定符 12、, 逗号 13、; 分号 14、() 括号 15、! 感叹号 第二章 FOR命令详解 一、基本格式 二、参数 /d仅为目录 三、参数 /R递归(文件名) 四、参数 /L迭代数值范围 五、参数 /F迭代及文件解析 第三章 FOR命令中的变量

一、 ~I- 删除任何引号(\"),扩展 %I 二、 %~fI- 将 %I 扩展到一个完全合格的路径名 三、 %~dI- 仅将 %I 扩展到一个驱动器号 四、 %~pI- 仅将 %I 扩展到一个路径 五、 %~nI- 仅将 %I 扩展到一个文件名 六、 %~xI- 仅将 %I 扩展到一个文件扩展名 七、 %~sI- 扩展的路径只含有短名 八、 %~aI- 将 %I 扩展到文件的文件属性 九、 %~tI- 将 %I 扩展到文件的日期/时间 十、 %~zI- 将 %I 扩展到文件的大小 十一、 %~$PATH:I 第四章 批处理中的变量 一、系统变量 二、自定义变量 第五章 set命令详解 一、用set命令设置自定义变量 二、用set命令进行简单计算 三、用set命令进行字符串处理 1、字符串替换 2、字符串截取 第六章 if命令讲解 第一种用法:IF [NOT] ERRORLEVEL number command

延时计算

t=n*(分频/f) t:是你所需的延时时间 f:是你的系统时钟(SYSCLK) n:是你所求,用于设计延时函数的 程序如下: void myDelay30s() reentrant { unsigned inti,k; for(i=0;i<4000;i++) /*系统时钟我用的是24.576MHZ,分频是12分频,达到大约10s延时*/ for(k=0;k<8000;k++); } //n=i*k |评论 2012-2-18 20:03 47okey|十四级 debu(g调试),左侧有运行时间。在你要测试的延时子函数外设一断点,全速运行到此断点。记下时间,再单步运行一步,跳到下一步。再看左侧的运行时间,将这时间减去上一个时间,就是延时子函数的延时时间了。不知能不能上图。 追问 在delayms处设置断点,那么对应的汇编语言LCALL是否被执行呢?还有,问问您,在C8051F020单片机中,MOV指令都是多少指令周期呢?我在KEIL下仿真得出的结果,与我通过相应的汇编语言分析的时间,总是差了很多。 回答 C编译时,编译器都要先变成汇编。只想知道延时时间,汇编的你可以不去理会。只要看运行时间就好了。 at8051单片机12m晶振下,机器周期为1us,而c8051 2m晶振下为1us。keil 调试里频率默认为24m,你要设好晶振频率。

|评论 2012-2-23 11:17 kingranran|一级 参考C8051单片机内部计时器的工作模式,选用合适的计时器进行中断,可获得较高精度的延时 |评论 2012-2-29 20:56 衣鱼ccd1000|一级 要是精确延时的话就要用定时器,但定的时间不能太长,长了就要设一个变量累加来实现了; 要是不要求精确的话就用嵌套for函数延时,比较简单,但是程序复杂了就会增添不稳定因素,所以不推荐。 |评论

windows批处理命令详解及脚本实例

批处理文件是将一系列命令按一定的顺序集合为一个可执行的文本文件,其扩展名为BAT。第一部分:批处理内部命令 1、REM REM 是个注释命令一般是用来给程序加上注解的,该命令后的内容在程序执行的时候将不会被显示和执行。例: REM 你现在看到的就是注解,这一句将不会被执行。在以后的例子中解释的内容都REM 会放在REM后面。请大家注意。 2、ECHO ECHO 是一个回显命令主要参数有OFF和ON,一般用ECHO message来显示一个特定的消息。例: Echo off Rem 以上代表关闭回显即不显示所执行的命令 Echo 这个就是消息。 Rem 以上代表显示"这就是消息"这列字符 执行结果: C:\>ECHO.BAT 这个就是消息。 3、GOTO GOTO 即为跳转的意思。在批处理中允许以":XXX"来构建一个标号然后用GOTO :标号直接来执行标号后的命令。例 :LABEL REM 上面就是名为LABEL的标号。 DIR C:\ DIR D:\ GOTO LABEL REM 以上程序跳转标号LABEL处继续执行。 4、CALL CALL 命令可以在批处理执行过程中调用另一个批处理,当另一个批处理执行完后再继续

执行原来的批处理。例: 批处理2.BAT内容如下: ECHO 这就是2的内容 批处理1.BAT内容如下: ECHO 这是1的内容 CALL 2.BAT ECHO 1和2的内容全部显示完成 执行结果如下: C:\>1.BAT 这是1的内容 这就是2的内容 1和2的内容全部显示完成 5、PAUSE PAUSE 停止系统命令的执行并显示下面的内容。例: C:\> PAUSE 请按任意键继续. . . 6、IF IF 条件判断语句,语法格式如下: IF [NOT] ERRORLEVEL number command IF [NOT] string1==string2 command IF [NOT] EXIST filename command 说明: [NOT] 将返回的结果取反值即"如果没有"的意思。 ERRORLEVEL 是命令执行完成后返回的退出值 Number 退出值的数字取值范围0~255。判断时值的排列顺序应该又大到小。返回的值大于或等于指定的值时条件成立。 string1==string2 string1和string2都为字符的数据,英文字符的大小写将看做不同,这个条件中的等于号必须是2个(绝对相等),条件想等后即执行后面的command EXIST filename 为文件或目录存在的意思。 IF ERRORLEVEL这条语句必须放在某一个命令后面。执行命令后由IF ERRORLEVEL来

批处理命令For循环命令详解

分类:2010-06-11 13:0416793人阅读(0) 批处理for命令详解 FOR这条命令基本上都被用来处理文本,但还有其他一些好用的功能! 看看他的基本格式(这里我引用的是批处理中的格式,直接在命令行只需要一个%号) FOR 参数%%变量名IN (相关文件或命令) DO 执行的命令 参数:FOR有4个参数/d /l /r /f 他们的作用我在下面用例子解释 %%变量名:这个变量名可以是小写a-z或者大写A-Z,他们区分大小写,FOR会把每个读取到的值给他; IN:命令的格式,照写就是了; (相关文件或命令) :FOR要把什么东西读取然后赋值给变量,看下面的例子 do:命令的格式,照写就是了! 执行的命令:对每个变量的值要执行什么操作就写在这. 可以在CMD输入for /看系统提供的帮助!对照一下 FOR %%variable IN (set) DO command [command-parameters] %%variable 指定一个单一字母可替换的参数。 (set) 指定一个或一组文件。可以使用通配符。 command 指定对每个文件执行的命令。 command-parameters 为特定命令指定参数或命令行开关。 现在开始讲每个参数的意思 /d 仅为目录 如果Set (也就是我上面写的"相关文件或命令") 包含通配符(* 和),将对与Set 相匹配的每个目 录(而不是指定目录中的文件组)执行指定的Command。 系统帮助的格式:FOR /D %%variable IN (set) DO command 他主要用于目录搜索,不会搜索文件,看这样的例子 @echo off for /d %%i in (*) do @echo %%i pause 把他保存放在C盘根目录执行,就会把C盘目录下的全部目录名字打印出来,而文件名字一个也不显示!

相关主题
文本预览
相关文档 最新文档