1746-HSCE with Incremental Encoder

ElectricFreak

Member
Join Date
Dec 2009
Location
Indiana
Posts
26
Hi Everyone,
I have searched the previous threads, but could not find an answer to my problem.
My process uses feed rolls to meter out product.
Attached to these rolls is an AB 845H-SJHZ24CNY2 Incremental Encoder with 1000 pulses per revoultion.
This is connected to a 1746-HSCE.
I need to tell the gearmotor driving these rolls to stop when a certian count is reached, and store that count as an
integer. then reset the count.
My program works for now. However I never really felt good about it.
Most of my head bashing results when trying to soft reset the encoder count, to start a new count.

Is the soft reset supposed to reset the count? if so what am I doing wrong?

Attached is a really quickly chopped part of my program,

Please look at ladder 13.


If someone has a sample of how to soft reset the HSCE I would love to see it.

Thanks,
Chris
 
Don't reset it in the card. If you do reset it, there will always be the chance that it moves during the reset and you end up "off" by a few counts.

Store the distance traveled in your own registers, which can be reset, but are calculated each scan by looking at the amount of change in the encoder count.

Just my opinion...
 
Won't the counter eventually exceed the 32 bit limit?

You are correct about the move during reset, but this encoder is super overkill for the process. movement under 100 counts means almost nothing.
Still, I would like to be as accurate as possible.

I guess I don't understand what happens when the encoder count rolls over? (assuming it does??)

I think I must be missing something here???
how do I compare the amount of change without keeping a running count?
 
The SLC processors make rollover kind of a pain. The firmware doesn't allow integer math overflows to work the way the CPU would allow it to. The firmware limits incrementing integer values to 32767. The processor will set the overflow bit indicating that an overflow occurred but it will limit the integer value to 32767 regardless of the result.

If you look at an integer as a group of bits the value 32767 is represented as all bits set except for bit 15. The next increment would result in all bits RESET except for bit 15. The 2's complement value for this bit pattern is -32768.
So take the example of -32786 - 32767. If you allow the CPU to operate without limits on this value the result would be 1 with the overflow bit set. In reality the CPU would come up with the correct negative mumber if it had enough bits available. But the CPU simply populated the data bits avaliable, discarss the rest and sets a bit indicating the result caused an overflow. We can use this to our advantage when looking for deltas in freely incrementing and decrementing integers. But the SLC won't allow this to happen.

How does this apply to you? If you want to be able to correctly detect rollover you need to limit the count value to a known value This will require you to set a rollover limit in the VHSC or at least know what the value is.

As OkiePC said, calculate the per-scan delta between the current scan count and the previous scan count. If the absolute value of the delta is greater than half of your rollover value you know the count rolled over in one direction or rhe other. If the delta is a very large negative number, add one plus the rollover count to the delta to get the true delta. If the delta is a very large positive number, subtract one plus the rollover count to the delta to get the true. Then add this conditioned delta to another variable to get the active count.

I guess the question is whether this gets you anything. It may or it may not depending on how you use the count and how flexible you want to be. As far as resetting goes, make sure that bit 7 in the reset mode control word is set. This enables soft reset.

Keith

Edit:
I just had a chance to look at your posted code. You are not setting the soft reset enable bit in the set-up and control word (N7:1). Move -14720 into N7:1 and you should be good for soft reset.
 
Last edited:

Similar Topics

I had a 1746-HSCE go suspected bad. have to swap the card in the morning. Other than dip switch settings is there any configuration to do?
Replies
1
Views
1,035
Hi there, I have a machine where was a servo with extra encoder. That encoder had resolution 100ppr/5V. We did replace complet servopack (...
Replies
0
Views
957
I have a SLC 5/05 processor and I am trying to reference an output from a High speed counter card to be used elsewhere in the PLC. The output...
Replies
1
Views
1,647
I am upgrading HSC modules and have some questions. I can't attach the manuals for reference as they are too large. 1746-HSCE uses M0:e.1/4 for a...
Replies
0
Views
1,661
Processor Error Message: G file configuration error.. user program G file size exceeds capacity of the module. I cannot seem to find any data...
Replies
3
Views
2,054
Back
Top Bottom