Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

How to control DC motor using NI Motion in C programming

I am using NI Motion card UMI-7764 and using c-language to control DC motor. I am using flexmotion library from NI and able to read the encoder value from NI Motion card using the function  flex_read_encoder_rtn(boardID, axis, &encoderCounts). Now I am willing to control a dc motor using PID control depending upon my desired position but I don't know how to send the output of PID control to the DC motor conneted to my NI Motion card. Please guide me how can I do that. 

Right now I have tried function flex_load_dac(boardID, NIMC_DAC1, (positionCommand), 0xFF) but it is not working.

Thank you.

Best Regards

Nabeel

0 Kudos
Message 1 of 10
(6,614 Views)

If you navigate your Start Menu to All Programs->National Instruments-> Motion -> Documentation, do you see examples listed in that folder?  There are several examples that should provide a starting point to control a motor there.

0 Kudos
Message 2 of 10
(6,589 Views)

yes I have checked that folder but there is no example. I can read the encoder value from NI Motion card but when I am trying to set voltage to roate motor, it is not rotating. I have made the program in LabVIEW and it is working fine but I have do it in c-language. Any help?

0 Kudos
Message 3 of 10
(6,581 Views)

could you please guide me what is max sampling rate of NI Motion card??

0 Kudos
Message 4 of 10
(6,575 Views)

I am using the attaced code provided by NI but motor is not moving at all, is there any configuration problem? but when I am using LabView code it is working file that's I am thinking that my configuration is correct. please guide me.

0 Kudos
Message 5 of 10
(6,571 Views)

Does the code return any errors or does the motor just not run?

 

I'm assuming you've made no modifications to the hardware setup itself.  You're just changing from LabVIEW to C and using the identical setup.  Is this correct?

0 Kudos
Message 6 of 10
(6,549 Views)
yes.hardware setup is same..Now motor is working but throughput of my application is 3ms. Is there any way to reduce the throughput of application from 3ms to 1ms?
Thank you.
0 Kudos
Message 7 of 10
(6,542 Views)

Did you choose the same profile you were using to see that behavior on LabVIEW or were you also getting 3ms with LabVIEW?

0 Kudos
Message 8 of 10
(6,524 Views)

yes I am also getting 3ms in LabVIEW.

0 Kudos
Message 9 of 10
(6,516 Views)

Motors have maximum limits.  Are you reaching the maximum for your motor?  If not, take a look at this: https://www.ni.com/docs/en-US/bundle/371242b/resource/371242b.pdf

0 Kudos
Message 10 of 10
(6,496 Views)