I2C vs serial between Picaxe

AlastairD(Aus)

New Member
I have need to share data between 2 picaxe modules, one a data logger measuring the cell voltages and temps of a bank of LiFePO4 batteries in the off road motorhome I am building on a Isuzu 4wd truck. This module using a 28X2 will be in a not so accessible spot running all the time. I will also have another unit (using either a 28X2 or more likely an 18M2+) with a display monitoring other temps and things. I want to be able to upload data on command and am happy about how to do it but would appreciate advice from the forum re the mode. I am already using i2C for communication b/n display, RTC, temp sensor etc but this is only relatively short distance.

Which form of communication has better noise immunity and likely to be less problematic, I2C or serial? I will use shielded twisted pair wire in either case for the 4 metre long run. Having great fun building bits using Picaxe, probably not necessary but fun to do and I always like knowing what is going on with things.

cheers
 

SAborn

Senior Member
At present you appear to be using the 28x2 as a I2C master with I2C slaves attached, where it can become a problem is requiring the 28x2 to be a master to all attached devices and also a slave to another picaxe to communicate data between.

It would be much simpler to leave the 28x2 as a I2C master for all devices and send serial data between the 2 picaxe boards.

If you used a 20x2 chip for the second board then you could use background receive for serial data. (18m2 only allows 2 bytes into background receive)

Another option would be to use a couple of Dorji transceivers and send the data wirelessly between the two modules, this might allow better flexibility with mounting of the second picaxe unit.
 

inglewoodpete

Senior Member
Shielded twisted pair cabling for i2c will be problematic. i2c needs a low capacitance transmission path, due to the pulse distortion that capacitance introduces. Also, i2c is not an electrically balanced medium, so twisting the pair is not beneficial. Each wire (clock and data) is unbalanced and referenced to a ground wire.

I have used i2c extender chips to reach distances of 15 metres quite reliably in a fairly noisey (electrical) environment. One way to overcome i2c distances is to slow the transmission speed. Eg if running the i2c master at 8MHz, use i2c_Slow_16 or i2c_Slow_32 parameter, which halves or quarters the transmission speed but extends the lengths of data pulses.

Otherwise, you can go to RS485 balanced serial connection but you have to build in all of the layer 2 link management in code. (Ie Addressing, acceptance/rejection of data packets, error recognition, data reception acknowledgement etc.)
 
Last edited:

Adamey

Senior Member
I have also used extender chips with i2c. I find i2c on PICAXE to be very easy to implement with all the heavy lifting already done for you.

Edited: Forgot a couple things. When using a PICAXE as a slave then it acts like an EEPROM with the scratchpad RAM becoming the EEPROM storage. So you simply save the data you want in your remote PICAXE by placing it into the scratchpad. The master PICAXE reads from the slave just like it would as if from an EEPROM.

You don't have to do anything other than issue a hi2cin command to fetch your data. Everything else happens in the background on both PICAXE's. Unlike serial commands, you don't have to wait for data, check interrupts or add any extra code for "housekeeping". Just read away...
 
Last edited:

westaust55

Moderator
To use a PICAXE chip as a slave i2c device you will need to use and X1 or X2 part.
Other PICAXE parts cannot be a slave device on an ic2 comms bus.
 

rossko57

Senior Member
I think you'll find TTL serial will be fine up a shielded cable only 4m long. Usual good practice, ground shield at one end only. Keep the speed down for reliability, say 9600 tops.
As important as the cable will be to see both devices have a common ground (assuming they have a local regulated supply each).
 

AlastairD(Aus)

New Member
Thanks everyone for the input.

I have the 28X2 running as the master for all the slave devices and swapping into slave mode in the long periods b/n sampling. As suggested I am storing the data in the X2 scratchpad and successfully reading it from the 18M2+ as master. Currently this is only happening at breadboard distances and as I have never used i2C over other than short distances wondered if I was expecting too much at 4m.

I will try as suggested doing it over i2C with everything slowed down and if I experience problems then I will switch to serial which I am sure would be ok not withstanding the issues of baud rate matching between chips.

thanks again.
 

SAborn

Senior Member
I do wonder what the reason is to have 2 picaxe chips, as why not just have the one doing all the I2C reading of the nodes.

As for I2C over 4mtr i doubt it will be a problem, as i have used I2C over 20mtr of cable, being the flat phone extention cords (4 wire ones) along with the oricinal RJ11connectors for I2C slave devices.
If you have problems try lowering the value of the pullup resistors on the bus, try to stay above 1K for the resistors.

How much do you know about working with lithium iron batteries, and are you expecting this system to maintain battery cycling.
For example if you cycle them to 70% max you will get around 5000 cycles from the cells at full capacity, but once you go below 70% your circle life satrts to fall to 3000 cycles rather quickly.

The other problem with LiFePO4 is keeping the cells in balance for their charge voltage, because some cells will tend to charge faster and slightly higher in voltage than other cells, causing a out of balance problem between cells.
Basically ... cell1 might be say = 2.9v, cell2 = 2.85v, cell3 = 2.95v, cell4 = 3.2v, which still adds up to 12v. So you can see cell4 could be overcharged to bring the other cells to full voltage, which they will never get to because the combined cell voltage will limit the charge.
Then the life of the cells are reduced from overcharging or undercharging different cells, it then starts to become a runaway train wreck as the balance problem gets worse.

LiFePO4 are great cells if you understand them and look after them, they will reward you well, abuse them and they will cost you dearly.
 

AlastairD(Aus)

New Member
SAborn,
Reason for 2 picaxe is that I want to have one dedicated to the battery monitoring - voltage on 4 cells, cell temp, ambient temp and also shutting down the system if imbalance or high/low voltage occurs. The other picaxe will monitor more benign things to do with fridge, water, in/out temps etc. The battery unit will always be on, the other will be off when the camper is stored.

From my computer days I have lots of the flat lead, cat5 cable and RJ11 connectors. I will use some of that - good idea.

Until recently I was ignorant of LFP technology but decided to look into it when I realised that my camper house battery system was going to be ~150Kg using conventional AGM batteries. I have now researched everything quite well and am very informed on the issues. I have a b/g as a scientist so it is well within my knowledge base.

I have purchased my LFP batteries and have them sitting on a test bench in my workshop and putting them through their paces , as well as testing the various chargers and monitors I will be using. My target is max 70% DOD to achieve good lifetime. This will be easy as I am used to aiming for 50% max with AGM. I spent time when I first got the cells to get them balanced - all wired in parallel and then charged to 3.7v using a well regulated bench supply. The cells are now wired in series as a 320AH 12v battery and so far have stayed within 0.01v of each other over several cycles to about 30% DOD.

I have been amazed at how readily they charge and can see how easily they could run away if balance was lost. I will cycle them deeper once I have my monitor/logging system working. Whilst they were expensive to buy if I achieve the projected life I will be well ahead of Pb systems in cost and have the benefit of better performance and a weight of 42Kg.

Will update when I progress further.
cheers
 

SAborn

Senior Member
Good to hear you have your head around the balancing problem with the cells.

I am in the process of developing a cell equalizer for LiFePO4 cells, and it has been in testing for some time now.

I dont know if you purchased your cells somewhat local to yourself, and if so may have been from Trev? who will likely be the supplier of the equalizers in development.

Trev runs a EV with 32 cells and demands a lot from them, and every bit of cell life counts when you have 32 cells to maintain, or the cost of early replacement.

Another advantage is the equalizer stores data from each cell, so for a warranty claim on failed cells, the cells and equalizer is returned and the data downloaded, which then tells if its a product fault or a user fault that caused the cell to fail.

Its still some way off before a production run is done, although getting closer.
Should you have cell balance problems in time, then feel free to contact me, as i might be a person with the solution.

Oh! yes it do use a picaxe in the circuit.
 

Puuhaaja

Senior Member
I am in the process of developing a cell equalizer for LiFePO4 cells, and it has been in testing for some time now.
I'm interested to know more about that because I have a plan to make my own 100w led diving canister light which is using 100w led like : http://www.ebay.com/sch/i.html?_trksid=p2050601.m570.l1313.TR12.TRC2.A0.X100w+led&_nkw=100w+led&_sacat=0&_from=R40
Biggest problem will be know how to control to charce batteries. Batteries for those project would be 18650 cheap li-on or lifepo4. That canister light would be good continuation for my first diy diving torch project: https://dl.dropboxusercontent.com/u/16735593/2013-01-14 00.49.12.jpg

Sorry about off topic.
 

AlastairD(Aus)

New Member
SABorn,
I purchased my cells from EV works in Perth. Did a bit of a search, probably not exhaustive, and got what I thought was a fair price from them. More particularly they knew what they were about and happily gave advice.

I plan to keep the charge rate down to 40A max which is way below the limits for my cells. My reading suggests that the imbalance and runaway problems are exacerbated when the charge rate is high. In an EV rapid recovery is necessary, for me it is less so. My cells will be recharged when the engine is running, by solar when camped and occasionally by mains power. My expected drain is ~100 - 150 AH when camped for the day and depends on the weather. Overnight stops would only be ~60AH so with the truck alternator or the 500W of solar panels I should be ok. I started out intending to either buy or build and equalisation system but when I considered how I would make it fault tolerant due to failed components I decided to just have a monitor and charge shutdown system instead. I could see that a failed component in a bypass link could quickly cause major problems.

I was going to build a sophisticated (Picaxe based) tilting system for the solar mounts so they would tilt to get the best sun angle. When I started to cost it I decided to just fill the available roof space with panels and have a more mechanically robust system. We tend to travel to more remote areas and I was concerned about the consequences of rough roads. By being aware of where I park I can minimise the panel losses and let the extra area make up for it. I am using mono crystalline panels and some test I did showed that the difference, in good sunlight, between being horizontal and optimally oriented at the sun was only about 25% and so by just having 5 panels instead of the originally intended 3 will make up. I was careful to buy panels with several diodes built in so partial shading is not as big a problem. The panel covering on the roof will act as a sun roof anyway in hot weather. I plan to monitor and log the panel output using my Picaxe system so over time I will be able to see if my decisions are sound.

Most of my projects are overkill for the vehicle but I like doing it and enjoy being able see what is happening with all my systems. Long way from finished but enjoying the journey.

cheers
 
Last edited:

manuka

Senior Member
Alistair: Perhaps consider submitting this LFP saga to Ozzies own "Silicon Chip"? I ran an AA/14500 slanted LiFePO4 article some months back (& am presently working on another) but your heavy duty application would be well received I'd say. Aside from DoD discharge and service life benefits,the weight saving on walkabout uses such as yours alone makes REAL sense.

Let me know if you want to go further with this. Stan.
 

premelec

Senior Member
Not sure if OP knows there are ICs to do the heavy balancing work etc - like AS8506C for industrial and other applications.Could communicate with it by PICAXE. There are several such chips like this I've seen introduced in the last several years... this one seen most recently. Best wishes on battery success!
 

AlastairD(Aus)

New Member
Stan,
Yes I would be happy to write an article but feel I need to progress things a little further first. Once I have things installed vs all being on the test bench and trialed I will make contact with you again. Probably 3 - 6 months given the competition with other demands around me.

I will send you a private message when I feel the time is getting near.

cheers
 

lbenson

Senior Member
Here's another person interested in following your progress. I hope you will continue to update here.
 
Top