Monday, 27 October 2014

I2C Issues Fixed and Dome rewired

Man what a long weekend!  Painful.

I thought id fixed the I2C issues, so i started a little rewiring.

I  tried to rewire the Adafruit to bypass the power on the board and use a direct supply for each relay supply, and swap from the dome 5v supply to all run on the 12v main battery.

Only to find that the Adafruit Servo driver wouldn't boot. Could I work out why?  No!  I didn't think about the library at first!  :(  So i tried to fix that and rewire at the same time, i tried all sorts.  :(  Eventually i found the issues, partly the library, partly bad connections.  Sorted them and rewired the dome using a UBEC (3a with 5A peak) to power the whole dome. Then i had crashing on the Adafruit.  Nightmare.

Also a few power issues initially, one servo not moving well and intermittent issues, so i added a capacitor to the supply and that helped sort some of the problems.  But the crashing was still happening.

After a lot of head scratching, and trying lots with the library to fix it, i realized what was happening.  The crashes were only after or part way through commands sent from the master, so the issue was passing I2C from the body.  The I2C was loosing the network and freezing the adafruit.  I had forgotten to tie the GND to the 12v into the dome, with all the problems i had overlooked it, with that re-added it is spot on. :D  So i went back to the library and reverted to an earlier attempt at the library fix.

Basically, lesson learned.  Test and fix one bug at a time, but make sure you test it fully!

The fix for the I2C was too severe initially, i needed a longer time out.  My new TWI.c file is great.  The master and ESC control is constant regardless of what happens on the I2C network, and the Adafruit works seamlessly.  :D  I will finish my rewire and run it for a week or so and post when im happy.

But the dome is now running powered by the main battery, so I have lost a lot of weight in the dome and managed to drop the dome battery.  All for £6 of ubec. :D  Here you can see my daughter boards for the power and mu UBEC fitted:

Body rewire next.  Im still not sure im doing the best thing, but im learning as i go, so having tried both i can make an informed decision.

Thursday, 23 October 2014

FACTS Fallout - MAJOR I2C Arduino Issue

If you use any I2C Arduino based elements in your droid please read on.  The way the default Arduino Wire library works may cause significant issues if power is lost to any end unit. 

FACTS was a great weekend.  Loved it.  But R2 had a few issues, and James' B4 had a few too.

Before lunch on day one, my dome battery came lose and pulled a ton of wires out.  But no harm done, re connected and added more support for the battery.  He seemed fine after that for the rest of Saturday and Sunday morning.

At one point James' droid drove on without any control!  First time id seen it do that with the master powered and relays fitted.  He said it was when the dome battery died on him.  Not something i had expected, and not what id seen in testing, but im not sure i had tested that order of issues/events. But this had to be taken very seriously and investigated ASAP.

When i got back i got straight on the case to solve it.  Testing it showed that if you boot up, then pull the power on any I2C unit, then drive dome or feet and while driving, trigger any script call, the master has then either crashed or is frozen and cant stop the ESCs.

After some analysis I found that if any device on the I2C network looses power that will freeze the master on the next I2C send.  Meaning that if driving when you trigger, it will carry on driving!!!!!  Any unit failing, or any lose wires could cause it.  Not good.  

Was this a general I2C issue?

I looked on-line for solutions and to see if i could find any others with similar issues.  All i found was Mosfet and Isolator options and level shifters, that would have added a lot of complexity to the setup, and not been ideal for my problem.  After 2 nights of research i finally bit the bullet and ordered some MOSFETs.  

But then i had a brain wave!  What if the issues were possibly code related, and could be tweaked to fix it, or at least make it safe if there is an issue.  So researching from a different start point it soon became clear that the default 'Wire' library has some pretty major issues and would wait forever for the communication to complete if there was a problem.

So i tried to use a couple of custom alternative libraries.  No joy, they wouldn't work with the higher level I2CEasyTransfer library from Bill Porter.  So i had a good read of the library files of the alternatives, and did a bit more reading.  Eventually i found that i could edit the default library, adding timeouts to stop the freezing.  All i did was to edit the 'TWI.ccp' file and add a few counters to return a 0 if the timers' max was reached to break the while loops that kept it locked.

Looks like it is sorted.  Pull the power on any I2C item and the master will not freeze on script call, so the Feet and Dome can still be controlled no matter what happens.  The network still stalls, and the first script you send is actioned if you reconnect power, but that is no bother as you will likely turn the droid off before trying to fix the issue.

I then looked at my big issue.  Starting late Sunday morning, every time i had triggered a big script the body unit would reset, and cause other niggles, pause the I2C network and was really got on my nerves!  I assumed something relating to a low 12v battery maybe? After some mucking about, i found that it was only when the Utility Arms moved that it crashed.  So i unplugged them and he seemed fine.  

The resetting of the Arduino was the puzzler, the voltage for the servos should be from the Stepdown, so them moving shouldn't have caused that issue, especially not mid move.  So i checked a few voltages and found that the 12v body DC/DC supply was reading as 8v in and 5v out, odd.  So i went round the back and there is a big red light on one of the fuses on the rigrunner!  Muppet.  Blown fuse and I guess leaking current from the pwm pins leaking trough the servos making it almost work!  Easy fix, but may look at isolating the servo power more efficiently eventually.

So R2 is working well.  But.......

While researching i kept seeing that the max output power from an Arduino as 500mA.  Knowing that the Master is now powering those big relays, it must be getting close, i will try adding a 2nd feed for the relays and retest to make sure it works as before, but leaving the draw through the master much lower.

I also found that R2 wasnt quite loud enough at FACTs, only a little, but he needed more volume.  So i have ordered a variable step up converter for the amp supply, a little more voltage should help. :D

Im debating moving to UBEC supplies for the 5v and dropping the 5v batteries and other stepdowns.  I did last 2 days on the 12v but not on the 5v ones, so it seems pointless to fight it.  I might add an alternate dome battery that i can switch to, i like the dome to be able to run alone, for when i eventually do other domes. But it might help simplify the setup theory.

Should be a safer system all round now.  Thanks to another couple of real world system issues showing themselves, and figured out, really pleased those are sorted.  I still cant believe it was that easy to address, i suppose i got lucky.  The I2C error hasn't shown it'self before in 2 years on 2 droids, but still great to see and sort it without an incident. 

 I will finish applying and testing these fixes and i have an event on the 16th, so i can do a proper test.  If it passes i will update the doc and code.

Sunday, 12 October 2014

Upgrading to 2.1 from 2.0

Upgrading from 2.0 to 2.1 should be easy, and is highly recommended.  Just replace all the mp3 files (overwrite them to make sure) and upload all the new sketches for the units you have.  Obviously swapping for your servo spots, speeds etc.

Download was updated today, it is syncing now, so check that the Master in the download is 2.1 version 4 not 3.  But I may update this week if i make any more changes.  Im playing with him till Thursday, so maybe wise to wait till then for the latest.  Link in the blog page, top right.

I have added a few things worth noting:
1.  60s after last pad interaction (stick move or script call) the feet relays turn off. Start to turn back on.
2.  Circle is now only the short scream not a random group, it also turns off LDP and Coin slot LEDs.
3.  11 More random sounds, plus the Leia snip repeated 4 time so it is more likley to be run.
4.  Music Album has been replaced.
5.  New dances and Dance bases added, and new elements added to old sketches.
6.  Fixed bugs with both dome pot and other things.
7.  Magic panel and DBC code in and tested for triggering via I2C.  DBC button triggering to follow.
8.  New Teeces sketch, this varies the timing and number of leds used.

Door relay wiring should be the same as the doc, if not swap the output of the relay, i got a bit lost on this one, unsure what was me and what was right.

Dome pot was changed to better cope with a stiffer drive.  If this causes issues i will rewrite it to make changing those values easier.

Any problems let me know. :D

PLEASE NOTE:  If using 2.0 Do NOT trigger the Luke message while driving.  It hasn't happened to me or James in over a year, but better to know about it.  The wrong delay type is used and so it may just continue to drive off for 20s.  This is fixed in 2.1.  Sorry.

I will redo the doc after FACTs.

Saturday, 11 October 2014

BHD2.1 Update and More Dancing

I finally got to do the news scripts. :D  Slow progress, but the body was a dream, that new wiring is amazing. :)  Dome is still hard work.

I started by looking at what i wanted to achive and the audio i had.  I had 11 clips i wanted to add as extra random sounds.  Several very cool R2 mashups from Trooper Trent on .net, and i was on a mission.  James came over and we started cutting the tunes to make shorter dances,  I also PM'd R2-X2 and borrowed his Addams Family mp3.  Superb stuff. thanks Dudes.  The Gangnam Style audio was easy because we used the start, but the some of the others wouldnt work.  So i decided just to trigger the Vegas and the Audio, then added to the Scream call to stop the Vegas as well as the track.  So at any point you can scream and stop on some.

These were the eventual additions:

Happy Birthday (2 versions), Jingle Bells and Leia snip ('Help me Obi-Wan Kenobie, you;re my only hope' quote, this one is also added as a random) is just the audio call.

Staying Alive, Mahna Mahna, Wookie and R2 Christmas and Gangnam long use the Start and Scream trick, with Gangnam Long also starting with the Gangnam Sort door dance.

The big all singing all dancing additions are the Muppets short, Addams Family, Gangnam style (both short and long start the same, but long doesnt do the dome motion).

Should be more fun with various options instead of just the good old Cantina.

First vis is the Gangnam short, with no input from me, with 2nd half being the Staying alive and me controlling the dome and doors:

This one is the Muppets and Addams Family, R2 and Wookie Christmas:

I would give it a week for me to test and upload fixes to be sure, but seems great, so the code is now on my drive, the link its to the right at the top of the blog page.  This will all run on the BHD2.0 wiring, it is just code and maybe a few tweaks to the relay setup, but im not sure that wasnt due to me wiring it wrong to start, i looks the same as the doc to me. :D

That said, after facts i will update the doc and add the new stuff and features.

Wednesday, 8 October 2014

He Lives, again. :)

I posted this elsewhere too, so please forgive the copy/paste. :D

The refurbishment/upgrades spell is done for the moment. It has been fun, lots learnt, lots of tinkering and touches I’m pleased with. Took a while to come good, but really feeling like a complete droid now.

I have finally done/added/tested and tweaked the following.

1. Magic Panel, used on lots of calls.
2. Dome Bump Controller – Running rear PSI. This is not currently connected for commands from buttons, but is on I2C for PSI control.
3. Replaced dome servo Mega Arduino, with a Nano and shield
4. New Teeces code that varies the effect
5. Relays for Utility arms, Door Servos, Feet and Dome drive
6. Current and Voltage metres for Body and Dome 5v batteries
7. USB breakout port for Body Arduino programming and rewiring
8. USB charge port connected up and able to charge PS3 pads
9. Dome power switch
10. Connected the 5 body door servos and redid Utility arm setup.
11. Moved volume knob to the front Octo Port
12. Reconditioned and checked over the 2-3-2 system (still not 100% happy, but working OK)
13. Replaced the missing Battery Boxes, Hoses strips and KHFs
14. Removed and replaced all dome doors
15. Fixed all loose door trims and a general service

Just need the Battery Harnesses and he is pretty much done externally and doors etc. Still got the gadgets to go. 

Here is a video of my progress, showing the new bits and them working with the combo scripts. I do love that magic panel, such a cool little thing, shame it’s not that clear in the vid.

Tuesday, 7 October 2014

TLC and Feet Hoses

I cant believe I hadn't spotted it before now, but the HPs were connected to the wrong points, so they weren't flashing and moving at the same time.  An easy fix. :D

Battery (or one of the options) arrived today, so popped that in place.  So much better.  The battery turns on with current draw.  Meaning the switch is now in control. :D  No more fishing for the battery button.

Long term, if I can improve the slip ring connection and position/configuration then the dome will be great to use and remove when needed.  Only downside will be the need for a new slip-ring on each new dome.

Next up were the hoses.  I had to strip the feet to do this job as the drive train gets in the way.  Same way as before, 10mm rawl plugs inserted into the back of the KHF to retain the hose.  But the cave makes these jobs so much easier.  Less than 2 hours for both sets. :D  Still need battery harnesses, must keep an eye open for the next run. 

So that is him done.  Ready for final assembly tomorrow night, and the last bit of testing.  Then i can relax and tinker with the code and drive him all weekend long. :D  Feeling much better about him today, I glued up a few of the lose door trims and tweaked a few servo spots and revisited the way the dome sits, it all feels much better now.

Expect an update vid of the whole thing over the weekend.

I forgot about the DBC control!  The PSI triggers fine, and the buttons do the colours, but the signal lines aren't connected.  Too late to test that now, enough is enough.  Will wait on that one. :D

Monday, 6 October 2014

Tweaks and Teeces Redo

I got the skins back on after the strip and was pleased to find the Servo positions were still fine. :)  So one less job to do. :D

The Meter looks great and the USB programming port still works fine.

So all back together, busy tweaking timings and uploading code while testing, and I spotted a few key things.

1.  The dome gear change has caused all sorts of issues with the dome pot code.

2.  The relay for the dome didn't have any effect.  Not good.

3.  The relays for the feet draw approx 0.3A for the pair, and only about 0.06A for the dome relay. I am glad I went to so much effort on the 2-3-2 relays to get them off in 3 leg mode. :D

4.  I seem to be having a few random 12v battery connection issues, the T-Bar wont connect perfectly every time.  I will send this back with the battery when it gets serviced.  Once properly connected it seems fine.

Starting with the dome pot.  It now needs more speed to turn at all, so it isn't as accurate due to having to decrease the sensitivity and adjust the speeds and distances at which it changes speed.  I will see if it runs in, but currently I think it very likely I will go back to the A&A plastic gear eventually.  But I tweaked the code to compensate and it seems OK, but not quite as spot on as before.

Then the dome drive relay. :(  Note to self:  If you tie the GND of all sorts, don't try and add a switch on a GND line!  Syren 10 was in an nasty spot under the 2-3-2, so I tried to cheat and cut the GND with a relay.  That doesn't work due to the signal GND.  Muppet.  Don't cheat, do it right.  So I rewired the dome drive and the relay, it is a horrible fix, I will most likely look at this again when I redo the 2-3-2 wiring and code.  I simply ran an extension of one motor leads to the relay and then back to the syren, ugly, but it works.

Then I added the timeout in the code for the feet relays, when on, 60s after any dome or drive stick move, or any script call sent, they now turn off. :D  That should add a few hours runtime on the 5v. :D

All tested and working fine, I wont say I'm 100% happy yet, it could do with more fiddling, but 'good enough for this job' as they say.

While I was thinking of code, I realized I had uploaded a Teeces version I had only bench tested. :D  It varies the speed and number of LEDs so it looks more like a true processor or memory state, I love it, just makes it that little bit more organic.  Also the PSIs only sweep, but from either direction.  Just a little cleaner.  Here is a vid.  I hate trying to film LEDs, this is the best I could do, sweep is much better in person, but you will get the idea. :D

With regard to physical electronics, it is just the feet left to test.  :D  And id love to add those new scripts and sounds.  9 days to go, 2 being weekend days.  Must get at least 2 evenings driving in before letting him lose too.  It can be done, but I'm starting to run out of momentum now.  I'm sure I will still end up working on him till late the night before!  But feet next, after one last reassembly and test of the body.

Saturday, 4 October 2014

10000 Views and more upgrades

Well it seems fitting that the rebuild is still going strong as we pass the 10,000 mark on the blog.

Carrying on from the door servos, next I looked at the dome drive pot setup, to make sure the position control was working on all calls.  I found an issue with the dome drive positioning script calls, not dome random, but just the user based calls.  I had disabled them!  So sorted that in the code and got all the dome pot stuff working well adjusting timings etc.

I've noticed the delay in transmission since moving back from my PS3 test code.   I had a similar thing on the PS3 stuff, so I know it can be addressed. I will have to redo the Master base for that upgrade, so I will fix that then.  This is still fine to control him, but I'm now sure it can be improved for more response, even with the accelerations.

Then I redid the body door relay wiring and sorted the code to stop the boot twitch.  Works beautifully, I also adjusted the timings of the relays, it is only on for a fraction longer than the servo needs and so the droid hardly buzzes even tho the servos are a little too closed to pull the doors up.

It has highlighted the need to add a 'close all doors' call, because when opened by hand when not powered, you currently cant close the doors, because the droid thinks they are closed already. :(

So that was the body done, retested and working well.  Dome time.  Popped it on, Powered it all up, only the Magic Panel worked on I2C.....odd.  DBC had the I2C wires on the wrong way, 1 sorted.  Teeces looked fine. so left that and looked at the Servo Unit, after a bit of research I found I had used the wrong Nano pins for I2C.  After a rewire of the shield to add the right long pins, the servos and the Teeces triggered fine.  So looking back at it all and admiring, I spotted the front HP was dead. :(  After some debugging it was a bad lead, so I added new terminals and that was it. All the physical elements, apart form the feet and legs done.  Sort of.

Dome is now fully tested via I2C, all new and old elements working well, body fully tested with all the servos, vegas kit and dome pot triggering sorted, 2-3-2 tested and serviced. Magic panel and DBC trigger perfectly via I2C.

I then tweaked all the scripts, got the timings sorted and generally played with the current combo calls adding the new elements.  Edited a couple of dome servo spots and decided that was enough of the old.  The new dance scripts were next. This is a WIP vid of some of the early combo timings:

Body Ammeter and Voltage Display:

But again I got side tracked.  The more items I add to these 5v Lipo batteries, the more I am amazed at what they can run.  So I was interested to see how much 5v current the setup is using.  I got online and found some Voltage/Current meters, nice little LED ones, only £4 each. :D  They arrived on Thursday, and i couldn't resist playing.

First I rigged up a little breakout board, this takes a USB in and out, and powers and feeds the meters.  D  Eventually after some fiddling and a few broken leads, I had the device reading voltage and current, and tested it on the R-Series rear logic, using the brightness pot on the back I could go from nearly 0.9A to 0.1A, but it seemed about right on 0.3A to me.  But concept proven. :)

So i then stripped R2 again, removed my rewired panel and started pondering. :D  By rotating the bus/bridge there was enough room, but where was best?  Looking at the holes i already had and the current locations, i decided simple was best and added it to the centre of the panel and added the bus below. 

I wanted to make a diagram for the doc while it was fresh in my mind.  Below is the layout of my USB power and programming setup with the display meters, well this is what I would have done, mine differs slightly:

I tested the body battery draw before installing the meter, the body runs at less than 0.4A most of the time with peaks at approx 0.8A when going bonkers. :D  The dome seems similar, 0.25-0.35A with peaks of about 0.9A.  Voltage runs a little lower than id thought, but all seems to be running well, so who cares. :D  The PS3 pad draws 0.33A with a 0.5A jump on connection, phone draws less than 0.2A, so I think I could possibly get away with feeding the dome supply through the slip ring and removing the dome battery.  But not yet, this works, and halves the draw on the batteries, and lets the dome run stand alone.

Dome Gear:

Dome gear arrived, James made a start on it for me, thanks dude.  It is very thin, only 1/8", but nicely cut, with a little tidy it looks the business.  The way I mount my gear and rockler is different, I mount the gear to the bottom, not to the top, as a result it needs approx 2mm off the radius to fit.  Took a few hours, but trimmed back fitted it and got the rockler spinning well. 

The A&A gear was really smooth and a great profile, it was very tolerant to positioning.  With the new gear, both the A&A head and the Ali head's teeth were hitting the main ring teeth not catching them.  The original motor location was too far out for this cog, so I remounted it about 4mm closer to the gear and tried again, position is great, less than 1mm offset so there is almost no slop, but still the Ali ran really rough, and the A&A was a little sticky.  :(  I want the ali one to work, it looks better, so I persisted.

I ended up shortening and reshaping the A&A gear head piece, it now runs pretty well.  I'm going to run it in and see how I feel, it may smooth down with use,  I haven't powered it up as yet, or refitted the front skins, so fingers crossed.

Body Ammeter and Voltage Display:

So while I'm getting side tracked I may as well have a quick look at the dome meters. :D  Same plan as the body, but just power at this stage, not the serial lines.  I made up a 2nd Display breakout, and had a bit of a ponder.  I wanted to be able to see it if working in the dome, but also wanted to be able to see it when he was running.  I decided to mount it at an angle in the silver door to achieve that.  I cut and bent a strip of 1mm ali, shaped the feet, and stuck it to the dome.  Then I thought about how I hate fishing in the dome to turn it off, so I wanted to add the switch again, it was useful.  If I did that and got a power sensing battery (my last ones are pants and not their stated capacity), I could then turn the dome on and off externally. :D

So with that decided, I had a think about the dome battery location, currently it sits on the base plate, but that is a pain because all the electronics are on the dome itself.  The rejig in the dome had unknowingly revealed the perfect spot.  I will order a new battery that will turn on with draw, for now this works, but is on via the button on the pack.

So just need to reassemble the body, finish the feet, do those new combo scripts and I'm pretty much done on the current refurb.  2-3-2, Master and Pad will be the next big set, but that can wait for now. :D  I will post a vid of the revamped R2 when he is rolling and the new scripts are done.

I would love to remount the slip ring the other way up and swap the pot to the dome and wiper to the body, but that seems like a lot to go wrong with less than 2 weeks to FACTs.