Showing results for 
Search instead for 
Did you mean: 

DC motor control using NI 9485

Go to solution

Nice to meet you guys. 

Im newbie at labview.

I tried to make a DC motor controller by using NI 9485.

Here is my code

when 'true' in boolean.

참.pngI aim, if i turn on boolean switch, that NI 9485 will generate the current to line 0.

If turn off, current go line1.

So i want to check it possible or not when i start that code.

Please give me some tips.

0 Kudos
Message 1 of 5

A few questions first:

  1. You're already set up with constant power to both line0 and line1?
  2. It is only allowed to have one powered at a time (i.e. before you connect line1, you must disconnect line0)?
  3. Do you want to run this VI continuously, and then be able to change direction by clicking the button, or do you plan to run the VI once each time you want to change direction (or stop)?

This VI as it is probably doesn't do what you want.

You should take a look at the State Machine architecture, and particularly consider how you want the "logic" of your program to be. For example:

  • At start, both switches are open
  • When you choose a direction (perhaps you also pres some button to "change"), one switch closes. The other MUST be open before this can occur
  • When you change direction, open the other side, then close the new switch
  • To stop the motor, open both switches
  • To control the direction (including stop) consider using an Enum with {Stop, Clockwise, Counter-clockwise} or similar

You could probably also get some use from an Event Structure if desired, but a polling state machine is a good first step and may do everything you need without adding complexity.

0 Kudos
Message 2 of 5

Thank you for apply.


1. I will provide constant power from 24V SMPS to NI 9485. So, both line having constant power from it.


2. Yes, you are right. That is why i choose NI 9485. I heard that it has relay function.

   During provide one power to line 0, line 1 should be disconnected by relay in 9485


3. I want to run this VI for a moment(about 7 second), then stop about 10second by clicking "Stop button", and  i will start again just after change direction.


This is my plan

1) Turn on boolean, then click start button.

2) Click stop button, then turn off boolean for change motor direction by closing line 0 and opening line 1.

3) Click start button

4) Click stop button, then turn on boolean for change motor direction.

5) Click start button,

repeat that step.


I hope this explanation will be helpful to fix my problems.


thank you.

0 Kudos
Message 3 of 5
Accepted by topic author pizzanews

Thank you for the clarifications.

Regarding your reply:

2 - Indeed, the 9485 is a relay module. It contains 8 separate switches (of which it seems you want to use the first two). However, any combination can be opened or closed at once - closing #1 does not automatically open #0, or vice-versa.


Based on your description of the workflow, I'd like to suggest the following:

  • Choose a direction (using a boolean as you have currently if desired)
  • Click "Run"
    • Open all switches (wire 8 falses into the port - see image below)
    • Create an appropriate boolean array based on the direction choice - either [False,True], or [True,False].
    • Write that array - the motor starts rotating because one switch closes
  • Click the "Stop" button
    • Open all switches - the motor stops rotating
  • Repeat VI as needed. Note that with this design, clicking stop in the VI will stop the motor - i.e. you cannot stop the PC and leave the motor running.

Note that "Clockwise" must be the line1 in this case. Otherwise, change the boolean name to "CCW" or similar.Note that "Clockwise" must be the line1 in this case. Otherwise, change the boolean name to "CCW" or similar.


If you wanted to wait a specific time, rather than having a stop button, you could use either a Wait function or a Stall Data Flow.vim node (available from LabVIEW 2017 onwards).

If you wanted to stop at a specific time (e.g. 10 seconds) but still have a button to stop earlier, you could add a "Greater Than" node and wire the "i" terminal in this loop, and set an appropriate check based on the wait time (e.g. with the current values, 10s/50ms -> 2000 iterations, so use the "Or" node and greater than 1998 (or equals 1999)).

0 Kudos
Message 4 of 5

Thank you for a kind explanation!!


I will try that! 🙂

0 Kudos
Message 5 of 5