Skip to content

Commit

Permalink
refactored tuning script + no more phab inf loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankrebs016 committed Apr 4, 2024
1 parent 38ed943 commit 0ede8d7
Show file tree
Hide file tree
Showing 2 changed files with 193 additions and 144 deletions.
6 changes: 5 additions & 1 deletion lab4_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,13 @@ def automatch_phab(self, lab, match=1):
phab = self.scan_value(scanNum, wr_edge) & 0x01
if self.invertSync:
phab = phab ^ 0x01
loop_count=0
while phab != match:
print("LAB%d wrong PHAB phase, resetting." % i)
loop_count=loop_count+1
if loop_count>9:
err=True
break
self.clr_phase(i)
phab = self.scan_value(scanNum, wr_edge) & 0x01
if self.invertSync:
Expand Down
Loading

3 comments on commit 0ede8d7

@barawn
Copy link
Contributor

@barawn barawn commented on 0ede8d7 Apr 4, 2024

Choose a reason for hiding this comment

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

@ryankrebs016 that PHAB loop limit of 9 is pretty low, actually: you wouldn't see it messing around, but a 1-in-1024 event isn't that large from an automation point of view

@ryankrebs016
Copy link
Author

Choose a reason for hiding this comment

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

I’ll keep this in mind if it starts causing issues. Right now Cosmin is seeing this loop get stuck indefinitely on a station so I’m just trying stop it

@barawn
Copy link
Contributor

@barawn barawn commented on 0ede8d7 Apr 4, 2024

Choose a reason for hiding this comment

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

You probably want to have it check to see if PHAB is actually toggling at all beforehand: in the code it just assumes it's OK:

                # Find our PHAB sampling point.
                self.set_tmon(lab, self.tmon['WR_STRB'])
                wr_edge = self.scan_edge(scanNum, 1, sync_edge)
                if wr_edge == 0xFFFF:
                    print("No WR_STRB edge found for LAB%d, skipping!" % i)
                    err = True
                    continue
                # if WR_STRB edge finding worked, PHAB should too

change to

                # Find our PHAB sampling point.
                self.set_tmon(lab, self.tmon['PHAB'])
                wr_edge = self.scan_edge(scanNum, 1, sync_edge)
                if wr_edge == 0xFFFF:
                    print("No PHAB edge found for LAB%d, skipping!" % i)
                    err = True
                    continue
                self.set_tmon(lab, self.tmon['WR_STRB'])
                wr_edge = self.scan_edge(scanNum, 1, sync_edge)
                if wr_edge == 0xFFFF:
                    print("No WR_STRB edge found for LAB%d, skipping!" % i)
                    err = True
                    continue

The only way I can think of this happening is if the timing is such that the PHASE signal (which toggles the PHAB flipflop) is so short that it disappears, but even that's weird because the PHASE signal's wider than say WR_STRB so who knows.

Please sign in to comment.