Let's Make Robots!

tilt sensor connection need help!

i just got one of these: (sharp-gp1s36hez tilt sensor)

 tilt sensor

and im not sure about these schematics and i thought you could help me connect this to a picaxe 28x1 project boad and a 5 volt regulator!!!

it should be simple! :D

it got 2 outputs and that wil tell me if it si opright, side, other side or down

and its about 4x4x5(+pins) mm in real size

please help me, it would be best if you could make a wire-schematic showing pins on the project board and on the sensor and the resistors in between.

ps. when i get this done i will post this sensor in the LMR "components"  thingy :D

EDIT: i got some advices but im still confused! im not good at understanding a schematic if it's on text

therefore i made two pictures of what i think you mean..

analog schematic

    ..but you still have to download these yourself and edit them                                                                                (dont worry, i made them simple and easy for you to edit, unless you are color-blind)

other one:

digital input schematic

 please download and edit! :)  and i would like the analog version best(i'm running out of digital inputs, that im going to use for other stuff then this)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

The main downside with a unit like this is that the output you get is either a serial string or a pair of analog voltages - either of which requires onboard processing to make use of. Although they're less flexible, the opto-switch sensors like the Sharp unit above output 2 binary values which makes sensor processing almost trivial.

MEMS sensors are fantastic no doubt, but I try to avoid component overcomplexity wherever possible.

Ok, since you're using the project board I'll assume you've got a 4.5V supply. All you need apart from the sensor and your PICAXE are 3 resistors: one to limit current going through the LED, and the other two will pull down the phototransistor outputs.

The LED has a typical voltage drop of 1.2V and happily runs at 20mA, which means we want a (4.5V-1.2V)/20mA=165Ω resistor, but anything close will do. Connect pin #1 to your 4.5V supply, and connect your ~165Ω resistor between pin #2 and ground.

Next are the two identical phototransistors, which each tolerate up to 20mA, and have a voltage drop of no more than 0.4V. 20mA per phototransistor is a bit of a waste, so we'll use 5mA instead, which is mentioned in the characteristics data so we can assume it's a good value. We don't know what the minimum voltage drop is, so we'll pretend it's going to be zero in the worst case. The resistor we need is therefore 4.5V/5mA=900Ω, but once again you don't have to be exact here, 1kΩ resistors for example are nice and common. Connect pin #5 to your 4.5V supply, and connect one ~900Ω resistor between pin #3 and ground, and the other between pin #4 and ground. Now connect pin #3 to one of your available digital input lines, and connect pin #4 to a separate input line. You can use one of your analog input lines here instead if you really need to, but the digital lines are less hassle and you've got twice as many of them.

Now all the hardware is done you just have to program it. Check out the 'supplement' diagram on page two of the datasheet: when an output is 'ON' you'll get a high signal at the connected input on the PICAXE, and likewise you'll get a low signal when the output is 'OFF'.

LED calculations are correct, but should usually use a resistor slightly higher than calculated value, to account for battery charge or changes in voltage. So a minimum standard value of 180 ohms could be used to get close to the max 20 mA current for the LED. In the Electro-Optical characteristics section, both 5 mA and 10 mA are used for determinations, so an even larger value might be used to keep from overtaxing the LED. 10 mA would be suggested to ensure photo-transistor saturation, so going with 4.5 volts, (4.5-0.4)/0.01= 410 ohm, use a standard 470 ohm 10% resistor.

The phototransistor calcs are a bit off due the missed attribution of If from the LED charecteristics. The phototransistor collector current Ic in the specs is 55 uA minimum, up to 300 uA, but not into the mA range. Using the 4.5 volt supply again, (4.5-0.4)/0.000055= 74545 or 74 Kohm. This time since the resistor is used to ensure the widest possible voltage swing and not to limit current, I'd go down to the nearest standard value to a 68K 10% resistor. This value should allow the output between collector and resistor to swing from 0.4 volts when the transistor is on in saturation, to a 3.4 volt high when the transistor is mostly off, only allowing a 17 uA leakage current. 

The LED tolerates a maximum of 50mA, like many IR LEDs, so you don't need to worry about overtaxing it. A lower resistor value will make the LED brighter, which allows more current through the phototransistor, so unless you're desperate to reduce your power consumption I'd aim for at least 10mA, or a (5V-1.2V)/10mA=380Ω resistor.

Robologist is right about the phototransistor current; although the phototransistors can run up to 20mA each that can only happen if they saturate, which can be quite difficult to acheive in a phototransistor.
Unfortunately the maximum voltage that a PIC Schmitt trigger input will read as 'low' is 0.2Vdd, or 0.2*5V=1V. If you use a 68kΩ resistor then @ 17uA 'OFF' current you'll get 1.156V at the input, which is just inside the forbidden zone, where the results will be somewhat unpredictable. Similarly the minimum Schmitt trigger input for 'high' is 0.8Vdd, or 4V, which is just over the 3.74V you'll get @ 55uA 'ON' current.
Since the 17uA maximum leakage current is something we can't fix, I'd suggest using a slightly ~47kΩ lower resistor to keep the maximum 'OFF' voltage below 0.8V. If the LED current is a healthy 10mA then it's unlikely the phototransistor output will fall below the 85uA 'ON' current needed to sustain an output voltage of 4V or more.

"and you say: "connect one ~900Ω resistor between pin #3 and ground, and the other between pin #4 and ground"
when you say the"the other" do you then just mean another ~900Ω??"
Yep, that's what I meant, although replace 900 with 47k.

EDIT: Here's a modified copy of your diagram -
PICAXE Tilt Sensor Wiring Diagram

by the way..   can i use a 330Ω instead of 380Ω?
Sure, the resistor values are all approximate. 330Ω for the LED resistor will net you (5V-1.2V)/330Ω=11.5mA, which should be strong enough but still way below the 50mA limit.

and you are sure it's 47k and NOT 4k7 or anything!?

???

Yep, 47,000Ω.
4k7Ω/4.7kΩ/4700Ω would net you:
• 'OFF' voltage = 4700Ω*17μA = 0.08V or less
• 'ON' voltage  = 4700Ω*55μA = 0.26V or more

Since you're using the analog inputs you could use a higher value resistor quite easily, but a lower value resistor will decrease the voltage change when going from 'ON' to 'OFF' or vice versa.
luckyly i just found some 47k in an old(broken) RC-remote

ohh..

i also have to ask you how  to use the sensor with the analog!?

you see..   i only know how to use the analog to handle  sharp ir stuff

i would know how tom use it on the digital but im almost out of digital inputs and i need them for other stuff i plan

please..!   please help me, by telling me how to use analog in programing editor! (by text exambles etc.) :D