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

changing out el3602 for el3602-0002 and updating link #78

Merged
merged 2 commits into from
Jan 17, 2025

Conversation

c-tsoi
Copy link
Contributor

@c-tsoi c-tsoi commented Dec 18, 2024

Description

We added the new EL3602-0002 and swapped it for the EL 3602.

Motivation and Context

The old slice was reading out incorrectly and a scientist requested us to change it out.

How Has This Been Tested?

Kaushik and I changed out the slice, logged into the plc and saw that the terminal was reading back a reason value.
Kaushik and Philip will do a checkout on Thursday to verify that it is working as requested.

Where Has This Been Documented?

Screenshots (if appropriate):

Pre-merge checklist

  • Code works interactively
  • Code contains descriptive comments
  • Test suite passes locally
  • Libraries are set to fixed versions and not Always Newest
  • Code committed with pre-commit (alternatively pre-commit run --all-files)

@c-tsoi c-tsoi marked this pull request as draft December 18, 2024 18:38
@KaushikMalapati
Copy link
Contributor

This looks good to me. There's still an xti file for the old 3602
https://github.com/pcdshub/lcls-plc-kfe-rix-motion/blob/9911fb89691ee5acb4ec32989ddcf7e6e246de11/plc-kfe-rix-motion/_Config/IO/PLC%20Rail%20(EtherCAT)/Power%20(EK1200)/Fiber%20Coupler%20(EK1521-0010)/Term%2034%20(EK1501-0010)/Term%2050%20(EK1122)/IM4K2-PPM%20(EK1100)/IM4K2-EL3602-E8.xti
but I assume that's okay since it's not being used anywhere. I will let you know if Philip and I notice anything tomorrow

@KaushikMalapati
Copy link
Contributor

@c-tsoi did you run and push pre-commit on this?

@c-tsoi
Copy link
Contributor Author

c-tsoi commented Dec 19, 2024

@c-tsoi did you run and push pre-commit on this?

Yeah, I am pretty sure I did. Are edits that were corrected?

@KaushikMalapati
Copy link
Contributor

KaushikMalapati commented Dec 20, 2024

I tried inputting some values from the el3602 manual into the IM4K2 custom analog input function block and I think there is a discrepency when plugging in max and min values.
image

https://download.beckhoff.com/download/Document/io/ethercat-terminals/EL36xxen.pdf#page=150

iRaw for 10V should be 0x7FFFFFFF, or 2147483647. With iTermBits=32, fTermMax=10, fTermMin=-10 (not using fResolution and fOffset for simplicity)
fScale := (EXPT(2, iTermBits) - 1), which is 4294967295
fReal := (iRaw / fScale) * fTermMax, which is 2147483647/4294967295* 10 = 4.999
which is half of what we want. Using iTermBits=31 would give us 10, the correct value.

@ZLLentz @jozamudi, can you tell me if this makes sense since you worked on #68 that added the custom analog input block for im4k2?

One of the sanity checks in #68 (comment) used 2^32-1 as the iRaw for a max voltage of 10V, but this seems to disagree with the manual page I was looking at.

@jozamudi
Copy link
Contributor

I think you're right. It looks like the iTermBits should be changed.

@ZLLentz
Copy link
Member

ZLLentz commented Dec 20, 2024

I think you're right too. I've gotten this one wrong too many times! Which means, maybe there's a better way to parameterize these that is less prone to errors....

@KaushikMalapati
Copy link
Contributor

Is there a way to make FB_AnalogInput.TcPOU capable of handling DINTs and INTs? For example, can we make
iRaw AT %I*: INT;
link to a DINT instead and let twincat upcast INTs?
We could also change its implementation to something like https://rosettacode.org/wiki/Map_range but use iTermBits to calculate a1 and a2

@KaushikMalapati
Copy link
Contributor

@c-tsoi once you make my suggestion can you makr this as ready for review and then we can merge?

@c-tsoi c-tsoi marked this pull request as ready for review January 17, 2025 18:29
@KaushikMalapati KaushikMalapati self-requested a review January 17, 2025 20:19
@KaushikMalapati KaushikMalapati merged commit 46d373d into pcdshub:master Jan 17, 2025
9 checks passed
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.

4 participants