Hi all!
Im worried i might be asking too much of i2c when i plan to use it for both pin extenders, dual arduino nano´s and a 128x64px oled display.
The hardware is as follows:
Pin extenders:
MCP23007 (x3)
MCP23018 (x1)
Arduino nano clone, (x2)
i2c 128x64 0.96" oled display:
http://www.ebay.com/itm/371773219529?_trksid=p2055119.m1438.l2649&ssPageName=STRK%3AMEBIDX%3AIT
The system is used as a light controller for a vehicle, to group a bunch of lights together and control them over i2c instead of installing cables for all the lights.
The pin extenders arent really traffic intense, but they do require somewhat "immediate" execution, a noticable lagg in input > output will not suffice.
A lagg undetectable by the human eye is "immediate+", i can live with minimal delays.
The pin extenders are ether input/output (handlebar unit) or pure output (light controllers)
The Light controller arduino controls all pin extenders and inputs for the system,
while the graphics processing arduino will recieve system notifications and present them onScreen.
The GPU Arduino might eventually have screen nav buttons directly attached, but we´re not there yet..
Im hoping to achieve a master/slave combinated sketch, so that for the main time, the GPU arduino is slave, but when it wants to write to display, it switches to master (while the light Arduino switches to slave) and when finished, changes back to slave.
Now, the information to be presented onScreen is going to be current speed (hall sensor and spoke magnet, as a normal bike spedometer), some status indicators, a symbol for each function i want, like a blinking arrow in the turn indicator direction, a circle that lights up if the position lights are turned on and so on.
So there isnt really a need for a multi-Hz screen refresh rate, 1fps would actually be ok, even if 2-4fps would be ideal.
This means i will have to pass multiple variables between the two arduinos, and figure out a way to pass the bus master "badge" between the two.
So what would the smart option be, regarding the data transfer between the two arduinos?
Should i merge together all the data into a string, "12312345001000" and then split them up on recieving end into SPD, DIST, (lights in specific order, if 1, then on)?
That way i would reduce the number of transfers between the units, and since there is a wee bit overhead on the transfer, that would be most efficient?
I could of course use a single-container transfer, to send "light on" to the display when the lights gets turned on, and then send the numbers (and/or text notifications) in a string separately.
What would the pro´s suggest?
And the idea of master/slave switch token, is it feasible?
Does anybody know of any good links that describe this?
I also have no clue regarding the actual bus traffic i might experience, or how a display draw in the wrong moment could affect button reaction time before activating corresponding lights.
Ive been trying to solve this project with the bare essential cabling, not a lead of wire to much so to speak, so im really hoping to be able to use the i2c for the whole project,
but if all else fails, i think i will use a softserial connection between the both arduinos and use them both as their respective masters on their own i2c buses.
It wont be nearly as pretty, especially since that will mean that the handlebar unit (with buttons and status lights) will have to interface with the display i2c bus (the only accessible bus in that area), meaning some of the light controller code has to go into the graphics sketch..
My programming level is somewhere between skilled newbie to a ignorant amateur, so i know pretty much WHAT i want, but am desperately clueless on how to get there.
So any hints or suggestions in general or on specific parts of the project are more than welcome!