Go to advanced search

by fopetesl
Mon Feb 01, 2016 11:05 am
Forum: Beginners
Topic: MMA7455 SPI pain :(
Replies: 4
Views: 925

Re: MMA7455 SPI pain :(

Did you figure out how to access your MMA7455 via SPI? Yes, sorted thanks. If I can find time I'll add some code so others might understand. Like most things, simple when you know how. Briefly char buf[] = { DEVID | REG_READ, 0x00}; // Read DeviceID of ADXL345 bcm2835_spi_transfern(buf, sizeof(buf)...
by fopetesl
Wed Jan 27, 2016 12:40 pm
Forum: Beginners
Topic: Constructing an unattended mS timer?
Replies: 5
Views: 824

Re: Constructing an unattended mS timer?

The directory no longer wants to serve up .c files. I have no idea why. I've put the latest code in http://abyz.co.uk/rpi/pigpio/misc/adc/pispi.zip Got it :) Thank you. Looking at your code while (sample < samples) { cb = rawWaveCB(); now_reading = (cb-1) / cbs_per_reading; while (now_reading != la...
by fopetesl
Wed Jan 27, 2016 8:55 am
Forum: Beginners
Topic: Constructing an unattended mS timer?
Replies: 5
Views: 824

Re: Constructing an unattended mS timer?

You may be able to do what you want on the Pi but I wouldn't consider it a beginners type task. For the SPI part see https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=71089 With your help earlier the SPI part now works a treat :) I looked at your link. Very interesting and looked like it migh...
by fopetesl
Tue Jan 26, 2016 6:28 pm
Forum: Beginners
Topic: Constructing an unattended mS timer?
Replies: 5
Views: 824

Constructing an unattended mS timer?

RPBi2 SPI link to ADXL345 accelerometer. Using C I need to read three axes every 555uS and write to 'disk', so the processor is going to be pretty busy doing just that? I also need to be running an interval timer to flash a LED every 500mS or so. I could use delay() with a couple of variables to set...
by fopetesl
Tue Jan 05, 2016 6:13 pm
Forum: Beginners
Topic: ADXL345 Bad Response?
Replies: 13
Views: 2060

Re: ADXL345 Bad Response?

Now we're humming :) Works great so far #include <bcm2835.h> #include <stdio.h> int main(int argc, char **argv) { if (!bcm2835_init()) return 1; bcm2835_spi_begin(); bcm2835_spi_setBitOrder(BCM2835_SPI_BIT_ORDER_MSBFIRST); // The default bcm2835_spi_setDataMode(BCM2835_SPI_MODE3); // NOT the default...
by fopetesl
Tue Jan 05, 2016 5:55 pm
Forum: Beginners
Topic: ADXL345 Bad Response?
Replies: 13
Views: 2060

Re: ADXL345 Bad Response?

That was a RTFM moment. It needs to be in SPI mode 3. Page 15. "and the timing scheme follows clock polarity (CPOL) = 1 and clock phase (CPHA) = 1. " Fantastic!! :o :o I must have read up on SPI modes yonks of times as well as this page 15 and it didn't click. Reading wikipedia now makes less sense...
by fopetesl
Tue Jan 05, 2016 5:31 pm
Forum: Beginners
Topic: ADXL345 Bad Response?
Replies: 13
Views: 2060

Re: ADXL345 Bad Response?

So that rules out the bcm library unless both have an unlikely bug. Interesting to see what the answer will be. I said earlier that I bought a pukka Analog Devices board but I begin to wonder whether ALL are made in China. The Chinese eBay boards have almost identical ADXL idents so apart from the ~...
by fopetesl
Tue Jan 05, 2016 4:53 pm
Forum: Beginners
Topic: ADXL345 Bad Response?
Replies: 13
Views: 2060

Re: ADXL345 Bad Response?

Sorry, probably worried you for no reason. I've just hooked up an ADXL345 in SPI mode and I get the same result. Interesting. I only get F2 from DEVID request the very first run, there after (until cold reset of Pi) I get 00. The F2 response is constant for every run when attempting to set POWER_CT...
by fopetesl
Tue Jan 05, 2016 3:48 pm
Forum: Beginners
Topic: ADXL345 Bad Response?
Replies: 13
Views: 2060

Re: ADXL345 Bad Response?

I2C defaults to 100 kbps on the Pi, so SPI can be much faster. Some of the modules require that a line be strapped high or low to determine whether I2C or SPI is being used. How does your module decide? If CS is tied high, i.e. strapped to Vdd, the ADXL34x is held into I2C mode otherwise it 'sees' ...
by fopetesl
Tue Jan 05, 2016 3:18 pm
Forum: Beginners
Topic: ADXL345 Bad Response?
Replies: 13
Views: 2060

Re: ADXL345 Bad Response?

joan wrote:If you configure the device as I2C rather than SPI you could try http://abyz.co.uk/rpi/pigpio/examples.h ... _adxl345_c
If necessary I'll do as you suggest.
Reason I have gone for SPI is bandwidth - I will need as much data as fast as possible.
I read I2C is much slower?
by fopetesl
Tue Jan 05, 2016 3:16 pm
Forum: Beginners
Topic: ADXL345 Bad Response?
Replies: 13
Views: 2060

Re: ADXL345 Bad Response?

Hmmm. Cannot upload files bigger than 64Kb...
So pics are here: http://postimg.org/gallery/3hz3n47s2/74ad64b5/
by fopetesl
Tue Jan 05, 2016 12:32 pm
Forum: Beginners
Topic: ADXL345 Bad Response?
Replies: 13
Views: 2060

Re: ADXL345 Bad Response?

Any help appreciated here.

Do I have a faulty unit or is my code bad somewhere?
by fopetesl
Mon Jan 04, 2016 6:42 pm
Forum: Beginners
Topic: ADXL345 Bad Response?
Replies: 13
Views: 2060

ADXL345 Bad Response?

RbPi2 to ADXL345.jpg Hi, I'm using a Pi2 to try and gather accelerometer data from an Analog Devices ADXL345. I'm using a propriety board made by Analog Devices not a Chinese one. It's connected to the Pi as per RbPi2 to ADXL345.jpg attached. I'm running this #include <bcm2835.h> #include <stdio.h>...
by fopetesl
Fri Dec 18, 2015 10:51 am
Forum: Interfacing (DSI, CSI, I2C, etc.)
Topic: ADXL345 Accelerometer
Replies: 51
Views: 31806

Re: ADXL345 Accelerometer

.... The "proper" usage (rather than using sudo) is to add yourself to the i2c group, e.g. if your user name is pi then sudo adduser pi i2c will allow you to use the i2c devices without needing sudo. Note, changes in user permissions don't take effect until you log out and back in. Note: didn't wor...
by fopetesl
Mon Dec 14, 2015 7:03 pm
Forum: Beginners
Topic: MMA7455 SPI pain :(
Replies: 4
Views: 925

Re: MMA7455 SPI pain :(

It's one of these, Joan: http://www.ebay.co.uk/itm/5V-3-3V-MMA7455-Three-Axis-Digital-Tilt-Accelerometer-Sensor-Module-For-Arduino-/141836415052?hash=item21061bf04c:g:h48AAOSwAKxWVExJ I'll have to do the wiring & pics in the morning. Carer's duty calls. Thanks for the quick response. Peter Edit: Try...
by fopetesl
Mon Dec 14, 2015 6:49 pm
Forum: Beginners
Topic: MMA7455 SPI pain :(
Replies: 4
Views: 925

MMA7455 SPI pain :(

I've hacked away at this. RTFMd again and again. I think I've got it right but I cannot get MMA7455 to respond. // Author: Mike McCauley // Copyright (C) 2012 Mike McCauley // $Id: RF22.h,v 1.21 2012/05/30 01:51:25 mikem Exp $ #include <bcm2835.h> #include <stdio.h> int main(int argc, char **argv) {...
by fopetesl
Wed Nov 25, 2015 9:19 am
Forum: C/C++
Topic: Yesterday it ran. Today "permission denied" even as root
Replies: 5
Views: 973

Re: Yesterday it ran. Today "permission denied" even as root

There are a number of possible avenues to explore. First, unless you alter your PATH to include the current folder, you have to prefix the executable with ./, such as ./SPIck Did that. See original post, please. Secondly, in the first version of your compile command line, you use both -c and -o. Th...
by fopetesl
Tue Nov 24, 2015 12:04 pm
Forum: C/C++
Topic: Yesterday it ran. Today "permission denied" even as root
Replies: 5
Views: 973

Re: Yesterday it ran. Today "permission denied" even as root

Did that and chown'd.
Still permission denied.
Now I cannot alter or delete the file, says cannot be found :(
by fopetesl
Tue Nov 24, 2015 11:36 am
Forum: C/C++
Topic: Yesterday it ran. Today "permission denied" even as root
Replies: 5
Views: 973

Yesterday it ran. Today "permission denied" even as root

SPI_check.c gcc -Wall -c -o SPIck SPI_Check.c -l bcm2835 No errors. Same yesterday except yesterday it ran. No code change. Today ./SPIck " permission denied " even as pi user, sudo or as root. However. If I gcc SPI_Check.c -l bcm2835 ./a.out I get no errors and it runs :) So If I look at mode I see...
by fopetesl
Mon Nov 16, 2015 1:42 pm
Forum: C/C++
Topic: error: conflicting types for bcm2835_spi_begin()
Replies: 7
Views: 1766

Re: error: conflicting types for bcm2835_spi_begin()

That's not actually the point.
My mistake seems to have been compiling without main() though why no "missing main()" error but instead "conflicting data types"?
by fopetesl
Mon Nov 16, 2015 11:26 am
Forum: C/C++
Topic: error: conflicting types for bcm2835_spi_begin()
Replies: 7
Views: 1766

Re: error: conflicting types for bcm2835_spi_begin()

I'll try it but I note it does have main()
by fopetesl
Mon Nov 16, 2015 7:42 am
Forum: C/C++
Topic: error: conflicting types for bcm2835_spi_begin()
Replies: 7
Views: 1766

Re: error: conflicting types for bcm2835_spi_begin()

blink.c worked "out of the box".

I cured the problem if unsure how but it seems because I didn't have a main|() function?
by fopetesl
Wed Nov 11, 2015 7:17 pm
Forum: Interfacing (DSI, CSI, I2C, etc.)
Topic: SPI. Full Duplex. How??
Replies: 2
Views: 844

Re: SPI. Full Duplex. How??

Thanks, Joan. I sort of got most of that already. It's the part about With SPI the master sends a bit then receives a bit. Until the 'slave' has received the request byte, eight bits if you like, it can't respond, (unless it can see the future :) ), so the 'master' needs to send a dummy byte to see ...
by fopetesl
Wed Nov 11, 2015 6:41 pm
Forum: Interfacing (DSI, CSI, I2C, etc.)
Topic: SPI. Full Duplex. How??
Replies: 2
Views: 844

SPI. Full Duplex. How??

Still a Noob :( I understand the principle that a SPI device can supposedly read and transmit data concurrently. Problem for me is how it CAN be concurrent when I am asking for,say, a one byte result from a status register. I think I understand that I must send two bytes, the second being a 'dummy'?...
by fopetesl
Sun Nov 08, 2015 10:35 am
Forum: C/C++
Topic: error: conflicting types for bcm2835_spi_begin()
Replies: 7
Views: 1766

error: conflicting types for bcm2835_spi_begin()

Note: not on PI2 - epiphany too sloooow. Trying to get to grips with SPI since I need to read data from a transducer. I installed the relevant c/c++ library as suggested without error. I have copied "Using The SPI Port With The BCM2835 library by Mike McCauley" which begins //Setup SPI pins bcm2835_...

Go to advanced search