Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

vhdl code for adxl 345

Status
Not open for further replies.

HTI

Newbie level 6
Joined
Jan 13, 2012
Messages
13
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
1,367
I'm user of Vhdl and i have the De0 nano .Also i have the program of the g_sensor(adxl 345) in Verilog and i don't know how is working.
If somebody help me by sending me the vhdl code for the adxl 345.

Thanks a lot
Best Wishes
 

If I'm not mistaken, the adxl356 is an accelerometer...am I right?
Be more specific about what you want to do...
 
  • Like
Reactions: HTI

    HTI

    Points: 2
    Helpful Answer Positive Rating
Yes you have right the adxl 345 is an accelerometer .
i want a program in vhdl code which i will can get values from the accelerometer when the de0 nano is moving.
I have it in verilog but i am user of vhdl.
 

The manufacturer notes that the sensor can communicate using either SPI or I2C protocols.
If you have an FPGA/CPLD connected to the sensor - you'll have to choose wich protocol to use and then implement a "master" device in HDL for that same protocol...

---------- Post added at 19:32 ---------- Previous post was at 19:23 ----------

Also, I hope you understand that you have to physically attach the ADXL345 to the DE0 board.
The sensor cannot tell if the DE0 board is moving unless it moves together with it.
 

i have the program of g-sensor but is in verilog code.
But i know only VHDL code, as i explained before i want the program of g-sensor in vhdl .

best wishes
 

So what's the problem?
Implemnet a VHDL SPI master with Tx and Rx FIFOs.
And start getting readings...
 

thank a lot and i appreciate your advice but can you more specific because general i'm new in the hardware description language (vHDL). how i can get numerical values from the accelerometer .

THIS IS THE PROGRAM FOR THE ACCELEROMETER IN VERILOG. how i can get numerical values (voltage) and how i can store this value in the memory in order to produce a data base.
Code:
//=======================================================
//  PORT declarations
//=======================================================

//////////// CLOCK //////////
input 		          		CLOCK_50;

//////////// LED //////////
output		     [7:0]		LED;

//////////// KEY //////////
input 		     [1:0]		KEY;

//////////// Accelerometer and EEPROM //////////
output		          		G_SENSOR_CS_N;
input 		          		G_SENSOR_INT;
output		          		I2C_SCLK;
inout 		          		I2C_SDAT;

//=======================================================
//  REG/WIRE declarations
//=======================================================
wire	        dly_rst;
wire	        spi_clk, spi_clk_out;
wire	[15:0]  data_x;

//=======================================================
//  Structural coding
//=======================================================
//	Reset
reset_delay	u_reset_delay	(	
            .iRSTN(KEY[0]),
            .iCLK(CLOCK_50),
            .oRST(dly_rst));

//  PLL            
spipll u_spipll	(
            .areset(dly_rst),
            .inclk0(CLOCK_50),
            .c0(spi_clk),      // 2MHz
            .c1(spi_clk_out)); // 2MHz phase shift 

//  Initial Setting and Data Read Back
spi_ee_config u_spi_ee_config (			
						.iRSTN(!dly_rst),															
						.iSPI_CLK(spi_clk),								
						.iSPI_CLK_OUT(spi_clk_out),								
						.iG_INT2(G_SENSOR_INT),            
						.oDATA_L(data_x[7:0]),
						.oDATA_H(data_x[15:8]),
						.SPI_SDIO(I2C_SDAT),
						.oSPI_CSN(G_SENSOR_CS_N),
						.oSPI_CLK(I2C_SCLK));
			
//	LED
led_driver u_led_driver	(	
						.iRSTN(!dly_rst),
						.iCLK(CLOCK_50),
						.iDIG(data_x[9:0]),
						.iG_INT2(G_SENSOR_INT),            
						.oLED(LED));	

endmodule
 
Last edited by a moderator:

If you don't know Verilog, I suggest you ignore the above code and start writing your own in VHDL.
You'll have to read the datasheet and understand how the device operates:
https://www.analog.com/static/imported-files/data_sheets/ADXL345.pdf

If you aren't interested in learning HDL and only want to get readings from the device,
I suggest you choose the microcontroller alternative instead. If you know C, there're many written and debuged codes on the internet.
 

I totally get what you are trying to say.
Now your problem is coding ADXL345 built-in DE0Nano board......
sadly, this isn't easy to do...
As you may have noticed , the code you are giving is sample/demo given by Altera ..right??
IF you watch carefully, the G_SENSOR project contains a number of files all written in verilog...
IT would really really tough to code each of those module in VHDL .....
because some files included in project are pre-coded by Altera like spipll.v spi_controller.v and spi_ee_config.v (see them in "Files" section of Quartus project)..
if you wana code them in VHDL, that would be a hard task bro..
secondly, in this project the ONLY USEFUL file which one can modify for desired project is "led_driver.v" which outputs the reading to 8 LED's buit-in DE0 Nano..
now you should only modify this file according to your desired project or whatever u wana do, because in this file you have the data from ADXL345 stored in 10-bit iDIG ..

I would again emphasize you learn verilog ...its really easy to learn and bears C-like structure..
the reason I'm stressing on learning verilog is that all Altera demo's are verilog written..
and I discussed this matter with Marketing Engineer at Terasic Tech. he said that all of our engineers at Terasic are coders of verilog...
in upcoming boards of Altera, there will be only verilog//.....
its even hard for vendors to code VHDL for their boards.... so........brother live with that :/
any queries you can discuss at Terasic facebook page...
Terasic Technologies | Facebook
they surely will help you a lot..
 
  • Like
Reactions: HTI

    HTI

    Points: 2
    Helpful Answer Positive Rating
I have translated the code to VHDL. PM me if anyone wants it.
 
Last edited:

you can't find the VHDL-code for the ADXL 345, i know that because i send an email to ALTERA and they send me that is difficult to create in vhdl but only in verilog....
 

Untested but compilable with no errors in Quartus V11.0
 

Attachments

  • DE0_NANO_G_Sensor.VHD.zip
    19 KB · Views: 182
  • DE0_NANO_G_Sensor.zip
    20.6 KB · Views: 101

    V

    Points: 2
    Helpful Answer Positive Rating
i tested and doesn't work.....
Error listed from the quartus


Error: Can't place node "LED[1]" -- illegal location assignment PIN_A13
.
.
.
Error: Can't place node "LED[7]" -- illegal location assignment PIN_L3
Error: Can't place node "KEY[1]" -- illegal location assignment PIN_E1
Error: Can't place node "G_SENSOR_CS_N" -- illegal location assignment PIN_G5
Error: Can't place node "I2C_SCLK" -- illegal location assignment PIN_F2
Error: Can't place node "I2C_SDAT" -- illegal location assignment PIN_F1
Error: Can't place node "G_SENSOR_INT" -- illegal location assignment PIN_M2
Error: Can't place node "CLOCK_50" -- illegal location assignment PIN_R8
Error: Can't place node "KEY[0]" -- illegal location assignment PIN_J15
Error: Can't fit design in device
 

i tested and doesn't work.....
Error listed from the quartus
The problem isn't related to Verilog or VHDL coding. You need to check the pins assignments. The archived project compiles in Quartus V11 as is, so you apparently have applied changes to it.

It's the DE0_NANO_GSensor example from the DE0_Nano_v1.0.5_SystemCD, translated to VHDL.

If something in the archived project doesn't fit your requirements, just refer to the individual design files, as addressed in your question.
 
  • Like
Reactions: HTI

    HTI

    Points: 2
    Helpful Answer Positive Rating
Is working!!
thanx a lot!!
 

    V

    Points: 2
    Helpful Answer Positive Rating
can you please mail the vhdl code for adxl345 in i2c mode. urgent
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top