Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support the configuration of slaves to use only dc sync1 #21

Merged
merged 2 commits into from
Sep 14, 2024

Conversation

marcfir
Copy link
Contributor

@marcfir marcfir commented Sep 3, 2024

Our problems with #15 come from a wrong DC configuration.
TwinCAT only uses the SYNC1 signal. If we use the same configuration, the slave can go to OP.

I don't know how to read this from the ESI, but it works.

<Dc>
	<OpMode>
		<Name>DcSync500us</Name>
		<Desc>DC-Synchron (Sync0Shift 500us)</Desc>
		<AssignActivate>#x0500</AssignActivate>
		<CycleTimeSync0 Factor="1">0</CycleTimeSync0>
		<ShiftTimeSync0>500000</ShiftTimeSync0>
	</OpMode>
	<OpMode>
		<Name>DcSync250us</Name>
		<Desc>DC-Synchron (Sync0Shift 250us)</Desc>
		<AssignActivate>#x0500</AssignActivate>
		<CycleTimeSync0 Factor="1">0</CycleTimeSync0>
		<ShiftTimeSync0>250000</ShiftTimeSync0>
	</OpMode>
	<OpMode>
		<Name>DcSync1000us</Name>
		<Desc>DC-Synchron (Sync0Shift 1000us)</Desc>
		<AssignActivate>#x0500</AssignActivate>
		<CycleTimeSync0 Factor="1">0</CycleTimeSync0>
		<ShiftTimeSync0>1000000</ShiftTimeSync0>
	</OpMode>
	<OpMode>
		<Name>FreeRun</Name>
		<Desc>Free Run (no synchronization)</Desc>
		<AssignActivate>#x0000</AssignActivate>
	</OpMode>
</Dc>

@marcfir
Copy link
Contributor Author

marcfir commented Sep 4, 2024

The magic number is <AssignActivate>#x0500</AssignActivate>. This is the Dc active flag. At least the top two bytes.
So when configuring from an ESI file, it may make sense to write the active flag directly instead of the enum number in ec_slave_set_dc_config().

@robert-burger
Copy link
Owner

ok it understand but did not see that configuration so far.

the "AssignActivate" is simply the content written to register 0x981 (activation register, byte swapped in XML).

Bit 0 : sync activation
Bit 1 : sync0 generation
Bit 2 : sync1 generation

I totally have no idea why they preferred sync 1 generation over sync 0, but obviously they did. Regarding your last comment, can you make the changes to pass the register content directly in ec_slave_set_dc_config? maybe also rename slv.dc.type to slv.dc.activation_reg?

Copy link
Owner

@robert-burger robert-burger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

write activation reg directly

@marcfir
Copy link
Contributor Author

marcfir commented Sep 13, 2024

Hello Robert. I have added the changes. Does that fit?

Copy link
Owner

@robert-burger robert-burger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm. Very nice, thanks.

@robert-burger robert-burger merged commit 231ca58 into robert-burger:master Sep 14, 2024
@marcfir marcfir deleted the feat/sync1 branch October 8, 2024 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants