Links to stuff on this blog

Use the Site Index of Projects page link above for an easier way to find stuff on my blog that you might be looking for!

Wednesday, December 30, 2009

Tamiya 1/16 Scale Leopard Chassis....

I have a couple of updates relating to robotics to share this week. Below is a picture of a Tamiya 1/16 scale model tank that was given to me as a gift. It is actually one tank with the upper plastic tank looking parts on the right and the metal mechanical motorized chassis on the left. I want to thank my friend DV here for giving it to me - Thanks!
Looking at it in detail it is clear that this is a quality kit but it has seen better days. The metal treads are not rolling smoothly and the tread tension adjustment is maxed out and the treads are still loose (maybe they have a few too many links!) There is also some missing screws and other things that at first glance I thought were missing parts but now I believe they were removed in an attempt to make this thing go.
 


The drive mechanism for this is pretty sophisticated considering that it is a model. There is one drive motor that is running all metal gears that is connected to two mechanical clutches (black cylinders in the picture). The clutches are activated by a servo (missing in this tank) similar to the servos that I used in My Robot.
 
The really neat thing about this kit and what really caught my eye initially is the quality of the gearbox and the fact that most of the entire chassis is metal.  The suspension for the treads actually works with each idler wheel in the tread being supported with a torsion spring. Additionally the plastic top seems to have amazing detail and a 'real' look to it. I'm not a tank expert but it appears that everything looks right...
 
These days I'm not spending a lot of time in the freezing cold garage where I can work on this but as soon as the weather warms up a bit (or at least the garage) I'm going to carefully photograph the entire chassis, gears etc... strip it down, clean it, paint and re-assemble it all to at least the point that it's at now. The action of the clutches seems to be really stiff and it needs a lot of work but I think that this is the beginning of a really cool project. I'm not sure if I'll rebuild it as a tank but I will figure it out and get it running.



 
On a similar and related note my son built up a tank as well as you can see in the second picture. He got his designed and 'running' in a matter of several minutes! Similar scale but it has a much more flexible architecture!!

As my son works on his vehicle I'll work on mine and post the progress of each as they progressively progress onward....

Saturday, December 19, 2009

Linear Power Supply (Hot Glue and High Voltage)

I'm sure that you have heard the old saying "you can never have enough power supplies".... I have found this to be true on many occasions. It seems that when trying to build something new and exciting I am lacking the required voltages and currents to make it go. So whenever I get the chance to build a power supply I take it (or if I have nothing better to do).
 
This one started with a power supply that had been modified by someone, then thrown in the garbage. It looked like it had a bunch of good parts, including a Variac, so I took it home. The first thing that I noticed  after getting it home was it had stickers all over the front of it in what appeared to be Korean. These were above and below a bunch of holes that looked like they were for switches and lights etc... Most of the holes were empty or had obviously incorrect switches and lights stuck in them. After opening it up it was clear that the insides had been cut, drilled, replaced, burned up, replaced again, drilled, cut, glued and burned up (again). I think it started out as a power supply and was then 'improved' in such a way that the 'improvements' came bursting out.
 
I decided to take all the major components out and clean and check each one. For the most part it all seemed to work. I tried to figure out what the previous owner was thinking when they added / changed everything but it was such a mess inside that I figured it wasn't worth the time. There were all kinds of connections made by twisting wires together and hot-gluing them very near 'weld spots' on the steel enclosure - those fun looking weld spots that happen when you get a lot of current flowing from a wire into the metal chassis and the paint burns off and blobs of molten copper go splattering all over.
 
Anyway after cleaning it all up I cut some new holes and mounted some new switches and lights. The original filter section seemed to be OK so I left that alone. It needed a new cooling fan, capacitors and some other things. The Variac was not an original piece in this so I changed how it was mounted and slipped some 0.09"  thick PTFE sheet between the coil windings and the metal chassis. Oh yeah  - I also added a ground so the chassis would actually be grounded and not 'live' as it was when I got it.
 


 
There is a lot of junk crammed inside at this point but it seems safe and doesn't look like it's going to catch fire or electrocute me. I don't think I would run it unsupervised for any length of time but these kinds of unknowns and uneasy feelings just make life spicy and interesting, exactly what garage experimentation is all about.
 

 
Above is a photo of the schematic of what I ended up hooking up. I decided to tap into the AC output from the Variac so I could get some variable AC voltage if I need it someday. The DC output is just the rectified and filtered AC. I can get 0 to 200 volts DC out of it and about 0 to 140 volts AC with no load with 120 volts AC input from the wall. Nothing special but may be useful for something one of these days. The DC seems to be filtered really well as under load with my oscilloscope there is no ripple. I haven't bothered figuring out what the power factor is to get a better idea of what the real output will be but I don't care right now... it works! The easiest way to figure out it's capabilities is crank it up until it glows red inside then back off a quarter turn on the Variac.

Sunday, December 13, 2009

More Excel Fun (nothin better on a rainy day)

Continuing in the pursuit of things I'm not very good at or understand very well, I decided to mess around a bit more with Excel and the Diffusion "thing" that I have been thinking and writing about. I got a bit bored with the 'Sawtooth' idea and decided to play with the Pseudo-Hadamard Transform. Specifically I decided to see how it works on 32 bit words or 4 bytes at a time. It's an easy thing to do with 16 bits or two bytes but 4 bytes isn't as straight forward in Excel. So to do this I wrote another Visual Basic script in Excel that will take the values in 4 cells (each a byte) then combine them into two 16 bit values. It then does the math Mod 2^16 and parses the values out into 4 new cells (each a byte). The code accepts 5 values from Excel, the first 4 are the byte values to do the calculation with and the 5th value is to determine which of the 4 output bytes to return. I posted the code at the end of this post.

What I noticed once I had done this is how crappy it seems to be at mixing or diffusing the  changes in the values when you are looking at one byte at a time. I shouldn't say crappy because I probably wrote the code wrong and I'm not doing the math correctly!! Ha Ha! Anyway what I got was a function that seems to work when I check the math by hand. Below is a few examples of what happens when you change various Input Values and how the Output Values change.


INPUT

1
0
0
0
OUTPUT

2
0
1
0


INPUT

0
2
0
0
OUTPUT

0
4
0
2


INPUT

0
0
3
0
OUTPUT

3
0
3
0


INPUT

0
0
0
4
OUTPUT

0
4
0
4

The interesting thing is that if you change one value in the input, two values change in the outputs. You can change the values of the inputs to whatever you want but almost always each input changes just the values in the locations above. For example looking at the first chart above with the value of 1 in the left input row it is changing the values in the locations noted by the 2 and the 1 in the output row below it. In the second chart the value of 2 in the input row is changing the values in the locations marked with the 4 and the 2. In fact I created a spreadsheet that runs through all the input values and for every input value the changes follow the above charts with the exception below:


INPUT

0
128
0
0
OUTPUT

1
0
0
128



INPUT

0
129
0
0
OUTPUT

1
2
0
129

So looking at the two above charts the value of 128 in the second input byte from the left is changing different output values than it did in the first set of charts. When the second input value from the left goes to 129 and above it is back to changing the second and fourth output values from the left. (but it leaves the first output byte larger by 1 from then on). Wow!! This is exciting!

I suppose another way to look at what is going on here is this:


INPUT

   A
   B 
   C
   D
OUTPUT

(A|C)
(D|B)
(A|C)
(D|B)


So the input in each location noted with a letter is having an effect on the output that has the same letter. Assuming you ignore the oddball change when the second input from the left is 128 and it changes the first output from the left by 1.

One problem in my opinion with doing this is only one input value is changing two of the output values. Ideally I would like to have all the output values change if one of the input values has changed. Thinking about this I decided to make two transforms in parallel with each acting on the input bytes rotated by location to the left one place. Here is a similar chart showing that:


INPUT

   B
   C
   D
   A
OUTPUT

(B|D)
(C|A)
(B|D)
(A|C)


Notice that the locations of A, B, C and D are all shifted. So imagine you have 4 input values A, B, C and D. They are 'loaded' into the chart locations above and simultaneously calculated causing the outputs to change in each location. Then the outputs from both transforms are Exclusive Or'd together to get the 4 output byte values:


OUTPUT    
(A|C)
(D|B)
(A|C)
(D|B)
OUTPUT
(B|D)
(C|A)
(B|D)
(A|C)
XOR
(ABCD)   
(ABCD)   
(ABCD)
 (ABCD)


Or something like that anyway. The reason I bring it up is because I did just that in a spreadsheet ;) So anyway it's not very interesting if you just take the exact same values for A, B, C, and D and put them into the same transforms and exclusive or the outputs together. What I decided to do is take the values A,B,C and D and put them into the first transform then take those values and swap the upper and lower bits (Nibble Swap). That way the the inputs to the two transforms are different but related to each other. If A changes then it's "Nibble Swapped" value will change too. An example is the value 12 decimal which  = 1100 in Binary. If you look at 12 in 8 bit binary (with the nibbles separated for clarity) it's 0000 1100. If you swap the nibbles it becomes 1100 0000 which = 192 decimal.

One obvious thing to mention is some values don't change when you swap the nibbles.
Obviously 0 = 0000 0000 and 255 = 1111 1111 don't change when you swap the nibbles. Neither does 17 = 0001 0001 or 85 = 0101 0101. In fact anything that is a multiple of 17 doesn't change when you swap the nibbles so I decided to fix that by performing a logical NOT (inversion) on all the values that don't change when you swap them. So 0 becomes 255, 255 becomes 0, 17 becomes 238 and 85 becomes 170. Wow!! This is exciting!! I posted the code for doing this special Nibble Swap at the end of this post.

Anyway that is what I have been up to this rainy weekend. I have not done a whole lot of testing on the above idea to see if it really does mix up the data and 'diffuse' it over the entire 4 byte output. I did write some simple scripts to run through a few thousand input values and checked for output changes and it seems to work pretty good.

On interesting thing to note about this is that the two transforms could actually be done in parallel if this were to be implemented in some kind of real time encryption system. I suppose that one method would be to take the 4 input values and substitute them with two different substitution (look-up) tables. This would be a lot better than using the Nibble Swap to get a different value for the second transform. So the A value could be substituted in two tables for 2 new values with each new value going into a transform - one being position rotated to the left. That way the values are different but would change if the A byte value changed. The subject of cryptographic substitution tables is best left for another day.


Visual Basic Code for Pseudo-Hadamard Transform (32 bit word)

Function PHT(A As Long, B As Long, C As Long, D As Long, Place As Long)
' Pseudo Hadamard Transform 16 bit words
' Shift A <<8 and C <<8 then Or C and D with them
' create Temp to hold left value
' check Place to figure out which byte is req'd as output
' December 2009 http://ottobelden.blogspot.com
Dim Left As Long
Dim Temp As Long
Dim Right As Long
Left = (A * 256) Or B
Right = (C * 256) Or D
Temp = Left
Left = (2 * Left) + Right Mod 65536
Right = Temp + Right Mod 65536
If Place = 1 Then
    Left = Int(Left And 65280) / 256
    PHT = Left
    End If
If Place = 2 Then
    Left = Left And 255
    PHT = Left
    End If
If Place = 3 Then
    Right = Int(Right And 65280) / 256
    PHT = Right
    End If
If Place = 4 Then
    Right = Right And 255
    PHT = Right
    End If
End Function

Nibble Swap with logical Not

Function SHIFTD(Value As Byte)
' Swap upper nibble for lower
' if swapping doesn't change value
' then invert (NOT) value
' December 2009 http://ottobelden.blogspot.com
Dim LN As Byte
Dim RN As Byte
RN = Int(Value / 16)
LN = (Value And 15) * 16
If Value = (LN Or RN) Then
    Value = Not (LN Or RN)
    SHIFTD = Value
Else
    SHIFTD = LN Or RN
End If
End Function