Showing posts with label hardware. Show all posts
Showing posts with label hardware. Show all posts

Sunday, March 19, 2017

Battery node with USB charging

Shortly after introducing rearranged PCB layout for nodes, I realized that I use LiPo batteries in all my battery powered nodes. That is making no use of the step up capabilities of the DC to DC converter. When designing it I was wanting to have possibility to run the nodes from variety of batteries. But it was never happened. In fact I have ordered some $3 to $5 LiPo batteries from eBay that supposed to be used for quadrocopters. These, although labelled RC 25C batteries, have battery protection electronic mounted on them (DW01+FS8205). My first happiness soon faded when I checked it does not stop the battery from under voltage. It will probably need some more investigation. Never the less, for the price, they seems like a nice choice for compact (43mm x 24mm x 9.5mm) power source and claiming ~720mAh of capacity (it really depends on supplier, ranging from 600 to 700mAh).

This led me to consolidation of what I use in case of LiPo powered node, and I ended up with new design of battery power circuit. I have taken out the DC to DC part and added low drop out linear regulator. MCP1700 with excellent quiescent current and drop voltage less then 200mV. I would lost the step up capability, but LiPo operate best in ranges of 4.2V to 3.4V as shown on the picture. Perfect match for such use. Taking a calculator in hand and the datasheet it revels, that the difference in terms of efficiency for LiPo battery is negligible. And in fact as the LiPo discharge it is more convenient to use liner regulator instead of switching, making it more energy efficient! Then single look on quiescent current makes the choice inevitable, linear consumes ~2uA while switching consumes ~80uA. That is 3 times more to what my ATmega328P@16MHz consumes while sleeping.

While having battery type set, it is much easier to choose charger circuity. Looking for easy solution I found MCP 73832 a single cell Li-Ion/Li-Po charge management controller. It is small footprint linear charger with charge current programmable by single resistor from 15 mA to 500 mA. Again datasheet stated very low standby current, and it seems to be used in many designs as Google reveals.

I ended up with new version of PCB and called simply node version 1.4. It has micro USB connector for power or charging and charge current set to ~450mA. With a rule of thumb of 1C charging current, it allow use of any Li-Ion or Li-Po battery with capacity bigger then 450mAh. It has no load sharing, but sleeping ATmega is not a problem. I have switched to blue solder mask colour and it is alrady tested and available for sale in my online shop.

I have measured power consumption in various stages to see how it behaves. Where there is range present it is difference between 3.5 and 4.2 input voltage.


MCP1700 quiescent current no other components 2.2uA

Just ATmega328P 16MHz@3V3:
ATmega328P sleeping 25.2uA
ATmega328P running 5.8~6.5mA

With added battery measurement - voltage divider:
ATmega328P sleeping 27.6uA
ATmega328P running 5.8~6.5mA

With added MCP7900 temperature sensor:
ATmega328P sleeping 32.6~33uA
ATmega328P running 5.8~6.5mA

With added MCP73831 charger:
ATmega328P sleeping 33.2~33.6uA
ATmega328P running 5.8~6.5mA

This is major improvement to previous design when Li-Po or Li-Ion battery is used, 1/3 power conumption over version 1.3. while sleeping.

Friday, October 21, 2016

Gateway 1.7. ready

Here it is fully functional and ready. I'm happy man :)

This is actual look of new and fully assembled board, except expansion connector. I have components to build few of these and final price is around 70EUR ~ 75USD without antennas and pigtails. Buy it on the right panel in my online store.

Just to speak about component quality. I'm using only branded and original parts that are supposed to last. Like Japanese and Korean(better to write Korean then Samsung these days :), just a silly joke) capacitors. IC from TI, ST, WizNet and Maxim. Ports are isolated by TVS or optocouplers . There are ferrite beads where they need to be, not replaced by 0 Ohm resistor. Isolated MagJack for RJ45 and so on... With this I hope it will last for years.

It comes with latest OHS firmware loaded, as available on my GitHub account.

Friday, October 7, 2016

Connecting balanced PIR sensor.

Picture on right side shows how to connect balanced PIR sensor. The idea is beautifully simple, I'm not the author I have got inspired by professional alarm boards. It is required to add two resistors into the end of every PIR sensor loop, and create simple voltage divider. Any analogue input on gateway is prepared to handle such divider. Resistor values are set in software and expected value is 2k2 Ohm for both. As you see from diagram there only 3 wires needed to connect a PIR to gateway input as ground is common to both. There is possibility to daisy chain the sensors in one loop, but then you need 4 wires and the resistor divider will be present only on last sensor in chain.

With such setup the gateway is then able to recognise 3 different states of any sensor. That is OK, PIR and Tamper. And it is very hard to tamper the wires connected to sensor as attacker is not able to measure the resistance hidden inside the sensor.

Saturday, September 24, 2016

Gateway 1.7 - new board

After busy summer, I had finished testing all other features of 1.6 gateway. All went fine and no additional change to layout is needed then the problematic W5500 PHY part. And I have sent to fabrication new version of Gerber called GW 1.7.

Here is the final render:



Monday, August 15, 2016

Back to gateway

I have used my recent W5500 breadboard friendly PCB to overcome problem with W5500 directly on gateway. As you may know there is problem with packed loss during transmission, which make it nearly impossible to further debug other parts. I have soldered ISP header on the gateway and used is as SPI to attach W5500 PCB. This works just great! I'm back to 100MHz full duplex Ethernet business. With improvements to Webduino library and some other tweaks, it have gained on speed towards web clients, as well as more time to process things internally in RTOS.

I have stared to test input blocks. Digital ones are same as on old gateway, and tere is no surprise. However analogue part was redesigned, but first test shows it works as expected. I will have to test further what over voltage or shorts it can withstand. I'm happy with that, because I'm more digital then analogue guy :), or better yet software type :D.

I have noticed that during uploading new sketches into gateway, I toggle the GSM module On and Off. This is a bit of drag as you imagine. It could be solved further in software, but I have rather done some changes on pin assignment.  I have tossed out GSM_RESET, as it can be reset hard way by switching GSM_POWER. And change it to input pin reading GSM state (GSM_STATUS). This way software can recognise instantly during start-up if the GSM module is already On or Off.

Next I will test outputs and RS485 interface. Then check power supply fall back and real time battery backup. If all goes well, I'll release final version of new gateway, which I plan to sell as starting point to DIY home security for anyone interested.

Monday, August 1, 2016

W5500 for sale

I have put the PCB and assembled board to store section on right. It offers all the function as W550io:
  • Size 2.5 x 5 cm.
  • Require 3.3V.
  • 80Mhz SPI.
  • RJ45 jacks with integrated magnetics.
  • ACT and LINK LEDs.
Choose PCB only or fully assembled version.
Standard 0.1" pin header with GND, 3V3, SS, SCK, MISO, MOSI, RST, INT pins.
Schematics are added for download.

Thursday, July 28, 2016

W5500 test PCB progress

PCB arrived on Monday and Tuesday I put it together. Say it short, it works. Happy again, I can continue with testing of new gateway. The differential pairs design worked, and the 33R dumping resistors are not required. Moving 3V3 power line out of RX and TX pairs probably also. Results is having a nice 2,5x5 cm breadboard friendly W5500 board. I will put PCB and finished version also to BUY section on right side. Maybe someone is interested.

Wednesday, June 15, 2016

Gateway progress

I have all components at home and I started already some tests. There are good results and bad results as well.

I'm happy to say, that my UART mux is working as I wanted it to work. There are 2 UARTs on ATmega1284P, one is used for GSM modem and second for RS485. Both need to be connected to hardware serial in order to have queue, interrupts  and other capabilities. But I keep compatibility with FTDI Arduino programmer, so I miss 3th serial. First I wanted to put jumpers to redirect serial 0 to GSM or FTDI, but later I have found nice little IC 74LVC1G3157 that is able to mux and demux one digital or analogue line to 2 outputs in both direction. With using the 3.3V present in FTDI it switches automatically from GSM to FTDI any time you connect the FTDI to header. Nice little trick.

New GSM module is working well, I have switched from external SIEMENS to more common SIM900. It did not send SMS, and I was not able to read extended status, but it was all matter of slightly different responses of the 2 modems to same AT commands. Some "/r" or adding empty line in library and all started to work. One thing that needs to be corrected on PCB for SIM900, is the placement of capacitor near GSM antenna connector. If one will put it in position toward the capacitor bank it can, with some bad luck, accidentally short 4V and ground. Hot glue will do will do for now, but I will move the capacitor 2-3 mm away. There is also SIM900 RESET connected to ATmega, which is most most probably unnecessary. I think rather to use it as input of  SIM900 STATUS to quickly see if module is ON or OFF.

Now the bad news, the Ethernet part is not working well, I keep on losing ACK or packets. Sadly I was expecting some problems there, as it requires differential traces tuned to some impedance and EMI reduction, I have sent the finished gerbers to friend to evaluate. Well, it turned out I have cross talk after the PHY. I'm absolutely not expert on such design, and I have no such equipment to debug 100Mbits Ethernet. But I have very slowly eliminated all to this hardware problem. Also lowering the speed to 10Mbits fairly lowered the error rate of my packets. All that is left is to try another brand MAGJACK.

All bad is for some good, I have tuned up Webduino code and W5500 library to use maximum bandwidth, and the embedded web server is now pretty fast, rising to over double the speed.

Rest is fine, I will just test the ADC protection circuit. For W5500 I will most probably design small 2,5 x 5 cm breadboard friendly PCB, not to waste another $50 for whole gateway board.

Sunday, May 15, 2016

PCB is here

New PCB version 1.6. is here, and I have started to put all components on it. All I had at home already is there and it is good so far. New switching power supply is delivering right around 4V required for SIM900. GSM module is starting up and when I put SIM in the socket it registers automatically to home network. W5500 also lights up the ACT and LINK leds when Ethernet cable is plugged it. I have to wait mainly for the UART multiplexer/demultiplexer to really start the tests. Waiting for you Mr. Postman :).

Thursday, April 21, 2016

PCB for new GW board.

Little later that I wanted here is 3D picture of new GW PCB version 1.6. I have already send it for fabrication. Wish me luck. :)

There is still 1284P, new WIZ5500, SIM900, new dual power supply, new analogue protection circuit and RFM69HW. It comes in 10*13cm size and will have nice big connectors.

Friday, February 12, 2016

Battery node


New node boards have arrived. I've ordered first time from seeed, and they look quite good. Nice sharp traces, I use usually bigger ones, as I tend to hand solder sometimes. Nicely aligned solder mask, and silkscreen without smudges. I will use them in future for sure.
This board was also for me first board to be made in KiCad, instead of Eagle, as I needed bigger PCB area for new gateway(main board). I can just say all as expected, if you check your Gerbers, there should not be any surprise. I feel a bit more confident to spend $50 for the big boards.

So, speaking of hardware, I soldered the battery option node. There is place on PCB for either battery or DC or even both if you want dual power (3.3V and 5V). And it works! Happy man :). To put it in numbers:

Battery voltage is more then 3.4V:
ATMega328P, and HW69W both sleeping:  0.09mA
ATMega328P working , and HW69W sleeping:  7.2mA
ATMega328P working , and HW69W receiving: 8.5mA 
ATMega328P working , and HW69W sending: 61mA

Battery voltage is less then 3.4V:
ATMega328P, and HW69W both sleeping:  0.12mA
ATMega328P working , and HW69W sleeping:  14mA
ATMega328P working , and HW69W receiving: 17mA 
ATMega328P working , and HW69W sending: 123mA

I tend to use it with li-po batteries, in theory they have self discharge ranges about 5% in month, then 1–2% per month (plus 3% for safety circuit). By raff numbers, and using the scenario of a remote sensor sleeping for 5-10 minutes, reading the sensor and doing the math for 500ms. Finally transmitting for at full power for 10ms, it gives me battery life for about 2 years with 2000mAh battery.

Now the question here is where it is a practical and economical solution to buy a li-po and let it basically drain by self discharge. Eneloops NiMH have seems to be more suitable, but li-po's are getting cheaper on eBay or such. Another solution is to go for a small li-po, around 200mAh and tiny solar panel. This or another, I'm happy with its wide input voltage and consumption. With this setup I can go from AA, to li-po or NiMH.

Going back to design, it uses MCP1252, which is inductorless, buck/boost, DC/DC converter with low quiescent power: 80 μA (Typical), and giving 120 mA (150mA max, high power RFM69HW can be used) output current. Add couple of ceramic capacitors, and you are set. On picture capacitors a a bit bigger then pads, since I have put what I found in drawer, and not the proper 1206.

Tuesday, January 5, 2016

New main unit.

As new node PCB is in transit, I have some time to move forward in design of new PCB for main board. It will be bigger with all necessary components on it. As I have moved from Eagle to KiCad, I will wait for the new node PCB to see what mistakes it will bring. Lately I was in search of new fabrication house, but boards bigger then 10x10cm are rather expensive.  My new board will be most probably 10x13cm and it is about 50USD without shipping for 5 pcs at least. It becoming a bit expensive fun, hope to not make serious mistake.

But new board is getting into final shape. It has WizNet W5500 Ethernet chip, SIM900 for GSM, and also some other improvements like better analogue protection, and RFM69HW. It will be drop in replacement for any old wired burglar alarm. It will also have new nice big and 45° angled screw terminals.

I have also in mind extension board the will plug on top of the analogue part that is on right side and allow 8 ports to be added. They will be stackable up to maximum of 4 boards, together 40 wired analogue inputs connected directly to main board.

Also I'm thinking now, it as it looks like final product, I will sell the finished boards and nodes. I guess it can be a good jump start to any one who wish to do some security alarm at home and use as sensor gateway for home automation as well. And still use the Arduino code and various libraries to tweak it, add new functionality or features. Believe me the old 8bit atmega has still power to do all these things fast and reliable.

Wednesday, December 23, 2015

New node


In past week I have created new board for remote node. Here is render from KiCad, how it should look like. It is my first board after switching from Eagle to KiCad, so we'll see what it will look like in real.

There are many changes, while keeping the current format 5x5cm, I have replaced most of the components. There is new switching power supply, actually two of them. One is for standard DC 5 - 20 V and up to 500mA. Second is for batteries and support voltage from 2 to 5.5 V but only 120mA. There is still present the RS485 half-duplex IC, speaker, and header for 1-Wire touch probe with 2 LEDs. IO Header grew with new pins and most importantly there is place for new RFM69W radio module on the back.

I have plans to use more battery powered nodes that should last long. Either to run them from rechargeable batteries like li-on or li-po or from standard packs or bigger button batteries. Waiting for the boards to get them alive :).


Tuesday, October 27, 2015

New design

It has been a while when I started real world testing of the whole system.  I have polished the code, fixed few bugs. Now I'm deciding that do next. I have few things on mind:

1. Design new PCB, bigger with all things on it. I have moved from Eagle to KiCad, and curently designing something like this:
It has WizNet W5500 Ethernet chip, SIM900 for GSM, and also some other improvements like better analogue protection. Size would be 10x15cm and it will be drop in replacement for any old wired burglar alarm.

2. Move the software to Arduino 1.6 to resolve the last bug with SPI transactions. Ethernet library disables interrupts and very seldom some interrupts are missed, causing a radio or RS485 packet to be not seen.  That would mean to rewrite libraries too, namely W5500 and RFM12B.

3. Port the RTOS from Nil to newer version called ChibiOS RT that allows dynamic threads and dynamic allocation of memory. This would eliminate the static allocation of memory for sensors and keys taking up RAM even if not needed.

For me all that work for many months is just fine, but I would like this to maybe become some kind of community project, so I'm not alone in this. I would gladly accept any hints, help in coding or design, or give some help to anyone.

Let me know...

Thursday, May 14, 2015

GSM and uptime

Just today, I have accidentally discovered that the GSM service provider had
some problems with his network. Luckily the thread that check GSM status handled the network failure just well, and recovered from it without issues.

I have the system up and running for 96 days with all threads working. I
must say the NilRTOS is really robust.I'm planning some software updates, but I have to create remote ISP first.


Also recently I have got W5500 chip and Wiz550IO and I'm very tempted to create a new mainboard together with SIM900. This would be all included alarm board that can simply replace old alarms and offer many features with open firmware and hardware.

Monday, January 26, 2015

RS485 protocol

Last post reminded me to write about library I have created for the wired network. It is called simply LibRS485, or NilRS485 adopted to work in NilRTOS. The library defines packet protocols on RS485 drivers. I use ST3485EB a 3.3 V powered, 15 kV ESD protected and up to 12 Mbps RS-485 half duplex transceiver. Inexpensive SO8 chip that has all that is needed already inside. As it is half duplex we need one extra pin to tell the transceiver if we are receiving or transmitting. The transmission itself require one twisted pair of wire and is able to push the data to distances over 1km with reasonable speed. The nice thing about RS485 it uses a differential balanced line and resists electromagnetic interference from motors and other equipment, more can be found on wiki.

LibRS485 uses a 9bit protocol and Multi-processor Communication mode defined in ATmega. This allows the MCU to do other thing without looking on communication unless there is a address frame. Basically i work like this:

  1. All nodes are in Multi-processor Communication mode (MPCM)
  2. One of the node sends an address frame, and all receive and read this frame.
  3. All nodes reads the address frame and determine if it has been selected. If so, it clears the MPCM, otherwise it waits for the next address frame and
    keeps the MPCM setting.
  4. The addressed node will receive all data frames until a new address frame is received.
  5. The other nodes which still have the MPCM bit set, will ignore the data frames.
  6. When the last data frame is received by the addressed node, the addressed MCU sets the MPCM and waits for a new address frame. The process then
    repeats from 2.
Library also defines a packet structure like this:
 -------------~~~~~~~~~~~~~~~~~~~~~~
 - A - P - X -  D0 - D63 ~ S0 ~ S1 ~
 -------------~~~~~~~~~~~~~~~~~~~~~~
  
  - Required fields
  ~ Data and signature fields
  A Address - 4 bits form and 4 bits to address.
    0  is master, but not really as any node can drive communication
    15 is broadcast to all
    14 addresses left for other devices
  
  P Packet definition - 2 bits type and 6 bits length.
    Flag bit configuration:
    FLAG_ACK 3
    FLAG_NAK 2
    FLAG_CMD 1
    FLAG_DTA 0
     
    Types: CMD - Command - user defined general commands value 0 - 63
           DTA - Data - user data length D0 - D63 and CRC S0, S1
           ACK, NAK - flags for data, using signature of data packet
           
  X XOR of A and P, for basic transfer safety.
  
  D0 - D63 user data.     
                       
  S0 ~ S0  CRC for user data or signature for ACK, NAK.   

So basically there are two types of packets. Command packet that has only 3 bytes (APX) and deliver a command(number 0-63) to node(s). It is used for example to issue a call for registration. Or data packet  that has 6-69 bytes (APX D0~D63 S0S1). This deliver any data to node(s). The nodes are addressed by its address 0-14, which select any individual node. Or address 15 that is broadcast to all nodes.

Wednesday, November 19, 2014

Short wires II / New PCB arrived

After taking some time to figure out what components died after the bead burned, I found the only one is the Ethernet module. One of the most expensive. This led me to adding extra protection to 3V3 power rail, a Zener diode which limit the voltage to 3.9V, I hope :)

But luckily all other components can be taken to new board that I have just received from factory. Next week I will get busy :)

Tuesday, November 11, 2014

How to wire up PIR

Bellow is only valid for gateway versions bellow 1.6.

Main board is equipped with 7 analogue inputs that are able to measure different states on the sensors by using just one wire. Well actually you need three together with power and ground. On the right you can see the wiring schema.  It is a simple voltage divider with 22k and 10k resistor that take the input voltage and create different voltage levels based on state of PIR outputs. In this way we can use any commercially available PIR sensor module that is able to operate with 12V power supply.

There can be more sensors on one input, but that would require more than just three wires as you need to daisy chain the signal and signal inputs from PIR and TMP. Not problem for someone who is using CAT5e cable to wire the sensors, it is actually cheaper than original 4-wire cable.

To sum up possibilities with such setting.  We are able to see these states:

  • normal operation
  • trip
  • tamper
  • unknown state / damaged

In software we measure the voltage level in zone thread every 250 millisecond. 4 times a second is safe way as the PIR modules usually keep the outputs on or off for one whole second. Also the thread has highest priority. In order to compensate for different wire lengths, there are voltage  rages feedback specified for each state, rather than a single value. And because input voltage can change when switching to battery and back, the whole measurement is compensated to the input voltage as well.

Saturday, November 1, 2014

New PCB for main board

After not very successful testing of main board in real life, I have put some effort and created a new version of it.

It I hope solves the problem of over current on power lines. I have put five 1206 polymer fuses on it as well as input one and over voltage protection. Also I have re-mapped the digital input pins so now it should be faster to read them in software. I have added one extra digital input and corrected the tamper. Now we have 7 analog input pins and 6 digital input pins. Another fix is reset watchdog circuit that was needed to properly start Wiz820io Ethernet module after power up. Others changes are minor, rearranged the connectors and battery. And I have deleted the 5V rail needed for the old GSM module, because now I use 12V one.

I've send the board for fabrication, fingers crossed :). New schematics are available in download area.
 

Tuesday, October 28, 2014

Power supply

In last post I have mention the power supply is too strong. By checking the documentation again I can say it way to strong, 60W. Originally I have designed my own power supply with transformer, rectifier and some switchers to deliver 13,8V for battery and 5V for GSM. Together with some led signalizing the status of mains and battery. But later I have considered it rather inefficient for 24/7 running.

Developing a true switching power unit is rather expensive, beside I have no previous experience, and I'm just a hobbyist. And my favourite producer of power supplies had a nice choice of 13,8V units. I have chose PSC-60-C, the one with enclosure. It has two outputs, one for battery charging and one to power for main board. It has also open collector outputs for signals when the AC is off, or the battery is reaching low level(11V). Then it also cuts of the battery when it reaches 10,5V. Just everything I wanted and it has 84% efficiency. Also it looks nice and shiny in the box :)