[SOLVED] Wink TX vs. Beep Interference

Wink setup, hardware, basic programming. User to user support.
wclift
Posts: 32
Joined: Sun Feb 07, 2016 6:10 am

[SOLVED] Wink TX vs. Beep Interference

Postby wclift » Sun Apr 24, 2016 12:13 am

This will probably end up a question for Kevin, but if anyone has hit this and found the issue, I'm interested. Here's my codebender sketch to demonstrate the problem:

https://codebender.cc/sketch:291002

The code is an expansion of the default TX/RX example program to use with the remote. I'm trying to have one remote button (PlumGeek Button) be a "missile launch" button. When a Wink receives the command, it should flash red and beep, then transmit a predefined value:

Code: Select all

TxIRKey(IR_Fire);

I extended the IR_* definitions by one and modified WinkHardware to treat this like a new kind of key. Wink transmits the code, and any other Wink that receives it, would perform the given response (spin and beep, in my example).

All this works well enough for now. That's not the issue. The issue is that as soon as I have Wink1 transmit the code, Wink1's buzzer stops working. No sound. It's easy for me to demonstrate repeatably on two different Winks, that after poweron, I can honk (X button), then press the PLUBGEEK button (red flash and beep), then try to honk again (X button). Honks before. Doesn't honk after! Reset, repeat. Works...doesn't work.

Somehow, as long as I don't use the TXIRKey() function, I can use all the other keys to spin and honk, etc. But as soon as I use the TXIRKey() function, that somehow interferes with the buzzer operation. I'm guessing there is some base-hardware/software variable or something that gets corrupted. I can think of no easy answer for why this operation disconnects the buzzer.

Suggestions welcome.
Thanks,
Wayne
Last edited by wclift on Sun Apr 24, 2016 7:29 am, edited 2 times in total.

Kevin
Posts: 125
Joined: Tue Jul 28, 2015 12:56 am

Re: Wink TX vs. Beep Interference

Postby Kevin » Sun Apr 24, 2016 2:49 am

Hey wc-

Good catch on this. What I think is happening is the function ModulateIR in WinkHardware is turning the Beeper pin to an input. I don't think this matters on the Wink, but on the Ringo (which is where I copied this function over from), the Beeper is actually a Chrip that creates tones by a PWM. We use the same internal PWM to modulate the 38KHz signal out the IR during the ModulateIR function. If we didn't do this (on the Ringo anyway) you may get the PWM of the 38KHz IR going into the piezo also.

At this moment I'm not sure if it's safe to remove this line from ModulateIR. We realized early on that if you send a high speed PWM signal into Wink's sound element, it may damage it. (We note this in the guide and that's why we use the beep() function which makes sure minimum timing is respected so things stay safe).

So the work around, is just before you call the beep function (or try to make Wink's sound element do anything), insert this line of code:

Code: Select all

pinMode(Beeper,OUTPUT);


This should flip that pin back to output mode and allow it to signal the beeper.

Let me know if that works.

Thanks!
-Kevin

wclift
Posts: 32
Joined: Sun Feb 07, 2016 6:10 am

Re: Wink TX vs. Beep Interference

Postby wclift » Sun Apr 24, 2016 7:27 am

That was the problem. But rather than insert the pinMode command before a beep() function, I just put it right AFTER the TXIRKey function, to restore the beep pin to usefulness. I'll experiment later with putting this functionality directly in the TXIR function somewhere. It makes more sense to me to localize this to the same function that disables the beep, and having it re-enable it when finished with the IR functionality.

Thanks for the pointer!
Wayne

Kevin
Posts: 125
Joined: Tue Jul 28, 2015 12:56 am

Re: [SOLVED] Wink TX vs. Beep Interference

Postby Kevin » Wed Apr 27, 2016 2:50 am

I would agree with this.

I would suggest placing the code to flip the pin back to an output at the very end of the TxIR function just before the closing curly. I would suggest leaving the ModulateIR function unchanged, as that function actually controls the internal registers to turn on and off the internal PWM peripheral on the chip. If you do it at the end of TxIR, that PWM action should be all finished by that point. If you discover this works and the buzzer doesn't make strange sounds during IR transmitting (which I don't think it can), let me know and I'll update the TxIR function on our end so the next release of the Base Sketch has this resolved.

Good catch again. :)


Return to “Wink Basics”

Who is online

Users browsing this forum: No registered users and 1 guest