Page 1 of 1
Gyro_L3GD20
Posted: Thu May 28, 2020 4:19 pm
by Lord Grezington
Hi Everyone
I am trying to use the Gyro L3GD20 in SPI mode, but it seems I cant re-map the pins even if I try software channel. If I use a standard SPI master it allows me to re-map the pins.
I am using the 18F24Q10
Thanks
Note - I also seem to be having problems compiling when the gyro is added to to the panel, below are the compiling errors
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_SPI.c:209:1: error: (192) undefined identifier "tris"
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_SPI.c:280:1: error: (192) undefined identifier "tris"
ZDBLSYC BLDC POC V1.0.c

2: error: (192) undefined identifier "FCP_TRIS_Unconnected_Port"
ZDBLSYC BLDC POC V1.0.c

35: error: (192) undefined identifier "FCP_PORT_Unconnected_Port"
ZDBLSYC BLDC POC V1.0.c

64: error: (192) undefined identifier "FCP_LAT_Unconnected_Port"
ZDBLSYC BLDC POC V1.0.c

100: error: (195) expression syntax
ZDBLSYC BLDC POC V1.0.c

2: error: (192) undefined identifier "FCP_TRIS_Unconnected_Port"
ZDBLSYC BLDC POC V1.0.c

35: error: (192) undefined identifier "FCP_PORT_Unconnected_Port"
ZDBLSYC BLDC POC V1.0.c

64: error: (192) undefined identifier "FCP_LAT_Unconnected_Port"
ZDBLSYC BLDC POC V1.0.c

100: error: (195) expression syntax
(908) exit status = 1
Re: Gyro_L3GD20
Posted: Tue Jun 02, 2020 10:20 am
by Benj
Hello,
I take it the problem is in Flowcode 8. I think I have now found the cause of this and fixed the problem for you.
The latest component should now be available via the update system.
Re: Gyro_L3GD20
Posted: Tue Jun 02, 2020 11:20 am
by Lord Grezington
Thanks Ben, again I will update and give it a go
Re: Gyro_L3GD20
Posted: Wed Jul 01, 2020 4:50 pm
by Lord Grezington
Hi Ben
I have the SPI MAster connected to the same pins as the SPI Gyro (MOSI, MISO, CLK) but with different SS for another component. The program compiles fine, but when I test it on hardware the it freezes. When I then set the Gyro to software mode it does not freeze.
Is it possible to use the same SPI channel for two different devices in hardware mode? (with differnet SS)
Thanks
Re: Gyro_L3GD20
Posted: Thu Jul 02, 2020 10:04 am
by Benj
Hello,
Yes this should be possible, maybe try disable the second call to the initialise to avoid initialising the peripheral twice. Maybe we could track if the peripheral is already initialised and automatically stop this from happening to make this process easier.
Just checking your not calling one from inside an interrupt are you as that might explain the lockup?
Re: Gyro_L3GD20
Posted: Thu Jul 02, 2020 1:59 pm
by Lord Grezington
Hi Ben
Thanks for the reply.
If I disable the SPI component compelty, and then try run in hardware the program freezes (the OLED backlight comes on, but shows blank screen). I can get data if I run in software mode. I have attached my program for you to see.
I also seem to be having reading the data from the Gyro, I get data on the bus but nothing seems to be saved into a variable. I have attached a trace of the SPI bus for you to take a look at.
**EDIT - I now seem to be reading data (by taking the DEN pin low), but seems values seem to be random**
Any idea where I am going wrong?
Thanks
Re: Gyro_L3GD20
Posted: Thu Jul 02, 2020 6:24 pm
by Benj
Hmm I wonder if the two components have a different SPI mode, there are generally 4 modes involving the state and sequence of clock and the data but generally two of the 4 modes will work on any one slave device.
As for what's causing the lockup if you could find out the specific component macro call that is doing this then I can investigate for you. I don't think it will be the low level SPI code though there is a while loop here in the send function this hopefully shouldn't cause any problems. It could instead be something higher up that isn't getting the value it wants and therefore staying in a loop.
Re: Gyro_L3GD20
Posted: Fri Jul 03, 2020 7:46 am
by Lord Grezington
Thanks Ben
I will do some tests to see which component is the culprit.
I have attached the latest testing variant of the Gyro test (still in software). When running I seem to be getting some data on Data2, but nothing on Data0 or Data1. Do you think you can take a look and let me know how I can distinguish between data on the various axis?
Thanks
Re: Gyro_L3GD20
Posted: Mon Jul 06, 2020 2:36 pm
by Lord Grezington
Hi Ben
Any luck with this? I just need an example of how I can extract say the z-axis data.
Thanks
Re: Gyro_L3GD20
Posted: Fri Jul 10, 2020 1:22 pm
by Lord Grezington
I found the issue with this
Re: Gyro_L3GD20
Posted: Wed Aug 12, 2020 3:55 pm
by Lord Grezington
Hi Ben
I am modifying this with more boards, and it seems like every Gygo has a different steady state. This was previously OK, but some of these new ones coming in have very high stationary values (above 15000). Is there some way I can easily set the default to 0, or do I need to do this in code to calibrate the stationary offset?
Thanks
Re: Gyro_L3GD20
Posted: Thu Aug 13, 2020 5:08 pm
by Benj
Hello,
Might be worth playing with the high pass filter settings for CTRL_REG2 0x21 as if this is on and enabled then I beleive it should remove any static DC values.
Otherwise you may be able to take an initial reading on power on. then subtract this reading from any of the measurements you take.
Or you could apply a software high pass filter to the data to remove any DC values.
If the reading is too high to get sensible values out of it then could the sensor be damaged? e.g. too much shock on their way to you in the post?