Monday, 11 February 2019

ATMEGA328P standalone sketch doesn't work as expected


As I finished programming the MCU in the Arduino Uno board to receive some RF Signal and drive relays, I moved it into a standalone board I made with Eagle. The circuit is pretty basic, the MCU receives data from a RF Receiver, processes it and then turns on/off some pins that drive 5V relays (through transistors, of course). When I test it on the Arduino Board, you can see that the LEDs toggle ON and OFF whenever I send the data through the RF Transmitter. You send once, it toggles ON, you send another time, it toggles OFF and so on. This works for all the 4 PINS that it has programmed. In my standalone board, each of these four pins are connected to transistors that drive 5V relays. The problem is that only one pin seems to activate, and then it won't even toggle OFF, like you send the data once and you can hear the relay's coil go ON, but then if you try to toggle it OFF it just won't, it's latched ON and I have to unplug and plug the USB cable again to reset it. The ATMEGA328P has a 16MHz crystal, two 22pF caps for the crystal, and a 10K resistor that goes from the Reset Pin to VCC. I'm not sure why the MCU behaves so weird in my board. There's also another VERY weird detail I didn't mention. If instead of using the RF Receiver, I connect the Data Output pin of the PIC that drives the RF Transmitter directly into the Receiver board, that one pin I mentioned that works is able to toggle OFF and ON again, but still, the other pins just don't work. I've tested it not only by hearing the relay's coil but also by using a multimeter. Any help would be really appreciated.


EDIT:


Here is the Eagle Schematic of the board:


Schematic


It's true that I really didn't concern about the noise, but since it was quite a simple project I didn't think that noise was going to attack so violently, plus I don't really know how to protect the circuit from inductive noise. Thank you for answering fast!


EDIT 2:


Okay so here goes more detail:



Board


Real photos:


Real photo


Real photo


The soldering seems quite awkward but I probed all the traces to check for continuity.


I could make some extra holes to, for example, add a 100nF decoupling capacitor for the MCU and so, but if you think I should enhance the schematic and add a lot more components, then I'll gladly remake the board.


About the supply, right now (for debugging) I'm connecting the Arduino Uno to a Cellphone Charger (Notebook won't supply enough current for relays), and I'm connecting those red and black cables to the Arduino Uno. I'm using that Cheap 433MHZ RF Receiver so if the circuit is so vulnerable to noise as you say, it may also be getting fouled up by the noise.




No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...