Page 1 of 2

fastest sensor reaction.

PostPosted: Mon Jul 09, 2018 11:48 am
by Battwell
im trying to orient and stop a slowly rotating spindle. (no brake)
the spindle has 1 index pulse sensor only.
im ramping up the pwm until the spindle just turns and the index signal is seen.
ramping up a #var with analogue out attatched to it to drive the spindle.

my question- re coding. what would be the best way
would a while loop- looking for the spindle pulse work faster than
an if loop. (as the if loop will only trigger if the index pulse is active at the precise timing of the if being called)

i have also tried running a macroloop- just running an if - setting a #var to 1 as soon as the index pulse is seen. (so its latched on once seen)
checking this #var in my orient spindle code- and if 1 killing the pwm back to zero.
im still getting rotation way past the sensor.

suggestions as to fastest way please.

Re: fastest sensor reaction.

PostPosted: Mon Jul 09, 2018 2:32 pm
by Vmax549
without a way to brake teh motor you will not be able to be that consistant with stop position and the inputs are slow. But that is not teh big problem as long as they are consistant.

With a DC motor you could try a crowbar relay where when teh relay opens to stop it also shorts across teh motor with a resistor to act as a brake.

You may want to consider engaging a small stepper or servo to teh spindle then you have total control over teh spindle position for index. You of course would need a spindle encoder with index signal. You could then engage teh driver and refhome teh spindle to teh index signal then rotate teh spindle to teh desired position for the ATC.

IF it is a brushed DC motor you could make a simple servo out of it.

Just a thought, (;-) TP

(;-) TP

Re: fastest sensor reaction.

PostPosted: Mon Jul 09, 2018 2:52 pm
by Battwell
its a dc servo with analogue only control (control techniques lynx drive)
ive left all original contactors etc intact that the original control used.
(so it was doing this using only whats still in the machine)- controlled by fanuc.
im using the original fwd run wires and analogue in. - the problem being that it requires to be at a certain pwm level before the motor starts spinning.
there is a tacho into the drive but no encoder.

this is the code that is giving best result so far- but its not fast enough.
i was wondering if using getled that its waiting for the actual led on the screen- instead of when the input toggles?- which would mean it cant update faster than the screen updates.?

int spinonport=3;
int spinonpin=2;

double p=2000;
bool pulse= (AS3.GetLED(35));

exec.Setvar (0,999); //set pwm to zero
exec.Setvar (0,998);
exec.Setoutpin (spinonport,spinonpin);

//wait for spindle sensor on = movement


exec.Setvar (p,998); //increment pwm analogue


if (exec.Ismacrostopped())
exec.Clroutpin (spinonport,spinonpin);

}while (!AS3.GetLED(10));

exec.Setvar (0,998);

exec.Clroutpin (spinonport,spinonpin);

Re: fastest sensor reaction.

PostPosted: Mon Jul 09, 2018 3:02 pm
by cncdrive
The LEDs states are updated quickly, not as fast as the screen drawing, but much faster.
The LEDs states are updated in a 10msec loop which is the speed of communication syncronisation data from the motion controller.
The screen is then drawn in another slower loop. When you query the state of the LED you not getting it from the screen, but from a variable array which is sent by the motion controller and that same array is read also by the drawing routine in another loop.
So, there is no faster way than querying the LED state.

Re: fastest sensor reaction.

PostPosted: Mon Jul 09, 2018 3:11 pm
by Battwell
ok. thank you.
thinking cap back on again!- ive already spent a lot of time with this.
i may have to end up putting in an ac servo with proper ab encoder and step/direction to achieve exactly what i want
the problem being finding a motor that will fit in the originals place.. drives are no problem i have loads here.
interesting this machine. ive already had to interface new drives to fanuc red cap motors- which everyone told me couldnt be done :-)
i love challenges!

Re: fastest sensor reaction.

PostPosted: Mon Jul 09, 2018 3:31 pm
by cncdrive
What about using an arduino or something like that to make the index pulse longer?

Re: fastest sensor reaction.

PostPosted: Mon Jul 09, 2018 3:37 pm
by Battwell
it sees the pulse ok. but the motor is already rotating. im trying to stop it at the index pulse. it over runs
(trying to work out how fanuc did it)

Re: fastest sensor reaction.

PostPosted: Mon Jul 09, 2018 3:40 pm
by Vmax549
OK so it it is already servo drive for teh spindle so all you need to do is replace teh analog drive with a step/Dir drive and add an encoder with index signal.

To make teh carousel super simple I would change out teh geneva drive with a belt drive stepper motor. Fast and simple to implement to UCCNC.

Easy Peasy, (;-) TP

Re: fastest sensor reaction.

PostPosted: Mon Jul 09, 2018 8:24 pm
by Robertspark
Thinking outside of the box

Is there any way to use the THC up / down signals to apply a break when a pulse is detected. They will be very fast

Re: fastest sensor reaction.

PostPosted: Mon Jul 09, 2018 8:52 pm
by cncdrive

The issue is that even if the signal is fast to get the information to the PC side software it still takes time.
For this reason time critical signals are handled directly on the motion controller, e.g. the THC control and because they are already handled it does not matter if the PC gets a feedback in 1msec or half second etc.
In a macro to read signals as LEDs the information must be sent to the computer side, because the macros run on the computer and so it takes at least 10msec for the info to get there.
And if a pulse is too short then it is possible that the sampling will be done before the short pulse and after the short pulse and the pulse itself will be not even sent to the PC.