Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

How to send data using rs232?

I want to send data using rs232. I'm using DE2 kit. How to i write a program doing this operation?

10 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    are you familiar with the sopc builder, the nios2 and its peripherals? you need to know these before worrying about RS232.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Open RS232 port as a file like " fp =fopen("/dev/UART...etc)" exact path find out in system.h and do your read arite operation as if you do in normal file operation like if you want to erite on rs232 port just type fprintf(fp,"%c",data); where fp is your uart port pointer

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    hello ..

    i want to use rs232 as input to board ,am using Quartus ii .

    the rs232 is connected to a speed sensor that generate pulses ,do you have any idea how can the board read these pulses through the rs232 and count them ??(this is my senior project ........ )

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    hello ..

    i want to use rs232 as input to board ,am using Quartus ii .

    the rs232 is connected to a speed sensor that generate pulses ,do you have any idea how can the board read these pulses through the rs232 and count them ??(this is my senior project ........ )

    --- Quote End ---

    1.> what boude rate your speed sensor generate data.?

    2.> is it use some start/stop , parity bit for makeing serial bit stream.?

    follow the same protocol at receiver end also.

    First you test your speed sensor weather it generate correct rs232 data by connecting this speed sensor serial bit stream to windows Hyperterninal utility ...this utility will display all the bit steram your speed senser generate. make sure while using Hyperterminal u must make a cross cable (Tx of Speed sensor connected to Rx of your Rx"PC").

    Or if your speed sensor is correctly generated the serial bit stream then you straight away connect serial cable from Speed sensor to board and write application in eclips environment, for reading this port use fread and for writing use fprintf.

    kaushal
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks for your reply.

    i think that my sensor is not generating the right data , it just produce pulses, it is maximum voltage is 1.2V ,and the minimum voltage is .5V .

    what i don't understand is how to make the FPGA(Altera DE2-70) broad understand these pulses? and count only the pulses with the maximum voltage.

    and do you think in that case that the rs232 will be the best choice for me or do you recommend something else ?

    Kindly Note : am using verilog language ,and Quartus ii to download the code on the fpga.

    thank you for your help .
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Thanks for your reply.

    i think that my sensor is not generating the right data , it just produce pulses, it is maximum voltage is 1.2V ,and the minimum voltage is .5V .

    what i don't understand is how to make the FPGA(Altera DE2-70) broad understand these pulses? and count only the pulses with the maximum voltage.

    and do you think in that case that the rs232 will be the best choice for me or do you recommend something else ?

    Kindly Note : am using verilog language ,and Quartus ii to download the code on the fpga.

    thank you for your help .

    --- Quote End ---

    1. First you amplify this voltage level (translater can do this job) and make data suitable for FPGA readiable ( like 3.2 volt etc)

    2. Give this pulse to FPGA and inside FPGA design a Counter which trigger by this pulses. evely pulse, increase counter value and u can easily track the max value.

    3. if youre sensor give data in RS232 format than you daon't have any problem if not thyen follow the point 2..

    4. i am not much familear with verilog.....but you can do this job in verilog also.

    gud luck

    kaushal
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    thank you for your replay

    i want to ask about SOPC BUILDER , what software do i need to use ???do i need to install altera moniter program and is there any other program that i can work with ??

    and how i will integrate the SOPC builder to my project ??

    and i use this program it gave me this error Using cable "USB-Blaster [USB-0]", device 1, instance 0x00

    Resetting and pausing target processor: FAILED

    Leaving target processor paused...

    http://www.alteraforum.com/forum//proweb/misc/progress.gif
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    thank you for your replay

    i want to ask about SOPC BUILDER , what software do i need to use ???do i need to install altera moniter program and is there any other program that i can work with ??

    and how i will integrate the SOPC builder to my project ??

    and i use this program it gave me this error Using cable "USB-Blaster [USB-0]", device 1, instance 0x00

    Resetting and pausing target processor: FAILED

    Leaving target processor paused...

    http://www.alteraforum.com/forum//proweb/misc/progress.gif

    --- Quote End ---

    Hello There,

    1.All you need to do is to just add UART in your system design in SOPC builder, and then generate new bsp. it will solve your first problem.

    2. in your eclips environment, ther you will find debug option just click on them and then enable usb blaster...this will solve your second problem.

    gud luck
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    hello again

    my gradution project submission next week , right now it is not working,i want to ask you can i use directly pin assigment for my input in assigment pin editior in quartus , i want to connect the input on the GPIO(expantion header 40 pin) on PIN_A0 to FPGA ??? wiil it work ?

    kindly NOte : the input is square pulses.

    thank you
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Yes , you can but make sure that the pin you are going to use should not be a dedicated pin on you board..

    there is no problem for connecting the expantion header pin on fpga.

    kaushal