News:

  • June 08, 2026, 03:08:48 AM

Login with username, password and session length

Author Topic: H2-CTRIO and negative numbers  (Read 17075 times)

DBen

  • Newbie
  • *
  • Posts: 5
H2-CTRIO and negative numbers
« on: March 08, 2008, 01:27:57 PM »
Greetings,

I posted this at AD with no reply, so I thought I would try here with more detail.

I have the following set-up:

DL260
Directsoft5
H2-CTRIO
C-more touch panel

I have a turntable application. The turntable rotates 360 degrees. There is an encoder tracking the position. 2144 encoder counts = 360 degrees. When the turntable is homed, it rotates in the CCW direction until the home switch rides up on a "dog". I need to continue rotation for 5 degrees, reverse direction until the switch clears the dog, clear the counter and stop. The reason for this is to take the mechanical backlash out of the table.

I have no problems reading the counter and controlling the table, but when the table rotates CCW past the switch, my counter register reads 0 (and thus my touch panel also). I really need to see that it rotated 5 degrees in the negative direction. Right now I have no scaling in CTRIO workbench and I am trying solve the problem mathematically in PLC code, but I am having very strange results.

Any suggestions?

David

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: H2-CTRIO and negative numbers
« Reply #1 on: March 12, 2008, 11:23:47 AM »
What kind of a actuator do you have operating the table? ie:hydraulic, ac, dc, stepper ,servo, and how are you interfacing with the motor controller? ie:current loop, voltage loop, pulse output, serial, digital, etc. What direction does the table rotate when operating in normal run mode? Are you reversing the direction to find home? Does the table reverse on every rotation? let me know and maybe we can figure something out.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

MikeS

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 264
    • Host Engineering, Inc.
Re: H2-CTRIO and negative numbers
« Reply #2 on: March 12, 2008, 01:18:17 PM »
when you mention "my counter register reads 0", are you referring to the register in the plc memory that the current count is mapped to? or are you looking at the count value in the ctrio itself (via ctrio workbench)?

if it's the plc memory register, which register is it? and what format (in dataview) are you using to look at it? the current count value is a signed 32-bit value, but the plc doesn't have a group of registers that are specifically for storing signed values, all v-memory is unsigned 16 bit. could it be that in dataview you're looking at the mapped register in the PC as an unsigned decimal (which is the default value)?
Good design costs a lot. Bad design costs even more.

Gene Bond

  • Newbie
  • *
  • Posts: 5
Re: H2-CTRIO and negative numbers
« Reply #3 on: March 04, 2010, 11:11:15 PM »
Maybe I'm trying to do it the hard way, because I have DS32v4(build 25), but I have a similar problem.

It's probably my rusty brain, but I am not sure what number format I should be using when comparing the current count to a preset (in ladder):

0 STR C1
1 LDD V2000
2 CMPD V4000
3 STR C1
4 AND SP60
5 OUT C1440
6 STR C1
7 AND SP62
8 ANDN SP61
9 OUT C1450
10 NOP
11 NOP
12 NOP
13 NOP
14 END

But, when the current count goes to -1, SP62 comes on, indicating the current count(v2000) > preset(v4000).

If I use LDR & CMPR, SP60, 61, 62 are all off! I suppose I could add a rung with all 3 ANDN, but that seems like an ugly bandaid!

An example would sure help!

Gene Bond

  • Newbie
  • *
  • Posts: 5
Re: H2-CTRIO and negative numbers
« Reply #4 on: March 04, 2010, 11:18:01 PM »
OK, this works:

0 STR C1
1 LDR V2000
2 CMPR V4000
3 STR C1
4 STR SP60
5 STRN SP60
6 ANDN SP61
7 ANDN SP62
8 ORSTR
9 ANDSTR
10 OUT C1440
11 STR C1
12 AND SP62
13 ANDN SP61
14 OUT C1450
15 NOP
16 NOP
17 NOP
18 NOP
19 END

Is it the best/only/right way?