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

Add fast_brake command for HWP rapid spindown #787

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

17-sugiyama
Copy link
Contributor

@17-sugiyama 17-sugiyama commented Oct 30, 2024

Description

Update brake command of hwp_supervisor.

Motivation and Context

WG team is trying to measure the time constant by changing the hwp frequency rapidly e.g. +2Hz to -2Hz.
Current brake command is designed for gentle spindown and it takes >10 min to start inverse rotation.
New option of brake command is expected to take <2 min to spindown.
https://docs.google.com/presentation/d/1-kgAFn2sVR3R_Hp8_HcEYgZ8_SoNihm-UwsMn-Skxto/edit?usp=sharing

How Has This Been Tested?

Not tested yet

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Comment on lines 1189 to 1201
elif isinstance(state, ControlState.WaitForFastBrake):
f0 = query_pid_state()['current_freq']
time.sleep(5)
f1 = query_pid_state()['current_freq']
if f0 < 0.2 or (f1 > f0):
self.log.info("Turning off PMX and putting PCU in stop mode")
self.run_and_validate(clients.pmx.set_off)
self.run_and_validate(
clients.pcu.send_command,
kwargs={'command': 'stop'}, timeout=None
)
time.sleep(5)
return
Copy link
Contributor

Choose a reason for hiding this comment

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

This block of code seems largely similar to the block of code handling ControlState.WaitForBrake in lines 1149-1165, with the only difference being that this block doesn't wait for the rotor to completely spin down. It might be simpler to add a boolean attribute to ControlState.WaitForBrake named fast which determines whether or not to run lines 1160-1164.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also whenever the ControlState.WaitForFastBrake finishes, it should set the state to ControlState.Done

@bbixler500
Copy link
Contributor

In terms of content this all seems perfectly reasonable to me (although we should definitely test the fast brake process with an actual device before merging). However, structurally it might be best to merge the fast brake control states into the normal brake states, as they seem to share many of the same lines of code.

Comment on lines +1149 to +1151
if state.fast:
time.sleep(5)
return
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not very safe. We should do WaitForTargetFreq.

But I think the motivation of this PR is to change the rotation direction quickly for special calibration, and you may not want to add WaitForTargetFreq. Therefore, it might be better to have a separate function that will change rotation direction, which will be faster than doing fast brake and spin up.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes I agree. Just wondering what is the behavior if you PID to -2 Hz by changing the PID direction while sitting at 2 Hz? If we can get something like that to work I agree we should make it a specialized operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what is the behavior if you PID to -2 Hz by changing the PID direction while sitting at 2 Hz?

This command will also rapidly change the rotation direction.
Changing PID direction flips the direction of acceleration and the HWP slows down. As the absolute PID frequency stays at 2 Hz, the PMX serves the highest voltage and current to recover 2 Hz, which results in a strong brake. Then the HWP speeds up to opposite direction and reaches -2 Hz.
But the current hwp_supervisor looks it doesn't expect this procedure so this will require some changes anyway.
Which looks better @ykyohei ?

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