RN-42 Bluetooth module and atmega328 interference problem

Hi everyone.

I’m trying to build a game controller using an roving networks RN-42 bluetooth module, an atmel atmega328p microcontroller and a LPR5150 gyroscope.

The problem i have found it’s that when the controller board (dual layer pcb) it’s steady on a table, the computer recibes constant data from the controller, like if it was being moved. The data shows very little movement (very little variation) on hyperterminal. I’m using the 4x output of the gyro. So this are the tests y carry on once i found myslef with this problem:

First, i tried replacing the gyro just in case. Problem persisted.

Later, I tried giving a dedicated supply source to the RN-42, just in case that the current consumption when transmitting could be the problem. Nothing changed.

I tried getting the gyro away from the BT module via cable extension (about 10 inches of cable were added). The problem persisted.

Then i got the gyro back to place in board, and get the rn-42 away via cable extension (also 10 inches aprox.). Here, altough the problem persisted, it changed its period of time…in another words, it took more time then before to the noise to reappear. (Let’s say.it appears every 2x the time that it appears before). range value of the noise (variation) didn’t changed at all, only time.

So i was thinking that maybe this noise or interference wold be generated between the BT module and the atmega328. I decided then to lower the rn-42 transmitting power via commands. I lower it gradually until i reach the minimum power (-20dbM), but the noise was still there, with no difference in range nor period.

so i decided to ask if anyone of you have seen this kind of situation before, and if knows how to solve this issue.

Getting the BT-module far away from the microcontroller it’s not a solution for me, since the entire board it’s 4 inches lenght, and it seemed after my tests that even 10 inches of distance it’s to little (because the problem was still there, altough “better”).

The reaction that this “noise” generates on my final project it’s that the computer detect continuous movement, and taking sensibility off causes that soft little movements don’t get detected by the computer (loss of accuracy or precision).

Thanks in regards.

nemor:
Hi everyone.

I’m trying to build a game controller using an roving networks RN-42 bluetooth module, an atmel atmega328p microcontroller and a LPR5150 gyroscope.

The problem i have found it’s that when the controller board (dual layer pcb) it’s steady on a table, the computer recibes constant data from the controller, like if it was being moved. The data shows very little movement (very little variation) on hyperterminal. I’m using the 4x output of the gyro.

I’m deducing that the controller is not supposed to output any data (via the RN-42) to the computer if there’s been no motion. What’s your algorithm to decide this and what’s the threshold for declaring motion vs no motion ? When you say “The data shows very little movement”, is this little amount inconsistent with your threshold ? I’m wondering if you’re compensating for the gyro bias that will be present and if that’s the source of your problems rather than some EMI or other noise. The gyro(s) will be indicating some small amount of motion even when there is none. You’ve got to compensate for this bias/offset.

Mee_n_Mac:

nemor:
Hi everyone.

I’m trying to build a game controller using an roving networks RN-42 bluetooth module, an atmel atmega328p microcontroller and a LPR5150 gyroscope.

The problem i have found it’s that when the controller board (dual layer pcb) it’s steady on a table, the computer recibes constant data from the controller, like if it was being moved. The data shows very little movement (very little variation) on hyperterminal. I’m using the 4x output of the gyro.

I’m deducing that the controller is not supposed to output any data (via the RN-42) to the computer if there’s been no motion. What’s your algorithm to decide this and what’s the threshold for declaring motion vs no motion ? When you say “The data shows very little movement”, is this little amount inconsistent with your threshold ? I’m wondering if you’re compensating for the gyro bias that will be present and if that’s the source of your problems rather than some EMI or other noise. The gyro(s) will be indicating some small amount of motion even when there is none. You’ve got to compensate for this bias/offset.

First of all, thanks Mee_n_Mac for your fast reply.

Yes, when the controller it’s steady it shouldn’t send any data via RN-42. I have implemented a compensation in the MCU program, but the variation that i have it’s bigger. For giving you an idea. my data range goes from 300 to 700 considering 500 as a center o zero. In normal operation, the range actually goes from 400 to 600 only. The noise I have produces variations from 480 to 520, that’s a lot, and my compensation goes from a range of ±3 (487 to 503) and it’s there mainly to reduce common hand vibration.

I tested the board replacing the RN-42 for a wired serial interface, and it works perfectly, no noise, completely stable. When steady in a table, the MCU sends nothing at all at the computer.

So from there i think that the problem it’s the RN-42, but maybe you guys have a different view of this.

Once again, thanks in advance.

Edit: wired* serial interface.

Well you did the 2 things I would have recommended, remove the RN-42 and see if the problem persists (it didn’t) and then isolate the RN-42 on it’s on PS (problem remains). Odd that the problem changes with distances though RF power made no difference. Can you describe the interference (“noise”) a bit more ? I’m envisioning a burst of “noise” X msecs long every Y msecs, with the noise having an amplitude of 40 counts pk-pk. The Y doubled with further distance between the RN-42 and the rest of your board.

Is there any chance that communications between your micro and the RN-42 is stepping on getting data from the gyro ? That the noise is corrupted data due to the A/D process getting interrupted or otherwise not having enough time to complete ? When you removed the RN-42 did you leave in the code to talk to it or remove it ? Are both gyro axes noisy or just one ? If the later, which one is sampled first ?

Mee_n_Mac:
Well you did the 2 things I would have recommended, remove the RN-42 and see if the problem persists (it didn’t) and then isolate the RN-42 on it’s on PS (problem remains). Odd that the problem changes with distances though RF power made no difference. Can you describe the interference (“noise”) a bit more ? I’m envisioning a burst of “noise” X msecs long every Y msecs, with the noise having an amplitude of 40 counts pk-pk. The Y doubled with further distance between the RN-42 and the rest of your board.

Is there any chance that communications between your micro and the RN-42 is stepping on getting data from the gyro ? That the noise is corrupted data due to the A/D process getting interrupted or otherwise not having enough time to complete ? When you removed the RN-42 did you leave in the code to talk to it or remove it ? Are both gyro axes noisy or just one ? If the later, which one is sampled first ?

Well, I manage myself to find the cause of the problem.

so first the problem, later i’ll answer your questions since it’s the least you deserve my friend.

I was ran out of ideas, so i decided to try the ones i considered the bests again, while i waited to see what you think about this. So, while i was re-doing the “isolate RN-42 on it’s on PS” i decided to completely isolate it, desolder it again and conect it in a completely different board. I then found that the problem disappeared!! So, angry with myself, i re checked all the lines that i cut that were connecting the rest of the pcb (the one that i used the first time i tested) with the RN-42 PS and I found one not completely cuted off.

Sorry about this, really.

Now i have placed 2 zener diodes, one for the RN-42, and one for the MCU, so i can with one battery supply both parts of the circuit, but separating the noise generated by the high current consumption of the bluetooth module. After some extra tests, for the sake of knowledge, i found that this current consumptions changes were generating voltage drop change in the very self tracks of the pcb, since the calculated resistance was from about 0.63 ohms.

Finally, for your questions:

About the noise: let’s say hyperterminal show this to me, with the gyro completely steady:

x 486 y 516

x 486 y 516

x 486 y 516

timeout 1 second max.

x 486 y 516

x 486 y 516

x 486 y 516

were the “x 486 y 516” data it’s the interference. Both axis show similar variation, altough X (roll) was always below 500 and Y (pitch) always above.

When i removed the RN-42 i left the code exactly the same, since all i did was putting cables from TX and RX of the MCU and sending them to a serial interface board that i already had from other projects.

Thanks for your help, and your willing to help. Great attitude. I f you want to know anything else about this project or the problem itself, i’ll be happy to reply.

And once again, i’m sorry for the trouble, it was my bad on cutting/bad testing the PS tracks of the pcb.

nemor:
Well, I manage myself to find the cause of the problem.

Then it’s time to go drinking !! :mrgreen: