background image

 

 

 

 

 

 

 

User’s Manual 

Rev. 1.1.0 

 

 

Summary of Contents for STEMBoT 2

Page 1: ...User s Manual Rev 1 1 0 ...

Page 2: ...ogrammable Hardware Components 4 2 1 0 Multicolor LED 4 2 2 0 Switches 4 2 3 0 Buzzer 4 2 3 1 Playing Songs from the Board 4 2 3 2 Creating Songs using RTTTL 4 3 0 0 Liquid Crystal Display LCD 4 3 1 0 Colors 4 3 2 0 Text 4 3 3 0 Shapes 4 3 3 1 Drawing Rectangles 4 3 3 2 Drawing Circles 4 3 3 3 Drawing Triangles 4 4 0 0 Radio Remote Controller 4 4 1 0 Initialization and Configuration 4 4 2 0 Readin...

Page 3: ...dule 4 6 3 3 Reserved 4 6 3 4 Reserved 4 6 3 5 Reserved 4 6 3 6 Reserved 4 6 3 7 SHT21 Temperature Humidity Sensor 4 6 3 8 MPU6050 Motion Processing Unit 4 7 0 0 Servos 4 7 1 0 Servo Calibration 4 7 2 0 Angles and Timing 5 0 0 0 Mobile Commander 6 0 0 0 Troubleshooting 7 0 0 0 Module Class Function Quick Reference Revision 1 1 0 January 2021 ...

Page 4: ...2 The STEMBoT 2 is the ultimate platform for learning how to program using the Python programming language With the proliferation of technology in our everyday lives it s as important as ever to develop an understanding of programming and computer science topics Python is one of the most popular programming languages in fields such as data science financial services and artificial intelligence but...

Page 5: ...losure which is mounted to the front of the aluminum chassis The stepper motors are mounted underneath the enclosure and plugged into the motor headers closest to each motor The battery is affixed to the chassis via velcro tape and a plastic cable hook attached with a screw and nylock nut The omnidirectional wheels are attached to the rear of the chassis facing inwards and at the bottom of the scr...

Page 6: ...rating the robot The controller is a standard XBox controller design with custom internal hardware 2 3 1 0 Pairing the Remote Controller To pair the remote navigate to Tools on your STEMBoT 2 and then click the B button to enter into the pairing mode Next press the sync button on the remote near to Left button bumper After it says Successfully paired you can then drive your bot by selecting the re...

Page 7: ...mputer must be unmounted before the USB cable is removed Failure to do so could corrupt data in transit making the STEMBoT 2 inoperable 4 1 1 0 Programming via Serial Communication After selecting the Exit to Python REPL option in the main menu the SB2 can be accessed through a serial communication program This allows programming in Python on a line by line basis Connect to the SB2 using your seri...

Page 8: ...H drive Restart the SB2 by pressing the blue reset button On the main menu the new program titled new led should appear Running this program will turn on the blue LED just above the SB2 display Note Due to the nature of the boot py file main function headers should start with the keyword async for example async def main Caution When changing data on the SB2 via this method the red LED will turn on...

Page 9: ...is program will turn off the main LED then cycle through its red green and blue components blinking each of them twice in an infinite loop import pyb grants access to the LED class import uasyncio grants access to asynchronous delays very useful async def main standard header for programs in the apps folder x 1 while x 4 turn off LEDs 1 through 3 all of them pyb LED x off turn off the x LED x 1 in...

Page 10: ...witch class in the switch module Caution The Pin function of the machine module can also be used to access other pins on the SB2 s main microcontroller Changing the function or value of certain pins may render critical functions of the SB2 inoperable As an example of how the switches work open a serial connection to the SB2 Type in the following lines pressing enter after each one from switch impo...

Page 11: ...r is the title of the tune The next set of parameters are d o and b which represent the default note the default octave and the tempo respectively For d 1 represents a whole note 2 is a half note 4 is a quarter note etc The o sets the default octave between 4 and 7 but individual notes can be programmed for different octaves if need be The b is the tempo given in beats per minute bpm The last set ...

Page 12: ... displayed These colors can be created by using the RGB function of the color module This function takes three parameters numbers between 0 255 corresponding to red green and blue Open a serial communication with the SB2 Input the following lines of code to demonstrate the basic functions of the lcd module import graphics import color red color RGB 255 0 0 graphics paint red Program 6 Coloring the...

Page 13: ... Program 7 Hello world Text that has been written using the print function can be erased using the erase function This function accepts four arguments as well the number of characters to be erased the x location the y location and the color The x and y locations should be the same as those sent to the print function The color should be the background color on which the characters have been written...

Page 14: ...shapes and other objects to be printed with ease graphics gfx GFX lcdWidth lcdHeight LCD lcd pixel async def main standard header LCD paint bgColor fill the screen x 1 set up variable to count while True infinite loop Print the time to the LCD the curly brackets allow numbers to be printed as strings when using the format method LCD lcd text Time format x 40 90 textColor Wait for 1 second to pass ...

Page 15: ...ectangles are rectangle and fill_rectangle The first function draws the outline of the shape while the second fills in the shape with a given color Both of these functions take five parameters the starting x and y coordinates the desired width the desired height and the color 4 3 3 2 Drawing Circles The two functions available for drawing circles are circle and fill_circle The first function draws...

Page 16: ...re s also a distance function that commands the motors to move a given number of steps at a given speed To begin using the motors turn them on by setting the sleep mode to false with sleep False as shown in the next program 4 5 2 0 Speed and Acceleration The speed method is used for setting a constant immediate speed or for accelerating to a given speed in a given period of time Passing no paramet...

Page 17: ...nd and will take 1 second to transition to that speed rightMotor speed 200 1000 do the above spin for 5 seconds await asyncio sleep_ms 5000 Program 11 Spinning Robot 4 5 3 0 Distance and Time The distance method accepts 4 parameters the distance to move in steps the speed the acceleration and blocking mode The speed and acceleration are the same as in the speed method If the blocking mode is set t...

Page 18: ...top can also be used to access this port The other ports J8 and J10 are also called left and right The individual pins can be accessed through the GPIO class like in the following example port pin 3 on turn on pin 3 SDA port pin 3 off turn off pin 3 port pin 3 returns either 1 or 0 if the pin if high or low The GPIO class of the uext module also contains two functions for turning all of the pins o...

Page 19: ...f functions The value function can be used to determine if the pin is high 1 or low 0 pinTX on pinTX off pinTx value this will return 0 since it was just turned off Note Toggling can be done at 35 7kHz T 2 13 3us Initial test 4 6 2 0 Serial Communication 4 6 2 1 Reserved 4 6 2 2 Reserved 4 6 2 3 Inter Integrated Circuit I2C I2C objects are created using the machine module Initially the user must s...

Page 20: ...rst i2c machine I2C 1 freq 9600 i2c writeto address fetchTemp False send command to address tempData i2c readfrom address 3 read three bytes store in tempData Program 12 Controlling an SHT21 PnP Module Manually Writing and reading via I2C to a register based device is done similarly The two relevant functions writeto_mem and readfrom_mem_into require an integer for the device and register addresse...

Page 21: ...y default Program 13 Displaying the Number 7 on the SSD PnP Module Note Using the displayNumber method automatically clears the previous number display but does not affect the decimal point 4 6 3 3 Reserved 4 6 3 4 Reserved 4 6 3 5 Reserved 4 6 3 6 Reserved 4 6 3 7 Reserved 4 6 3 8 Temperature Humidity Sensor This module uses an SHT21 sensor for detecting temperature and relative humidity The SB2 ...

Page 22: ... three values the acceleration or angular velocity along the x y and z axes Figure 2 MPU 6050 Orientation from InvenSense Example serial import pnp mpu pnp MPU top make sure the module is plugged into the top port ax ay az mpu getAcceleration place values in ax ay and az gx gy gz mpu getAngularVelocity place values in gx gy and gz Program 13 Getting Motion Data from MPU6050 PnP Module Since this d...

Page 23: ... microseconds and should be provided with the servo s datasheet Regardless calibration should be completed to achieve optimal results Note Although the SB2 comes pre calibrated it is highly recommended that this procedure is followed for any new servo Once new calibration values are found they should be recorded for repeated use 1 Create a serial connection between your computer and the SB2 2 With...

Page 24: ...o Note The servo used for testing this procedure smraza S51 gave good results with S1 calibration 550 2475 1500 4 7 2 0 Setting Angles As demonstrated in the calibration procedures setting angles can be done with the angle function This function will accept parameters between 90 and 90 which determines the servo angle with 0 being the center position Using the function without parameters returns t...

Page 25: ... enter REPL mode Enter raw REPL mode Raw REPL is like REPL except for the following there is no prompt characters which are typed are not echoed back there is no auto indent i e prompt This mode is extremely convenient for programs as opposed to humans to use CTRL B enter normal REPL mode Gets you back to what s referred to as a the friendly REPL in the code This is the REPL that you normally see ...

Page 26: ...mmand i 1 j 23 x abc dir j x __name__ pyb i dir shows that you have some variables in the local scope Press Control D and they all get wiped out PYB sync filesystems PYB soft reboot MicroPython v1 5 51 g6f70283 dirty on 2015 10 30 PYBv1 0 with STM32F405RG Type help for more information dir __name__ pyb CTRL E paste mode This allows you to paste in functions from your computer without getting messe...

Page 27: ...rint Here is a second line foo Traceback most recent call last File stdin line 3 IndentationError unexpected indent Whereas with paste mode you d see paste mode CTRL C to cancel CTRL D to finish def foo print This is a test to show paste mode print Here is a second line foo This is a test to show paste mode Here is a second line Revision 1 1 0 January 2021 ...

Page 28: ...ove you replaced the second line with redLED pyb LED 1 it would function exactly the same The names of objects however must be kept in tact that is no spaces The line red LED py b LE D 1 would not work Module pyb Class LED i Used to access the tri color LED The parameter i can be either 1 2 or 3 to access the red green and blue LEDs respectively Method on Turns the LED on Method off Turns the LED ...

Page 29: ...d the color o Function fill_rectangle x y width height color Draws a rectangle starting at coordinate x y with a given width and height The shape is filled in with the given color Function circle x y r color Draws a circle centered around coordinate x y with a given radius r The circle will be drawn with the given color and have a thickness of 1 pixel Function fill_circle x y r color Draws a circl...

Page 30: ...e next line of code from being executed until the motor finishes moving Method stop Causes the motor to stop moving Function setWheelDiameter x Sets the wheel diameter in millimeters This value is used for distance conversions Default is 85 Function getWheelDiameter Returns the current wheel diameter in millimeters Function inches_to_steps x Converts the given number of inches to steps based on th...

Page 31: ...ons object Object L1_BIT L2_BIT L3_BIT R1_BIT R2_BIT R3_BIT Numerical value representing the left and right buttons L3 and R3 are the joystick buttons Used in conjunction with the RemoteData buttons object Object DPAD_UP_BIT DPAD_RT_BIT DPAD_DN_BIT DPAD_LT_BIT Numerical value representing the buttons on the directional pad Used in conjunction with the RemoteData buttons object Object A_BUTTON B_BU...

Page 32: ...MPU6050 position Used to access the methods of the MPU6050 accelerometer gyroscope plug and play module Accepts one parameter either top left or right Method getAcceleration Returns x y and z axis acceleration data in meters per second squared Method getAngularVelocity Returns angular velocity about the x y and z axes Data is returned in units of degrees per second Class OPT3001 position Used to a...

Reviews: