Jump to content
OMRON Forums

How to address bit of I-value?


jwlamb

Recommended Posts

I want to be able to set a bit in an I-value register. Specifically, I would like to control the limit flag (bit 17) in the Motor Mode Flag Mode (Ixx24).

 

The suggested code (see below) writes all the bits; is there a way of setting all the bits?

 

 

;*********** Motion Program Set-up Variables (to be saved) *************

CLOSE

I123=-10 ; Home speed 10 cts/msec negative

I124=$000000 ; PMAC-style flags, normal mode

I125=$78000 ; Use Servo IC 0 Channel 1 flags for Motor 1

I126=32000 ; Home offset of +2000 counts

; (enough to take you out of the limit)

I7102=3 ; Capture on rising flag and rising index

I7103=2 ; Use +LIM1 as flag (negative end switch)

;*********** Motion program to execute routine *********************

OPEN PROG 101 CLEAR

I124=$20000 ; Disable +/-LIM as limits

HOME1 ; Home #1 into limit and offset out of it

I124=$0 ; Re-enable +/-LIM as limits

CLOSE ; End of program

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

To set bit 17 alone, you can use:

 

I124 = I124 | $20000 ; Logical OR with bit 17

 

To clear bit 17 alone, you can use:

 

I124 = I124 & $FDFFFF ; Logical and with all bits except 17

 

To make the code more readable, you could use the following substitutions:

 

#define Bit17Val $20000

#define Bit17Comp $FDFFFF

Link to comment
Share on other sites

To set bit 17 alone, you can use:

 

I124 = I124 | $20000 ; Logical OR with bit 17

 

To clear bit 17 alone, you can use:

 

I124 = I124 & $FDFFFF ; Logical and with all bits except 17

 

To make the code more readable, you could use the following substitutions:

 

#define Bit17Val $20000

#define Bit17Comp $FDFFFF

 

Excellent! Thanks.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...