Raspberry Pi RoboPi Скачать руководство пользователя страница 22

RoboPi v1.00

User Manual v0.85

Copyright 2014 William Henning

A/B Two Wire interface

For two wire drivers, use 

digitalWrite()

 to set the direction you are 

NOT

 going in to 0, then use 

analogWrite()

 to control the motor speed using pulse width modulation for the direction you want the 

motor to turn. Please note that the minimum speed will likely be higher for two wire motors, and 
different for different motors.

The inexpensive low current L9110S h-bridge is one example of a two wire A/B interface, however 
many L293D and L298 boards tie EN high to effectively become two pin drivers.

A B

Function

0  0

Break

0  1

Rotate in one direction

1  0

Rotate in opposite direction

1  1

Break

EN/DIR/PWM Three Wire Driver

Some motor drivers will have an EN signal, but use extra logic to to use one pin as motor direction, and 
another as a PWM input to control the motor speed.

For these drivers, use 

digitalWrite()

 to set the enable and direction pins, then use 

analogWrite()

 to 

control the motor speed using pulse width modulation. Please note that the minimum speed will be 
different for different motors.

DIR/PWM Two Wire Driver

Other motor drivers use extra logic to to use one pin as motor direction, and another as a PWM input to 
control the motor speed.

For these drivers, use 

digitalWrite()

 to set direction pin, then use 

analogWrite()

 to control the motor 

speed using pulse width modulation. Please note that the minimum speed will be different for different 
motors.

http://Mikronauts.com

22

2014-01-27

Содержание RoboPi

Страница 1: ...Henning Using RoboPi Copyright 2014 William Henning RoboPi User Manual v0 85 Photo 1 Fully assembled RoboPi v1 00 The most up to date documentation will always be available at http www mikronauts com...

Страница 2: ...ep 4 Using the Raspberry Pi serial port with RoboPi 9 Step 5 Installing RoboPiLib 10 Step 6 Installing the RoboPi Firmware 10 Step 7 Installing SimpleIDE for the Raspberry Pi OPTIONAL 10 Introducing R...

Страница 3: ...2 Why the ENABLE signal of three wire drivers is useful 23 Two pin motor driver sample code 24 How to Read Analog Distance Sensors 26 How to Read Digital Ultrasonic Range Sensors 27 Supported Ultrason...

Страница 4: ...r selectable power from Pi s 5VDC supply or external servo power supply P8 P15 jumper selectable power from Pi s 5VDC supply or external servo power supply P16 P23 is powered by 5V from the Pi expansi...

Страница 5: ...ile wiring your robot after assembling your RoboPi PLEASE NOTE The PROPPLUG connection is for stand alone RoboPi operation where RoboPi is NOT stacked on top of a Raspberry Pi Pins 1 4 are the same as...

Страница 6: ...processor pins 3v3 I O only connects to signal pin on SERVO9 16 through a 2k4 current limiting resistor 5V I O safe For the servo header SV3 selects between the Pi s 5V and VBat from the screw termina...

Страница 7: ...EXP3 3v3 Expansion Connectors EXP1 is for Propeller pins P0 P7 and servo connectors 1 8 EXP2 is for Propeller pins P8 P15 and servo connectors 9 16 EXP3 is for Propeller pins P16 P23 and sensor connec...

Страница 8: ...ters to make a bootable Raspbian SD card Step 1 Get a compatible Class 10 speed SD card 8GB 32GB in size You can find a database of SD cards that are known to work with the Raspberry Pi at http elinux...

Страница 9: ...isplay boot messages after which it becomes a serial console My favorite small text editor is joe which you can install with sudo apt get install joe then sudo joe boot cmdline txt remove console ttyA...

Страница 10: ...uts com raspberry pi robopi You will also need to download the latest version of propeller_load zip from the product page Step 7 Installing SimpleIDE for the Raspberry Pi OPTIONAL You only need to ins...

Страница 11: ...available for both Python and C and the native Spin object uses the same API as RoboPiLib The Python interface that is almost identical to the C interface all you have to do is prefix the library func...

Страница 12: ...RoboPi v1 00 User Manual v0 85 Copyright 2014 William Henning http Mikronauts com 12 2014 01 27...

Страница 13: ...t pin to one of INPUT OUTPUT SERVO PWM digitalRead pin returns int returns 0 or 1 state of pin digitalWrite pin val sets pin to 0 or 1 analogRead chan returns int returns 0 1023 from specified channel...

Страница 14: ...igitalWrite int pin int val sets pin to 0 or 1 int analogRead int chan returns 0 1023 from specified channel int analogReadRaw int pin returns 0 4095 from specified channel void analogWrite int pin in...

Страница 15: ...the top level Spin object for implementing the functionality that is exposed by the firmware and as such it can be used directly from Spin programs running on RoboPi s Propeller micrcocontroller Plea...

Страница 16: ...nalogRead chan read analog input channel scale to 0 1023 return value analogReadRaw chan read analog input channel return raw 0 4095 value analogWrite pin value write PWM value to pin 0 is off 255 is...

Страница 17: ...s to ground when closed include stdio h include RoboPiLib h define LEFT_BUMPER 22 define RIGHT_BUMPER 23 define PRESSED 0 int main int argc char argv RoboPiInit dev ttyAMA0 115200 pinMode LEFT_BUMPER...

Страница 18: ...pins through 470R resistors include stdio h include RoboPiLib h define LEFT_BUMPER 22 define RIGHT_BUMPER 23 define LEFT_LED 8 define RIGHT_LED 9 define PRESSED 0 int main int argc char argv RoboPiIn...

Страница 19: ...rt schematic of CdS circuit Connect a 10K pullup to the signal pin of an analog input to 5V also connect one side of the CdS to the signal pin Connect the other leg of the CdS to GND Use analogRead ch...

Страница 20: ...SERVO_MIN i SERVO_MAX i 100 servoWrite LEFT_SERVO i servoWrite RIGHT_SERVO SERVO_REV i printf LEFT SERVO d n servoRead LEFT_SERVO printf RIGHT SERVO d n servoRead RIGHT_SERVO sleep 1 Controlling a Con...

Страница 21: ...note that the minimum speed will be different for different motors Some driver boards permanently tie EN high in order to use only two pins however I do not recommend this practice as it is harder on...

Страница 22: ...tate in opposite direction 1 1 Break EN DIR PWM Three Wire Driver Some motor drivers will have an EN signal but use extra logic to to use one pin as motor direction and another as a PWM input to contr...

Страница 23: ...speed control is used both inputs are guaranteed to be driven low during the off period of the PWM signal which will short the two motor leads actively breaking This is less than ideal for the motor...

Страница 24: ...TORB_IA 14 define MOTORB_IB 15 int main int argc char argv int i RoboPiInit dev ttyAMA0 115200 while 1 set both motors FORWARD pinMode MOTORA_IA PWM pinMode MOTORA_IB OUTPUT digitalWrite MOTORA_IB 0 p...

Страница 25: ...h motors REVERSE pinMode MOTORA_IA OUTPUT digitalWrite MOTORA_IA 0 pinMode MOTORA_IB PWM pinMode MOTORB_IA OUTPUT digitalWrite MOTORB_IA 0 pinMode MOTORB_IB PWM for i 0 i 256 i 16 analogWrite MOTORA_I...

Страница 26: ...ble at ranges shorter than 15cm Unfortunately the output voltage is not linear with respect to the distance to the object however it is easy to construct a table of voltages corresponding to the dista...

Страница 27: ...ted should function SEEDSTUDIO_136B not tested How to connect your ultrasonic range sensor HC SR04 pin RoboPi Pin use any of 24 servo three pin headers Vcc Servo header red wire any of 24 servo three...

Страница 28: ...minal of power selection header SV2 or SV3 Supply GND to RoboPi via one of pins 9 14 of the Pi Header GND terminal of the external motor power screw terminal If you will never mount your RoboPi on a R...

Страница 29: ...u can find the data sheets for the listed Digikey part numbers at Digikey com by typing in the part number and clicking on the pdf icon on the resulting page Appendix C Support For Raspberry Pi suppor...

Страница 30: ...EEPROM use MCP3208 While there is no motor driver on RoboPi if you connect a two channel motor controller as follows it will be RoboProp compatible Tie EN1 2 and EN3 4 high P8 to IN1 P9 to IN2 P10 to...

Страница 31: ...distributors Please contact us for a custom quote Q Can we make our own RoboPi printed circuit boards A I am afraid not While RoboPi is an open platform in that it is fully documented with source code...

Отзывы: