Reading output from LDR encoder connected in an external circuit.

Hi,

I've decided to build a coil winding machine. Currently I have a linear traverse operated by a stepper motor with step direction reversed using a hall effect sensor and flip flop with magnets either side of the travel as limit switches. This is run from a Nano and a leadshine stepper driver and works fine fine.

I also have a programmable commercial coil winder - with turns counter and no traverse. The turns counter has a resolution of 0.1 turns. I can break in to the circuit of the optical encoder of the commercial unit - the turns counter PCB has a V+, V- output and three additional leads. Two of the three additional leads appear to have a 12.5V signal output, the other appears to be a signal ground.

If I want to interface my Arduino Nano to this commercial coil winder in order to synchronise my traverse stepper motor with the winding spindle of the commercial machine, what is the best way of achieving this? I was thinking of using a PC817 optocoupler, but would I be better off just using some sort of voltage divider network to get the signal voltage down to the correct levels for the Nano input pins?

Would this be likely to adversely affect the operation of the counter on the commercial unit?

Thanks,

Jonathan.

Moved your topic to it's current location / section as it is more suitable.

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Need diagrams of your circuits so far and some photos (taken with perfect focus in full daylight but not sun, certainly not in some dingy room),

Also please explain what you're really planning to use, and how. Some images would be helpful.

The subject mentions an LDR for pick-up, in the text you talk about a hall effect (magnetic) based encoder and a light based encoder (which quite certainly does not use an LDR).

Hi,

Sorry, I'm not in a position to take photos at the moment.

I think the question is quite general really, I was a little unclear and perhaps gave too much detail before which confused the issues.

The general question I have is:

If I want to intercept and read a digital signal in an external circuit where the external circuit is operating at a higher voltage level than the Arduino can accept, Would a voltage divider from the external signal with Arduino ground linked to the external signal ground work, or would I be better off using an optoisolator between the Arduino and the external circuit.

Is it likely that I would I need to buffer the signal to avoid degradation of the signal in the external circuit?

Sorry - just started learning about digital stuff, I normally just experiment with valved equipment.

The specific situation is as follows:

I currently have a commercial coil winder which does not include a traverse mechanism. This coil winder has a digital turns counter which is fed from a small PCB. The PCB has an LDR sensor, a small number of passive components, and a Hex Schmidt trigger IC.

The spindle of the coil winder has a metal plate with ~ 5 slots cut in it that rotates through a slit in the LDR sensor.

If I break into the circuit between the digital counter and the LDR sensor PCB via 5 connecting wires between the two modules, I can see that one wire is V+ (presumably for the LED of the LDR the other V- (ground for the LED of the LDR?). The other 3 wires appear to be ground and two signal wires which provide ~ 12 volt signal pulses in response to the spinning. of the spindle of the motor.
The turns counter has a resolution of 0.1 turns. I assume that the two signal wires provide some sort of quadrature output.

Independently I have a separate traverse mechanism that I built from stepper, Leadscrew, Stepper Driver, hall effect sensor for limit switches, and Arduino Nano which controls the Traverse system. I want to integrate the traverse system with the existing coil winding machine.

What I want to do is detect the signal that feeds the turns counter in the commercial unit with the Arduino in my traverse system.

This way I hope to synchronize the Arduino driven traverse mechanism movement with the speed of the spindle in the commercial winding machine.

However the 12.5 volt voltage levels of the commercial machine would be incompatible with the maximum input voltage to the Arduino digital pins.

Sorry additional note, LDR might not be the correct terminology - sorry, but it is a sensor which appears to respond to a light beam being broken by a spinning slotted metal disc attached to the spindle.

That's simply an encoder. Those things don't use LDRs, as an LDR is way too slow.

Most likely a voltage divider will do the job.

Hi,

I tried using a P817 Module to read the data, but I think it was drawing too much current from the external circuit, and interfered with the signal processing in the external circuit. Instead, I used a restive voltage divider to drop ~ 26V down to about 3.5V using 660K and 120K.

This appears to work Fine.

In the sketch below, I've had to move some of the code incrementing the count of turns into the ISR's as it seemed to slow everything down when the ISR's were just reading the bits from the external signal, and then the code was processing them in the main Loop.

The code reeds the turns count output of a transformer coil winder (without traverse). Ultimately I'll be using this to control a stepper motor traverse to lay coils neatly as they are wound on the machine.

Thanks,

Jonathan

Thanks,

Jonathan.

[code]
volatile int Orange_Rise = 0;
volatile int Brown_Rise = 0;
volatile int Last_Orange = 0;
volatile int Last_Brown = 0;

volatile float TrnCnt = 0;
float LastTrnCnt;

void setup() {
  Serial.begin(9600);
  Serial.println("Started");
  pinMode(2, INPUT);
  pinMode(3, INPUT);

  attachInterrupt(digitalPinToInterrupt(2), orange, CHANGE);
  attachInterrupt(digitalPinToInterrupt(3), brown, CHANGE);

if (digitalRead(2) == HIGH) {Last_Orange = 1;}
if (digitalRead(3) == HIGH) {Last_Brown = 1;}



}




void loop() {

  
    if (LastTrnCnt != TrnCnt) {
      Serial.println(TrnCnt);
    LastTrnCnt =TrnCnt;}

}

void orange() {

  if (digitalRead(2) == HIGH) Orange_Rise = 1;
  else
    Orange_Rise = 0;

  if (digitalRead(3) == HIGH)  Brown_Rise = 1;
  else
    Brown_Rise = 0;

    if  (Last_Orange != Orange_Rise || Last_Brown != Brown_Rise)
  
    { if (Last_Orange == 0 && Last_Brown == 0 && Orange_Rise == 0 &&Brown_Rise == 1)
    // 1110
    // 0001
      {TrnCnt=TrnCnt+0.2;}
      if (Last_Orange == 1 && Last_Brown == 0 && Orange_Rise == 1 && Brown_Rise == 1)
      //0010
      //1011
      {TrnCnt=TrnCnt-0.2;}
         Last_Orange = Orange_Rise;
    Last_Brown = Brown_Rise;}
     
}

void brown() {

if (digitalRead(2) == HIGH) Orange_Rise = 1;
  else
    Orange_Rise = 0;

  if (digitalRead(3) == HIGH)  Brown_Rise = 1;
  else
    Brown_Rise = 0;
      if  (Last_Orange != Orange_Rise || Last_Brown != Brown_Rise)
  
    { if (Last_Orange == 0 && Last_Brown == 0 && Orange_Rise == 0 &&Brown_Rise == 1)
    // 1110
    // 0001
      {TrnCnt=TrnCnt+0.2;}
      if (Last_Orange == 1 && Last_Brown == 0 && Orange_Rise == 1 && Brown_Rise == 1)
      //0010
      //1011
      {TrnCnt=TrnCnt-0.2;}
               Last_Orange = Orange_Rise;
    Last_Brown = Brown_Rise;}
}

[/code]