Welcome Guest! To enable all features please Login or Register.
Options
Go to last post Go to first unread
krohneew  
#1 Posted : Sunday, January 24, 2016 4:06:59 PM(UTC)
krohneew

Rank: Member

Groups: BetaUser, Registered
Joined: 12/6/2015(UTC)
Posts: 10

I'm trying to create different nodes that write to PCF8574 chips, which are 8-channel IO expanders that the arduino talks to via I2C.

The following

contains two identical custom arduino nodes. Each is responsible for communicating with one PCF8574, which have I2C addresses from 0x20 to 0x27 -- hence I give the last hex digit as an integer input to the custom node. I have two PCF8574 chips on a breadboard, each controlling eight LEDs. If I delete one node, the remaining node can control either of the two chips, depending on which I select, from Embrio's "connected" mode. Adjusting an activation input will immediately light or darken an LED on the breadboard. With both nodes, however, neither node can communicate correctly with the I2C lines -- random lights light up on both chips, and changes seem to happen several times after I change the activation values, if ever.

The two above nodes, when together, produce the following code:


It's possible for the arduino to control both chips without Emrbio. The following sketch:


causes both chips to work in tandem, counting from 0 to 65536, representing ones with lit LEDs and zeroes with unlit LEDs.

I'm using Embrio 1.3.5.0, Arduino IDE 1.6.6, and I'm running on an arduino R3. I'm using Windows 7 64 bit.

I can provide a Fritzing diagram or a schematic if needed; Fritzing is most appropriate for this but I never use Fritzing so I'd have to figure out how to do it. Essentially, the arduino powers the board, both chips get +5V, I use two 10K resistors as pullups for the I2C lines, and each chip is connected to both I2C lines and is directly connected to eight LEDs, no resistors on the LEDs (I don't even think I have 16 220 ohm resistors).
EmbrioAdmin  
#2 Posted : Sunday, January 24, 2016 4:21:24 PM(UTC)
EmbrioAdmin

Rank: Administration

Groups: Administrators
Joined: 12/11/2014(UTC)
Posts: 661

Thanks: 1 times
Was thanked: 109 time(s) in 104 post(s)
I'll debug this as best I can without the hardware.

Not sure if it matters, but I notice in the resulting program with 2 nodes the line "Wire.begin()" is called twice. Could you try deleting it from one of the nodes?

Below are two custom nodes that reproduce the Arduino example you posted. Could you try uploading that and see if it works or has the same weird behavior?

krohneew  
#3 Posted : Monday, January 25, 2016 1:34:32 AM(UTC)
krohneew

Rank: Member

Groups: BetaUser, Registered
Joined: 12/6/2015(UTC)
Posts: 10

Yes, that code worked perfectly. Worked just like my non-embrio example.

So I tried to figure out what the difference was. Restoring the #ifndef code did not cause a problem. I thought it might be a timing issue, but adding "delay(10)" before the I2C write did not cause a problem. Adding eight activation inputs to each node did not cause a problem. But then, when I computed a byte based on those eight inputs, the code continued to work, but at about 1 update per second. Both nodes are running just as slowly -- the second node starts counting when the first one finishes. Subsequently commenting out (and deleting entirely) the offending code did not help; that's really odd. It's as if the code having been there is permanently changing the state of the node, and as if Embrio's detection of which variables are present in the code has some lasting effect even once all the references have been removed. The following runs at about 1 update per second.

krohneew  
#4 Posted : Monday, January 25, 2016 1:48:22 AM(UTC)
krohneew

Rank: Member

Groups: BetaUser, Registered
Joined: 12/6/2015(UTC)
Posts: 10

I started over from your example. The following works at full speed:
krohneew  
#5 Posted : Monday, January 25, 2016 1:57:39 AM(UTC)
krohneew

Rank: Member

Groups: BetaUser, Registered
Joined: 12/6/2015(UTC)
Posts: 10

Even better: the following does not use I2C at all, and runs at full speed:



The following also doesn't use I2C, and runs at 1 update per second


The only difference is that the right node in the former example has no activation inputs, and the right node in the latter example has eight activation inputs.

I should also note that in all the instances with the I2C code, the program returned to full speed (I could see by the LEDs on my desk) when the program was not connected.
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Notification

Icon
Error