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

Update triangle waveform function to match pslab-android #218

Closed
bessman opened this issue Oct 30, 2023 · 4 comments · Fixed by #224
Closed

Update triangle waveform function to match pslab-android #218

bessman opened this issue Oct 30, 2023 · 4 comments · Fixed by #224

Comments

@bessman
Copy link
Collaborator

bessman commented Oct 30, 2023

fossasia/pslab-hardware#111
fossasia/pslab-android#2364

The triangle waveform generated by pslab-android was messed up due to a difference in how the modulo operator is handled in Python and Java. pslab-python uses this function:

y = abs(x % 4 - 2) - 1, -1 <= x < 3

In Python, -1 % 4 == 3, so this results in:

Figure_1

But in Java, the modulo operator return the negative remainder if the dividend is negative; -1 % 4 == -1, so this function instead results in:

Figure_2

pslab-android now uses this function instead:

y = abs(x % 4 - 2), 0 <= x < 4

Which results in:

Figure_3

This function should also be used in pslab-python, for two reasons:

  1. We want to minimize differences between pslab-python and pslab-android
  2. As the bug in pslab-android demonstrates, it is unwise to rely on the behavior of the modulo operator with negative numbers

Since this change will change pslab-python's observerble behavior (i.e. the bytes it sends over serial), it will be necessary to re-record the serial traffic for the associated test case.

@ShashankSrivastava2002
Copy link

i want to work on this issue.

@bessman
Copy link
Collaborator Author

bessman commented Nov 27, 2023

Go ahead! You will need to change:

  1. This function
  2. And the associated test data

To update the test data, your changes must be run against the PSLab hardware. I can help you with that when you are done with point 1 above.

@suvanbanerjee
Copy link
Contributor

@bessman Is this issue still open ?

@bessman
Copy link
Collaborator Author

bessman commented May 12, 2024

Yes.

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 a pull request may close this issue.

3 participants