Asked — Edited

I2c Help

Don't really want the answer of how to do this, YET ... LOL. Would like to pull my hair out a little first. I just wish to know by anyone is it possible to have EZB call a subroutine inside a script?

Ex: Rich's BlinkM Script Would it be possible to write several subroutines and then call anyone of them when needed?

Ex: Subroutine Red LED blink 3 times.

Subroutine Blue LED blink 7 times.

Subroutine Yellow LED blink 6 times.

Is this possible?

Thanks all for your thoughts on this.

P.S. I guess this might be a little confusing without the rest of what I wish to do ... LOL. I plan on having another microcontroller (not EZB) that runs a program. It is in that microcontroller that I need to call a subroutine through I2C from EZB. Hope that makes sense?


ARC Pro

Upgrade to ARC Pro

With ARC Pro, your robot is not just a machine; it's your creative partner in the journey of technological exploration.

United Kingdom
#1  

While not I2C but the theory behind it and methods used should be the same... have you seen my latest Ping Roam script?

It uses a whole bunch of separate scripts for each section/module/routine such as the "Avoid" script or the "Roam" script, these are called using the ControlCommand() in the main script. All are neatly in their own Script Manager renamed Ping Roam, run the main script and you will see the other scripts starting and stopping to suit the main script.

The scripts are pretty well commented so you should be able to read them one by one and see what's going on and why. Hopefully it will guide you in the right direction. Your sub routines will be much simpler with the I2C commands only but the ping script will show an example of how to call the sub routine scripts up and get them starting and stopping.

#2  

Good timing @ Herr Ball! I too have a question regarding " I2CWrite " and BlinkM's. But....checking out the Forums' archives , https://synthiam.com/Community/Questions/3431 , @Richs example of I2C answered my question perfectly and perhaps @Herr Ball's. Just my guess ...if Herr Ball assigned a variable for each subroutine then he could call it up anytime! If....and a big IF, one can create a subroutines as a "variable" it might solve his issue .......I see that Rich has used letters in his command script like c and f etc , which tells me that DJ has included ThingM's, Blink_M funcs.h library ..hooray I would like to give Rich an informal " solved it"

United Kingdom
#3  

The BlinkM is pretty much an Arduino with a few LEDs connected to it (in fact, you can turn a BlinkM in to an Arduino). If memory serves me correctly you can program the BlinkM with sequences that can later be called up with commands. I haven't read the datasheet for a long time but it is one of the best datasheets I've read so it will say everything you need to know in it.

Yes, I assume you could set variables, such as; $sequence1 = "0,0x09,n,0xff,0x00,0x00" $sequence2 = "0,0x09,n,0x00,0xff,0x00"

I'll have to read the datasheet again when I have chance and look in to the sequence programming (if it exists, it is possible I was dreaming). However, separate scripts called with a ControlCommand("blinkmscripts", "script2", ScriptStartWait) will also work.

#4  

@Herr Ball are you using a BlinkM clone(piranha) or the real BlinkM ? My EZ "browns out " ! When I diminish one LED ie 0x22 instead of ff it stays on ..run the script again and the EZ B browns out . I hope someone on the Forum uses a BlinkM to compare notes!:)

United Kingdom
#5  

I use a BlinkM. It's powered from the I2C port (I have used it plugged directly in and have used it on an extension wire) and I have no problems with browning out.

I did have issues with my I2C LCD Display however that turned out to be due to the HD servos in melvins pan/tilt head bracket, as soon as I power the servos from their own 6V regulated source the problem went away.

In fact, I power my LCD (with backlight), 1 BlinkM (soon to be 3) and an accelerometer all from the I2C port with no issues. No pull up resistors installed or anything.

It may help if you added a power cap to the I2C Vcc and Ground to give a small reservoir for any power dips.

#6  

Awesome Rich !:) Makes total sense....now the proof is in the um... pudding? Lighting effect !:)

United Kingdom
#7  

OK I just read the datasheet, there are "light scripts" pre-set in the BlinkM. They are detailed on page 21.

You are also able to write light scripts however it states that only ID 0 is writeable. It's not something I've tried yet but I've added it to my list.

If the light scripts on page 21 would do for your sequences this may be the way to go about it, otherwise it is simple to write your own scripts in ARC with the I2C commands and sleeps etc. then call them with a control command.

Hopefully it's enough to get you started @Herr Ball

#8  

Thanks all for the help. You just got to love this forum and the people that use it ...:)