NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Project Help and Ideas » Distance sensor

January 26, 2011
by archee
archee's Avatar

Hi,

I have idea to measure and visualize road quality in my country mostly because its terrible. So I had an idea to put an sensor for measuring distance from my cars shock absorbers top till the bottom. The speed could be 10 times a second.

I would like to hear some opinions on which sensors to use. I found in internet about ultrasonic sensors for measuring distance especially i think this one suits my needs the most.

http://www.robotshop.com/eu/dfrobot-urm-ultrasonic-sensor-2.html

but might be there is some other way. Like put one sensor on the bottom of shock absorber and other one on top of shock absorber, and measure distance between these too.

Will be thankful for any information about distance measuring in electronics.

Best regards,

Arturs Vitols

January 26, 2011
by hevans
(NerdKits Staff)

hevans's Avatar

Hi Archee,

Neat project you have in mind. I think the biggest problem you are going to run into is the harsh environment of a car. Make sure you enclose your project well to withstand all the dust, rocks, and heat under your car. Just another suggestion for a sensor you could use is an accelerometer mounted at the bottom of the shocks. This point will spike up or down for bumps and holes and you should able to detect the sudden changes in acceleration.

Humberto

January 30, 2011
by archee
archee's Avatar

Hi Humberto,

That is a really good idea to use accelerometer, using accelerometer and knowing the speed I`m driving should make me able to calculate height of the bumps.

Arturs

February 02, 2011
by archee
archee's Avatar

Hi,

Now I`m trying to write my own display drivers, just for training my skills, and learning to understand data sheets.

It was all fine I created a function which checks busy flag, and then sends data to LCD:

void nibb(char P4, char P3, char P2, char P1, char P0)
{
...
}

P4 is for RS pin on LCD all others are data pins. It works fine. When I want to send some data to LCD I just write:

nibb(1,0,0,1,1);
nibb(1,0,1,0,1);

but it takes twice as much space in code writing like this, so I decided to make on function that sends 8 bits.

void nibb_8(char b[9])

    {
        nibb(b[0], b[1], b[2], b[3], b[4]);
        nibb(b[0], b[5], b[6], b[7], b[8]);
    }

and when I want to send some info to lcd i write in code

nibb_8("100100110");

function nibb(); works perfectly, but finction nibb_8(); refuses to cooperate. Could someone explane me the flood in my plan..? why it`s not working..? Any kind of help will be appreciated.

Thankful

Arturs Vitols

February 02, 2011
by hevans
(NerdKits Staff)

hevans's Avatar

Hi archee,

There are actually a couple of problems with your approach. You are correct that a string of numbers is really just an array of chars, however there is these a mapping between the ASCII representation of a character and the character you see. The ASCII representation of the character "0" is actually not the number 0, it is the number 48. You actually can't really encode the number 0 in a character easily since 0 is the null character which is usually used to indicate the end of a string.

The other issue is that literal strings on microcontrollers a bit tricky since there are two memory spaces (RAM and program memory). By default our Makefile specifies not to put the .text section of the program into RAM since this is generally good practice in MCUs (you have very limited RAM). Instead we recommend literal strings be held on the Flash memory which is why we always use the PROGMEM macro when using strings. For much more info about this (and how to get around it) take a look at this thread.

Humberto

February 05, 2011
by archee
archee's Avatar

Thanks Humerto, this info helped me a lot.

At this part I really need some help I draw some sketches of how this system should look like: scheme

  1. LCD I choosed this(NOKIA 3310) display because I wanted it to draw a graph of like past 10kM or so so I could visually compare how smooth Im going. My other choice was Nokia 3200 LCD, because it has color LCD built in Back-lights, but Im sort-of afraid, that atmega wont be able to refresh display data as fast as for B&W NOKIA 3310 LCD.

  2. Memory storage. Here I really would like to hear some opinions. I would chose 1Gb SD card, but might be there is some better solution.?

  3. Keypad 4x4 to write some notes and add some additional data on places I got some big hits.

  4. Timing event. Need some precise technique to calculate time. +/-5 secs in one hour wouldnt be such a big deal. here I would like to here some advices. Should I use some external hardware for this or use Atmega for this time calculation?

  5. Accelerometer. I think I use this one It detects acceleration in 3-axes. I need only one of them. If somebody sees some reason why I shouldnt use this accelerometer, then I`m open for suggestions.

  6. Not sure jet how Im going to calculate speed. Car Im going to use is as mechanic as it can be(Honda Civic EC9, engine D14A1 dual-carb). And I dont want to dismount speedometer to get readings from it. This is another problem in which I would be glad to hear your opinions.

I would really like to here some opinions on suggestible hardware and software solutions. Im not as smart as I wana be.. :D

Arturs

Post a Reply

Please log in to post a reply.

Did you know that you can make a capacitive proximity sensor with some aluminum foil and paperclips? Learn more...