Human Oscilloscope

I needed a way to compare two signals on an engine control unit project I’m working on. I’ve only got a very cheap and basic single channel digital oscilloscope so I couldn’t use that to compare them.

So, I though I could probably use a pair of headphones to feed a signal into each ear, and I would perhaps be able to hear the difference. This actually worked pretty well. I suppose if you’ve got some of those mad 7.1 channel headphones then you can have 7.1 oscilloscope channels!

This will probably only work well for fairly low frequency signals, I’m in the low kHz range at the moment. You can’t really take measurements or see the shape of the signal (although different shapes will have different sounds), and it probably only works for comparing two signals to hear if they’re the same. I don’t think you’ll be able to detect phase difference either. Also, I’m not sure that driving the headphones directly from the microcontrollers this way is completely safe.

Here’s a guide to this highly complex procedure

  1. Chop off a few centimeters of single core wire
  2. Pull the insulation off of it
  3. Wrap it around your headphone jack
  4. Repeat three times and stick each loop into some breadboard

Pull the insulation off of some single core wire

Pull the insulation off of some single core wire

Wrap single core wire around headphone plug

Wrap single core wire around headphone plug

Use one ear per channel

Use one ear per channel

Honda Variable Cylinder Management Engine

Honda New Zealand have a really nice explanation of their ‘Variable Cylinder Management’ technology. The idea behind this is similar to the Scalzo Piston Deactivation Engine in that it reduces pumping losses in the engine at part load. The great thing about Honda’s system is that it utilises the already proven VTEC technology to achieve a similar effect. The disadvantage compared with the Scalzo engine is that it cannot remove the friction losses as the pistons are still connected to the crank shaft and still move up and down in the bore. The Honda v6 engine can run on 6, 4 or 3 cylinders.

http://www.honda.co.nz/technology/emissions/vcm/

 

2004 Corsa C Wheel Hub Removal, wheel bearing, brake pads and disk renewal

Information given here describes working on the braking system of a car. This is only a rough guide, if you are not experienced with working on vehicles, I do not suggest starting on the brakes. If you crash and die – do not blame me.

This is a rough guide on working on some of the wheel hub parts on a 2004 1.2 L Vauxhall/Opel Corsa C. This may or may not apply to your vehicle, and should only be used as a guide. Additional  tools or steps may be required. I am not a mechanic, merely a hobbyist, and so any advice should be taken with a pinch of salt, as there may be better ways to do things. You follow this information at your own risk, if you cause any damage to your self or your car, do not blame me. If you are not confident in solving problems as they arise, or are not prepared to spend more money to fix things if they go wrong then get a professional mechanic to do the job.

I was quoted £150 for a garage to replace the wheel bearing on this vehicle, and £250 from a different garage to replace the wheel bearing, brake pads and brake disks. Upon starting the job, I found that the drive shaft gator and stabiliser link (between strut and anti-roll bar) also needed replacing, so the cost would have been more than this.

On parts I spent about £100:

  • £20 for a pair of brake disks
  • £16 for a set of brake pads
  • £20 for a single wheel bearing
  • £10 for a stabiliser link
  • £10 for a drive shaft gator
  • £10 for two hub nuts (replacement on removal recommended)
  • £10 for replacement strut bolts and nuts (replacement on removal recommended)
  • £2.50 for new brake calliper bleed nipples

This list of tools is pretty much the minimum that you’ll need. Don’t even bother starting unless you’ve got all of these, or you’ll have to go out and buy them (like I did) or end up with a car in bits and no way to finish the job. You may be able to get away without some of them, but I don’t think so. (also – don’t rely on this list, I may have left some things out, so just make sure you have a good and comprehensive tool kit)

Tools required for brake disk replacement:

  • 15mm Torx/Alldrive socket/spanner (caliper bolts)
  • T27 torx bit/key to remove the brake disk retaining bolt
  • Soft faced hammer/wood and large hammer
  • String (to support brake calliper)
  • Brake cleaning spray/petrol (to clean new disks)
  • WD 40

Tools required for hub removal:

  • 2x 18mm socket/spanner (Strut bolts, track rod joint)
  • 2x 16mm socket/spanner (lower ball joint)
  • Ball joint splitter
  • Hammer
  • 32mm socket (hub nut)
  • Pliers (remove split pin)
  • Hammer (general persuasion)
  • Torque wrench (refitting bolts)
  • String (support brake caliper)

Tools required for removing the wheel bearing from hub:

  • All of the above (to remove hub and disk)
  • Either a hydraulic press & puller or:
    • A large vice (at least 4″)
    • An assortment of sockets/metal tube sizes (to use as drifts)
    • A large hammer (4lb ideal)
    • A cold chisel (to remove bearing inner race from hub flange)
    • Possibly a blow torch (to heat bearing inner race when chiselling off of hub)
  • Circlip pliers or screwdrivers, a vice and locking wire

A brief step by step explanation of hub removal:

  1. Loosen the road wheel bolts before jacking the car up (only to free them)
  2. Chock and jack the vehicle, and support on axle stands
  3. Remove the road wheel
  4. Spray all the nuts and bolts to be removed with WD40 or similar to give it time to penetrate while you’re working. If you are not replacing the brake pads and disks be careful not to get oil, grease or WD40 on them!
  5. Remove any dust cap from the centre of the hub, remove the split pin from the hub nut
  6. Get an assistant to put their foot on the brake, or wedge something on the brake pedal (if you start the engine – servo assist will help with brake pressure – but make sure that the car is safely supported first)
  7. Using a 32mm socket, free the hub/castle nut from the drive shaft, remove the nut and washer. (You should use a new nut and split pin on reassembly)
  8. Loosen and remove the steering rod ball joint nut – make sure you fully remove the nylock nut (if you are using jaw type splitters – wind a normal nut back on to protect the ball joint threads for when you split the joint)
  9. Using a ball joint splitter, (or a hammer if you are careful and lucky) split the steering rod ball joint
  10. Loosen the lower strut bolts (2x at the top of the hub) – but do not remove them yet!
  11. Loosen and remove the lower ball joint clamp nut and bolt – make sure to fully remove it as it will prevent the ball joint from separating from the hub otherwise.
  12. Remove the ABS wheel speed sensor from the back of the hub, and hang it out of the way
  13. Get some string handy and loop it around the suspension spring, and get ready to tie and support the brake calliper with it
  14. While supporting the calliper – remove the calliper mounting bolts from the back of the brake calliper and hub (2x)
  15. Tie the string to the calliper and do not let the brake hose come under stress, as it may break off from the calliper
  16. If you are changing the brake disks or the wheel bearing, then you may need to free the brake disk from the centre hub – there are probably a number of ways to do this, but I removed the retaining screw from the brake disk, and then put an old bolt in one of the blank holes through the hub and disk (not a road wheel bolt hole) and then hammered it sideways. This causes the brake disk to twist off of the hub, and free it up.
  17. Push the drive shaft through the hub – use a soft faced hammer if necessary – and support the drive shaft by placing it on the lower wishbone. Do not let the drive shaft hang under its own weight
  18. While supporting the hub, remove the strut bolts, and lean the hub outwards from the vehicle slightly
  19. Ensuring that the steering rod and other parts are free, the hub should lift off of the vehicle.
  20. If the lower ball joint is tight, wedge a chisel or large screwdriver in the clamp to separate it and allow the hub to be removed

Heres some pictures of the hub, disks, and bearings

SAMSUNG

Drive Shaft side of wheel bearing in hub

Wheel side of hub and brake disk

Drive shaft side of hub showing wheel bearing

Drive shaft side of hub showing wheel bearing

Front hub with brake disk

Front hub with brake disk

New brake disk, wheel bearing and circlips

New brake disk, wheel bearing and circlips

Close up of drive shaft side of hub showing wheel bearing and drive shaft splines

Close up of drive shaft side of hub showing wheel bearing and drive shaft splines

New wheel bearing and drive shaft side of hub

New wheel bearing and drive shaft side of hub

Scalzo Piston Deactivation Engine – Whole cylinder deactivation

Some engines can ‘deactivate’ cylinders by preventing the valves from actuating, and hence inhibiting any airflow through that cylinder. This is great for part load conditions, as it reduces some of the pumping losses of the engine. This system doesn’t quite achieve full cylinder deactivation though, as the piston still moves up and down in the cylinder, hence some energy is still lost to friction. The Scalzo ‘Piston Deactivation Engine’, however, can deactivate the whole cylinder and stop the piston from moving.

A full explanation is given on their website, and apparently can also be designed to provide a variable compression ratio.

The advantages stated are:

  • Substantial reduction in fuel consumption estimated in excess of 30% with similar reduction in emissions.  Ref. SAE Paper 2011-01-0368.
  • An estimated additional 5% to 10% fuel reduction with the inclusion of VCR.
  • An estimated additional 10% to 15% fuel reduction with the inclusion of VCR and turbo charging.
  • Applicable to Diesel engines and in particular to large diesel engines for road transport.
  • Can be applied to V-type and horizontally opposed engines.
  • Does not affect existing production of head, manifolds and fuelling systems.
  • The small crankshaft to cylinder offset can be used to advantage for east-west installations.
  • It uses conventional pin jointed and lubrication technology.
  • Balancing requirements are within acceptable levels at all positions.
  • Complementary to all other combustion technologies.
  • Potential for reduced cooling system size. (Cost and weight reduction)
  • Probable reduction in the size of starter motor and battery as the engine is started at minimum capacity. (Cost and weight reduction)
  • Very low additional production cost relative to economy gains.
  • Can be used in combination with a lower cost mini electric or flywheel hybrids.

Apart from the advantages, some of the disadvantages might be

  • Increased complexity probably means higher initial cost (although this could be offset by savings)
  • An additional control system would be required, increasing ECU cost (again offset by savings)
  • Greater complexity also leads to more possible points of failure
  • Increased weight, and size for a given displacement
  • As cylinders are deactivated, the engine rocking motion and balance changes, which could lead to increased vibrations and noise

As with any development, the advantages may easily outweigh the disadvantages in the long term, especially with increasing fuel costs.

Convert LaTeX tables into HTML

Update: Here’s a much better version of this that someone has obviously spent a lot of time on – which I had found it before! http://truben.no/latex/table/ You can import TeX by going to Tools-> Import (although it doesn’t appear to work for my tables).

I have just converted my undergrad dissertation project from a document written in LaTeX to HTML to display on the web for anyone who is interested in Lego Mindstorms, or flocking.

At the time I wrote it (3 years ago) I found LaTeX a nightmare. It’s supposed to allow you to perfectly typeset documents, but I found even between print previewing the document and actually getting it on paper it changed! Anyway, so in the process, I needed to convert some of my results tables from LaTeX syntax into HTML. I couldn’t find any existing tools to do this, so I wrote one.

This was only a quick fix, and there are some problems with it, I have no idea what possible formats LaTeX uses for tables, so this will probably only work with the exact examples which I used to test it with. If you know any Javascript, or RegEx, then you should be able to ‘fork’ the jsFiddle to make your own version, fix problems, or improve it.

You will need to delete the last <tr><td> since it adds it erroneously.

If you find any more problems with it (I expect that there are many) then leave a comment.

WordPress sticky header

I didn’t finish this, but I will leave this post here in case anyone is interested in the jsFiddle

I’ve seen a new style of header around recently which I really like. It’s like a normal header, but once you being scrolling down the page, it sticks to the top as if it was position:fixed.

So I thought I’d have a go at modifying the default ”Twenty Eleven 1.3″ theme to see how easy it is.

I’ve created a jsFiddle which does what I want: http://jsfiddle.net/Gadgit/AJ3AX/8/

WordPress auto capitalises the ‘press’ in WordPress!

I’ve just noticed that when I type in a post title the word ‘WordPress’ and preview the post, it comes out as ‘WordPress’. This only works if you have the first letter as a capital ‘W’ and not lower case (which I guess is correct since it’s assuming you mean the proper noun).

 

Just thought that was strange, I’ll see if I can see why it does it later.

Javascript replace all occurrences of a string only once

When building a Javascript endless scroll, I wanted to use variable placeholders in a template which I could then replace with the data returned from an ajax request.

I initially did this by looping through my data object and using a greedy regular expression to replace each occurrence of a placeholder with the returned data.

This leads to a problem if the data contains a string which is also used as a place holder.

var reps = {
   UN: "Ali",
   LC: "Turkey",
   AG: "29",
   ...
};

return str.replace(/\[(\w+)\]/g, function(s, key) {
    return reps[key] || s;
});

I found quite an elegant solution to this on stackoverflow which utilises Javascript’s string.replace(regex, funtion()) function. The mapping function is passed each of the matched groups as a parameter. My function then looks up the matched placeholder in the data array and returns the data if found, otherwise leaves the placeholder untouched.

I have then modified the code to allow me to use place holders with curly braces like so:

{some_variable_name}

function cloneIdea(data){
       var clone = jQuery('.idea_clone').html();

       // Replace all occurrances of {SOME_KEY} with the key value from reps (our returned data)
       // %7b = { and %7D = } because for some reason, the image src is returned from .html() as url encoded
       clone = clone.replace(/(\{|%7B)(\w+)(\}|%7D)/g, function(orig,p2,key) {
              // This function is called with the parameters matches from the regex,
              // Only return the value from data if it's defined. If not, don't replace.
              return (typeof(data[key]) != 'undefined')?data[key]:orig;
       });

       return clone;
}


Note that the function is passed parameters of the matched groups (round brackets) in the regular expression in the order they occur. I experimented a bit with this functionality, and am still as little confused as to why it works the way it does since the MDN docs seem to suggest that you use parameters named p1, p2, pn… to get the matches.

The expression itself works as follows:

  • (\{|%7B) The round brackets create a group so that you can use the | as an OR. The \ escapes the { as it is a special character. %7B is the percent encoded character for {
  • (\w+) Creates another group, \w is the special character class for a ‘word‘ character, the + indicates that there should be 1 or more of those characters.
  • (\}|%7D) This is the same as the first half but for matching the } character instead
  • The g at the end indicates that the regular expression should do a global match, i.e. not stop at the first instance.

I quite like this Regular Expression Cheat sheet.

Setting up a Galaxy S for ADB

So, I thought it would be as easy as plugging the phone in, but it’s not, and obviously the drivers are impossible to find.

  1. Ensure application debug mode is turned on on your phone. (Settings->Applications->Development->USB Debugging)
  2. Plug the phone in (probably won’t automatically find the drivers – didn’t on XP anyway)
  3. Download the drivers from here: Samsung Galaxy S USB Debug Drivers @samsung
  4. Check your device is installed and connected by opening a command prompt and running “android_SDK_path/platform-tools/adb devices”
  5. You should then be able to ‘Run’ your application as normal from Eclipse and it will download it to your phone and provide you with debugging info.

Unsupported configuration: sampleRate 44100, format 1, channelCount 1

I believe that my problem in the last post regarding the Unsupported configuration in the AudioRecord class was because I hadn’t enabled the ‘Audio Playback Support’ and ‘Audio Recording Support’ for my virtual device

No, that didn’t work, still have the same problem. I have made sure that I added the required permission in the manifest.xml:

<uses-permission android:name="android.permission.RECORD_AUDIO" />

But that hasn’t done it either.

I tried changing the sample rate down from 44100 Hz (which is supposed to be supported by all devices) to 8000Hz and that actually removed the original error, and now I get:

Could not get audio input for record source 1

After doing some internet looking, I believe that it may be because the emulator doesn’t support recording audio (despite setting this as a hardware feature in the AVDM). I’m now setting up my phone to see if it’ll work on there.