Hi All, I am currently starting a project for work.I have to control the position of a small stepper motor using labview rt.I have as yet not purchased the output module for my compact rio device but it looks like i will be buying a digital output unit and not an analog 0-10v module.My plan is to control a stepper motor with an arduino inbetween labview and the motor.I would like to output a digital output and then use the arduino to control the position of the motor relative to the frequency of the output pulse.Is this posible ?? the project is going to be on a standalone device,based on some calulations i am doing in labview i will need the pressure in a system increased or decreased,I plan to use labview to output the signal and the arduino to take care of the motor for me. I will only have remote access to the labview unit and using pid control i will need the arduino unit to also stand alone with the program loaded onto it and just move the motor relative to the inputs it recieves from the digital output module on labview..is this possible.ps i have zero and i mean zero experience of arduino programming.Thanks all :-?
Yes it is possible but your explanation of what you want to do is not very clear.
LabView will allow you to send strings to the arduino, these will look like they have come from a serial port. You then use those strings in the arduino code to do what you want.
Once programed the arduino is stand alone and repeats that program every time it is switched on.
Thanks Mike.I am not too hot on the whole senging commands type programming,or programming in general as may be obvious ! sorry if my explaination wasnt great.What i hope to do is write a code for the arduino which will allow me to connect a pwm signal from my labview system to the arduino board.basically what i want to end up doing is turning a knob on my labview screen which will change the frequency of the outputted signal,i then want the motor to move to a position relative to the width of the signal i am outputting,basically one signal from labview and i am hoping that the arduino will figure out the forward and reversre from this. the entire range of the motor maybe two full revolutions.so if i increase the knob position i want the output signal frequency to increase and i want the motor to rotate x amount of steps cw,if i decrease the knob position i want the frequency of my signal to decrease and also the motor to rotate in a ccw direction until it reaches its new position.
Thanks for all your help
turning a knob on my labview screen which will change the frequency of the outputted signal,i then want the motor to move to a position relative to the width of the signal i am outputting,
That's the point you are mixing things up. Altering the frequency does not alter the width of a signal. The width is also called the duty cycle and altering this can be useful in control it is called PWM:- http://www.thebox.myzen.co.uk/Tutorial/PWM.html
Now for the motor, I suspect you want to use a servo motor, that will rotate to a certain angle depending on the signal you give it. See:- http://www.arduino.cc/playground/ComponentLib/Servo
I suspect all you actually want is LabView to output a number in string form and use the received string to set the value for the servo. Start off with the simple examples in the playground and then build in the LabView communications when that is working.
Yes Mike you are right,it is the duty cycle i want to change, I currently have the option of an analog -10v - +10vdc output module or a digital output module for national instruments.the analog unit is much more expensive so i am hoping to avoid it if possible,my plan if nessesary would be to output a 0-10v dc signal to the arduino which i want to use as a position indicator for it, but i would prefer if i could use a digital signal where i could alter the duty cycle as it would cost the company far less,I am not sure i would be able to program labview to output the strings needed but thats another learning curve for me to sort out ! I need the motor to be pretty small and cheap!! but also very quick moving,I was looking at the Futaba site and was wondering if these little motors would be quick enough and torquey enough for my job. Would a pwm signal be enough to control position of a motor or should i learn how to output strings on labview?if i was outputting a sting do i need to use 8 output terminals or do i use one which is switching on/off to output the correct number to the arduino?
Outputting a string in LabView is simple. You need to direct that output to the serial port that appears when the arduino is plugged in.
You don’t need to feed the arduino with signals generated from labView via an analogue or digital interface. Your arduino is the physical interface.
You can feed it strings or single bytes. These appere in the arduino’s input buffer. Your arduino code then looks at them and performs the appropriate operation.
So you will take the reading from your knob, send it as a string to the arduino. The arduino code then converts the received string into a number which is then fed to the servo control library. The servo then moves according to the knob position.
Thanks Mike,going to get cracking now and start ordering my parts.!
The only thing is labview will be running on a real time system which has no windows etc on it,so there will be no usb connection,the only form of connection i will have between labview and the arduino will be digital output lines from the digital output module of the labview controller to the arduino unit,this should still be ok to setup?
which has no windows etc on it,so there will be no usb connection
I can't see how one follows from the other. By no windows do you mean no operating system? Will your computer not be able to use USB when it is running?
Yes Mike,It has no operating system as such,The National Instruments unit i use is a real time operating system which only runs the sections of labview i need to collect data and is not a computer as such. Its called a compact Rio unit. What i hope to do is use the digital output module of the compact rio unit to send a signal to the arduino board and then have the arduino board position the servo accordingly.I am hoping to get a code somewhere for the ardiuno which i can load onto the arduino and it then remains imbedded in the arduino,at system start up the arduino will power up and move to a set position,then start looking for position commands from the labview code.as my machine does its thing! it will require different pressure settings depending on the calulations from labview,i then want labview to send a signal to the arduino to move the motor as required,the motor will be hooked up to open and close a pressure valve using rotary motion.
All of the hardware will sit in a box and then using a router i can see what is happening with my sensors,i do this by creating a virtual hmi on my pc,the labview unit then publishes its data on the router and it links it to my hmi on screen
Mike as I begin to dig into this i am beginning to wonder if i even need the Arduino,if i can connect a servo red and black to a supply and then use a pwm output signal from the national instuments unit to control position of the servo on its inout signal i ight not need the arduino unless there is something i am missing,I can output from the ni unit at about 20khz,now as you will have no doubt guessed at this stage i am no expert so maybe i am missing something obvious..thanks
Yes I think you might be right, you could feed the digital signal from the digital output to the servo. Servos use PPM rather than PWM although some servos are happy with PWM and others are not. The only question is can you generate the PPM from LabView?
yet again i must reveal my ignorance...i am after googling ppm and have come up with pulse position modulation,had a quick look and it looks like a changing time gap between pulses that seems to be irregular. I have had a quick check of the ni site and yes it can generate it but i dont think its something i would be able to get into my labview code and understand it at the same time!!,best off for me to vary the duty cycle of a digital output and let the arduino handle the rest of it. I take it once i get a suitable code the arduino should be able to do what i require.After looking through loads of servo sites and supplier it looks like a lot of them are cabable of only 180 degrees, so this now leaves me the option of gearing the hell out of it as i may need upto 5 full rotations at the business end or using a stepper to do it.
Either way the arduino is very much back on the cards.
So your problem is how to communicate with the arduino without a serial link. Just using the digital outputs will get you a binary flag but you need a number. Can you generate I2C in LabView (I know LabView can but can you?) If so you could implement an I2C slave device on the arduino and take it from there. As you want 5 turns, it is either a geared servo or a stepping motor. Problem with a stepping motor is that you don't know where it is initially positioned so you have to move it up to your 5 turns and monitor when it gets to the correct position with a switch or some other form of sensor. After that you are OK.
It appears I do have a serial output on my c-rio device which i can use for serial communication.I am waiting on a national instruments engineer to come visit me to show me how to output serial commands and what i am wondering now is what kind of commands,strings i woulod need to be sending to the arduino.for example at start up i will want the motor to go to a fixed position and then move cw or ccw depending on my calulations. so if i make up a 9 pin d sub cable and connect it to an arduino what would i actually need to be sending to the arduino for it to move cw ccw.I know your probably reading this through your fingers covering your eyes going dear god this man hasnt a clue....your not wrong !!!
I know your probably reading this through your fingers covering your eyes going dear god this man hasnt a clue....your not wrong !!!
OK. I'll admit it. That made me laugh.