PDA

View Full Version : Basic Stamp2 and Blink M



Oper8r Al
02-03-2010, 08:46 PM
On a whim I purchased a BlinkM led module when I was ordering some other stuff. I have been trying to get it to interface to a bs2. Between the Sample code that was on the BlinkM site and reading i2c nuts and volts columns. I have been able to send data commands to it. My code probably isn't the best way and I know it needs improvement but sending data is working now. The problem I have is I can't seem to receive data back from module. I was trying to get the firmware version just as a test to read from the BlinkM and all I get back is (255). I am sure it is something in my code and was hoping someone could take a look at it and point me in the right direction. . I will attach the code and a link for data sheet for the BlinkM. Any help appreciated.

Thanks,

Al

Here is the link for the Data Sheet:thingm.com/fileadmin/thingm/downloads/BlinkM_datasheet.pdf (http://thingm.com/fileadmin/thingm/downloads/BlinkM_datasheet.pdf)



Edit: fixed link to datasheet

Ron Czapala
02-03-2010, 09:24 PM
Al,

·· I had a similar experience and finally gave up. I wanted to read the preloaded scripts but never could get it working. It was frustrating!

Good luck!

Miccim
08-22-2010, 06:16 PM
Having the same problems over here...sending data to the BlinkM via i2c is working fine. Selecting scripts and/or colors and so can be done. However, reading data from the BlimkM is a problem, I just cannot get it to work how it should.

PJ Allen
08-22-2010, 06:33 PM
Are you using I2CIN/I2COUT as with a -2p/pe/px or are you using a bit-banging routine with one of the "non-p" Stamps?

Mike Green
08-22-2010, 06:45 PM
If you haven't been using them already, there's a set of I2C routines for the BS2 in Nuts and Volts Column #85 (http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol3/col/nv85.pdf). It should be pretty straightforward to use them with the BlinkM.

Phil Pilgrim (PhiPi)
08-22-2010, 07:17 PM
Just a footnote/reminder: Parallax's ColorPAL (http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/colorpal/List/0/SortField/4/ProductID/617/Default.aspx), in addition to being a color sensor, is also a programmable color generator with capabilities similar to those of the BlinkM.

-Phil

sam_sam_sam
08-22-2010, 09:35 PM
This is on page 17


Numbers are interchangeably represented as decimal or hexadecimal, and in some cases,
ASCII characters. Hexadecimal numbers are represented with either a “0x” prefix (to indicate use in code, like “{0xff,0x00,0x9a}”) or “#” prefix (to indicate a color, like “#FF00FF”);

Go to RGB Color Now n 0x6e 3 0 {‘n’,R,G,B}

Fade to RGB Color c 0x63 3 0 {‘c’,R,G,B
}
Fade to HSB Color h 0x68 3 0 {‘h’,H,S,B}

Fade to Random RGB Color C 0x43 3 0 {‘C’,R,G,B}

Fade to Random HSB Color H 0x48 3 0 {‘H’,H,S,B}

Play Light Script p 0x70 3 0 {‘p’,n,r,p}

Stop Script o 0x6f 0 0 {‘o’}

Set Fade Speed f 0x66 1 0 {‘f’,f}

Set Time Adjust t 0x74 1 0 {‘t’,t}

Get Current RGB Color g 0x67 0 3 {‘g’
}
Write Script Line W 0x57 7 0 {‘W’,n,p,...}

Read Script Line R 0x52 2 5 {‘R’,n,p}
Set Script Length & Repeats L 0x4c 3 0 {‘L’,n,l,r}

Set BlinkM Address A 0x41 4 0 {‘A’,a...}

Get BlinkM Address a 0x61 0 1 {‘a’}

Get BlinkM Firmware Version Z 0x5a 0 1 {‘Z’}

Set Startup Parameters B 0x42 5 0 {‘B’,m,n,r,f,t}

New MaxM/MinM commands MaxM / MinM*

Knob Read RGB k 0x6b 3 0 {‘k’,R,G,B}

Knob Read HSB K 0x4b 3 0 {‘K’,H,S,B}

Jump, relative j 0x6a 1 0 {‘j’,j}

Input Read & Jump i 0x69 3 1 {‘i’,i,v,j}

Input Jump Immediate I 0x49 3 0 {‘I’,i,v,J}

blinkm

Miccim
08-23-2010, 08:59 PM
Thanx for the help.
I'm using a plain BS2, so must use bit-banging for the i2c communication.

The strange thing is that sending data is no problem, BlinkM reacts succesfully to all kind of commands, so far so good. This means that the (simple) start- , stop and send i2c procedures must be correct.
For example these commands work fine:
- Go to RGB Color Now n 0x6e 3 0 {‘n’,R,G,B}
- Play Light Script p 0x70 3 0 {‘p’,n,r,p}
- Stop Script o 0x6f 0 0 {‘o’}

But I still have not succeeded in reading data from the device.
For example these commands:
- Get Current RGB Color g 0x67 0 3 {‘g’}
- Get BlinkM Address a 0x61 0 1 {‘a’}
- Get BlinkM Firmware Version Z 0x5a 0 1 {‘Z’}

I have attached the bs2-file, I have used a source file of Jon Williams.
The read procedure is called: BlinkMCmd_read

Summary:
1. start procedure
2. put write address i2c bus (BlinkM address = 9, shift left, address is upper 7 bits makes write address 18)
3. send command 'g' (get current RGB color from BlinkM)
4. repeated start procedure
5. put read address on i2c bus (read address is 19)
6. read 1st byte (Red) with ack
7. read 2nd byte (Green) with ack
8. read 3rd byte (Blue) with Nack
9. stop procedure

Maybe the above mentioned sequence is wrong somewhere?

Both Nuts & Volts 85 and 115 I have been studying, but I cannot seem to find the problem.
On this forum more people have had this same problem, unfortunately unresolved so far...

Miccim
08-25-2010, 08:50 PM
Is there anyone with experiences with the BLinkM and I2C?
Has ayone tried this -or something similar- and succeeded?

Miccim
08-26-2010, 05:45 PM
Problem solved!!!! All works perfectly now...thanx!

*SHAME* ... pull up resistors wrong mounted ... *SHAME*
Only looking at the source code instead of thoroughly checking the hardware...