background image

www.nexusrobot.com                                                           Robot Kits manual 

 

92

 

 

 

 
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Diagram_Omni3WD_V3.3 

 

Содержание Nexus Robot

Страница 1: ...t Kits manual NEXUS ROBOT Looking to the future Robot Kits User s Manual Nexus Automation Limited ADDR 2 F Chengxi Building 819 S358 Road Shatou Changan Dongguan Guangdong China Robot Kits User s Manu...

Страница 2: ...s device for military or medical purpose as they are not designed to C Attention Do not use over voltage power supply ensure stable power supply if there is high voltage pulse may cause the micro cont...

Страница 3: ...ower 5 Getting Started 5 Language Reference 9 Programming structure 9 Re write Arduino bootloader 10 FT232RL BitBang Mode AVR Writer 10 Modify the Diecimila 10 Downloading 11 Installing 11 Setting 12...

Страница 4: ...el Class Reference 36 Class Motor Reference 37 Class GearedMotor 43 Class MotorWheel 45 R2WD 49 R2WD Class Reference 49 Public functions 49 Private parameters 62 R2WD_test 68 2WD platform with 3 SONAR...

Страница 5: ...guage based on Wiring and the Arduino development environment based on Processing Arduino projects can be stand alone or they can communicate with software running on a computer e g Flash Processing M...

Страница 6: ...nalog Port with 8 analog inputs one input is tied internally to the supply voltage One General Purpose I O Port with 13 I O lines 4 5 6 7 can be used to control motors One Reset Button Jumper bank to...

Страница 7: ...e pins support SPI communication using the SPI library LED 13 There is a built in LED connected to digital pin 13 When the pin is HIGH value the LED is on when the pin is LOW it s off Communication Th...

Страница 8: ...ce Removing the jumper will disable wireless module and allows the sketch to be uploaded Arduino IO Expansion Board To support RS485 interface or drive 4 motors IO Expansion Board is available This Ar...

Страница 9: ...arranty against such damage Make sure you take time to apply power correctly Otherwise it could get costly for you Power from USB Simply plug USB cable and the controller is able to work Please notice...

Страница 10: ...Connect the Arduino board to your computer using the USB cable The green power LED labelled PWR should go on 4 Install the drivers Installing drivers for the Arduino Uno with Windows7 Vista or XP Plu...

Страница 11: ...est driver in these locations is checked uncheck Search removable media check Include this location in the search and browse to the drivers FTDI USB Drivers directory of the Arduino distribution The l...

Страница 12: ...es are available on the environment page 8 Select your serial port Select the serial device of the Arduino board from the Tools Serial Port menu This is likely to be COM3 or higher COM1 and COM2 are u...

Страница 13: ...uage Reference Arduino programs can be divided in three main parts structure values variables and constants and functions If you want to understand more please See http www arduino cc en Reference Hom...

Страница 14: ...itself This section describe the method on Windows XP Attention If you want use avrdude serjtag on Linux or Mac OS you must remake patch reconfigure and recompile it There are useful projects avrdude...

Страница 15: ...site avrdude GUI 1 0 5 zip original site http yuki lab jp hw avrdude GUI index html avrdude GUI 1 0 5 zip mirror site avrdude GUI yuki lab jp Version require Microsoft NET Framework 2 0 When NET Frame...

Страница 16: ...BitBang type ft245r miso 3 CTS X3 1 sck 5 DSR X3 2 mosi 6 DCD X3 3 reset 7 RI X3 4 avrdude GUI yuki lab jp Version Extract avrdude GUI 1 0 5 zip Copy avrdude GUI 1 0 5 folder into C Program Files fol...

Страница 17: ...s jp arduino_diecimila bootloader index_en html Adjust PWM frequencies The ATmega328P has three timers known as Timer 0 Timer 1 and Timer 2 Each timer has two output compare registers that control the...

Страница 18: ...0x05 128 244 140625 0x06 256 122 0703125 0x07 1024 30 517578125 TCCR2B TCCR2B 0b11111000 setting All frequencies are in Hz and assume a 16000000 Hz system clock From koyaanisqatsi in this forum post h...

Страница 19: ...the results but it is also possible to display the results on the PC as demonstrated in the CMPS03 example All the modules which use the I2C bus have 1k8 pull up resistors to 5v You only need one set...

Страница 20: ...icated in the red circle S6 uses Digital Pin2 S7 uses Digital Pin3 Once these enable jumpers have been applied Pin 2 and 3 will be occupied Sample code int ledPin 13 int key_s6 2 int val 0 void setup...

Страница 21: ...es any previous function that was attached to the interrupt Most Arduino boards have two external interrupts numbers 0 on digital pin 2 and 1 on digital pin 3 The Arduino Mega has an additional four n...

Страница 22: ...r by establishing serial communication between your Arduino and your computer over USB Sample code const int PIN 12 set pin 12 as the signal pin void setup Serial begin 9600 pinMode PIN INPUT set mode...

Страница 23: ...tate of your Sharp 2D12 after establishing serial communication between your Arduino and your computer Sample code const int GP2Y0A21 0 set analog pin 0 as the signal pin void setup Serial begin 9600...

Страница 24: ...are using to power the servos The Signal wire will be hooked up to the microcontroller used to control the servo in our case the PIC A noticeable first impression the servo only requires 1 pin from th...

Страница 25: ...speed control pins Pin Allocation PWM Control Mode PLL Mode Pin Function Digital 4 Motor 1 Enable control Digital 5 Motor 1 Direction control Digital 6 Motor 2 Direction control Digital 7 Motor 2 Ena...

Страница 26: ...you how to monitor the state of a switch by establishing serial communication between your Arduino and your computer over USB Sample code DigitalReadSerial Reads a digital input on pin 0 prints the r...

Страница 27: ...allows a number of sensors working together Up to 32 units may be connected together in a RS485 network The ultrasonic sensor allows you to determine the exact distance of an obstacle in the sonar fie...

Страница 28: ...n and Pin definition RS485 Interface Two connectors 5V DC Power 5V GND Ground A A RS485 A B B RS485 B ISP Pin For factory firmware uploading Communication LED As the device is powered up this LED will...

Страница 29: ...raight cable all noise current is flowing in the same direction practically generating a looping current just like in an ordinary transformer When the cable is twisted we see that in some parts of the...

Страница 30: ...d signal quality may degrade significantly RS485 functionality Default all the senders on the RS485 bus are in tri state with high impedance In most higher level protocols one of the nodes is defined...

Страница 31: ...o return data The default address for the sensor is 0x11 Example Command 0x55 0xaa 0x11 0x01 0x55 0x12 0x79 Set Address to 0x12 Return 0x55 0xaa 0x12 0x01 0x55 0x01 0x69 Address set successfully Trigg...

Страница 32: ...er Address Length Cmd High Byte Low Byte SUM 55 aa ADD 2 03 H L SUM PS The command will return the temperature reading The return temperature reading is using Celsius scale If the temperature is above...

Страница 33: ...delay SONAR duration 60 millissecond Serial println s11 getDist DEC Display the distance S11 received s11 showDat Display the data S11 received Serial println s12 getDist DEC Serial println s11 getTe...

Страница 34: ...he data transmission speed may slow limited by the serial port baud rate it is a simple and pratical way No wonder that many netizens recommended the inclusion of such Arduino module support Manufactu...

Страница 35: ...nd provides macros that make it drop in compatible with the PcInt code To attach an interrupt use PCintPort attachInterrupt pin userFunc mode or PCattachInterrupt pin userFunc mode To detach an interr...

Страница 36: ...PIN INPUT set the pin to input 17 digitalWrite PIN HIGH use the internal pullup resistor 18 PCintPort attachInterrupt PIN burpcount RISING attach a PinChange Interrupt to our pin on the rising edge 1...

Страница 37: ...ng values to use There isn t one right answer The values that work for one application may not work for another just as the driving style that works for a truck may not work for a race car With each n...

Страница 38: ...itive wire from your supply to the screw terminal labeled VIN on the Arduino board NOTE Maximum supply voltage cannot exceed 14V DC Ground The black one marked by should be connected to a ground pin o...

Страница 39: ...pply is applied to the load and the off time is the period during which that supply is switched off Given a sufficient bandwidth any analog value can be encoded with PWM Figure 2 shows three different...

Страница 40: ...t ISRVars Reference This section gives a full listing of the capabilities of a struct ISRVars struct ISRVars Define a struct named of IRSVars In the struct there are 7 values Values void ISRfunc A poi...

Страница 41: ...e a Motor object called Motor You can then use any of its methods for instance to control a motor attached to pins you could write Parameters unsigned char _pinPWM The motor PWM control pin unsigned c...

Страница 42: ...igned int PWM The PWM set for the Motor Bool dir The direction set for the Motor Bool saveDir A flag to confirm if the direction will be reset Return PWM unsigned int getPWM const Get the motor s curr...

Страница 43: ...edDir const Get the desired direction Return Desired Direction bool reverseDesiredDir Get the reverse desired direction Return Desired Direction bool setCurrDir Set a current direction on the basis of...

Страница 44: ...ate Regulate the speed of the Motor on the basis of the direction bool PIDSetup float kc KC float taui TAUI float taud TAUD unsigned int sampleTime 1000 Setup the The class PID use these datas to regu...

Страница 45: ...lease it Return PID PIDSetup bool PIDReset Reset the state of PID This will lie within the range specified at PID Reset Return False if the PIDGetStatus return false Ture ortherwise See PID Reset bool...

Страница 46: ...ed Return speedRPMDesired void debugger const Debug to sure if the result is right int getSpeedPPS const Get the pulse rate pulse per second Return speedPPS long getCurrPulse const Get the current Pul...

Страница 47: ...d int speedPWM Save the current PWM int speedRPMInput Save the Motor s current speed it will be used in class PID int speedRPMOutput Save the speed of the Motor output int speedRPMDesired Save the spe...

Страница 48: ...direction control pin unsigned char _pinIRQ The IRQ pin unsigned char _pinIRQB The IRQB pin struct ISRVars _isr A point of the struct IRSVars s member unsigned int _ratio A variable equal 60 float get...

Страница 49: ...save a value Class MotorWheel Interface for visit of peripherals and it s Inherit from the Public Motor Public functions MotorWheel unsigned char _pinPWM unsigned char _pinDir unsigned char _pinIRQ un...

Страница 50: ...umference of the wheel This will lie within the range specified at MotorWheel getCirMM parameters unsigned int cirMM The value want to set See MotorWheel getCirMM unsigned int getSpeedCMPM const Get t...

Страница 51: ...For example include PinChangeInt h include PinChangeIntConfig h include PID_Beta6 h include MotorWheel h ifndef MICROS_PER_SEC define MICROS_PER_SEC 1000000 endif irqISR irq1 isr1 This will create a...

Страница 52: ...robot com Robot Kits manual 48 Serial println wheel1 getSpeedRPM DEC display the speed of the MotorWheel Serial print MMPS Serial println wheel1 getSpeedMMPS DEC display the speed of the motor wheel1...

Страница 53: ...erials of sensors making it aware of the environment Sonar sensors to detect the obstructions IR distance measure sensors used as a fall arrest detector bumper sensors to make it turn around while run...

Страница 54: ...millimeter Return Wheel span unsigned int setWheelspanMM unsigned int wheelspan Set the wheel span This will lie within the range specified at R2WD getWheelspanMM Parameters Unsigned int wheelspan The...

Страница 55: ...PS 0 Set car move backoff This will lie within the range specified at R2WD setCarStat and R2WD setcarbackoffBase Parameters unsigned int speedMMPS The speed of the car moves initialize it see R2WD set...

Страница 56: ...t unsigned int radiusMM The radius the car moves Locus see R2WD setCarStat R2WD setCarArcBace unsigned int setCarLowerLeft unsigned int speedMMPS unsigned int radiusMM Set car moves Lower left This wi...

Страница 57: ...ceDistance unsigned int speedMMPS unsigned long distance Set the distance the car move advance This will lie within the range specified at R2WD setCarAdvance and 2WD setCarStrightdistance Parameters u...

Страница 58: ...es rotate right This will lie within the range specified at R2WD setCarRotateRight and R2WD setCarRotateAngle Parameters unsigned int speedMMPS 0 The speed ofthe car moves initialize it float radian 0...

Страница 59: ...AN The radiusMM when the car move as upper left initialize it unsigned long duration 5000 The time the car last initialize it unsigned int uptime 500 The time the car used to stop see R2WD setCarLower...

Страница 60: ...left initialize it unsigned long duration 5000 The time the car last initialize it unsigned int uptime 500 The time the car used to stop see R2WD setCarLowerRight R2WD setCarArcTime unsigned int setC...

Страница 61: ...fied at R2WD setCarUpperRight and R2WD setCarArcAngle Parameters unsigned int speedMMPS The speed for the car to moves Unsigned int radian The radian when the car make upper right moves see R2WD setCa...

Страница 62: ...d int speedMMPS 0 bool dir DIR_ADVANCE Set the speed for right wheel This will lie within the range specified at MotorWheel setSpeedMMPS Parameters unsigned int speedMMPS The speed for the car to move...

Страница 63: ...st time for the car work as the same action In the function every 10 milliseconds it will call the function PIDRegulate once Parameters unsigned long ms 100 The time the action last bool debug false A...

Страница 64: ...r s state was one of the following STAT_UPPERLEFT STAT_LOWERLEFT STAT_LOWERRIGHT STAT_UPPERRIGHT This will lie within the range specified at R2WD getCarSpeedMMPS Parameters unsigned int speedMMPS 0 Th...

Страница 65: ...TOP The car s state is stop STAT_ADVANCE The car s state is moves advance STAT_BACKOFF The car s state is get backoff STAT_ROTATELEFT The car s state is moves rotateleft STAT_ROTATERIGHT The car s sta...

Страница 66: ...diusMM const Get the radius the car moves If the car state was rotateleft or rotateright This will lie within the range specified at R2WD getWheelspanMM return radius Private parameters MotorWheel _wh...

Страница 67: ...See R2WD getSwitchMotorsStat unsigned int _radiusMM Save the data of the radius unsigned int setRadiusMM unsigned int radiusMM Set the radius for the car moves This will lie within the range specifie...

Страница 68: ...PS 0 The speed set the motors run initialize it See R2WD setMotorAll unsigned int setMotorAllBackoff unsigned int speedMMPS 0 Set all motors run backoff This will lie within the range specified at R2W...

Страница 69: ...edMMPS R2WD wheelRightSetSpeedMMPS R2WD getCarSpeedMMPS unsigned int setCarRotateAngle unsigned int speedMMPS 0 float radian 0 Set the angle when the car moves rotate This will lie within the range sp...

Страница 70: ...meMS the time the car moves unsigned int setCarArcTime unsigned int speedMMPS 0 unsigned int radiusMM WHEELSPAN unsigned long duration 5000 unsigned int uptime 500 Set the time the car moves as Arc Pa...

Страница 71: ...2WD setCarAdvance set car to moves advance R2WD setCarBackoff set car to moves back off R2WD setCarRotateLeft set car to moves as rotate left R2WD setCarRotateRight set car to moves as rotate right un...

Страница 72: ...a car with two wheels after this you will More thorough understanding of the library Simple code include MotorWheel h include R2WD h include PID_Beta6 h include PinChangeInt h include PinChangeIntCon...

Страница 73: ...write void setup TCCR0B TCCR0B 0xf8 0x01 warning it will change millis TCCR1B TCCR1B 0xf8 0x01 Pin9 Pin10 PWM 31250Hz TCCR2B TCCR2B 0xf8 0x01 Pin3 Pin11 PWM 31250Hz _2WD PIDEnable 0 26 0 01 0 10 Enab...

Страница 74: ...www nexusrobot com Robot Kits manual 70 Sample Wiring Diagram for RB004 2WD V2 0...

Страница 75: ...tialization SONAR is be defined in SONAR h as a class unsigned short distBuf 3 Used to save the data of the 3 sonars return void sonarsUpdate static unsigned char sonarCurr 1 A variable save data used...

Страница 76: ...s Sensor signal pin unsigned char bumperR_pin 2 Set pin 2 as the right Bumper s Sensor signal pin irqISR irq1 isr1 Intterrupt function on the basis of the pulse work for wheel1 MotorWheel wheel1 9 8 4...

Страница 77: ...urrMillis millis sonarsUpdate if bumperL bumperC bumperR If the car hit something _2WD setCarBackoff speedMMPS Set car backoff at the speed of speedMMPS _2WD delayMS 300 last 300 ms if bumperL bumperC...

Страница 78: ...ection of each wheel Moving all four wheels in the same direction causes forward or backward movement running the wheels on one side in the opposite direction to those on the orther side causes rotati...

Страница 79: ...kit This is a 3 wheels drive mobile robot utilizing omni wheels It s capable of moving in any directions by changing the velocity and direction of each wheel without changing its orientation It includ...

Страница 80: ...char switchMotorsLeft Rotate left to choose the motors This will lie within the range specified at Omni3WD getSwitchMotorsStat See Omni3WD getSwitchMotorsStat unsigned char switchMotorsRight Rotate r...

Страница 81: ...rward This will lie within the range specified at Omni3WD setMotorAll Parameters unsigned int speedMMPS 0 The speed for the motor to run initialize it See Omni3WD setMotorAll unsigned int setMotorAllB...

Страница 82: ...unsigned int speedMMPS 0 Set the car moves Reverse This will lie within the range specified at Omni3WD setCarstat and Omni3WD wheelBackSetSpeedMMPS and Omni3WD wheelRightSetSpeedMMPS and Omni3WD wheel...

Страница 83: ...kSetSpeedMMPS Omni3WD wheelRightSetSpeedMMPS Omni3WD wheelLeftSetSpeedMMPS unsigned int setCarRotateLeft unsigned int speedMMPS 0 Set the car for rotate left This will lie within the range specified a...

Страница 84: ...1000 Set the car stop in 1000 milliseconds This will lie within the range specified at Omni3WD setCarSpeedMMPS Parameters unsigned int ms 1000 The time to stop the car initialize it See Omni3WD getCa...

Страница 85: ...getSpeedMMPS See MotorWheel getSpeedMMPS unsigned int wheelLeftSetSpeedMMPS unsigned int speedMMPS 0 bool dir DIR_ADVANCE Set the speed for the left wheel This will lie within the range specified at...

Страница 86: ...heel PIDRegulate void delayMS unsigned int ms 100 bool debug false The time used for the car work as the same action In the function every 10 milliseconds it will call the function PIDRegulate once ti...

Страница 87: ...s turn right STAT_LEFT The car s state is turn left unsigned char getCarStat const Get the state of the car return The car s state Motor _state enum Used to configure the behavior of a motor Note that...

Страница 88: ...ed char stat The state want to set return Carstate if the stat in the range of the want STAT_UNKNOWN otherwise unsigned char _switchMotorsStat Switch the motors state unsigned char setSwitchMotorsStat...

Страница 89: ...setCarRotateLeft set car rotate left Omni3WD setCarRotateRight set car rotate right for int i 0 i 6 i there are six base actions this carAction i 0 choose one of the six actions setCarSpeedMMPS speed...

Страница 90: ...eel3 Wheel2 Wheel1 irqISR irq1 isr1 Intterrupt function on the basis of the pulse work for wheel1 MotorWheel wheel1 9 8 6 7 irq1 This will create a MotorWheel object called Wheel1 Motor PWM Pin9 DIR P...

Страница 91: ...le PID void loop Omni demoActions 100 5000 1000 false Call the demoActions speedMMPS 100 duration 5000 uptime 1000 Omni setCarLeft 0 Omni setCarSpeedMMPS 300 1000 Omni delayMS 10000 true Omni setCarSl...

Страница 92: ...www nexusrobot com Robot Kits manual 88 Diagram for Omni3WD_V1 0...

Страница 93: ...Wiring Diagram for Omni3WD_V1 0 Tis code is matched for it Diagram_Omni3WD_V1 0 code Power Switch Sonar0x11 M3 M2 INT0 INT1 Sonar0x12 Sonar0x13 M1 include fuzzy_table h include PID_Beta6 h include Pin...

Страница 94: ...r Trigger sonar12 else if sonarCurr 2 distBuf 2 sonar13 getDist Ger the value of distance from sonar13 sonar13 trigger Trigger sonar13 else distBuf 0 sonar11 getDist Ger the value of distance from son...

Страница 95: ...D STAT_LEFT Omni setCarSlow2Stop 500 Omni setCarLeft speedMMPS Set car turn left else if distBuf 0 distance If the front have something if Omni getCarStat Omni3WD STAT_ROTATERIGHT Omni setCarSlow2Stop...

Страница 96: ...www nexusrobot com Robot Kits manual 92 Diagram_Omni3WD_V3 3...

Страница 97: ...3 Tis code is matched for it Diagram_Omni3WD_V3 3 code Power Switch Sonar0x11 Sonar0x16 Sonar0x12 M3 IR03 M2 IR02 Sonar0x15 Sonar0x13 Sonar0x14 M1 IR01 include fuzzy_table h include PID_Beta6 h inclu...

Страница 98: ...rr 3 sonarCurr 1 else sonarCurr if sonarCurr 1 The conditions is ture distBuf 1 sonar12 getDist Get the value of distance from sonar12 distBuf 4 sonar15 getDist sonar11 trigger Trigger sonar11 sonar14...

Страница 99: ...5 PhaseB irqISR irq3 isr3 MotorWheel wheel3 3 2 4 5 irq3 Pin3 PWM Pin2 DIR Pin4 PhaseA Pin5 PhaseB MotorWheel wheel3 5 4 2 3 irq3 Omni3WD Omni wheel1 wheel2 wheel3 This will create a Omni3WD object ca...

Страница 100: ...something Omni setCarLeft speedMMPS else if distBuf 4 distance distBuf 5 distance Left side have something Omni setCarRight speedMMPS else if distBuf 0 distance distBuf 3 distance IRs 0 Omni setCarRo...

Страница 101: ...gle wheel Programmable with c c Based on Arduino microcontroller RB009_4WD Mecanum wheel Simple Base 4WD 100mm Omni wheel DC motors with encoders Microcontroller and IO expansion board Idea platform t...

Страница 102: ...heelUL wheelUL _wheelLL wheelLL _wheelLR wheelLR _wheelUR wheelUR setSwitchMotorsStat MOTORS_FB Construct a new Omni4WD instance in your sketch This will create a Omni4WD object called Omni4WD You can...

Страница 103: ...he motor run initialize it bool dir DIR_ADVANCE The direction the motor run See Omni4WD wheelULSetSpeedMMPS Omni4WD wheelLLSetSpeedMMPS Omni4WD wheelLRSetSpeedMMPS Omni4WD wheelURSetSpeedMMPS unsigned...

Страница 104: ...l lie within the range specified at Omni4WD wheelULSetSpeedMMPS and Omni4WD wheelLLSetSpeedMMPS and Omni4WD wheelLRSetSpeedMMPS and Omni4WD wheelURSetSpeedMMPS and Omni4WD setCarstat Parameters unsign...

Страница 105: ...and Omni4WD setCarstat Parameters unsigned int speedMMPS 0 The speed for the motor run initialize it See Omni4WD wheelULSetSpeedMMPS Omni4WD wheelLLSetSpeedMMPS Omni4WD wheelLRSetSpeedMMPS Omni4WD whe...

Страница 106: ...specified at Omni4WD setCarstat and Omni4WD setMotorAllAdvance Parameters unsigned int speedMMPS 0 The speed for the car moves initialize it See Omni4WD setCarstat Omni4WD setMotorAllAdvance unsigned...

Страница 107: ...igned int speedMMPS 0 Set the car upper Right This will lie within the range specified at Omni4WD wheelULSetSpeedMMPS and Omni4WD wheelLLSetSpeedMMPS and Omni4WD wheelLRSetSpeedMMPS and Omni4WD wheelU...

Страница 108: ...Omni4WD getCarSpeedMMPS Parameters unsigned int speedMMPS 0 The speed for the car moves initialize it unsigned int ms 1000 The time used for the to moves the car at this speed See Omni4WD getCarSpeedM...

Страница 109: ...i4WD getCarSpeedMMPS unsigned int wheelULGetSpeedMMPS const Get the speed of the upper left wheel This will lie within the range specified at MotorWheel getSpeedMMPS See MotorWheel getSpeedMMPS unsign...

Страница 110: ...peedMMPS unsigned int wheelURSetSpeedMMPS unsigned int speedMMPS 0 bool dir DIR_ADVANCE Set the speed for the upper right wheel This will lie within the range specified at MotorWheel setSpeedMMPS Para...

Страница 111: ...Proportional term initialize it Float taui Integral term Float taud Derivative term Unsigded int interval The time the PID work last see MotorWheel PIDEnable bool PIDRegulate Regulate the PID in orde...

Страница 112: ...nown STAT_STOP The car s state is stop STAT_ADVANCE The car s state is moves forward STAT_BACKOFF The car s state is get back off STAT_RIGHT The car s state is turn right STAT_LEFT The car s state is...

Страница 113: ...getSwitchMotorsStat const Get the state of the Motor return The motor s state Private parameters MotorWheel _wheelUL A point named _wheelUL as the object of MotorWheel MotorWheel _wheelLL A point nam...

Страница 114: ...ons unsigned int speedMMPS 100 unsigned int duration 5000 unsigned int uptime 500 bool debug false A demo function for four wheels car to show void Omni4WD demoActions unsigned int speedMMPS unsigned...

Страница 115: ...not available in function pointer setCarSpeedMMPS speedMMPS uptime in the uptime the car s speed accelerate from 0 to speedMMPS delayMS duration debug the car s state last duration times setCarSlow2St...

Страница 116: ...Omni4WD h include PID_Beta6 h include PinChangeInt h include PinChangeIntConfig h Include the header files wheel1 wheel4 Left Right wheel2 wheel3 Right Left irqISR irq1 isr1 Intterrupt function on the...

Страница 117: ...id setup TCCR0B TCCR0B 0xf8 0x01 warning it will change millis TCCR1B TCCR1B 0xf8 0x01 Pin9 Pin10 PWM 31250Hz TCCR2B TCCR2B 0xf8 0x01 Pin3 Pin11 PWM 31250Hz Omni PIDEnable 0 31 0 01 0 10 Enable PID vo...

Страница 118: ...www nexusrobot com Robot Kits manual 114 Sample Wiring Diagram for RB011 Mecanum 4WD V4 1...

Страница 119: ...e PinChangeInt h include PinChangeIntConfig h include SONAR h Include the header files Sonar 0x12 M3 M2 Sonar 0x13 Sonar 0x11 Power Switch M4 M1 Sonar 0x14 irqISR irq1 isr1 Intterrupt function on the...

Страница 120: ...riable save a data used to flag the state of sonar if sonarCurr 4 sonarCurr 1 else sonarCurr if sonarCurr 1 The conditions is ture distBuf 1 sonar12 getDist Get the value of distance from sonar12 sona...

Страница 121: ...RotateRight 0 Omni setCarSpeedMMPS speedMMPS 300 void rotateLeft unsigned int speedMMPS if Omni getCarStat Omni4WD STAT_ROTATELEFT Omni setCarSlow2Stop 300 Omni setCarRotateLeft 0 Omni setCarSpeedMMPS...

Страница 122: ...te if sonarcurrent 4 unsigned char bitmap distBuf 0 distance right Four of every byte bitmap distBuf 1 distance 1 back bitmap distBuf 2 distance 2 left bitmap distBuf 3 distance 3 front motion bitmap...

Страница 123: ...Includes microcontroller and motors it is programmable Programming is performed by connecting to your PC and writting programs There are still pre drilled holes of screw and its firm aluminum alloy b...

Страница 124: ...MOTOR1_E 36 reverse run motor 1 analogWrite MOTOR2_E 32 reverse run motor 2 analogWrite MOTOR3_E 34 reverse run motor 3 void allStop analogWrite MOTOR1_E 48 stop run motor1 analogWrite MOTOR2_E 44 sto...

Страница 125: ...its manual 121 pinMode MOTOR1_E OUTPUT Define the pin Mode as OUTPUT pinMode MOTOR2_E OUTPUT pinMode MOTOR3_E OUTPUT Serial begin 19200 void loop demotion Call the demotion Sample Wiring Diagram for 3...

Страница 126: ...pin define MOTOR3_E 11 define the pin 11 as the motor3 s pwm signal control pin unsigned short distBuf 3 unsigned char sonarUpdate static unsigned int sonarCurr 1 if sonarCurr 3 sonarCurr 1 else sona...

Страница 127: ...gWrite MOTOR2_E 40 Revese analogWrite MOTOR3_E 40 Revese void RotateRight analogWrite MOTOR1_E 66 forward analogWrite MOTOR2_E 62 forward analogWrite MOTOR3_E 64 forward void RotateLeft analogWrite MO...

Страница 128: ...on judge if the time more than SONAR duration currMillis millis sonarcurrent sonarUpdate if the requirement was ture call the function if sonarcurrent 3 unsigned char bitmap distBuf 0 20 front bitmap...

Отзывы: