Reading optical sensor in milliseconds (ms), how do I do this?

I have an Arduino Mega 2560.
What I want to do is connect it to a 3 pin sensor (optical with reciever and transmitter on same part).

I can't remember the color coding on the wiring, but I can find out during the week. The operation is as follows:

Solenoid opens a "shutter", and a PLC system can read it in milliseconds and display that on a small LCD display.

This "shutter" is something we/I can repair and when doing so, we need to set it to a good value, let's say around 190 - 200ms.

For this I need something to read it whilst the "shutter" unit is out of the machine and on the workbench. I have read some topics, but I'm unsure what code to use and where to connect the +, - and sensor reading cable. (Other than GND, and a free Digital pin connector).

Also, the sensor gets the reading from a metal piece with a cutout in the middle which is connected to a metal arm. This piece of metal is what can be adjusted.

And no, I do not know (as yet) if the sensor operates in 5 or 3 volts. But I can find out that as well.

The solenoid has it's own power, which is 24VDC, this will be operated by a toggle switch/button.

Did also read somewhere (not here) about a Google Play app called "Terminal". I need to be able to get the reading on the phone somehow - connected either via BlueTooth or USB (with OTG adapter).

Thanks in advance from a complete beginner
Roger

Generally, you would record the value of millis() or micros() before and after your shutter event. Then just subtract the two to get the interval.

Bluetooth just transmits whatever you send to Serial, so Serial print commands will work.

The rest of it, well, please update the thread next week or whenever you get hardware details. It' impossible to answer without those.

That is making things difficult. :face_with_raised_eyebrow: A Nano is more useful for most tasks.

Almost certainly 5 V.

You need to provide the Web link for the "sensor". (And anything else apart from the Arduino which we know well.) Then we can see all the details. Having you describe it bit by bit is going to be absurdly tedious.

Don't forget that photos are most useful in describing a setup.

Thanks for the replies so far!
Yes, a Nano would have been great. But they only had the 2560 in store at the time.
There is no "weblink" for the sensor itself (machine is over 13 years old, supplyer of machine have the sensors if we need them), I can take a picture of on Tuesday (doing maintenance on the parts right now).

If everything works - sensor readings etc. I'll make sure that our boss can buy an Arduino Nano for us. They are not expensive, and it would help us a lot. As of now - we have to use an allen wrench to adjust it.. When not connected to the system.

But I will take a picture of the sensor in place, the connector (already taken that pic.) and the piece that moves between the sensor's transmitter and reciever.

And yes, I asked one of the engineers/mechanics that is there in place - they are 5 volt.
The cables connecting to the sensor is red, brown, black (see picture provided). There is a red light emitting from one sensor.

The adjustments for sensor reading will be on the metal piece that goes in between the sensor's transmitter/reciever.

Thanks in advance
Roger

Is that all they can tell you? What about the connections? Input/output specifications? Part number?

Is the OP trying to measure shutter speed?

Post a picture/image of the shutter.

I'd think that something like using a LIDAR placed about 3 or 4 inches from the shutter, with the LIDAR and shutter aligned. The LIDAR would give distance measurements, When the shutter is open the distance measurements as the LIDAR looks through the open shutter would increase and decrease as the shutter closes. The time of the increased distance reading could be used for the timing.

Sorry, have been working (non stop it seems), so haven't had time to post pictures until now.
The sensor itself, is 3 pins, black to the left, brown in the middle, and red to the right.

Ok, could only upload one picture.

The latest picture is where the sensor is "installed". The metal sheet has an opening and is usually closed.

So the coding itself needs be "run once", because that's how it's operate when testing directly when mounted in the machine.

Part number? No, because they have their own part number, and that is something you can't search (neither can I as it seems).

I guess it measures from closed to open(?). Meaning it is closed, I push a button, it opens and closes again. Within that time frame, the opening in the middle lets the light from the LED or whatever it is pass through.

The value we get when it is mounted on the machine is in ms (milliseconds). But trying to reach the settings screws is a real pain in the neck! So I thought, why not use the Arduino to "extract" the same information?

Mounting? I will use a relay connected to the Arduino, the 24 volt to the solenoid will be connected to the relay itself. When it is run once, the Arduino will activate the relay - the relay will close the circuit on the relay and establish a connection to the solenoid coil and activate it.

From there on, I need to get a reading.
This is what I want to do, try "dry run" the shutter, and get values. So I do not need to unscrew it from the machine, go back to work shop and "hope" the settings give a better value.

Thanks in advance
R

Ok, so I have been reading other forum members questions about sensors (and also on Google).

So, this is how it will work:
Siemens LOGO! will provide power to a solenoid to move the parts needed. This can be configured to be "run once" if I understand it correctly. So a push button perhaps will be needed (if not the entire thing can be controlled directly by the LOGO!).

And I guess all that the Arduino needs to to is to read the sensor. This is however something I need a bit more help with.. I'm more of a "mechanical" type of person, electronics is something I have to learn on a rolling basis at work.

I'll look into this more, since I need to know if a resistor should be used before powering up the sensor - don't want to destroy anything!

Resistors must always be used, with both the emitter and the detector. If they aren't built into the sensor, you need to include them in the external circuit.

If you can't find the sensor data sheet, remove the plastic cover and post clear, focused pictures of all the innards.

It may be better just to buy a sensor for which the data sheet is available. Look for "optointerruptor" at any major parts supplier.

Would a resistor rated at 330Ohm be good, or do they need to be higher??

Thanks in advance, yes I will start work earlier and take apart one sensor, post pics and go over it with a multimeter.

330 Ohm would give 12 mA into the LED which is generous.

The pull-up on the photosensor needs to be much higher, in fact about 47k would be reasonable but this is about what INPUT_PULLUP provides, so you should be able to use that instead of a resistor. As long as there is not too much distance between sensor and Arduino.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.