sib
-
Posts
27 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Gallery
Posts posted by sib
-
-
Hi Attila
My question to you is . Please can you write out a command script rather than a protocol script for the PMOD ACL2
and test together with the following version of waveforms .
As you can see , I am putting a lot of effort in to get this working we have been chatting on and off for quite a while.
This should just work but it is not working.
Enclosed are all of my work books to date to try and get this working. Work book 5 "SPI_test_5_test.dwf3work" contains the latest files
It seem that the SPI write / read method is the thing that is failing .
I think the best bet to solve the case would be if you post back a working work book that uses command script rather than a protocol script for the PMOD ACL2 .
Please use the same SPI setup as me
Protocol.SPI.Select.Active.value=0;
Protocol.SPI.Clock.Polarity.value=0 ; // set up spi clock initial Polarity
Protocol.SPI.Clock.Phase.value=0 ; // set up spi clock initial Phase
Protocol.SPI.Clock.Frequency.value=1e6 ; // set spi clock freqncy at 1MHz page 19 of the data sheet min spi clock 1MHz
if(Protocol.SPI.Clock.Frequency.value > 1e6) Protocol.SPI.Clock.Frequency.value = 1e6;
Protocol.SPI.Select.value = 3; //Assigns pin Analog Disovery 2 GPIO Pin DIO 3
Protocol.SPI.Clock.value = 4; //Assigns pin Analog Disovery 2 GPIO Pin DIO 4
Protocol.SPI.DQ0.value = 5; //Assigns pin Analog Disovery 2 GPIO Pin DIO 5
Protocol.SPI.DQ1.value = 6; //Assigns pin Analog Disovery 2 GPIO Pin DIO 6
Best wishes
Simon
SPI_test_3.dwf3work SPI_test_4.dwf3work SPI_test_5_test.dwf3work SPI_test.dwf3work SPI_test_2.dwf3work
-
Attempt 2) as full script but this time trying to assess the under lying class structure that the Wavefroms GUI uses
Waveforms GUI has a hidden spi mode which have class commands starting : Protocol.SPI.Simple.
-------------------------------------------------
if(!('Protocol' in this)) throw "Please open the Protocol tool";
clear();
Protocol.Mode.text = "SPI"; // make sure SPI tab is selected
Protocol.SPI.Start(); // activate select
Protocol.SPI.Select.Active.value=0;
Protocol.SPI.Clock.Polarity.value=0 ; // set up spi clock initial Polarity
Protocol.SPI.Clock.Phase.value=0 ; // set up spi clock initial Phase
Protocol.SPI.Clock.Frequency.value=1e6 ; // set spi clock freqncy at 1MHz page 19 of the data sheet min spi clock 1MHz
if(Protocol.SPI.Clock.Frequency.value > 1e6) Protocol.SPI.Clock.Frequency.value = 1e6;
Protocol.SPI.Select.value = 3; //Assigns pin Analog Disovery 2 GPIO Pin DIO 3
Protocol.SPI.Clock.value = 4; //Assigns pin Analog Disovery 2 GPIO Pin DIO 4
Protocol.SPI.DQ0.value = 5; //Assigns pin Analog Disovery 2 GPIO Pin DIO 5
Protocol.SPI.DQ1.value = 6; //Assigns pin Analog Disovery 2 GPIO Pin DIO 6
Protocol.SPI.Simple.Wordbits.value=8;
Protocol.SPI.Simple.Words.value=4;
Protocol.SPI.Simple.Commandbits.value=8;
Protocol.SPI.Simple.Command.text="0x0B, 0x00"
Protocol.SPI.Simple.Command.Write="h01, h02, h34, h56"
var rg = Protocol.SPI.Simple.Command.Read ;
Protocol.SPI.Stop(); // deactivate select
print(rg);
-------------------------------------------------
Output result from print statement : undefined
-------------------------------------------------
-
This my two attempts to get it to work using scripting
Attempt 1) as full script
-------------------------------------------------
if(!('Protocol' in this)) throw "Please open the Protocol tool";
clear();
Protocol.Mode.text = "SPI"; // make sure SPI tab is selected
Protocol.SPI.Select.Active.value=0;
Protocol.SPI.Clock.Polarity.value=0 ; // set up spi clock initial Polarity
Protocol.SPI.Clock.Phase.value=0 ; // set up spi clock initial Phase
Protocol.SPI.Clock.Frequency.value=1e6 ; // set spi clock freqncy at 1MHz page 19 of the data sheet min spi clock 1MHz
if(Protocol.SPI.Clock.Frequency.value > 1e6) Protocol.SPI.Clock.Frequency.value = 1e6;
Protocol.SPI.Select.value = 3; //Assigns pin Analog Disovery 2 GPIO Pin DIO 3
Protocol.SPI.Clock.value = 4; //Assigns pin Analog Disovery 2 GPIO Pin DIO 4
Protocol.SPI.DQ0.value = 5; //Assigns pin Analog Disovery 2 GPIO Pin DIO 5
Protocol.SPI.DQ1.value = 6; //Assigns pin Analog Disovery 2 GPIO Pin DIO 6
Protocol.SPI.Simple.Wordbits.value=8;
Protocol.SPI.Simple.Words.value=4;
Protocol.SPI.Simple.Commandbits.value=8;
Protocol.SPI.Start(); // activate select
var rg = Protocol.SPI.ReadWrite(8, [0x0B, 0x00]);
Protocol.SPI.Stop(); // deactivate select
print(rg);
-------------------------------------------------
Output result from print statement : 255 , 255
-------------------------------------------------
-
-
Still no joy.
It is not working
The code you sent me does not run and give a result
-
Hi Attila
Have you managed to get your hands on a PMOD ACL2 board yet ?
So that you can help me resolve what is going wrong with this code example.
Best wishes
Simon
-
Hi Attila
I am being hope fully here.
Please put some effort in here, If you are to busy to fix the case , please get the case referred to someone else in your team who can spend the time to get to work.
It would be really interesting to be able to display 3 way axis accelerometer data as 3 reference scope channels just like the PMOD MIC3 example reference this post notes
If you can get this application working it would make a very good application for university teaching for example with robots to get student use to the Analog disocvery 2.
So the student can execute robot to move using a command line call . so some thing like
var move_robot = Tool.exec("robot_move.exe", [ " 5cm left , 5 cm up "])
SPI read PMOD ACL3 on a 100ms time step so as to get acceleration date during the move of the robot arm.
There are lots of thing this stuff can be used for anyway so it is good idea to get it working.
AD2 is very good tool with many options !!
-
Hi Attilla
I wrote full proper script using the main script window. As the protocol.spi custom window would not work as shown on the previous post.
This executed script below actually chatted to the PMOD ACL2 device but could not read the x,y,z,temp data for the PMOD ACL3 only its chip ID .
Scripts run sequences is
1) Power up AD2 internal PSU to power PMOD ACL3 card with 3V3
2) Set up the physical SPI bus
3) Send a SPI Write command to the PMOD ACL2 to issue it a reset command
4) Read the CHIP ID for ADXSL362 using SPI BUS
5) Read the status register
6) Set the Power control register to 0x22
7) Read the status register
8 ) Read ADXL362 using 8 bit values X{H} Y{H} Z{H}
9) Read ADXL362 using 16 bit values X{L,H} Y{L,H} Z{L,H} Temp{L,H} as 16 bit numbers
10) Power down AD2 internal PSU to power PMOD ACL3 card .
Please help to get this to work fully . This is after all what application engineers do ...
Attached is a copy of my waveforms work book. So you can actually take it and get to work with the pieces from your office cupboard.
Best wishes
Simon
//######################################################################################################
// This is the output of the script
/*
SPI Script for PMOD ACL2 3 axis accelometer with Analog devices ADXL362 running
Device is ADXL362 : SPI register 0x00 read { 0dxx in decimal} : 173,29,242,2
ADXL362 Status regiser raw data after reset = 173
Write SPI [0x0A, 0x2D , 0x22 ] :: ADXSL262 SPI register setup for POWER_CTL to be permantly on without sleep
ADXL362 Status regiser raw data after POWER_CTL_setup = 0
Raw data {8 bit data} {x,y,z} = 0,0,192
Write/Read SPI [0x0B, 0x0E] :: Read ADXL362 Device X{L,H} Y{L,H} Z{L,H} Temp{L,H} as 16 bit numbers Page 23 of the ADXL362 Data sheet
*/
//######################################################################################################
//************************************************************
//
// Real script to chat with PMOD ACL2 3 axis accelometer
// using a Digilent Analogue Discovery 2
//
// ref for spi register data : https://www.analog.com/media/en/technical-documentation/data-sheets/ADXL362.pdf
//
// ref https://os.mbed.com/users/tkreyche/notebook/adxl362_tkreyche/ look at the bottom of the page there is a NXP ARM C mbed example
//
// Note for this script to work the following Waveforms window panels have to be open
// - Supplies - the internal AD2 PSU can be used
// - script -- location where this script is cut and pasted
// - Protocol - required to have acces to the AD2 internal SPI bus engine
//
//************************************************************
clear(); // clear display screen
print(" SPI Script for PMOD ACL2 3 axis accelometer with Analog devices ADXL362 running " + "\n\r ");
//************************************************************
// Set up mini PSU inside Analogue Discovery 2 to supply 3.3V
//************************************************************
Supplies.Output.PositiveSupply.Voltage.value=3.3;
Supplies.Output.PositiveSupply.Enable.setEnable();
Supplies.Output.NegativeSupply.Enable.setDisable();
Supplies.run(); // Turn on PSU unit inside AD2
wait(2); // wait 1 seocnds for system to stabilise.
//************************************************************
// Script using Protocol UART.
// SPI BUS Set up
//************************************************************
//
// SPI Bus physical wired set up
//
// PMOD PIN 1 = : Select AD_2_DIO3 // SPI: /CS
// PMOD PIN 4 = : Clock AD_2_DIO4 // SPI: Clock
// PMOD PIN 2 = DQ0 AD_2_DIO5 // SPI: MOSI
// PMOD PIN 3 = DQ1 AD_2_DIO6 // SPI: MOS0
// PMOD PIN 5 = GND= AD2_GND
// PMOD PIN 6 = VCC = AD2_VPOS_VCC
//
Protocol.SPI.Select.value = 3; //Assigns pin Analog Disovery 2 GPIO Pin DIO 3
Protocol.SPI.Select.Active.setValue(0);
Protocol.SPI.Clock.value = 4; //Assigns pin Analog Disovery 2 GPIO Pin DIO 4
Protocol.SPI.DQ0.value = 5; //Assigns pin Analog Disovery 2 GPIO Pin DIO 5
Protocol.SPI.DQ1.value = 6; //Assigns pin Analog Disovery 2 GPIO Pin DIO 6
Protocol.SPI.Clock.Frequency.value=1E6 ; // set spi clock freqncy at 1MHz page 19 of the data sheet min spi clock 1MHz
Protocol.SPI.Clock.Polarity.value=0 ; // set up spi clock initial Polarity
Protocol.SPI.Clock.Phase.value=0 ; // set up spi clock initial Phase
//************************************************************
//************************************************************
// Main program block read ADXL362 Device ID
//************************************************************
if(!('Protocol' in this)) throw "Please open the Protocol tool";
Protocol.Mode.text = "SPI"; // make sure SPI tab is selected
Protocol.SPI.Start(); // SPI activate select
Protocol.SPI.Write(8, [0x0A, 0X1F, 0x52]); // SPI RESET ADXL362 by making a soft reset page 26 of the ADXL362 Data sheet : SOFT RESET REGESTER
wait(0.100); // wait 100 milli second before reading ID data . Datahseet say device needs 500 micro seconds to stabilise after reset.
Protocol.SPI.Write(8, [0x0B, 0x00]); // Read ADXL362 Device ID Page 23 of the ADXL362 Data sheet
var rgID = Protocol.SPI.Read(8, 4); // read 4 words of 16 bit length
Protocol.SPI.Stop(); // deactivate select
var Device_ok=0;
if(rgID[0] != 0xAD || rgID[1] != 0x1D || rgID[2] != 0xF2){
print(" Device ID mismatch " + rgID );
print(" ");
print(" Is the physical SPI Bus physical wired set up correctly ?? " );
print(" ");
print(" The SPI setup should be :- ");
print(" ");
print(" Select AD_2_DIO3 // SPI: /CS ");
print(" Clock AD_2_DIO4 // SPI: Clock ");
print(" DQ0 AD_2_DIO5 // SPI: MOSI ");
print(" DQ1 AD_2_DIO6 // SPI: MOS0 ");
}
else
{
print(" Device is ADXL362 : SPI register 0x00 read { 0dxx in decimal} : " + rgID + "\n\r" );
Device_ok=1;
}
//**********************************************************************************
//
// Result shoudl be : Read: hAD, h1D, hF2, h02,
// Output : 173,29,242,2 in dec --> hex --> 0xAD 0x1D 0xF2 Ox02
//
//*********************************************************************************
function bitExtracted( number, k, p)
{
// Function to extract k bits from p position
// and returns the extracted value as integer
// eg first 11 bits of a 16 bit number
// bitExtracted(int 0xfff,10,0)
return (((1 << k) - 1) & (number >> (p - 1)));
}
function initial_first_measuremnt_test()
{
Protocol.SPI.Start(); // activate select
/*
*
* ADXSL262 SPI register setup for POWER_CTL to be permantly on without sleep
*
* Bit 7 Reserved 0x0
* Bit 6 External CLK =1 int=0 0x0
* Bit 5:4 Power ns Noise Trade off 0x10 = Ultra Low Noise
* Bit 3 Wakeup mode 0x0 = OFF
* Bit 2 Autosleep 0x0 = OFF
* BIT 1:0 Measurement state 0x10 = Measurment Mode
*
* Resultant setting = b00 10 00 10 = 0x22
*/
Protocol.SPI.Write(8, [0x0B, 0x00]); // Read ADXL362 STATUS_reg Page 23 & 25 of the ADXL362 Data sheet
var STATUS_reg = Protocol.SPI.Read(8, 1); // read 4 words of 16 bit length
print(" ADXL362 Status regiser raw data after reset = " + STATUS_reg + "\n\r" );
wait(0.01); // wait 10 milli second before reading data.
Protocol.SPI.Write(8, [0x0A, 0x2D , 0x22 ]); // ADXSL262 SPI register setup for POWER_CTL to be permantly on without sleep
print(" Write SPI [0x0A, 0x2D , 0x22 ] :: ADXSL262 SPI register setup for POWER_CTL to be permantly on without sleep " + "\n\r" );
wait(0.01); // wait 10 milli second before reading data.
Protocol.SPI.Write(8, [0x0B, 0x00]); // Read ADXL362 STATUS_reg Page 23 & 25 of the ADXL362 Data sheet
var STATUS_reg = Protocol.SPI.Read(8, 1); // read 4 words of 16 bit length
print(" ADXL362 Status regiser raw data after POWER_CTL_setup = " + STATUS_reg + "\n\r" );
wait(0.01); // wait 10 milli second before reading data.
Protocol.SPI.Write(8, [0x0B, 0x08]); // Read ADXL362 Device X{H} Y{H} Z{H} Page 23 of the ADXL362 Data sheet
var rg_eight_bit = Protocol.SPI.Read(8, 3); // read 4 words of 16 bit length
print(" Raw data {8 bit data} {x,y,z} = " + rg_eight_bit + "\n\r" );
wait(0.01); // wait 10 milli second before reading data.
Protocol.SPI.Write(8, [0x0B, 0x0E]); // Read ADXL362 Device X{L,H} Y{L,H} Z{L,H} Temp{L,H} Page 23 of the ADXL362 Data sheet
var rg = Protocol.SPI.Read(16, 4); // read 4 words of 16 bit length
wait(0.01); // wait 10 milli second before reading data.
print(" Write/Read SPI [0x0B, 0x0E] :: Read ADXL362 Device X{L,H} Y{L,H} Z{L,H} Temp{L,H} as 16 bit numbers Page 23 of the ADXL362 Data sheet " + "\n\r" );
Protocol.SPI.Stop(); // deactivate select
var gx = 0.001* (rg[0]<<16) /256/256;
var gy = 0.001* (rg[1]<<16) /256/256;
var gz = 0.001* (rg[2]<<16) /256/256;
//var temp = 0.065* (rg[3]<<16) /256/256;
var temp_sign= bitExtracted(rg[3],10,1);
var temp =bitExtracted(rg[3],1,11);
if(temp_sign==1){ temp= temp * -1 ; }
print(" Raw data {16 bit data} {x,y,z,temp} = " + rg + "\n\r" );
print(" Accelerometer initial X value = " + gx );
print(" Accelerometer initial y value = " + gy);
print(" Accelerometer initial z value = " + gz);
print(" Accelerometer initial temp value = " + temp);
}
if ( Device_ok==1)
{
initial_first_measuremnt_test();
}
//************************************************************
// Power down mini PSU inside Analogue Discovery 2 to supply 3.3V
//************************************************************
Supplies.stop(); // Turn off PSU unit inside AD2 after measurment has finished.
//************************************************************
-
Hi Attila
As I need this working I am doing my own application engineering .
The script function inside the protocol.spi window does not seem to be working
The script will not run and just gives the error message " Data transfer error " which is not helpful .
Outcome :: No usable result ...
I had to fix a few things in script as the SPI bus command where not correct. Indicating know one in Digilent has been testing the scripts properly.
Digilent spi command :: Write(8, 0x0A, 0x00); // Read Register, Device ID
Fixed SPI command Write(8, 0x0B, 0x00); // Read Register, Device ID
Best wishes
Simon
//------------------------------------------------------------------------------------------------------
// This is the script I ran in the protocol.spi window:
// Pmod ACL3 - ADXL362
//************************************************************
// Script using Protocol UART.
// SPI BUS Set up
//************************************************************
//
// SPI Bus physical wired set up
//
// Select AD_2_DIO3 // SPI: /CS
// Clock AD_2_DIO4 // SPI: Clock
// DQ0 AD_2_DIO5 // SPI: MOSI
// DQ1 AD_2_DIO6 // SPI: MOS0
Select.value = 3; //Assigns pin Analog Disovery 2 GPIO Pin DIO 3
Select.Active.setValue(0);
Clock.value = 4; //Assigns pin Analog Disovery 2 GPIO Pin DIO 4
DQ0.value = 5; //Assigns pin Analog Disovery 2 GPIO Pin DIO 5
DQ1.value = 6; //Assigns pin Analog Disovery 2 GPIO Pin DIO 6
Clock.Frequency.value=5E3 ; // set spi clock freqncy at 5KHz
Clock.Polarity.value=0 ; // set up spi clock initial Polarity
Clock.Phase.value=0 ; // set up spi clock initial Phase
//************************************************************
Start();
Write(8, 0x0B, 0x00); // Read Register, Device ID
var rgID = Read(8, 4);
print(rgID);
Stop();
if(rgID[0] != 0xAD || rgID[1] != 0x1D || rgID[2] != 0xF2){
return "Device ID mismatch "+rgID;
}
else
{
Start();
Write(8, 0x0B, 0x0E); // Read Register, Data
var rg = Read(16, 4);
Stop();
// convert data bits to signed value relative to gravitational constant
// MSbit sign, LSBit 0.001g
var gx = 0.001* (rg[0]<<16) /256/256;
var gy = 0.001* (rg[1]<<16) /256/256;
var gz = 0.001* (rg[2]<<16) /256/256;
var temp = 0.065* (rg[3]<<16) /256/256;
return [gx,gy,gz,temp];
}
-
Hi Attila
Just walked over to the goods in office and collected the PMOD MIC3 board and tried the PMOD MIC3 with Digilent Analogue discover 2 .
It just worked straight out of the box.
Download the script. Followed the read me document . Run the script.
Result -> Working PMOD MIC3
So my conclusion is there is some thing fishy with the PMOD ACL2 set up in the example script or the PMOD ACL2 board has some hidden secret.
Its time for your to do your Application Engineer magic and go get the bits from the cupboard and solve the case .
Look forward to hearing from you soon with a working PMOD ACL2 on your desk and some photos on this blog and copy of the working script on this blog page
Best wishes
Simon
-
Hi
The PMOD MIC3 I have order should turn up soon . So I will try the example
https://blog.digilentinc.com/capturing-and-analyzing-live-audio/
https://testandmeasure.org/#/category/scripts/pmod-mic3-audio-streaming-recording-125baaaf
Maybe this will give some light on the issues causing the problems
Best wishes
Simon
-
-
Hi
This the latest beta version of waveforms i can find : digilent.waveforms_beta_v3.13.1_64bit.exe
You are using a not released for public use version of Waverforms maybe ??
Please can you send me an attachment with the python file PMOD ACL3 ADXL362 IC and I will try that.
Many thanks &best wishes
Simon
-
Hi Attila
Where do I get hold of Waveforms Beta 2 .
Is located here
Or is there another download location ?
Best wishes
Simon
-
Hi Attila
All the pieces have arrived in the post . I have assembled the set up. But no working communications.
The set up as a below. Text book setup between Digilent Analog Discovery 2 and PMOD ACL5. Its is UHD photo so you can really zoom in to
see which wire goes where and there is a wiring diagram and the voltmeter is attached across the PSU wires PIN GND-PIN5 , VCC3V3 PIN6
Below is the output from Digilent Analogue Discovery 2 using waveforms
As you will notice . It is not working . The return result from running the example script you suggested for the PMOD-ACL2 return the message "Device ID mismatch"
So my question to you is the following
- 1) Build the set up yourself in your office they are after all Digilent components. Properly test the solution.
- 2) Put up a good post showing all the components working together
- 3) makes sure you post the newly updated correct working python script.
- 4) Add a proper connection diagram between the PMOD ACL2 and the Analogue Discovery 2 . It was a bit poor this was not include in the AD2 or the PMOD ACL2 document.
Basically this should just work out of the box without issues .
Best wishes
Simon
-
-
Hi Attila
Thank you for showing me the example all that is missing is the pin connections between the PMOD ACL2 and the Digilent AD2
This is the pin out of the PMOD ACL2
This the pin out for the Digilent AD2 example you showed me
So the pin map can see so far is
PMOD_ACL5_PIN1 --> ~CS --> AD2_Digital_DIO_0
PMOD_ACL5_PIN4 --> SCLK --> AD2_Digital_DIO_1PMOD_ACL5_PIN11--> GND --> AD2_V-Power_Supply
PMOD_ACL5_PIN12--> VCC --> AD2_V+Power_SupplyThis still leaves
AD2_Digital_DIO_2
AD2_Digital_DIO_3
AD2_Digital_DIO_4
AD2_Digital_DIO_5Which pins do these 4 Analog Discovery ports , connect to which signals on to the PMOD_ACL5 board ?
Best wishes
Simon
-
Hi
I think I have found the answer already maybe
https://blog.digilentinc.com/capturing-and-analyzing-live-audio/
https://testandmeasure.org/#/category/scripts/pmod-mic3-audio-streaming-recording-125baaaf
These examples show a microphone which is read by SPI . and the result is displayed on the scope screen as channel ref 1
It would not be so big a step to modify the code to read a SPI accelerometer .
Maybe you even have and example which is already for reading a PMOD accelerometer.
Best wishes
Simon
-
Hi
With the waveforms tool is it possible using python scripting in the Waveforms platform to do the following ??
Use the Digilent Analogue discovery 2
- Attach a device like a PMOD device eg accelerometer https://store.digilentinc.com/pmod-acl-3-axis-accelerometer/
using the Analogue discovery 2 ability to chat SPI & IC2
- pmod DEVICES SUPPORT 12-pin Pmod connector with SPI interface and 2×4-pin I²C interface- Then using the read information from the PMOD device treat it like an extra oscilloscope channel .
Either as a Analog channel or Digital channel depending on the the signal type acquired from the PMOD device.
This is possible with Labview but that would also require a lot of code writing.
If this is possible this is outstanding feature when considering all the available PMOD devices available from the list
https://store.digilentinc.com/by-function/input/This would be a real product enhancement for Digilent and the Analog Discovery and help sell the AD2 in to many new
places .Best wishes
Simon
Waveforms with accelerometer
in Test and Measurement
Posted
Hi Attila
Your spi-custom code would run but did not give an output
This was why i asked you to translate it to to a standard script . As the standard script method in the past has sometimes worked where as the
spi-custom script method has never worked ,
The only thing that has worked every time is the spi-master gui interface using read-write command.
Best wishes
SImon