Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

BlinkM


  • Please log in to reply
40 replies to this topic

#1 trustme

trustme

    Member

  • Members
  • PipPip
  • 12 posts

Posted 26 August 2010 - 08:21 PM

I need a little help. I have a BlinkM setup I believe correctly. Here is my code:

            byte[] init = new byte[4] {(byte)'c', 0xff, 0xc4, 0x30 };
 
            I2CDevice i2c = new I2CDevice(new I2CDevice.Configuration(0x09, 100));
            I2CDevice.I2CTransaction[] xActions = new I2CDevice.I2CTransaction[4]
            {
                //I2CDevice.CreateWriteTransaction(init)
                I2CDevice.CreateWriteTransaction(new byte[] {(byte)'c'}),
                I2CDevice.CreateWriteTransaction(new byte[] { 0xff }),
                I2CDevice.CreateWriteTransaction(new byte[] { 0xc4 }),
                I2CDevice.CreateWriteTransaction(new byte[] { 0x30 })
            };

            int result = i2c.Execute(xActions, 100);



Which is my translation of this from the blinkM docs:

Wire.begin();                // set up I2C
Wire.beginTransmission(0x09);// join I2C, talk to BlinkM 0x09
Wire.send(‘c’);              // ‘c’ == fade to color
Wire.send(0xff);             // value for red channel
Wire.send(0xc4);             // value for blue channel
Wire.send(0x30);             // value for green channel
Wire.endTransmission();      // leave I2C bus

result is returning 1 when I use either the 4 CreateWrieTransactions or the single. It might be the clockRate is bad but I do not know what value to pass.

Any help or suggestions would be appreciated.
Thanks!

#2 stacyh3

stacyh3

    Advanced Member

  • Members
  • PipPipPip
  • 47 posts

Posted 26 August 2010 - 10:20 PM

I was running into some odd issues too. It turned out to be my pull-up resistors. I guess most people know to double check this, but I figured I suggest it anyway. Stacy

#3 trustme

trustme

    Member

  • Members
  • PipPip
  • 12 posts

Posted 26 August 2010 - 11:36 PM

Thanks Stacy - I'm still very new to the hardware side of all this fun. The BlinkM doc says this: In this configuration, power is drawn from the Arduino’s analog in pins 2 & 3, configured via software to act as for BlinkM & BlinkM MaxMpower pins. This does not damage the pins, but does reduce the maximum brightness of BlinkM by about 30%. How do I configure through software analog pins 2 and 3 to act as power? My first guess was to create an OutputPort for GPIO_PIN_A3 and set its state to true, but that did not work. It appears there was an AnalogOut but that is not available anymore. Am I missing something?

#4 greg

greg

    Advanced Member

  • Members
  • PipPipPip
  • 169 posts
  • LocationChicago, IL

Posted 26 August 2010 - 11:41 PM

Thanks Stacy - I'm still very new to the hardware side of all this fun.

The BlinkM doc says this:

In this configuration, power is drawn from the Arduino’s analog in pins 2 & 3, configured via software to act as for BlinkM & BlinkM MaxMpower pins. This does not damage the pins, but does reduce the maximum brightness of BlinkM by about 30%.

How do I configure through software analog pins 2 and 3 to act as power? My first guess was to create an OutputPort for GPIO_PIN_A3 and set its state to true, but that did not work.

It appears there was an AnalogOut but that is not available anymore. Am I missing something?


I'd have to check but the analog pins can only supply 2ma I think vs 16ma from the digital pins. From the tech specs:

max current: 8 mA per pin
digital pins 2, 3, 7: 16 mA per pin
analog pins 0-3: 2 mA per pin
microcontroller max current: 200 mA total

So make sure you can supply enough power for your component off those pins.

#5 trustme

trustme

    Member

  • Members
  • PipPip
  • 12 posts

Posted 26 August 2010 - 11:56 PM

Assuming that the analog pin can provide enough power. I still do not know how to configure the analog pin to act as power. My guess now is that this functionality is not part of the Netduino SDK.

#6 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 27 August 2010 - 12:21 AM

Assuming that the analog pin can provide enough power. I still do not know how to configure the analog pin to act as power. My guess now is that this functionality is not part of the Netduino SDK.


Some Arduino extensions will pull a bit of power from the Arduino's pins--which can drive quite a bit of power.

To do this on Netduino, you just create an OutputPort and set the default state to true:
OutputPort power1 = new OutputPort(Pins.XXX, true);

I would generally avoid doing this--and would generally use the 3.3V/5V power headers to supply power to your accessories. But if you need to do it, remember that pins A0-A3 provide 2mA of power, and all other digital pins provide 8mA of power (with the exception of 3 of the digital pins on top--which can provide 16mA).

You probably won't be able to power this particular device off of 2mA of power--so you'll need to use jumper wires and/or a breakboard to pull the power from somewhere else... The lower-power ARM processor isn't really designed for providing power from GPIOs...

Chris

#7 trustme

trustme

    Member

  • Members
  • PipPip
  • 12 posts

Posted 30 August 2010 - 11:49 PM

I'm sorry I still need help.

Here is what I've done.

5v to 4.7k resistor to d on blinkM and Analog4
5v to 4.7k resistor to c on blinkM and Analog5
5v to + on blinkM
gnd to - on blinkM

        static I2CDevice i2c = new I2CDevice(new I2CDevice.Configuration(0, 100));

...
            int result2 = i2c.Execute(new I2CDevice.I2CTransaction[]
                    {
                        I2CDevice.CreateWriteTransaction(new byte[1] {(byte)'o'})
                    }, 5000);

When it runs result2 in this case is 1. But no command that I send affects the blinkM.

I also tested HardProvider.GetI2CPins(). The returned pins are not analog 5 and 4. They are digital 10 and 11. But that may mean nothing.

Thanks!
Duane

#8 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 30 August 2010 - 11:58 PM

        static I2CDevice i2c = new I2CDevice(new I2CDevice.Configuration(0, 100));

...
            int result2 = i2c.Execute(new I2CDevice.I2CTransaction[]
                    {
                        I2CDevice.CreateWriteTransaction(new byte[1] {(byte)'o'})
                    }, 5000);

When it runs result2 in this case is 1. But no command that I send affects the blinkM.

I also tested HardProvider.GetI2CPins(). The returned pins are not analog 5 and 4. They are digital 10 and 11. But that may mean nothing.


Two quick things:
1. You're sending an 'o' command to the BlinkM, which according to the documentation is a "stop script" command. What other commands have you used?
2. The pin #s returned from GetI2CPins are the actual port pin #s on the Netduino's Atmel ARM MCU. Pins 10 and 11 are SDA/SCL--which correspond to A4/A5 on the Netduino.

Chris

#9 trustme

trustme

    Member

  • Members
  • PipPip
  • 12 posts

Posted 31 August 2010 - 12:13 AM

I have also tried this: byte[] init = new byte[4] {(byte)'n', 0xff, 0xc4, 0x30 }; Thanks.

#10 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 31 August 2010 - 12:29 AM

Anyone here used BlinkMs with their Netduino yet? Any tips for trustme? If not, we should probably get some in here to play with as well. Chris

#11 TechIsCool

TechIsCool

    New Member

  • Members
  • Pip
  • 4 posts
  • LocationClinton, WA

Posted 02 September 2010 - 12:34 AM

Hey Whats up Unless you have changed the location of the BlinkM its should be 0x00 on the i2c bus not 0x09. See if that makes a difference I own one but do not own a netduino

#12 Spike

Spike

    Member

  • Members
  • PipPip
  • 24 posts

Posted 11 September 2010 - 05:23 PM

I have just got a BlinkM MinM, and am also having trouble getting it working. I have tried the code that trustme posted with no luck, however I am completely new to C# and was hoping to use netduino as a way of learning it, I have had some experience with vb.net so I am not a complete newbie to programming.

#13 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 11 September 2010 - 05:30 PM

I have just got a BlinkM MinM, and am also having trouble getting it working. I have tried the code that trustme posted with no luck, however I am completely new to C# and was hoping to use netduino as a way of learning it, I have had some experience with vb.net so I am not a complete newbie to programming.


Hi Spike,

Welcome to the community! Can you share how you've wired it up, etc.? Perhaps some members of the community who have used BlinkM's can help spot what's awry?

Chris

#14 Spike

Spike

    Member

  • Members
  • PipPip
  • 24 posts

Posted 11 September 2010 - 05:53 PM

Sure, probably should have posted that in the first place! I have:

C going to Analog 0
D going to Analog 1
+ power to Analog 2
- power to Analog 3

And my code is:
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace NetduinoSpike
{
    public class Program
    {
        public static void Main()
        {
            OutputPort power1 = new OutputPort(Pins.GPIO_PIN_A2, true);
            OutputPort grnd = new OutputPort(Pins.GPIO_PIN_A3, false);

            I2CDevice rgbLed = new I2CDevice(new I2CDevice.Configuration(0x09, 100));

            I2CDevice.I2CTransaction[] xActions = new I2CDevice.I2CTransaction[4]
            {
                //I2CDevice.CreateWriteTransaction(init)
                I2CDevice.CreateWriteTransaction(new byte[] {(byte)'c'}),
                I2CDevice.CreateWriteTransaction(new byte[] { 0xff }),
                I2CDevice.CreateWriteTransaction(new byte[] { 0xc4 }),
                I2CDevice.CreateWriteTransaction(new byte[] { 0x30 })
            };
            Thread.Sleep(10000);
        }

    }
}

Which is mostly what was posted before.

Thanks for your help :)

#15 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 11 September 2010 - 05:55 PM

Spike, First thing I notice, although this might not be the issue... The 32-bit ARM processor on the Netduino is lower-power than the AVR chip used on the Arduinos. So it only puts out 8mA of power on analog pin 2 (instead of 20mA). Could you try to connect the + power connection to the 3.3V header instead? Chris

#16 Spike

Spike

    Member

  • Members
  • PipPip
  • 24 posts

Posted 12 September 2010 - 12:21 PM

Thanks, that did the trick, it now lights up when power is applied. Just got to work out how to program it now :P

#17 Spike

Spike

    Member

  • Members
  • PipPip
  • 24 posts

Posted 12 September 2010 - 12:36 PM

Ok, now I am having the same problem as trustme, nothing I send effects the LED. The LED continues to cycle through what I presume is the default colour cycle.

#18 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 12 September 2010 - 06:34 PM

Ok, now I am having the same problem as trustme, nothing I send effects the LED. The LED continues to cycle through what I presume is the default colour cycle.


Hmm, what changed?

Perhaps we need to get some of the units in here and create a sort of unofficial driver for them? They seem to be quite popular, and we'd like to help promote hardware from the community...

Chris

#19 Spike

Spike

    Member

  • Members
  • PipPip
  • 24 posts

Posted 12 September 2010 - 08:44 PM

Well after I attached it to the 3v pin it cycles without having been programmed by me, which it still does, however I cant seem to program it. I would happily have a go at writing a driver, however I don't think I have the C# knowledge to do so, and I lack the hardware knowledge im afraid!

#20 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 12 September 2010 - 08:59 PM

Well after I attached it to the 3v pin it cycles without having been programmed by me, which it still does, however I cant seem to program it. I would happily have a go at writing a driver, however I don't think I have the C# knowledge to do so, and I lack the hardware knowledge im afraid!

Oh, okay... So it looks like things are working but the trouble is changing the program on the BlinkMs...

I would happily have a go at writing a driver, however I don't think I have the C# knowledge to do so, and I lack the hardware knowledge im afraid!

With a name like Spike, I don't think you're afraid of anything :)

One big question: it looks like you're using I2C to program/control the BlinkM's. I2C is on analog pins 4 and 5. Do you have the data lines plugged into A4/A5--or A0/A1?

Also, do BlinkMs have their own pull-up resistors built-in or do you need to add those?

Chris




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.