Saturday, 29 June 2013

Testing almost done

Another boring text update.  But im not quite ready for another video, and its all code based stuff anyway, mostly to get it doing what it before did but better. :)

I have been uploading, testing and fine tuning my code, all week.  Started on the Vegas and CBI code, took ages to get it running, i wasn't powering the 2-3-2 system and so the I2C wouldn't boot and the body Arduino wouldn't start.  But once i figured it out and unplugged the 2-3-2 I2C it ran fine.

I then got all the dome positioner stuff retested and I moved onto the MP3s, I added a few new sounds, and made a couple of my most used ones more available.  Once all the new commands worked i moved onto the dome.  Plugged it in and the logics and PSIs ran random fine, but nothing on remote, and the HPs and dome servo controller wouldn't boot, so I assumed I2C issues and tried everything I could think of and nothing would work.  So i looked at the whole dome setup again.  Because of the Adafruit, the 5v system in the dome was totally isolated from the body 12v system, so i added a ground wire from the slip ring power feed to the teeces supply and booted it up.  It ran great.  So I tested and tweaked all the lights commands.  Then fitted a ground for the dome servo and HP controller and powered the adafruit from the arduino.  That ran great too.  I adjusted all the servo open and close points and tested all the dome servo and HP commands.  All great so far. :)

I think the lesson is to ground every system together no matter what, that way there is less reliance on other connections to ground it. By grounding each arduino it also allows them to be run with the lead connected from the PC, for much easier uploading and testing,  So might have to redo some of the wiring in the body.

So all the fitted bits were working, but the timings on the combos needed adjusting and a few of the new scripts kept growing. :)  The pad needed a slight fix, i had the 2/3 leg mode the wrong way round.  I found a system for working with all the different sketches.  I would open those i needed for the combo, make all the changes as i went and then upload, when happy with that combo i would save and close that sketch, so i only had those i needed to upload open.  Worked really well, it can get confusing. :)  But my new spreadsheet helps a lot too. :)

While in the dome servo code I took advantage of the slow mode and added a really nice Mexican wave, also redid a few of the other servo scripts.  Then had the thought that the HP servos and lights are on the same controller, obvious I know, but I hadn't seen the potential.  :)  It would be pretty easy to add a flash when it moves the servo in random mode.  It looks wicked.  The random mode sometimes selects the same position so you just get the odd flash with no motion, really cool.  There is a slight compromise, it adds a delay of 0.3s for every flash, so there may be a slight delay starting dome servo scripts if it is flashing at the time, but i can happily live with that.

Really pleased with progress, it has been slow and a little frustrating at times, but it has been great to see him come back to life. :)  193 options now, and the improvements have bean a big success. :)  Assuming the drive code and 2-3-2 stuff works ok, we should be running by next weekend. :)

A couple of odd MP3 not responding issues, but not sure if it was just me, last run it ran for at least 2 hours with no issues.  So fingers crossed.

I then started on the utility arms, i fine tuned the positions in the openings so they swing freely.  Then thinking about the dome servos only using half the available range (will redo the pies soon, but lower doors are a pain) and knowing how much power these servos need as they are currently, i decided to shorten the arms by about 25mm.  It uses nearly double the servo range and will maximize the servo efficiency.  I am a little worried about running these higher power servos through the Adafruit.  Will keep my fingers crossed.  Just need to neaten those up and i can get on with mounting the 2nd 12v-5v converter and adafruit and i can get testing that too. :)

Remaining jobs:
Sort Utility Arms for better range usage and alignment.
Fit adafruit, DC/DC and wiring for body servos.
Connect body door servos and test servo code.
Test 3 and 2 leg driving modes, speeds retune and retune 2-3-2 positions adding feet drive for max stability, plus wobble and walk tweak
Trolley revamp to better protect the skins from damage.
Back door repair and reinforce
Get chargers, extension and plug converter, to be able to charge all 4 batteries at once.  3 USB and the big one.
Cheat sheet redo, may need to be double sided now. 

If Time:
Pad Mk2 or Redo controller strap hanger bar for better hang when in use.
Redo pie dome servos, for better range usage
Centre vent remount.
Magic panel install and code up - unlikely

Dome bump controller install and code up - very unlikely 

Mancave floor arrived today. :)  We marked it out, it is going to be great, my brother has oak panel frames, so that is 5 windows and a double door sorted, just need a frame for the doors and the 7 bits of glass. :)  Each bit of glass will be about 6 foot long and about 15" deep.  Cladding and shingles are sorted and timber arrives Wednesday morning.  Getting really excited now, should look great.  Need to start looking at electrics and internals straight after CE2.  But the sofa is sorted. :)

Monday, 24 June 2013

Recoding EVERYTHING and rewiring the dome

Wow, knackered.  I had a 4 day weekend from Thurs-Sunday, so broke up from work on Wednesday and was looking forward to a productive R2 weekend.

I got my Adafruit I2C servo controllers back, made up a test sketch and mucked about with the new library that Graham Short (James’ dad) wrote for me.  He has done a superb job, it does exactly what I want.  Any Adafruit can be setup and addressed, from any Arduino on the I2C bus.  I have tested 2 arduinos on 2 adafruits, both running looped scripts, and as long as the Adafruit recieves commands from only one arduino at at time its fine.  Superb library, really brilliant and saves a lot of messing about.  I will post that once I get the go ahead, and have it running in the droid and fully tested to death. :)

So with the basic testing done, I mounted the Adafruit (0x41 address) in the dome and neatened all the servo wires, it looks so much better, but I did have to remake all my servo extensions, a bit of a painful job, but done now.   

Then while rewiring the Teeces I went to reconnect the USB (how it got power), and found there was no USB adapter on the board.  It was stuck to the end of the USB lead.  So one dead Pro Micro. :(  The new promicros have less space thanks to a different compiler, so I had no way to update my Teeces code.  So a decision had to be made.

After a bit of thought, I removed all the HP code from the Teeces BHD code, and that gave me loads of spare room, I added back in all the stuff I had recently changed due to lack of space and used one of the new promicros to run it.  So logics and PSIs back on. :)  But that left me with no HP LEDs, so I added all the HP LED control to the dome servo controller Arduino, but this time I added them as PWM, so I have a nice flicker and a strobe (more of a scroll from low to full brightness and back on a loop), really pleased with the change.  I just have a few combo scripts to rebuild now, but the base code works.  I have just used single LEDs for the HPs, I haven’t added the holo boards, think I will save them for R3, the single LEDs are fine.  Why anyone needs enough power to blind people is beyond me, seeing it’s on is all I need, I rarely run him in the dark, so lighting the room from the HPs isn’t needed. :P

So having sorted the HPs on the bench, I then had to rewire them in the dome.  I simply removed them from the PSIs and wired them back to the Servo controller Arduino (currently just a Mega I had spare), I intend to put all that code on either the dome bump controller or magic panel eventually.  The wiring was getting better and then worse again in stages.  So I looked at it objectively, and came to the conclusion that mounting the slip ring board to the baseplate was making it difficult.  So I removed it from the baseplate and mounted it to the dome, so all the wires are now fixed and don’t need disconnecting to get the base off, it also acts as an I2C bus.  With that mounted I managed to get the internals of the dome looking better than ever before. :D

The wiring stands clear of the servo arms for a short section.

Adafruit All wired up.

Mega (was spare, uno would do same job), with 3 PWM HPs and I2C connected.

Then I was looking at the cheat sheet and the commands spread sheet and decided I haven’t got enough command space, especially with more gadgets planned.  So I decided to add the 4 sets of 3 triggers pressed. E.g. L1+L2+R1 (Not R2) and a button.  And moved a lot of the functionality about to better use the sets that are easily accessed (single triggers).  So I finished off my spreadsheet of all the newly configured layout and new options, and set about redoing the code.  I started with the Pad, then the Master, then Teeces, Dome Servos, Body, MP3 and 2-3-2 controllers and now I have 193 commands (up from 145).  Basically I rewrote the lot, I edited the way things work to be simpler, added logic to turn elements on and off (2-3-2 controller and Dome position pot), and I annotated all the code better and also made a lot of changes for the better to help standardize the code.

I have a few bits to finish off and polish, i need to mount the body Adafruit and DC converter and connect the servos, then I need to load up and retest all the options and make sure it is reliable and safe to use.  Should be ok, most issues will be human error, I am pretty sure the concepts and methods are fine.  But it is at least a few nights testing.  I am a lot closer to a write up thanks to those changes. :)

So to sum up, ALL the code has been re-written for all Arduino to increase the number of options.  The HPs are now PWM controlled.  The dome has been completely rewired and neatened and now uses the Adafruit for the servos.  I have a day or 2 more coding to add a slow Mexican wave and a few new sound files etc and add the HP LED timings to the combo scripts (was easier when running on the teeces), and a couple of lights demos that will be a good way to show off quickly.  Also added the secret script.  Hope that CE2 will like that new one.

The dome redo has highlighted the slip ring again.  I think I will eventually move the Dome Pot to be on the dome and the wiper on the droid (flip the current setup) and mount the slip ring to the dome not the droid.  It will mean I need one for each dome, but the benefits outweigh the pain of buying one for each dome and of passing it up into the dome to connect it.

Once the testing is done I will upload the code to my drive.

Oh and I got the new pad battery and a few other little bits, so just need the new screen now and I can start Pad Mk2 :)

Then i get in tonight and my brother arrives with a cutting list for the Mancave!  5.5mx3.5m internal space, double glazing, insulated, well excited.  Hope to start on the frame in the next week or 2. :)  Im gonna be dangerous once i get a workbench and some space. :)

It has been a top R2 week.

Sunday, 16 June 2013

More testing and fixing

Having combined the software for the body, i rigged the wiring to run all but the servos, and booted up the droid and pad and all the old bits for the first time with all the new code (minus the dome).

All seemed fine, but i was having some odd things happen, the main one being that it wouldn't repeat the same command twice.  After a bit of checking i found the issue in the pad code, uploaded a fix and prayed that it wouldn't make the crashing return.  But joy of joys, it sorted the problems and still no crashing.

MP3s were fine after that so i knew the pad and master were ok, but some of the coin slot and LDP commands weren't doing as expected, so i fixed those, and got them all working as they should.  They work great with the CBI code and it is as good as them running independently. :)

The dome drive wouldn't work at first, but i turned it all off, reconnected the wires and tried again and it came back, not sure what that was, but seems fine now.

The main lesson today has been that cut and paste is great, but only when you change it once pasted. :)  All the coding issues were related to it.  Must pay more attention in future. :)

I now need to find combos for the CBI and body servo commands, get the Adafruit controller in and get those servos hooked up.

I have Thursday and Friday off, so hope to test that 2 leg driving mode, and maybe have time to add the 2-3-2 code to both droid master and 2-3-2 controller before then so i can test that with James on hand to act as catcher. :)  So more coding to follow, but so far im really pleased with progress. :)

Also having said that the pad redo would be post CE2, i did some shopping yesterday evening.  I managed to find a slim I2C LCD screen, it has White text and a black background, and is 16x2 characters, the total board is 14mm deep and 80x36mm, i also got some proto board that is 80x120mm so that will trim down perfectly.  Then i looked for batteries, i ordered a few, but the one i have the highest hopes for is 80x40x17mm, and is 2Ah 5v, so should easily last a full day, and i hope that the new screen and power pack block can no bigger than 90x45x40.  The current steup is approx 120x70x65mm, so only 30% the total volume. :)  But will only have about 40% the battery life of the current setup.  Most of it is from China, so we will have to see when it all arrives. :)

Saturday, 15 June 2013

Pad Crash Fixed - Hopefully

After tweaking all the pad code for the 2/3 leg mode status and changing the strings usage i was having a read through the code, and saw that i could remove all the individual code setup stuff, so it now just adds the trigger state value to the button pressed factor and cleans it up a lot.  So eventually i booted it up to do some testing.

I did loads of button bashing, and even using the sequences that crash it, it just keeps on running. :)  So it looks like that is another thing off the list. :D     

Fingers crossed that is cured.

The code size has dropped to about 15Kb, and with minimal strings should now easily run on almost any arduino.  Im considering trying to make a proto shield for a pro micro, Xbee breakout board, and my connectors for the Screen, PS2 pad, and power in, this would be the first draft of a custom pad PCB, also considering running a 16x2 screen instead of the 20x4, the screen is the limiting size thing.  So there is potential to shrink the control box considerably, but this will be a post CE2 thing.

The CBI, Vegas and Body code is both split on the chains and combined, it should work, but needs testing.  I will fit the bits and test the lights with the controller next. :)

I also, with James' help, added connectors to the Sabertooth wires.  It will be so much more practical. :)

The CE2 list is shrinking. :D

CE2 job list:
Test 2 leg driving mode and speeds retune (a little more agility needed and more turn in fast mode)
Fit controller, DC/DC and wiring for body servo, CBI and Vegas kit
Test Vegas Kit, CBI and servo code
Connect door servos using Adafruit
Fit door servo rods (been putting this off, gonna be tricky)
Sort Utility Arms and test in place
Retune 2-3-2 positions and add feet drive for max stability, plus wobble and walk drive and tweak
Controller strap bar for better hang when in use.
Face Button Setup: (These may change)
All 3 HP on then off to X button
Scream to O button
Johnny5 ‘Laser Lips’ clip to Square button
LDP Cylon in red plus CS Random White 2 to Triangle button
Up  Happy Sound
Down Sad Sound
Light Demo Mode 1 to Left
Light Demo Mode 2 to Right
I may also redo some of the combos and take out some of the options to allow room for more script based stuff, that are more reactive and more useful than scrolling through modes for the PSIs etc.
Secret CE2 special script – Details to follow

If Time
Redo all dome servos, for better range usage and use new SpeedServos library for Adafruit
Magic panel install and code up.

Dome bump controller install and code up.

Saturday, 8 June 2013

Vegas Pack - RGB LEDs in LDP and Coin Slots

Having done a few events now, and spent most of my time playing with the kids, I feel R2 needs more fun factor.

I have been thinking of adding a Larson Scanner to the LDP for ages.  So he can do Kitt and Cylon impression. :)  But I didn't want only red LEDs.  So I was looking at RGB options, but for an estimated 15 LEDs that would be 3 pins per LED, or use PWM shields or even custom PCBs.  It was becoming a pain to implement.  I also wanted to do a similar thing with the coin slots.

Then I happened upon WS2801 chip based LED Pixels from eBay, they are £16 for 25, full range RGB and all addressable.  So I ordered a set.  :)

To fill the Coin Slots I needed 12 LEDs, 2 for each slot, leaving 13 for the LDP.  The spacing was almost perfect. :)

So I coded up a few modes and had a play.   :)  In person it looks great, really pleased.  And it can be as showy or as subtle as needed.

I have 6 modes for the LDP; Off, On, Fill from Center (outer 2 at half brightness), Kitt (Move 3 LEDs back and forth, 3 brightness levels on the LEDs brightest on leading edge), Cylon (4 LEDs back and forth with the outer 2 at half brightness) and flash between 2 colours. For the coin slots i have 7, Off, On, Fill from top, Kitt (move 1 pair up and down) Random Single colour, Random random colour, Alternate row colour and swap. All the timings can be adjusted on all the sweeps etc, and i can set the number of random calls on the random modes. All the modes use 2 colours so i can swipe red over blue for example, and both those colours and the modes can be triggered from the pad at any time.   I can manually change the direction of all modes that use it at any time too. :)  Useful for things like a Kitt Voice box simulator.

I will try and add these to a few custom scripts, id like to add a Kitt sound or 2, and the Cylon noise.  But might add Coin Slot effects during the Leia message or short circuit.

Currently they run as 1 chain, but I have decided to run them as 2, this will allow anyone wanting to copy the idea just the elements they choose.  Currently the LDP is 0-12 and CS is 13-24 so you cannot run just the coin slots.   I will edit that before uploading the code.

Surprisingly it fits in the droid.  I did have to remove one of the dome motor supports, and I do need to move the 5v DC converter for the body and the controller for the CBI/Servos, but I may look at running all on 1 arduino for the body.  It won’t be that busy most of the time.  So All body functionality, CBI, Vegas Pack, Body Adafruit servo controller.  But coin slots can only be seen when on, and the LDP looks fine, but i am considering putting the LDP set behind a dark lens to make it look more discrete, or a white diffuser, But for now it's sound as it is. 

I will upload the code when i have combined and tested in the fully assembled body.  Shouldn't be too bad to combine it. :) 

Ard2-P2 Code Updates:

I have been looking around and doing some reading, i kept reading that strings and arduino aren't great together.  Over half my pad code is strings, so time to try something different.  It will no longer tell you what you pressed, only that a command has been sent and it is running.  The up side is that the pad end will now run on a smaller controller again, so may look at the layout one more time. :)  It might stop that crashing, you never know. 

With that done, i then changed the 1/2 Stick drive mode status line to be a 2/3 leg mode status line.  The 1/2 stick mode command still works but no longer displays on the screen.

I then added a feed line from the 2-3-2 controller to the master in the code (the wires have been installed for a while, there are 3 in total), i made sure that the boot of the 2-3-2 and any leg mode change changes the digital output state, and that is read by the master on boot up and after any button press is actioned.  This line on the pad is connected via the internal pull up, and needs to be low for 2 leg mode, so with no 2-3-2 controller, it defaults to 3 leg mode. :)

I also made a start on some of the User Friendly mods, the variables for the fast/slow and 2 leg speeds are now all int he one place and easier to change, and i started some annotations to make it easier to understand.

Once i finish and test this latest batch i will upload it all as a new version with all the units and the most recent updates for each.

So combine the body code next, split the string of pixels, and then next up is the motion of the feet on the 2-3-2 and Walk scripts.

Fingers crossed.