dinsdag 30 juni 2015

Making everything wireless; PCBs.

For a long time I've had the plan to make all my projects wirelessly controllable, but I never really found a cheap, reliable module. I experimented with simple 433Mhz RF modules, zigbee modules, and wifi modules before I found the 2.4GHz NRF module I ended up using. 

With the simple RF modules the arduino had to do the encoding and such itself, this didn't work really well for me and meant less processing power for other stuff. The zigbee modules were all quite expensive, but did work well. Wifi became pretty interesting when the ESP modules started coming up, but having 20 wifi devices on my router might become somewhat impractical, and I didn't feel like I needed all the TCP handshakes and such. 

The 2.4Ghz (NRF24l01+) modules were really cheap, and worked straight out of the box with a pretty clear library. The downside to these were that the library I picked used the hardware SPI pins, which I also used in the shiftPWM library to control a bunch of LEDs in the first project I wanted to make wireless. At the time I didn't really get all the C++ stuff in the library, so I didn't think if touching the library itself. It was a few months later when I had an actual C++ course at my study and tried to implement software SPI instead. This did take quite some time to get right, apparently the atmega locks the use of the hardware SPI pins once you have initialized the SPI mode. Once I got this sorted out and the software SPI worked the modules became pretty flexible to use. I made the room lighting I had at the time wireless with these modules, but it always turned into a big wirey mess. To solve this, and make it really easy to add new devices, I started designing PCBs for the module. 



On the first version I had an Arduino pro mini, an NRF module, and, because I had space left, an ESP Wifi module aswell. For the 5 and 3.3v regulators I used through hole ones, because they use less board size than standard SOT-232 regulators. On the bottom are 6 smd 4A N-channel mosfets hooked up to the atmega's PWM pins. On one of those there is place for a TO-220 mosfet aswell, might I need more than the 4A the small ones can deliver. All the headers at the top are used to break out the atmega's analog and SPI pins. 

The downside to this version was that it was really high. The TO-220 regulators and mosfet made it hard to fit in a small box, and when programming it the USB-Serial converter had to go in vertically. 


To make everything a lot smaller I went with an Arduino Nano on the next version. This saves me a 5V regulator, since there is one on the Nano itself. I also redid the layout for a bit, and added an optional ldr and temperature / humidity sensor. I also replaced the last two TO-220 packages with smd versions, and removed the electrolytic capacitor that I never really used. One addition was the possibility to place diodes at the mosfets, for when switching inductive loads.

Most adapters I used had a DC jack though, so one thing I almost always had to do when hooking light up to the boards was screw a female DC jack to the screw terminal. This was rather anoying, so the next version had to have a DC jack itself. The two modules sticking out at the end were also quite anoying. I also switched from Ultiboard to Circuit maker here, so the 3D previews are a bit more fancy. 


Apart from adding the DC jack I removed a lot as well. The arduino library uses one of the atmega's timers to count all milliseconds and microseconds since it started. This is pretty usefull because I don't have to use any timers to run a bit of software every so much seconds. The downside to this is that you can't really change this timer's frequency, and thus can't increase the PWM frequency of the two connected PWM pins. For lighting the standard 1000Hz frequency is, in my opinion, a bit too low. So on the new board I removed the two mosfets from these pins. 

The ESP modules on the two previous boards were also never used, so those could go too. The large humidity sensor didn't get placed either, so I removed that aswell. If I would feel like using one I could easily grab one of the older boards. I did place a small digital thermometer in it's place, and kept the LDR. Another change is the use of a smaller version of the NRF module. It works exactly the same, but is smaller. No reason to keep the big one! I also put the capacitor back, because some cheap chinese power supplies tend to make a lot of noise without it, and again changed the layout. I now ended up with a pcb that I can't think of improving yet. (:


On the order with the previous PCBs I had a bit of space left. I order my PCBs on dirtyPCBs.com, where you can just fill a 10x10cm piece with whatever you want, and get 10 of those for $25. If you use less of the 10x10 shape it won't save you any money, so I had to think of something to fill the bit I had left. When making the smartphone controlled looping louie I wanted to put the board into the base of the game itself, but that didn't fit. For this I made a really small pcb, with only the NRF module and it's 10uF capacitor. This way I can upgrade every Arduino Nano with wireless capabilities! 

Geen opmerkingen:

Een reactie posten