Saturday, December 20, 2008

Arduino and Flash

The Arduino can be made to cooperate with FLASH CS3 (and other languages).
A prog is put on the Arduino and running a XML socket in FLASH and a serverproxy we could get the serial port doing the connection.
The glue lib posed some problems, not really working with the firmata ???
In the end the example from the sketchbook called SimpleAnalogFirmata gave readings from an analog port and these readings were dispaled in the FLASH outputusing the SimpleIO from the glue library.

It seems CS3 poses more problems than CS2.
The code on this page, which must have worked then, didn't really work with me, it gave output, but the values were kind of rubbish: http://aralbalkan.com/1243

NXT Arduino and I2C

Having ordered the I2C sensorkits from mindsensors.com we quickly soldered the components to the bord. But, it did not work. Since we had no idea how to analyze the situation, nor any idea how the real I2C sensor worked we left it where it was...

After a few months we obtained an Arduino. The philosophy of the Arduino is really different from the NXT. (Books can be written on this...:-)

A bit of research on the internet showed examples of how to connect the NXT to the I2C chip from mindsensors.com: http://www.tau.ac.il/~stoledo/lego/i2c-8574/
This schema also showes how to connect it in general, so also to the ARDUINO.
With the wiring.h lib of the ARDUINO we can connect to I2C input output ports. So the IC's from the mindsensor I2C kit could be steered using the Arduino too. Maybe we can get the I2C chip working and resolve the problem of the I2C chip and the NXT, finding our mistake with my soldering the mindsensor setup.
But not having too much experience (coming from the NXT, which shields this kind of troubles) we had to figure out the pin config of the chip.
First we were put on the wrong track by the sketch on the page of Silvan Toledo, which suggests quite a different pin config. ( http://www.tau.ac.il/~stoledo/lego/i2c-8574/ )
After a bit of time, (and failure) we found out the right pin config by looking at the datasheet of Philips.
(found here: http://www.datasheetcatalog.com/datasheets_pdf/P/C/F/8/PCF8574.shtml )

And now these IC's worked, we got the address right and we could connect 2 IC's to the same Arduino using different addresses. (More is possible, but we had only two PCF8574A.)
This gives the possibility to connect up to 8 times 8 LEDS to one Arduino.
(Something for a Led matrix...but these can be steered directly from the ATMega168 in other ways)

(actually reading nxtasy.org/wp-content/uploads/2006/08/digital%20vs%20analog.pdf
we can wonder about how many sensors can be connected to the NXT...)

Actually mindsensors.com ships the PCF8574A, and not the promised PCF8574. Does this make a difference? Actually in the Arduino code i had to change the adress from B0100000 (PCF8574) to B0111000 (PCF8574A)
(this hint was found out here: (also this code was used to test)
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1173047782/5
)

analog port 4 SDA
analog port 5 SCL (http://www.neufeld.newton.ks.us/electronics/?p=241 )

another experiment used one address port A0 to HIGH for the second PCF8574A.
and the second PCF8574A could steer LEDS.

The next step will be to get back to the NXT, now that we know the adress and the workings of the I2C inport output IC's.

The comment from Vinh Vu made us review the original text and add links and the picture. Vinh Vu asks how to connect the ULTRA sonic sensor (I2C) to the ARDUINO. The pin fig of the sensor showes the SDA SCL in the connector: connection to the NXT:
http://forums.nxtasy.org/index.php?showtopic=2092
this works: the ultrasound sensor clicks if the 9V is applied.

The experience with the bluetooth commands researched in other blogs seems to be the way to go...(? or does the NXT perform special things in between the commands, normally filtered out, to prevent hacking its expensive sensors for the cheapo ARDUINO :-)....

then looking at the Hardware Developer Kit (HDK) of Lego
http://mindstorms.lego.com/Overview/nxtreme.aspx
you find the communication protocol with the ultrasound sensor...will this work?

all seems to be understandable, but this remark indicates possibly (the expected) interference of the NXT:
---NXT firmware will deal with the "R + 0x03" part---

This links explains how to deal with the "R + 0x03" (does it?)
http://forums.nxtasy.org/lofiversion/index.php?t141.html

the above mentioned link explains the R in ARDUINO - wire terms: endtransmission begintransmission - i did already try it that way...

anyway first try the most basic: shutting the sensor off using:
0x02 write address 0x41 internal address 0x00 write zero

all kind of variations tried out,
Wire.beginTransmission(expander);// tried expander 0x01 and 0x02

Wire.send(0x41);
Wire.send(0x00);
etc.
or

char a[]= { 0x00, 0x41, 0x00 }; // { 0x41, 0x00 }
Wire.send(a);

the sensor still clicks....
so.....

unsolved problem, better either use the nxt in combination with the Ultrasound and use bluetooth in combination with C#, see bram fokke lib, or use a distance sensor the ARDUINO can handle without a problem?