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

Logic error on first sample with daisy #42

Open
baffo32 opened this issue Nov 2, 2016 · 0 comments
Open

Logic error on first sample with daisy #42

baffo32 opened this issue Nov 2, 2016 · 0 comments

Comments

@baffo32
Copy link

baffo32 commented Nov 2, 2016

I do not have a daisy board to test anything, but I noticed this reading the code:

firstDataPacket, initialized to true, is cleared to false at the end of updateBoardData(). It is then checked if false which it always will be because it was just set, data that hasn't been read yet is backed up, and the flag is re-cleared to false if true which will never happen because it has just been set to false, in updateDaisyData(). It looks like this would result in the first sample being corrupt.

It looks like the clearing of firstDataPacket should be moved out of the individual channel update functions here and here and into the end of updateChannelData which calls them both, right here.

After this change, though, it still looks like the first sample sent would still be corrupt, because meanDaisyChannelDataRaw is not specified in the first sample. One solution would be to add an else { } block here containing code that would fill meanDaisyChannelDataRaw with the contents of daisyChannelDataRaw without any averaging.

If one were to address this area of code more thoroughly, there is an additional possible 'issue' which is that the daisy and board running averages are sampled when output, alternatingly, so there is no way to reconstruct from the output a complete 'snapshot' at any point of time -- the daisy information represents time = (x+1/2), and the board information represents time = (x-1/2). A different approach would be to change the logical flow to output briefly buffered averages from the past that are both taken from the same points in time.

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

No branches or pull requests

1 participant