My goal is to be able to control the position of a DC motor using a PID controller with the Labview interface for arduino (LIFA) and I am a facing a problem.
When I wire the motor's quadrature encoder to arduino analog pins and read them in LIFA, I a supposed to get 2 square wave signals, but I get funky-looking signals instead. They seem unreliable to me. What is happening? See image below
When searching the internet I found this thread saying that I'm in a dead-end since LIFA isn't fast enough to handle this kind of work. Is this true?
I also read that I should implement a code on the arduino itself to control the motor and then use LIFA only to send commands and display it on a GUI. But you can't send two programs on the arduino, right ? One to allow LIFA to work and the other to control the DC motor
I am trying to solve this first so that I can implement a pulse counter that will be able to control the position of the motor, after that I will be working on implementing a PID.
When I wire the motor's quadrature encoder to arduino analog pins and read them in LIFA, I a supposed to get 2 square wave signals, but I get funky-looking signals instead.
Encoders are digital devices. Why are you connecting them to analog pins? Why are you expecting an analog pin to give you a square wave?
Is this true?
It must be. I read it on the internet. Actually, it isn't an Arduino question, so has no place here.
But you can't send two programs on the arduino, right ?
Correct. So, ditch LIFA and use a real PC application that talks to the serial port.
PaulS:
Encoders are digital devices. Why are you connecting them to analog pins? Why are you expecting an analog pin to give you a square wave?
Because I should get a signal similar to this image (see attached) and I think it should be analog? The signal varies between 0 and Vcc (5V). When I wire my encoder signals in Arduino digital pins nothing happens.
PaulS:
Correct. So, ditch LIFA and use a real PC application that talks to the serial port.
What PC application would you suggest? I have all the hardware (motors, drivers, relays, etc) and now I need to build a GUI so that an user can choose between multiple motors and specify their position.
I started with Labview because I'm used to that program and because I have limited experice in coding something else than matlab. Coding an entire GUI seems like an enormous task for what I need, but maybe I am wrong.
Because I should get a signal similar to this image (see attached)
That looks like a square wave, with a pin jumping from LOW to HIGH and back to LOW. Looks digital to me.
The signal varies between 0 and Vcc (5V).
Please add a circle around the part where the signal is something other than 0 or 5V. I guess I'm missing that part.
When I wire my encoder signals in Arduino digital pins nothing happens.
Without seeing a schematic and some code, I can't begin to guess what is wrong.
now I need to build a GUI
A perfect job for C#, which is the easiest language to use to talk to the serial port, too. Of course, there are two threads - one for the GUI and one for the serial port, and the serial port thread can't talk directly to the UI objects. I have an example C# application that I can share, if you want.