Go Down

Topic: How do I get the boolean code, true or false, for this sensor? (Read 812 times) previous topic - next topic

ArturDB

Hello! I'll try to be brief.

I'm basically building a tool to help me record some cool time-lapses of my 3D prints, where my iPhone will be sitting in front of my printer taking shots every layer. I'll do it using an Arduino where I already figured out how the iPhone will take the pictures and I want to use a spare induction sensor from an old printer to detect whenever the extruder comes close, so that it sends the signal to the iPhone to take a picture at the layer change.

I already have the sensor working, just don't know how to extract the boolean (TRUE or FALSE) for coding, this is all I need to get everything working.







dougp

If the sensor output is connected to digital pin, say 6, then just if(digitalRead(6)==0) then a else b.
Everything we call real is made of things that cannot be regarded as real.  If quantum mechanics hasn't profoundly shocked you, you haven't understood it yet. - Niels Bohr

No private consultations undertaken!

Wawa

That circuit (the 2*10k resistors) won't work with the NPN (open collector) sensor you have.

If you're sure the sensor is NPN, then connect the output directly to a digital pin, set to INPUT_PULLUP.

The pin will be normally LOW, and HIGH when metal is near.
Leo..

ArturDB

If the sensor output is connected to digital pin, say 6, then just if(digitalRead(6)==0) then a else b.
"digitalRead", that's exactly what I was looking for. Yes, I'm beginner. Thank youu!

ArturDB

Hello, I got this 12v sensor and I want to connect it to my Arduino. But I actually seem to have damaged my board using it cause I didn't know it was 12v, so I want to reduce it to 5V using a resistor divider, but how should I connect the wires?

I'm assuming Vin is the +12v, Vout the -12v and the signal wire keeps the same, is that right?


Paul__B

Sounds plausible, but have you figured the resistor values and you better first explain just what that sensor is?

BabyGeezer

you have to give more information about that sensor !

what is it ?

it's not just that it's "12V" but that it's "-12V" as well.

i don't think a voltage divider will solve your problem.
Attach your images to be viewed directly - THIS WAY;
https://forum.arduino.cc/index.php?topic=519037.0

ArturDB

It's an induction sensor for metal detection. I read another topic about reducing from 12v to 5v and they were saying to use R1 as a 10k and R2 as a 15k for stable voltages. I just wasn't sure if leaving the signal wire unattended was right, since I'll be buying another Arduino today and I don't want to burn it, LOL

The whole idea btw is to create a time lapse tool to register my 3D prints in a fancy way, where the sensor will detect the extruder every layer change and send a signal to my iPhone to take a picture. :)

ArturDB

you have to give more information about that sensor !

what is it ?

it's not just that it's "12V" but that it's "-12V" as well.

i don't think a voltage divider will solve your problem.
I got these info about it, it's from an old 3D printer I had




Wawa


Paul__B

Just to make absolutely sure, put a diode with cathode to your sensor and anode to the Arduino input pin.  If it is not sufficiently reliable, add an extra pull-up of 4k7 or so from the Arduino input to 5 V (not 12!).

PerryBebbington

Let me check I have understood correctly, the brown wire connects to +12VDC, the blue wire to -12VDC and the output is the open collector on the black wire. Assuming this is correct then the output needs a load resistor between black and brown and the voltage can, in theory, vary between about +12V and -12V, so it's not a 12V sensor it's one that needs 24V. That being the case I suggest this sensor isn't what you need.

How about either an optical sensor or a Hall effect switch and a small magnet?

JohnRob

I've not seen many sensors require + 12V / -12V.


I would assume the reference to -12V is really the 12V common (aka 12V return and unfortunately ground).

If this is the case then all you need to do is:

1) Connect the blue to the arduino GND** and the 12V common (return, ground etc)****

2) Connect the black to any arduino digital input, enable the internal pullup on that input.  I would add a 1k in series for saftety in case the two "grounds" are not exactly the same.
If you want to be really safe you could but a diode (1N4148) in series with the black wire.  The banded end (cathode) would connect to the sensor side of the black wire. The other end (anode) would go in series with the 1k.

3) Connect the brown to +12V


** I use ground here because the boards are marked GND.


****
So lets talk  +12V and -12V.

My car battery is a 12V battery.
The connection posts are marked "+" and "-"
This means the "+" post is 12V higher that the  "-" post.
 The "-" post is  connected to the car frame.  This becomes the created circuit "common" (sometimes called the return).

The "common" is often called "ground".  While folks understand what ground means in this context it is not a good term to use, because the word "ground" suggests an absolute 0 voltage which is not always the case.






Please do not PM me with thread based messages.  If your thoughts are worth responding,  the group should benefit from your insight.


ardy_guy

My car battery is a 12V battery.
The connection posts are marked "+" and "-"
This means the "+" post is 12V higher that the  "-" post.
I too was wondering if the -12V in OP's pix actually meant one side was 24V below the other, or if it just meant the ground side (0V) of a 12V system.

But this:

I would assume the reference to -12V is really the 12V common (aka 12V return and unfortunately ground).
... might not be wise, because it might actually be a 24V thing?

But then why have a +12 V and -12V label with no 3rd wire called ground as the midway between then, for a pair of +ve and -ve voltages?. Might as well label then +24V and 0V or ground in that case.

So while it might be likely that this is a 12V thing and -12V is actually ground zero for the 12V side, it's by no means a cert.




Go Up