i2c status led

klaasje

Member
Hello,

I am using a master and a number of slave's. I want to use a led to see if the i2c bus is still running. Is there a command for it? I can't find it

Thanks in advange
 

lbenson

Senior Member
I'm not exactly sure what you're looking for. If your master issues a command and gets a response, would that not indicate that the i2c bus was working? You could have the master light an led in that case. And if no response, something is wrong.
 

inglewoodpete

Senior Member
Perhaps you could provide some more details on why you think you need on indicator for i2c. I have PICAXE projects that run continually, using i2c to communicate between PICAXE chips. This very public project has been running continuously for the last 3 months.

If you i2c bus is longer than about 1.2 metres, you are likely to see errors occur. If data accuracy is important, you will need to incorporate an error-checking and correction overlay. This could include a simple checksum byte created by the master and checked by the slave. The slave would then place a positive or negative acknowledge byte in a specific location, which the master could read periodically via i2c.

Back in the days of the early (2008 - 2009) firmware versions of the 28X1 and 40X1 chips i2c bus lockups did occur (is was using an extended i2c bus). I built a hardware i2c bus monitor consisting of an op-amp and a "bipolar" (2-wire red/green) LED. When the scl and sda wires were pulled high (normal working state), the LEDS would show green. When a lockup occurred one or the other bus wire would be permanently pulled low by one of the chips and a red LED would light in this case. Normal data transmissions would show as barely visible flickers of red in the practically constant green. Nowadays, the i2c firmware of modern PICAXE chips is so reliable that I would not consider using these hardware monitors.
 

klaasje

Member
I must see with flickering led if there is data transmissions. So than i can see the bus is still working. I have a spare led on the pcb that i can use for it. But i need to now how i can get the signal in the software.
 

inglewoodpete

Senior Member
I must see with flickering led if there is data transmissions. So than i can see the bus is still working. I have a spare led on the pcb that i can use for it. But i need to now how i can get the signal in the software.
The easiest way to do this would be to turn an LED on immediately before a hi2cIn or hi2cOut command and then turn the LED off again immediately after the i2c command. If the PICAXE executes an i2c command, then it will send data on the i2c bus.
 

klaasje

Member
The easiest way to do this would be to turn an LED on immediately before a hi2cIn or hi2cOut command and then turn the LED off again immediately after the i2c command. If the PICAXE executes an i2c command, then it will send data on the i2c bus.
In that case you don't now if it is working. I solved it. I now read if there is a message comming to the master. If it is than i let blink the led with a toggle.
It is the best i can think of.
What i was thinking is that there is a command that you can see if the master is scanning the bus.
 

lbenson

Senior Member
I don't understand what "the master is scanning the bus" would mean.

Is there any activity on an i2c bus other than when the master queries a slave and the slave responds?
 

westaust55

Moderator
Typically, when a PICAXE chip is communicating over the i2c bus, only that command (ie Hi2cIN or Hi2cOUT) is performed – a second task/command is not possible to monitor the i2c bus comms.
The background i2c comms within an X1/X2 part used as a slave i2c device may be the only exception.
Therefore your options are setting the LED HIGH before and LOW after the i2c bus comms from the Master device as suggested in another thread I believe by hippy or a separate hardware as suggested by IWP.
You might be able to use pulse stretching with the external circuit by incorporating say a 74HC123 or similar, so that the LED stays on for a longer period to make the LED “flicker” more perceivable.
 

hbl2013

Senior Member
If you are willing to use an chip like an 08M2 to use it as an indicator it seems to me that you can use one as a Slave. This Slave should have a little program in it that will light an LED when it is being accessed through the I2c Bus. (Or even any port?) I don't know very much about the I2c protocol, but if the chip can sense any activity and react to it, you are in business. The data does not even have to be decoded for your purpose.
 

lbenson

Senior Member
M2 chips can be i2c masters, but not slaves. Any input pin could detect low-going pulses, indicating activity, but could not easily tell whether the activity was successful.
 
Top