Hello

I'm trying to create a service to control the neopixel ring that will be mounted on my InMoov

the problem is that the neopixel library use the same interrupt as the servo motor. So it's not compatible and to neopixel ring need to be drive by a separated controller.

To avoid screwing MRLComm.ino sketch, I have choose to route the commands for the neopixel this way

 

MRL <- Serial -> Right side Arduino <- I2C -> Neopixel Arduino

 

So I need to create a service to activate the I2C protocol between the arduino and one to control the Neopixel ring

Here a video of the results

https://youtu.be/yfzVxlb5Apc

 

I have made some modification to the MRLComm.ino sketch locally, but I don't know how to make that change in MRL, part seem generated automatically and I want to be sure I do it the right way

Same thing to send the message from the arduino to MRL. I have use CUSTOM_MSG and it's worky, but to stay in how the rest is code, I should implement something like publishI2C or something, but I don't know how to do. Again some part seem to be autogenerated in arduino.java

Christian

 

Mats

8 years 7 months ago

Hi Christian.

I have been working on creating a generic i2c interface for a few weeks, and it's currently implemented in the RasPi service. My plan is to make the same set of methods available in Arduino / MRLComm so that it will be easy to add i2c communication to any service that wants to use it, either directly from a Raspberry PI or thru an Arduino. The idea is to only have low level i2c read / write methods in Arduino / MRLComm and that the device specific parts should be in the driver services. I don't like that MRLcomm has device specific methods like the ones I created for Adafruit16CServoDriver. So I want to remove them. 

If you have Eclipse installed you can look at the method implementation ( I2CControl ) in the RasPi service, and how it's used in Adafruit16CServodriver and AdafruitINA219. 

AdafruitINA219 is a device that measures voltages and calculates current and power from  the measured values. So it's a very small service, but it's made the way I want the final result it to be. 

Adafruit16CServoDriver contains the logic that I used for my first test and also the new set of methods that I want to implement in Arduino / MRLComm so that you can see the old and the new way. 

Please take a look at them. Will they work for the i2c command you want to send ?  Will they remove the need for you to use CUSTOM_MSG ? Any comments are welcome.

/Mats

Hi Mats

That exactly how I want to implement things; have generic code to do the I2C communication and a service that use it. 

my I2c communication code is quite simple, it just connect to the arduino, send message like this arduino.sendMsg(I2C_WRITE, i2cAddress, regAddress, data);, listen to publishCustomMsg and check if the returning data are the right one since CustomMsg can potentially be use for something else. But I believe it can work with any I2C device, but I have not test it yet.

you code seem already way more complete than mine :) But how do it get/send data to the arduino?

I can definitively use it with my neopixel service with minimal change as yours is build very similar than mine.

I'm a newbie here, i'm even newbie working with Java. So I have a lot to learn. 

I want to work more on my "slave" arduino code. I'm seeing a nice potential to add device that required specific arduino library or that can disrupt MRLComm 

Christian

 

Ohh i just discover this post  , I do it from scratch. With 1 arduino nano . and  usb serial data comunication from MRL. ( to chose a pixelring funtion inside the ino )

– Connect NeoPixel to Arduino Nano
– Flash it with : https://github.com/MyRobotLab/pyrobotlab/blob/master/home/moz4r/Neopixel_MRL.ino
– Connect Nano to computer USB
– Use this script sample in MRL : https://github.com/MyRobotLab/pyrobotlab/blob/master/home/moz4r/Neopixel_Serial.py

https://www.youtube.com/watch?v=deQxRQBNk3s

 

This is also a good way to do it

On my side, I was looking for a solution that did not add USB connections. 

I was also looking for a solution more generic to add sensors or device that are either not yet supported by MRL, need special library to run, that are not compatible with mrlComm usage (like the neopixel) or that you want to drive from a microcontroller.

For this to work I need a good I2C protocol, Mats is working on this so I patiently before reactivating this

Christian