Home > Back-end >  The realization of the intelligent vehicle specific line, who can help to do it, thank you
The realization of the intelligent vehicle specific line, who can help to do it, thank you

Time:10-20

ASURO is a fully use of C language programming can be movement of the micro robot, it is a subordinated to the German space agency is responsible for the design of a robot and mechanical device agency DLR development for education purposes, experienced electronic technology personnel and even beginner can finish ASURO assembly, in addition to printed circuit board, the device completely using standard components,
ASURO only using open source software complete programming, therefore ASURO is very suitable for use in a micro control unit introduction to study, can be used for curriculum design and research of college or high school or professional and technical training center of teaching, ASURO in the whole design process of hardware and software is used in the compiling process of open source software, which also shows how to use expensive tools and equipment and complete robot design method,
ASURO is equipped with a RISC processor (reduced instruction set processor) and two independent control of the motor, a linear tracker, six collision detection switch, two stroke sensor, three lights and one for programming and by PC remote control using infrared communication port (see figure 1.1),

Figure 1.1 ASURO structure diagram

By northwestern polytechnical university institute of computer programming (CP Team) faculty to upgrade, ASURO entitled ASURO -s version, this version is deleted: linear tracker, change to "ultrasonic range finder," lost "tracing" feature, which increases the "have a distance obstacle avoidance" (original "obstacle avoidance collision"),

Figure 1.2 ASURO circuit layout

1.1 programming interface
ASURO using Atmel AVR series Tmega8L chip as the microprocessor, its programming environment for WinAVR (Code: : Blocks support),
1.1.1 interface function
ASURO interface function definition in ASURO. J h, realize the ASURO. C, need to add the interface when programming projects,
1. The Init function
The function prototype:
# include "asuro. H"
Void Init (void);
Function:
Used to the car's microprocessor reset to initial state, it must execute before the start of the program is really a function, if there is no this function, they don't know how to work the processor,
The sample code:
# include "asuro. H"
Int main ()
{//asuro hello, world
//define variables
The Init ();
//insert your program
while(1);//infinite loop
return 0;//this step will never be executed
}
Why do we need to at the end of the main function, combined with an infinite loop? This is because under normal circumstances, the main function will be through the end of the return value of 0, the return signals the end of the program, but in asuro, we used to go in the program is likely to remain in the memory of the microprocessor, also may be performed, this may lead to some unexpected results, in order to avoid the old program fragment is executed, we add an infinite loop in the middle of the program, make these fragments of program didn't have a chance to be executed to forever, so programs can be according to the way we scheduled over,
2. StatusLED function
The function prototype:
# include "asuro. H"
The inline void StatusLED (unsigned char color);
Function:
Used to control the status lamp (D12) on and OFF, legal argument is: OFF, GREEN, RED and YELLOW,
The sample code:
# include "asuro. H"
Int main ()
{
//define variables
The Init ();
StatusLED (RED);//the status lights turn red
while(1);//infinite loop
return 0;//this step will never be executed
}
3. FrontLED function
The function prototype:
# include "asuro. H"
The inline void FrontLED (unsigned char status);
Function:
Used to control the front lamp (D11) ON and OFF, legal argument is: OFF and ON, for example: FrontLED (ON),
4. BackLED function
The function prototype:
# include "asuro. H"
Void BackLED (unsigned char left, unsigned char right);
Function:
Used to control two lights behind (D15 and D16) ON and OFF, one of the first parameter description ON the left side of the light behind D15 state, and the second parameter to describe the right of the light behind D15 state, legal argument is: OFF and ON, for example: BackLED (OFF and ON); On the left side of the lights went out, and on the right side of the light,
5. Sleep function
The function prototype:
# include "asuro. H"
Void Sleep (unsigned char timer36kHz);
Function:
This function can make the CPU to wait for a period of time, the processor waiting time is determined by a parameter, and a maximum of this parameter is only 255, and from a 72 KHZ (or 36 KHZ) calculation cycle timer,
For example, the calculator will wait 3 ms, 0.003 S/1/72 (KHZ)=216, so, Sleep (216) will force the processor wait 3 ms,
6. MotorDir function
The function prototype:
# include "asuro. H"
The inline void MotorDir (unsigned char left_dir, unsigned char right_dir);
Function:
This function is to control the car two wheels of the direction of rotation, the general use before speed control function, legal parameter FWD (forward), RWD (backward), BREAK (stop) and FREE (freewheeling), for example: MotorDir (FWD, BREAK); Will make forward, on the left side of the wheel and the wheel on the right to stop,
7. MotorSpeed function
The function prototype:
# include "asuro. H"
The inline void MotorSpeed (unsigned char left_speed, unsigned char right_speed);
Function:
This function is used to control the speed of the two wheels, maximum speed is 255, according to the mechanical conditions, the engine will rotate to about 60 value, the value of this parameter control is actually the engine power, while the actual speed is restricted by many other factors, as friction and slope surface slope,
MotorSpeed (255, 0); On the left side of the wheel rotates at top speed, and the wheels on the right, before the function call, of course, be MotorDir () to set the wheels in the direction of rotation,
8. SerWrite function
The function prototype:
# include "asuro. H"
Void SerWrite (unsigned char * data, unsigned char length);
Function:
This function through IR, serial interface to a 2400 - bit/s, 8 data bits, parity, 1 stop bit, the numerous, according to the mode of flow is from ASURO receive data parameters to describe characters to be transmitted, and the length of the transmission, for example: SerWrite (" Hello, how are you?" , 18); If start super interrupt when the car will Hello how are you? Transferred to the super terminal
9. SerRead function
The function prototype:
# include "asuro. H"
Void SerRead (unsigned char * data, unsigned char length, unsigned int timeout);
Function:
Contrary to the above function, the function of this function is to ASURO receive we sent out the string, the first parameter is used to store the string pointer, the second parameter to describe how many strings, want the car to receive the third parameter describes the delay time,
The Timeout parameter is used to prevent when the small car is not received enough characters, infinite waiting, if not enough within the delay time of characters to receive, then this function will be ignored, and receives the character will be 'T' (=a Timeout) instead of, if you define the Timeout parameter to 0, so this function will have been waiting for, until to receive all the desired character,
The sample code:
# include "asuro. H"
Int main ()
{
char data;//to hold the received string
The Init ();
SerRead (data, 1, 0);//read the data
If (data=https://bbs.csdn.net/topics/='G') {
//if the character is received by the G car forward
FWD is MotorDir (FWD);
MotorSpeed (120120);
}
while(1);//infinite loop
return 0;//this step will never be executed
}
10. LineData function
The function prototype:
# include "asuro. H"
Void LineData (unsigned int * data);
Function:
This function is used to read in the car on both sides of the car the strength of the photosensitive transistor,
The first thing you have to define a can store two int data pointer, the function will be two of the photosensitive transistor analog conversion to digital quantity, and the first value stored in an array is the digital quantity on the left side of the transistor, the second store is right, the biggest strength is 1023, and all black, is 0,
For example:
Unsigned int data [2];
LineData (data);
Data [0] to describe the strength of the transistors on the left
The strength of the data [1] to describe the right transistor
Under normal circumstances, will not have these limits data detected, and can detect the actual value is between 0 and 1023,
The sample code:
# include "asuro. H"
Int main ()
{
char data;//to hold the received string
The Init ();
SerRead (data, 1, 0);//read the data
If (data=https://bbs.csdn.net/topics/='G') {
//if the character is received by the G car forward
FWD is MotorDir (FWD);
MotorSpeed (120120);
}
while(1);//infinite loop
return 0;//this step will never be executed
}
11. OdometrieData function
The function prototype:
# include "asuro. H"
Void OdometrieData (unsigned int * data);
Function:
This function scans the reflective light sensor (D13, D14), when the two sensors are activated, then this function returns the photosensitive sensor (T11, T12) analog-to-digital conversion value, and LineData () function, the data in the data array, same one of the first integer is the left sensor (T11) analog-to-digital conversion value, and the second integer (T12) is the right values, among them, the maximum intensity is zero, and all black is 1023, as is often the case, will not have these limits data detected, and can detect the actual value is between 0 and 1023,
For example:
Unsigned int data [2];
OdometrieData (data);
Data [0] to describe the strength of the transistors on the left
The strength of the data [1] to describe the right transistor
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related