PuP - Pretty useless Playtoy
PuP - Pretty Useless Playtoy
PuP is just a hack of an old toy that was getting thrown away. Honestly the factory function was likely as entertaining as he is now as it would bark, bark, and drive forward and backwards… but only over and over again. Now he can “see” what’s around him and respond in a couple different manners. Still only forward and backwards but he does move at least.
Original Plans / New Plans
Originally my thoughts were pretty grand for such a small little thing. I wanted a Pro-Mini, LiPo battery, sonar, sound, IR receiver, LDRs, a wagging tail, servo head, RGB mouth, a piece of metal on top of his head using touch sensing for petting, and more. BUT the reality of getting just the CPU and battery inside the small ½ section of the body stopped those plans. I had even thought about using a “leash” to power him to remove battery needs and make more room for CPU, etc but wasn’t sure how well that would have worked out.
I still really wanted PuP to move forward and backwards, talk, and have a sonar for eyes though. So after some success with an ATTiny85 on Buford and Buzz I figured that may work for PuP. So the plan was scaled back to ATTiny85, sonar, speaker, RGB LED, and home brew transistor H-Bridge.
Pup was decapitated, man that sounds harsh but that’s what happened, and a 9g servo replaced his head after some “plastic surgery”. Once mounted up a couple face options came to mine but the easiest route was taken. Servo horn, 4 pin header mount, piece of metal across the top and some brown printer paper for ears worked for me. I found another small speaker, glued it up in between the sonar “eyes” and then thought about what to do for light output, tongue or something..
By now I was already running out of pins with the 5 pin limit for an ATTiny85. I already had 1) Forward drive, 2) Reverse drive, 3) Single Pin Sonar, 4) Speaker Output, and 5) Head servo… Actually I was already OUT of pins but I wanted PuP so have some light of some sort!
So the first thing I tried was paralleling the Red of the RGB with the speaker output. That works but you can barely see it as the output is pulsed and the speaker takes most of the current. Next I hooked the green and blue up across the forward and backwards output pins. Since the pins go HIGH to make him move and the RGB LED has a common POSITIVE lead, the Blue and Green stay ON while sitting still and go off depending on if PuP is moving forward or backwards. Works at least and gives a little light show.
Making It Fit
Getting it all to fit was still a challenge, even with the ATTiny85. I had to make sure I could get to the ATTiny85 to pull it to reprogram it the million or so times it takes me to get code right. Plus I had to fit the battery and the tiny Pololu 5v step up/down regulator in to make sure the sonar would run at 5v properly. It kind of worked, I really should have put the regulator on top of the battery and the ATTiny board in the rear but too late at that point. I had to do some more plastic surgery to get the top half to mount properly and now PuP has his “brain” sticking out of his back a little but hey, he’s just a PuP.
Fitting things on the head wasn’t quite as complicated. I needed to get signals power to the sonar, LED and speaker and signals back for each as well. I ended up tapping of the power and ground on the sonar and then added a couple more female headers for the speaker and LED. I actually have an extra wire running from head to body now but do not see anything to use it for.
The unique thing about PuP is how he “walks”. There is only ONE motor deep inside his guts. It drives some gears that then drive the balls on his feet which are splayed out. As the balls turn together one direction, he moves forward, the other direction, in reverse. Looks nice and functions pretty good actually.
One thing I did NOT realize until he was completed was the right front leg not turning when he backs up is apparently a “feature” I was unaware of. I thought there was a problem or broken issues with him until I watched it a couple times in action. This allows PuP to move reasonably straight forward but to turn by backing up to the right. Like some real cheap RC cars you see that only have forward / reverse but turn when backing up.
This is something I really need to take advantage of when I further develop the code for him to allow him to roam around a bit more.
PuB - Pretty useless Brain
PuPs brain is pretty simply, but has room to grow if I want it to since it’s only about ½ full at this time. Right now he starts out just sitting there staring out to the world. If you get close enough he’ll lock onto you hand and try to follow you, if you move too close though he’ll back up, and if you get super close he starts to get worried, his voice goes up in pitch, and he turns his head away and continues to back up. Get even closer and he turns his head the other direction like “get away from me!”
The next step is to add some more modes to him such as roaming while looking around and just avoiding things. Trick here is there is no easy way to swap modes as I am out of input pins so I will likely use my old tick like on Chomper and others of getting in his face as a mode changing option.
Obviously some random features of just getting bored, looking around, making some sounds etc if not stimulated for awhile need to be added as well. Just makes it a bit more enjoyable to mess with.
Closing - Good Results from Bad Code
MaxHires and I were chatting in the shoutbox about “unintended good results of bad code”. Max said he has had that happen in the Apple coding days with graphics where code errors can generate some awesome artistic results.
PuP has a very simple example of this in my opinion. I am using the SoftwareServo library in PuP. It works but is a little different in that it requires you to constantly call the SoftwareServo:Refresh routine to keep the servo moving and in place. Since I am not using a library to read the sonar on one pin, I have to go read sonar and wait a bit so the refresh doesn’t always happen as quickly as it needs to.
One result of this is that sometimes, if PuPs head is turned away 90 degrees, he doesn’t just snap it back to front and center when he’s done hiding, he kind of bumps it a couple times when the refresh hits. Which is actually more “natural” than speeding back to center. This results without any intentional coding on my part. Heck if I TRIED to do it, it would likely not work at all.
My TED robot has a similar effect in that in some instances he seems alarmed and jerks back when he sees something while walking. Reality is I’m not handling the object detection cleanly and am jumping to different servos positions but it still “works” well.
So go build, go code, and sometimes, leave the bugs in… may make it a bit more fun!