background image

2

SKILL 

LEVEL

Ringo Educational Guide Rev04.1 ~ Plum Geek

The function 

TxIRKey()

 is the easiest way to send commands from Ringo just like 

he was a remote control. You can use this to communicate with other Ringos. 

Have a look at the graphic below. This shows the “key number” for each of the 

keys on the remote control, as well as the actual data packet sent by each key. 

So by passing a given key number to 

TxIRKey()

, Ringo will send the packet 

corresponding to that key.

Advanced User Note: We are presently having problems with the TxIR 

functions which makes the reception of the packet somewhat spotty. It seems 

the Arduino delayMicroseconds() isn’t accurate enough to reliably time the 

packets. We would welcome any help from the user base to have a look at the 

TxIR function in the RingoHardware tab. We’d like to replace the several calls 

to delayMicroseconds() with something more accurate, like polling a timer or 

something.

1

0

X

A

B

MENU

2

3

4

5

6

7

8

9

00 FF 45 BA

00 FF 47 B8

00 FF 44 BB

00 FF 40 BF

00 FF 43 BC

00 FF 07 F8

00 FF 15 EA

00 FF 09 F6

00 FF 16 E9

00 FF 0C F3

00 FF 18 E7

00 FF 5E A1

00 FF 08 F7

00 FF 1C E3

00 FF 5A A5

00 FF 42 BD

00 FF 52 AD

00 FF 4A B5

00 FF 46 B9

00 FF 19 E6

00 FF 0D F2

Packet Sent by Keys

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15 16 17
18

19

20

21

IR Communication

Summary of Contents for Ringo

Page 1: ...Ringo Educational Guide Rev04 1 Plum Geek Ringo Educational Guide...

Page 2: ...ts Ringo is Open Source Hardware which means his design is open to study and learn from He wouldn t have been possible without others before us sharing their own open source creations with the world W...

Page 3: ...don t have to worry about discharging Ringo too far He will take care of himself if he is left on or run too long without a charge If you notice Ringo is tending to reset on his own it is likely beca...

Page 4: ...Reset Button This button connects to a special pin on Ringo s brain Whenever pressed it will halt Ringo s processing and when released Ringo will startup fresh from the beginning of his program This...

Page 5: ...ws Ringo to charge through the Programming Adaptor Normally this should be left in place It is however occasionally useful to remove this jumper As the battery in Ringo reaches its maximum charge leve...

Page 6: ...nux 32 bit 64 bit 1 In order to program your Ringo you ll need to download the newest version of the Arduino software first from www arduino cc it s free This software known as the Arduino IDE will al...

Page 7: ...nal Guide Rev04 1 Plum Geek 2 Visit www plumgeek com and follow the instructions to install the required driver for the programming adaptor It is super important that you do this before connecting the...

Page 8: ...n connect the Programming Adaptor to your Ringo robot using the supplied cable You will require a USB A to Mini B cable commonly supplied with digital cameras and the like Red Stripe on Cable Turn swi...

Page 9: ...time Warning Take care to not bend the pins when handling Ringo or attaching the programming cable TIP You don t need to press the ribbon cable all the way onto Ringo s programming pins Normally it l...

Page 10: ...ctive sketch Note the sketch is not saved automatically when uploading or verifying Serial Monitor This will open a window that display any serial information your Ringo is transmitting It is useful f...

Page 11: ...t Archive Sketch Fix Encoding Reload Serial Monitor dev tty usbmodem262471 dev cu usbmodem262471 dev tty Bluetooth Modem dev cu Bluetooth Modem dev tty FireFly 7256 SPP dev cu FireFly 7256 SPP dev tty...

Page 12: ...examples You will need to place the three library folders RingoMsTimer2 RingoWire and Adafruit_NeoPixel into your Arduino libraries folder You will also want to place the Ringo_Examples folder into y...

Page 13: ...uit_NeoPixel Copy the three folders RingoMsTimer2 RingoWire and Adafruit_NeoPixel into Arduino s folder named examples Find Arduino in your applications folder Right click ctrl click on Arduino Select...

Page 14: ...a tabs hide the background functions used by Ringo Rather than install them as a library in which case they wouldn t appear as tabs we ve included them with each sketch so more advanced users can easi...

Page 15: ...write or edit in the Arduino IDE The important parts of the code in a given example are highlighted in purple Opening Heading This area includes basic information about the program It is not actually...

Page 16: ...re more than one line to write There s a solution for that You can begin a comment block with a forward slash followed by a asterisk Then you can write as many lines of comment as you like You then en...

Page 17: ...go or until his battery runs too low and he shuts off automatically The loop function is where the bulk of you program usually lives void setup HardwareBegin initialize Ringo s brain to work with his...

Page 18: ...board without connecting headers we ve just connected the electronics directly to the microcontroller so many of the examples you ll find online are still applicable to Ringo Arduino Course for Absolu...

Page 19: ...s We owe them a huge high five for writing the code required to communicate with these awesome little lights Each light can have each of its red green and blue LEDs set to any level between 0 and 255...

Page 20: ...in project page above the line void setup Like this This include line will insert the RingoHardware h file which itself includes a special line include Adafruit_NeoPixel h By including RingoHardware h...

Page 21: ...ngo s brain to target the pixel at address 3 The next three numbers tell the pixel at address 3 how bright to turn on the red green and blue lights inside the pixel In this case the red is set to 0 so...

Page 22: ...red or green or blue Like PLUM You can easily create different colors by mixing different amounts of the three primary colors Red Green and Blue Try this example code Compile it load it and observe wh...

Page 23: ...his brain will usually remain active even during current limit When the current limit is engaged you will see the pixels and other current limited parts stop working or behave in strange ways This is...

Page 24: ...xels use this function to resume pixel operation If you spend more than five minutes learning how to code you will find your patience tested Writing code is really pretty simple but there is a small c...

Page 25: ...50 90 curley braces are wrong no workey SetPixelRGB 1 120 50 90 brackets are wrong no workey SetPixelRGB 1 120 50 90 correct semi colon This works SetPixelRGB 1 120 50 90 oops no semi colon upset comp...

Page 26: ...run this code Experiments Challenges void loop SetPixelRGB 4 255 255 255 set pixel 4 Right eye SetPixelRGB 5 255 255 255 set pixel 5 Left eye RefreshPixels Woah That s BRIGHT Now take Ringo into a da...

Page 27: ...o call the RefreshPixels after running it This function is most useful for turning off all the NeoPixel lights at the same time Occasionally if Ringo is reset or the User button is pressed during a co...

Page 28: ...nt with these on your own and you ll get the hang of using them OffPixels turns off all pixels OffPixel Address turns off a specific pixel OnEyes Red Green Blue makes eyes the given color LeftEye Red...

Page 29: ...es have sensors to see the edges of tables but he won t respond to them unless your code specifically tells him to do so We ll get to that eventually but these simple examples do not automatically loo...

Page 30: ...driving forward Then we tell his brain to wait one second with delay 1000 so he will drive forward for one second Then we set both of Ringo s motors to speed 0 with the command Motors 0 0 which makes...

Page 31: ...o move forward and the other motor to move backward Try using this command to set motor speed Motors 200 200 What happens This is causing the left motor to move at speed 200 in the forward direction a...

Page 32: ...uld be turning at the same speed right You would think Ringo would have been driving in a perfectly straight line but I m guessing he didn t though you may have gotten lucky this time and perhaps he d...

Page 33: ...n most robots require some way of sensing how they are moving Wouldn t it be smart if Ringo could somehow know that he was starting to veer to the right and automatically adjust the speed of his motor...

Page 34: ...straight on to Ringo while he is on a surface Look at the areas with the purple circles There should be a gap of about 1mm between the running surface and the lowest portion of Ringo s motor clip If...

Page 35: ...afts especially hair from your pets when he is run on the floor Usually this is easy to remove Using tweezers carefully pluck the hair off the shaft by rolling the shaft with your fingers A bit of hai...

Page 36: ...nd motor functions in the previous example and didn t even realize it Let s look at an example PlayChirp Frequency Amplitude You pass a frequency which is the pitch of the tone to be played in hertz A...

Page 37: ...r main loop function and see what happens Run the code on Ringo and see hear what happens You should hear a mid pitch tone for one second that then transitions to a higher pitch tone for one second th...

Page 38: ...reate interesting effects Like this Ringo should be playing the C Major chord every second If you work with the notes and timings it is possible to make Ringo play simple songs void loop PlayChirp NOT...

Page 39: ...has three inputs that can read the analog light sensors However there are actually six light sensors on Ringo s body there are the three ambient light sensors on the top side and there are also three...

Page 40: ...sson Let s load up the following code example and see what happens In previous examples we simply told Ringo to do something In this example we re going to read a value from a sensor Ringo needs to ma...

Page 41: ...d see this value go up You may notice a few interesting things First it is impossible to bring this value all the way down to zero This is beyond the scope of the lesson but the light sensor always le...

Page 42: ...rint sensorRear print sensorValue through serial port Serial println print a blank line feed Serial println print a blank line feed delay 250 delay 250 milliseconds Three sensors at once Reading one s...

Page 43: ...eye lights are turned off then the light sensors are read then the eye lights are turned back on immediately following it will appear that Ringo s eyes were lit up the entire time Try this code and s...

Page 44: ...ger seeing any after glow from having his eyes turned on As soon as this delay is complete we can go grab the three readings we want with analogRead functions As soon as the readings are complete we f...

Page 45: ...l movement For example if you keep Ringo in the same location but you rotate him in a turn the Gyroscope can be used to determine how many degrees he has rotated Taken together these sensors embody an...

Page 46: ...ertain speed and that taken over time can determine distance If the sensor data isn t read out every 80 milliseconds the memory inside the sensor called a buffer will overflow The overflow doesn t hur...

Page 47: ...Vibrations or wiggles on your table will adversly effect the calibration The sensors should be recalibrated every so often Keep in mind that it is useful to place a delay before each calibration to m...

Page 48: ...s Ringo to perform a turning movement or rotation It is not quite as accurate as the next rotation example but will arrive at the target rotation a bit more quickly The function takes five arguments a...

Page 49: ...stop immediately He will skid on the surface for some period of time Once the motors are turned off Ringo will continue to evaluate his gyroscope and wait for the readings to indicate that he has in f...

Page 50: ...st argument is Direction Ringo will attempt to turn to this direction as he begins driving Speed is the average motor speed he should try to maintain This will be adjusted up or down slightly between...

Page 51: ...an be positive or negative 0 to 255 for a distance of about 300 mm He will allow 2 seconds to complete the maneuver allow 100 milliseconds to come to a complete stop after the maneuver and he ll do it...

Page 52: ...s he starts to drive because he is trying to return to the 0 degree direction An easy way to avoid this is to always place GetHeading in place of the zero The GetHeading function reads Ringo s current...

Page 53: ...ntended to work together with three infrared light sources placed near the three light sensors Setup As stated in the previous chapter the LightSense lines to Ringo s brain are shared between the top...

Page 54: ...sent a couple super easy functions that automate the edge detection process How edges are measured The edge sensors are just light sensors mounted to Ringo s bottom side If Ringo is placed on a white...

Page 55: ...use each surface will reflect a different amount of light this difference value can be evaluated and we can draw some assumptions about the surface from the difference value Darker surfaces will refle...

Page 56: ...talWrite Edge_Lights HIGH turn on the IR light sources delayMicroseconds 200 let sensors stabilize leftOn analogRead LightSense_Left read sensors w IR lights on rightOn analogRead LightSense_Right rea...

Page 57: ...ke a short time for the sensor to stabilize to the new input level After we let the sensors stabilize to the new light level we read each of them We then do the same process after turning off the IR l...

Page 58: ...to determine if the left edge sensor has recently moved to a surface that is brighter or darker compared to the running average You can call LookAtEdge by itself on your own if you like Now lets get...

Page 59: ...e average determine if if any edges were seen place the coded binary result in the variable edge This edge variable will be zero if no edge was seen if FrontEdgeDetected edge do something if either fr...

Page 60: ...quick list FrontEdgeDetected True if either front edge sensor saw an edge BackEdgeDetected True if the rear edge sensor saw an edge RightDetected True if front Right edge sensor saw an edge LeftDetect...

Page 61: ...Ringo to communicate with other Ringos or devices around him digitalWrite IR_Enable_Front HIGH Enable Front IR source digitalWrite IR_Enable_RearLeft HIGH Enable RearLeft IR source digitalWrite IR_En...

Page 62: ...cation using the 3 IR sources The supplied remote control sends packets of 4 bytes each time a key is pressed so it is suggested that any IR communication use packets containing 4 bytes of data You ca...

Page 63: ...akes the reception of the packet somewhat spotty It seems the Arduino delayMicroseconds isn t accurate enough to reliably time the packets We would welcome any help from the user base to have a look a...

Page 64: ...ll this function the IR receive functions run in the background You don t need to do anything else to actually receive data When a 4 byte packet has been received IsIRDone will return a non zero which...

Reviews: