sib

Members
  • Content Count

    27
  • Joined

  • Last visited

About sib

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. 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
  2. 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
  3. 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 -------------------------------------------------
  4. 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 -------------------------------------------------
  5. This what works . So this proves that there is SPI communication and it is working
  6. Still no joy. It is not working The code you sent me does not run and give a result
  7. Also additionally as a user you have to make this setup change each time you start the waveforms environment before selecting the Analogue discovery device setup you wish to use.
  8. Hi Allita I found the solution myself . As a user you need to change a setting in the Waveforms program to fix the issue from to This solves the issue Best wishes SImon
  9. Hi Allita My Analog Discovery AD2 crashes waveforms when I plug in a external +5V psu. My PSU has cable has the deminsions 5V DC voltage supply with at least 3A max current, Outer diameter 5.5 mm and inner pin 2.1mm diameter positive inner pin = 5v Outer case =0 V DC plug connected up as shown the in above photo. This solutions complies to the hand book rules here https://reference.digilentinc.com/reference/instrumentation/analog-discovery-2/reference-manual Normally my Analog Discovery AD2 when just powered by the USB cable works fine without any issues. Any ideas of how to fix the issue ?? Best wishes Simon
  10. 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
  11. 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 !!
  12. 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. //************************************************************ SPI_test_2.dwf3work
  13. 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]; }
  14. 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
  15. 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