Community
cancel
Showing results for 
Search instead for 
Did you mean: 
msuga1
Novice
1,432 Views

Edison and mraa(node.js) can't communicate with MAA7455L correctly via SPI

I tried to connect edison and MAA7455 via SPI with mraa(node.js).

But in some data patterns, they were not able to communicate correctly.

MAA7455 is a 3d-accelerometer sensor which communicates with SPI.

When I tried a program (communicating via SPI with edison-arduino board, edison-environment), it works well, and nothing is wrong.

But I tried the same logic program with mraa + node.js, it does't work well in some data patterns.

When edison read the register of x-axis/ y-axis/ z-axis, edison can read back the data from MAA7455L correctly like this.

send : 0x06 << 1 , 0x00 (x-axis, dummy)

recieve : 0x00 , 0x12 (dummy, x-axis data)

('0x06' : x-axis register)

When edison write the mode-control-register, edison cannot read back the data.

send : 0x16 << 1 + 0x80 , 0x09 (mode-control-register + write-mode , work/stanby-bit data)

resieve : 0x00 , 0x00 (dummy data, dummy data)

send : 0x16 << 1 , 0x00 (mode-control-register(read back) , dummy)

resieve : 0x00 , 0x00 (can't read back '0x09', not released stanby-mode)

('0x16' is the number of control-register, '0x80' means write-mode)

('0x09' : work/standby-bit -> "work" )

With node.js + mraa, it failed to write the control-register.

But, at first I run the program in edison-arduino-environment, then run the program in node.js environment, node.js program can read back the registers correctly, too. The control-register may have written correctly by edison-environment, so both "read back" and "write" may become OK.

By the way, with python , I have got same result.

As you know, SPI is a simple protocol which exchenges the data between master-device and slave-device at the same times.

So there is essentially no difference between "sending a normal-data" and "sending a control-data". Both are only bit stream expression for SPI.

The only difference may be MSB.

* read back : MSB = '0' (---> works well)

* writing : MSB = '1' (---> not works)

So I think mraa wrapper might cause the trouble. (when it convert "unsigned char" and "signed char")

I wonder what is the difference between edison-arduino-environment and mraa.

And how to avoid this.

Any help would be appliciated.

Thank you.

30 Replies
Pablo_M_Intel
Employee
175 Views

Hi nekosan0,

1. Have you checked with a logic analyzer if the CS and CLK signals are working well?

2. Is there any difference between the frequencies of the Arduino environment and Mraa/node.js?

3. Also, could you tell us which image are you using? As well as the version of mraa and node.js.

Regards,

PabloM_Intel

msuga1
Novice
175 Views

Hello, PabloM_Intel

I have checked CS/CLK signals with logic analyzer.

And the data to/from MAA7455L looks fine.

It looks normal SPI signal.

OS version : yocto linux release 2.1

node version : v0.10.38

mraa version : 'v0.8.0'

New information !!

I have tried to change the interval between SPI transactions.

( /CS set 1 -> /CS to 0 and exchanging data -> /CS to 1 -> usleep(500000) )

this '500000' micro seconds interval is inserted after every SPI trancaction.

If I set the interval timer over 30000 micro seconds -> SPI signal is bad

example : usleep(30000)

If I set the interval timer under 20000 micro seconds -> works well

example : usleep(20000)

It seems long "usleep" function cause a bad effect to SPI signals or MAA7455L's behavior.

I have no idea why "usleep" function efects to SPI signals........

With edison-arduino-environment, "delay(500)" function cause no effect to SPI and run normaly.

I want to keep "500000" micro seconds (0.5 seconds) interval between every transactions.

I don't know what causes this and how to fix it.

I get confused.....

Pablo_M_Intel
Employee
175 Views

Hi nekosan0,

I would suggest you to use the latest stable version of node, which I believe is 0.12.0, you can check that information in their website.

Also, did you make sure to configure the pins of the Arduino Expansion Board accordingly? You can check how this is done following this link: http://www.emutexlabs.com/project/215-intel-edison-gpio-pin-multiplexing-guide http://www.emutexlabs.com/project/215-intel-edison-gpio-pin-multiplexing-guide. There you can find the Edison multiplexing Guide, and one of the examples explains how to configure the pins for SPI use (Example 5 – the first instruction should be corrected to echo 111 > /sys/class/gpio/export).

About the differences between using numbers over 30000, I'm not sure what could be causing this. We will investigate this further.

Regards,

PabloM_Intel

msuga1
Novice
175 Views

Hello, PabloM_Intel.

I will try the version 0.12.0 later.

By the way, I found a page referring about MMA7755L.

(japanese page... please translate with translator like bing)

link:

http://d.hatena.ne.jp/suikan+blackfin/20090614/1244943229 MMA7455Lの変な癖 - Blackfin空挺団::Blog

translator:

http://www.bing.com/translator Bing Translator

This site says that MMA7455L could have a habit, which need a dummy reading

before writing a setup-data.

I have experimented.

Valid : if reading a dummy-data before writing setup-data.

It is re-initialized if make a interval over 30000us.

Invalid : if no dummy data.

Valid : after reading some data.

So I think that MMA7455L works almost well (reading and writing).

But it seems to need a read proccess (normal reading or dummy reading)

before writing the setup-data with mraa.

In edison-arduino-environment, there is no need pre-reading, and works well.

And every SPI pin's setting might be right with node-version 0.10.38, too.

I wonder why there is need a reading-proccess with mraa library.

Is there any difference between mraa and arduino-environment?

Both mraa and arduino programs have gcc compiled binary in itself,

so I think there are no difference between them.

It could be caused by a tiny timing jitter for only MMA7455L ???

msuga1
Novice
175 Views

I have tried to update node.js to 0.12.0, but I couldn't find how to update node 0.12.0.

I tried to handle spi and mraa with python in the same way.

Result : same to node.js !

(1) with pre-reading before writing setup-data

---> working good

(2) without pre-reading before writing setup-data

---> not working

(3) with long interval from reading(30000 micro seconds)

---> not working

So it may not caused only with node.js.

mraa library? mraa wrapper?...........

Is there a way to examine what causes the behavior?

I have no way to do.

Pablo_M_Intel
Employee
175 Views

Hi nekosan0,

We are still investigating your issue, we will get back to you as soon as we have a more accurate answer. Thank you for your patience.

Regards,

PabloM_Intel

msuga1
Novice
175 Views

Hello, PabloM_Intel.

Thank you for your help.

I think I have not distinguished the problem caused with only my device or every same devices.

It can be special for only my device. (or for some defective products of MMA7455L)

So I think there is a possibility not to solve it.

I want to try with another MMA7455L, If I would get another MMA7455L.

(Now I have only one device.)

By the way,

I have mistaken the device name. It's not "MAA7455L", It's "MMA7455L". sorry.

Pablo_M_Intel
Employee
175 Views

Hi nekosan0,

It could be possible that it is something with your device, but some issues have been reported with SPI in release 2.1. I would suggest to try downgrading to the previous image.

Another option would be to write a C code and use the Arduino spidev library as a guide given that the example works well in the Arduino IDE. Which Arduino IDE are you using? In case you're using 1.6.5, check this path \Users\\AppData\Roaming\Arduino15\packages\Intel\hardware\i686\1.6.2+1.0\libraries\SPI\src\SPI.cpp which uses /linux/spidev.h.

Regards,

PabloM_Intel

msuga1
Novice
175 Views

Hello, PabloM_Intel.

I have checked the version of Arduino IDE. -> 1.6.4

And found the path to spidev.h in SPI.cpp.

> # include

But I'm not good at x86 assembly language or runtime libraries of x86.

(I know AVR environment, so I have made some spi programs for

Arduino/AVR with C or assembly language.)

I have tried to read SPI.cpp, but I can't understand the detail of what the

spidev.h/SPI.cpp does instantly.

(I don't know what the tags/functions/variables means)

For the present, I will try the previous version of yocto image.

Thank you.

Pablo_M_Intel
Employee
175 Views

Hi nekosan0,

Please let us know your results once you try with the previous Yocto image.

Regards,

PabloM_Intel

msuga1
Novice
175 Views

I'm sorry I'm late.

I have tried old yocto image and old mraa library.

I was looking for old OS images, but I could find only yocto 2.0 image,

so I installed yocto 2.0 image and tested.

--> mraa version = v0.7.2

Result : same to v0.8.0.

It could not be caused only with mraa of yocto 2.1.

This could happen not only edison but also other micro controller,

so the cause could be "not" in edison, mraa, node.js, yocto linux......

http://d.hatena.ne.jp/suikan+blackfin/20090614/1244943229 MMA7455Lの変な癖 - Blackfin空挺団::Blog

(mentioned in a japanese site)

I have searched other reports of MMA7455L with SPI, but I have not found.

Pablo_M_Intel
Employee
175 Views

Hi nekosan0,

Have you considered using I2C instead of SPI? According to the datasheet, both protocols are supported. Another option would be to contact the manufacturer or their forums, maybe they can provide a different input.

Regards,

PabloM_Intel

msuga1
Novice
175 Views

I have tried with I2C.

(1) arduino (at-mega328 3.3V 8MHz)

---> runs normally, ofcourse.

(long interval, short interval)

(2) edison with arduino-environment

--->runs normally like arduino.

(3) edison with node.js, mraa

---> runs normally like arduino.

So I think that it would be caused only with SPI.

But I can't conclude which causes the behavior with "mraa library" or "MMA7455L".

Pablo_M_Intel
Employee
175 Views

Hi nekosan0,

We will order a MMA7455L sensor so we can reproduce the issue. Have you tried sending/receiving dummy data before initializing the sensor with MRAA?

Regards,

PabloM_Intel

Pablo_M_Intel
Employee
175 Views

Hi nekosan0,

Could you please tell us where did you buy the MMA7455L sensor? Is this one from Parallax, https://www.parallax.com/product/28526 https://www.parallax.com/product/28526?

Regards,

PabloM_Intel

msuga1
Novice
175 Views

Hello, PabloM_Intel

I bought a MMA7455L board at this shop.

http://strawberry-linux.com/catalog/items?code=12102 http://strawberry-linux.com/catalog/items?code=12102

But, this shop seems to ship only in Japan.

(I have tried to find english page, but not found.)

This board do not have any special parts.

(only MMA7455L, resistor, and capacitor.)

So, another boards would work as same as this board.

>Have you tried sending/receiving dummy data before initializing the sensor with MRAA?

With dummy data sending/recieving, or without, both are tried.

---> no special effect.

The condition which effects for the validity of setup-data

might be the interval-time length just before

proccessing of setup-data writing.

isamu2
Novice
175 Views

Hi Pablo,

Were you able to buy the accelerometer? I have similar issues. I bought one and same problems. If you did order it then please let us know when the estimated shipping date is so we can come here after you have received the device.

Thanks!

Pablo_M_Intel
Employee
175 Views

Hi guys,

We would let you know as soon as we have updates on the case. Hopefully we will have some answers about this behavior.

xxChadxx, are you using the exact same device as nekosan0? Where did you buy it?

Regards,

PabloM_Intel

Pablo_M_Intel
Employee
175 Views

Hi nekosan0,

We want you to know that we are still working on your case. We'll have some more information soon.

Regards,

PabloM_Intel

msuga1
Novice
40 Views

Hello, PabloM_Intel

Thank you for your help.

I'm looking forward to the probrem solved.

(Do you need my program source?

I don't know how to send you my program via e-mail)

Reply