Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)

vhdl for reading pwm

Altera_Forum
Honored Contributor II
2,457 Views

hi i'm using ultrasonic sensor to detect water level and implement on De2 board. The output of the sensor is in pulse width which is 147uS/inch. Can anyone guide me how i can write the vhdl code for this output if i want to detects to 8 level? Let say im using 50Mhz clock on FPGA then (147us/20ns) i will get 7350 count per inch.  

can anyone help me what should i do so it can detects 8 levels of water level. tq
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
1,716 Views

Please provide a part number or link to a data sheet (once you can post links). 

 

What is the repetition rate of the ultrasonic pulses? 

 

Did you want to record the length of the echo pulse for each repetition? 

 

You've already figured out most of what you need to do - count the length of the pulse. To do that, you need to receive the pulse on a pin, synchronize it to the 50MHz clock (using a cascade of two D flip-flops) and then use that as the enable to a counter. The first pulse you get will cause the counter to count up. If you also create logic to detect the falling-edge of the pulse, you could copy the count to a RAM location. You could record multiple pulses, and then read them out, or average them, or ... 

 

If you can control the pulse repetition rate, then you could enable the sensor to generate a pulse, wait for the echo to be counted, read the counter value, clear it, and restart. 

 

You can control your logic using the JTAG interface on the DE2 board. See this tutorial: 

 

http://www.alterawiki.com/wiki/using_the_usb-blaster_as_an_sopc/qsys_avalon-mm_master_tutorial 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
1,716 Views

this is the link for data sheet 

ww.maxbotix.com/documents/MB1010_Datasheet.pdf
0 Kudos
Altera_Forum
Honored Contributor II
1,716 Views

This device has serial data output, PWM output, and analog output. Why not read the serial output directly? 

 

The device serial output is between 0 and Vcc. From the data sheet, it sounds like they invert the normal UART levels to create out-of-spec RS232 logic levels. You should be able to invert the signal and connect it to a regular UART IP block. If you power the sensor from 3.3V, you can read the range using a NIOS processor and a UART. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
1,716 Views

faizul hassan 

 

Hello, 

 

I'm Thomas from MaxBotix Inc. I am glad to provide some additional support regarding your question. Dave is correct with his statement. Additionally, if you wanted a direct TTL output, our MB1013 has RS232 and TTL outputs available.  

 

If you have any additional questions, please email me and I will be glad to assist you.  

 

Best regards, 

 

Tom Bonar 

Technical Support 

of MaxBotix Inc. 

Phone: (218) 454-0766 

Fax: (218) 454-0768 

Follow us on Facebook 

 

Technical support and sales are subject to the terms and conditions listed on our website. MaxBotix,MaxSonar,EZ0, EZ1, EZ2, EZ3, EZ4, AE0, AE1, AE2, AE3, AE4, WR1, WRA1, and WRLA1 are 

trademarks of MaxBotix Inc.  

 

 

 

0 Kudos
Altera_Forum
Honored Contributor II
1,716 Views

Hello  

I work whith EPM570 and I need help if is possible. 

I have 4 button 2 is for increase and decrease one counter "std_logic 14 bit, (That are the maximum frequency of my step motor) the other 2, is for start cw and ccw. 

Now I need, when I push one off the cw/ccw button, to send out the step clock for step motor whith ramp, and when the frequency arrive equal to my counter, it stop to increase, 

and it continous to run until i release the button.  

When I release the button, the frequency decrease automatic until arrive to zero. 

The program for direction is ok tested, but for the clock, for me is very difficolty, I have not a big experience whith VHDL 

Can somebody help me?? 

Thanks in advance 

Maurizio
0 Kudos
Reply