dc motor control using lab view via arduino

hello: i am really new to arduino and i was wondering if i could use one to get signals come from an encoder, send them to labview for processing and get an output signal (PWM) from the arduino to the motor. and i was wondering since the encoders frequency would be about 20khz, do i need 2 arduinos: one for sending the encoder signals to the pc and the other one for sending the pwm to the motor or is one sufficient to do both jobs? if yes could some one help me with the programming

thank you in advance

Well, the basic Arduino does have I believe 6 PWM pins on it, so my initial guess would assume that you could do what you are hoping for. I might be wrong on this, but the hardest part would be to integrate the two read functions into the same loop without missing any data.

first of i would like to thank you for replying. but what you just said is the the problem i dont know how to start in programming the arduino to send the signals and recieve them in a real time application especially if the signals being recived from the encoder are quite fast unless i use frequency dividers (i think)

The Arduino should be able to process it, it operates at 20MHZ; as for the Serial, it too is a 115,200 Baud Rate. Do you have all the parts, or are you still shopping? If the question is "can it", I believe you will find away.

Also, what exactly are you trying to do? There might be better methods.

im trying to reduce the steady state error of a dc motor by getting values of its current speed (from an encoder), comparing it to the reference speed and using a pi controller (in labview which is already done) and the sending the analogue signal to the arduino which sends a PWM signal to the dc motor

Got it, all of that sounds very reasonable in the Arduino. You will need to write a loop function that is constantly reading the encoder, and I would recommend then having the Serial also continuously stream your data, considering the speeds. I would then have a comparison variable that drives your system.

It doesn't seem too complex, just very fast. It'll take a few headaches, but in regards to your equipment, you should be good to go.

what about the analogue signal from the labview to the arduino to the dc motor how can i program the arduino to do all four (encoder signals in and out and pc signals in and out) tasks without having any problems with the outputs

multiplexing???

wa7ad:
what about the analogue signal from the labview to the arduino to the dc motor
how can i program the arduino to do all four (encoder signals in and out and pc signals in and out) tasks without having any problems with the outputs

The Arduino must use serial communication to talk to labview. Short of jumping through additional hardware.

You need to break this project in steps. 1) read encoder when spun by hand and display reading on serial monitor. 2) control dc motor speed using hardware to power motor and serial monitor to control it. 3) learn how to communicate with labview using the computers serial port and the Arduino serial. 4) Combine all of the above.