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

Pulse distance encoding #140

Closed
wants to merge 10 commits into from

Conversation

echo-bravo-yahoo
Copy link

Hey! This is a WIP (it doesn't work right now), but I figured I'd open the PR in case you have feedback. I haven't used C/C++ in nearly 10 years, so very much welcome advice.

Closes #139.

uint32_t separator;
};

std::map<uint32_t, PDESettings> bcm2835_pin_settings_map = {};
Copy link
Author

Choose a reason for hiding this comment

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

This dependency on map makes it C incompatible... Not sure how to sanely get around it without dropping in a whole map replacement or consuming way more memory than necessary.

bcm2835_delayMicroseconds(bcm2835_pin_settings_map[pin].separatorDuration);

for(uint32_t index = 0; index < len; index++) {
// TODO: LSB. Should allow customizing for MSB as well
Copy link
Author

Choose a reason for hiding this comment

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

TODO: Allow for LSB/MSB setting.

bcm2835_gpio_clr(pin);
}

// TODO: should these be renamed? long is actually "high", short is actually "low"
Copy link
Author

Choose a reason for hiding this comment

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

TODO: Rename long -> high, short -> low.


void sunxi_delayMicroseconds(uint64_t micros)
{
// TODO: Implement this
Copy link
Author

Choose a reason for hiding this comment

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

TODO: Implement delayMicroseconds on sunxi hardware.

@echo-bravo-yahoo
Copy link
Author

So, I confirmed with an oscilloscope that - at least on a raspi zero W - the new busy wait strategy is accurate +/- 3 microseconds when sleeping for 400 & 1200 microseconds. This is well within my application's error tolerance!

However, it still doesn't work to drive the IR device I'd like to drive, and I don't know why. Some possible theories:

  • The IR device relies on the carrier wave also being at the correct frequency (this would make me so sad)
  • I have the endian-ness of my bytes wrong
  • My checksum is wrong
  • The durations (separator, long, short) were recorded incorrectly (if they're recorded as 400, but were actually 500, then reproducing 400 still means I won't be able to talk to the IR device)

I think my next step is to find the highest clock-rate arduino I have, hook an IR receiver to it, and send it messages to see if I can spot anything wrong with them.

@echo-bravo-yahoo
Copy link
Author

Ok, I've done a little more research, and I suspect the issue is that my separators (LED HIGH) aren't on a 38khz carrier wave. It appears that's incredibly standard for IR equipment, and most sensors filter for it to avoid being turned on by sunlight, bright lights, etc.

Ugh. Modulating my separator on a 38khz carrier wave is going to complicate this a lot. I think I'm going to try pigpio's node bindings and see if sending a waveform that way works. If it doesn't, I'll be back to explore modulating the separator for this PR.

Either way, leaving this up as a historical record. Feel free to close it whenever. :)

@echo-bravo-yahoo
Copy link
Author

Ok, so pigpio worked great for this. I'm closing this PR.

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.

Pulse Distance Encoding
1 participant