Jump to content
  • 0

Waveforms with accelerometer . Digilent Analog Discovery 2 with PMOD ACL2 . Java Script SPI


SIB-V2

Question

 

 

Hi Attila 

Have you have had almost 2 years to paste up a working example of how to get a PMOD ACL2 working but I still can not finding a working example any where.

This is the latest code for from the last time 

Is there any chance you will actually spend the time to get this to work ..

I feel it is not so good that a good tool like AD2 is being not supported.

 

Best wishes & friendly greetings

SIB 

 

Direct_protocol_test.dwf3work SPI_test.dwf3work SPI_test_2.dwf3work SPI_test_3.dwf3work SPI_test_4.dwf3work SPI_test_5_test.dwf3work

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hi @SIB-V2,

I pulled out a Pmod ACL2 and an Analog Discovery 2 and was able to get the existing Pmod ACL2 example with WaveForms (under Protocol -> SPI tab -> Custom tab -> Pmod ACL2 example) working on the first try with using the same wire setup that you show in your picture in this specific post (https://forum.digilentinc.com/topic/19237-waveforms-with-accelerometer/?do=findComment&comment=52066, though this post shows that you are attempting to use the Pmod ACL code in the Sensor tab rather than the Pmod ACL2 code in the Custom tab). The example as it's currently structured only runs through a single iteration rather than providing multiple pieces of data over time. I will also concede that the measured temperate is confusing (it is thankfully not 2 degrees Celsius in my office), but that it is because it's measuring the internal temperature of the chip with respect the environment rather than reporting absolute temperature, but I also don't plan on specifically using an accelerometer to measure absolute temperature.

I also took a look at the work spaces you attached and noticed the following things.

Direct_protocol_test -- You don't have a supplies tab open to provide a 3.3V power supply to the board and the DQ2 and DQ3 are also mapped to DIO 4 and DIO 5, respectively, which are already being used in your other pin assignments that you changed for some reason. Once you open the Supplies tab and set up a 3.3V voltage and change DQ2 and DQ3 to other DIO pins (I changed them to DIO 0 and DIO 1), the script works.

SPI_test --- You have the same issue with DQ2 and DQ3. You also use "write" with a lowercase 'w' rather than "Write" with an uppercase 'W'. Additionally you use the wrong command to read the device IDs; you use the write command '0x0A' rather than '0x0B' to read the device ID which is what the code is attempting to do. You later do the exact same thing with the second (correctly capitalized) Write function sending a write command rather than read command. Once I changed those details and added back in the lines of code that set the module into measurement mode rather than leaving it in standby mode which is the default state of the ADXL362, I started successfully receiving data though I'm not sure what data conversion you're doing for each variable, though I can tell you that you are doing it incorrectly because the ADXL362 does not provide data in the registers MSB to LSB as you are presuming it does in you calculations. The module as per the datasheet instead provides bits 7 through 0, then bits 15 through 8 of the two bytes which is why the built in sample code Attila has pointed to does some bit manipulation and rearranging.
I didn't check the logic analyzer tool that you had pulled up in this workspace.
You also have the SPI clock running at 5 kHz where as the datasheet recommends a serial clock rate between 1 MHz and 8 MHz, especially for multibyte transfers like you are doing.

SPI_test_2 --- Looking at the protocol tab, there are the same issues with DQ2 and DQ3, the lack of turning on measurement mode, slow SPI clock, and the conversion is incorrect as explained previously. Again, once I added in measurement mode to your else statement and fixed DQ2 and DQ3, I started receiving data correctly.

The script seems to work (or at least provides numbers) when I adjusted DQ2 and DQ3 in the Protocol tab to non DIO 4 and DIO5 values; by default it does not work. You can also specify the details specifically in the setup. The Power Control register bit of the script only sets up measurement and the ultralow noise mode, not the adjust the autosleep function that is mentioned in the comments. I didn't look into it much though.

SPI_test_3 --- Looking at the protocol tab, there are the same issues with DQ2 and DQ3, the lack of turning on measurement mode, slow SPI clock, and wrong conversion that you are performing. Again, once I added in measurement mode to your else statement and fixed DQ2 and DQ3, I started receiving data correctly. I didn't check the script.

SPI_test_4 --- For the protocol tab, this only needed the DQ2 and DQ3 to be fixed. I didn't look at the script tab.

SPI_test_5 --- The protocol tab is successfully reading back the 4 register values as configured. I didn't check the script tab. 

Based on my experiences though, which to be fair is only a single person with only one Pmod ACL2 to test, I think that the WaveForms software and the Analog Discovery 2 is supremely well supported by Digilent and specifically Attila.

If you have any questions or comments, please let me know.

Thanks,
JColvin

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...