09-24-2013 11:03 AM
Good morning,
I am working on my university project and I have some questions I hope you can help me a little bit.
A brief description of what I must develop:
Make a real mode based on PONG game from Atari, using artificial intelligence, in my case I am going to use Fuzzy Logic control.
Hardware selected and their purpose:
-Arduino UNO R3: read signals from encoders attached to my DC car motors and read/write data processed in Labview fuzzy logic tool.
-USB Camera: Used as input on my fuzzy control, because of this I have installed all Vision toolkits, but for now I am investigating how it works.
-12 VDC Motors: Move the cars of my printer riels (2) according to received & processed packets from Labview in Arduino.
-Sparkfun quadrature encoders: Used to get the position from both cars and interact with Labview giving the second input used in my fuzzy control.
-Kick-pallets: This kicks the ball from one side to other, but this is not part of my control logic, just mechanical.
So, the aim is kept the ball in the field avoiding goals, all in automatic mode.
I am working first on my encoder readings, not using interrupts, just pulling method, and my first question, anticipating any error is time response between Arduino and Labview enough to do all this processing? considering read position (X, Y) from an object and also reading the encoder data from both motors and then get the processed fuzzy output and send it to Arduino?
First test I am gonna make this week is manual movement applicated on one motor, send the digital pin to LV, from LV send a digital output, making both motors move at the same direction, ideally at the same time.
I will appreciate your hel and guide, sorry about my english.
Best regards,
Alberto.
09-24-2013 12:54 PM
Assuming that the ball speed and direction of travel will be close to linear, a simple predictive strategy to determine where and when the ball will cross the line would work best.
If the speed and direction have some degree of unpredictability, then there will be a point where you will experience an inability to keep up. Where that point is depends on more than just the processing speeds, and communication between Arduino, and your software.
Paddle size, Motor ramps (starting and stoping), and how fast you can read the encoder counts need to be looked at.
09-24-2013 02:43 PM
Dear MoviJOHN,
I am agree about the linear response, but I trust this will not be a trouble, well, in my next experiences this will be revealed.
But, I am even more worried about time response of Arduino, if does not work, I will need to use another devices such as PIC's, and not so much time left to make this radical decision....
Have you ever worked with some similar applications using LIFA? I mean, sending quick data signals (PWM)? How was your experience?
Thank you for the answer.
Regards.
09-25-2013 08:01 PM
Using interrupts for quadrature encoder with LIFA is, in my opinion, the only way to use quadrature encoders. If you try any other type of polling method then you are at the mercy of all the other code running on the system and is unreliable. This is even true if you were polling with custom code in the firmware on Arduino.
From what I read, it is possible to run two quadrature encoders with only two interrupts. Ideally, you would want two interrupts per quadrature encoders.
09-26-2013 10:13 AM
Nathan_B.,
You are right, I am gonna try it using interrupts, but I am using Arduino UNO board, which means that I just have 2 interrupt pins (2 and 3).
Can I read my two encoders just with this board?
Also I have found a special LIFA that you developed for quadrature encoders: https://decibel.ni.com/content/docs/DOC-30184
Read both encoders it is very important, because this will be my inputs on my fuzzy control.
Thanks.Regards.
Alberto.
09-26-2013 10:27 AM
Sorry, I have forgot to mention about custom LIFA firmware for quadrature encoders does not compile on my IDE, I need to do something additional?
Regards.
09-26-2013 01:53 PM
I just tested compilation with Arduino 1.0.5 and it worked without any modifications. It's hard to determine why it's not working for you without knowing the errors that you are getting. If I had to take a shot in the dark, it's possible that if you have an encoder library (by the same name as the one I'm using) installed through Arduino, it could cause issues since I had to modify my version of the library to make it work.
IIRC, you should be able to use a single interrupt line for an encoder according to the encoder library but something will probably need to be changed in the firmware to make it work.
09-26-2013 02:54 PM
Nathan,
Yes, you were right, I was using a library with the same name, then I removed from Arduino and compilation result successful.
Now I have to try to connect both encoders.
Thanks for your help!
Regards.
Alberto.
09-26-2013 03:26 PM
Please note that in his whitepaper he says that an Arduino Uno will work with One encoder as the two inputs are dedicated to it.
11-02-2013 05:46 AM