03-18-2022 10:44 AM
Hello ,
I am doing a project of control and regulation of a DC motor, with an Arduino Uno board and LabVIEW
I want to measure the speed of this motor with the sensorTCST2103
a disk on a drive shaft with a single tooth, once the disk cuts, the signal provides a low front
So I want to measure my speed by counting the time between two successive fronts, that makes a complete turn and then we can deduce the speed in rpm. Then in rpm
1-problem A: with Arduino and LabVIEW I can't find a function that allows me to detect a rising or falling edge and that calculates the frequency directly (on the other hand I tried a NI card that has a frequency counter input that works perfectly) but in my case, I thought to make a threshold (in red) below this value it is detected either as a rising or falling edge
-My question is how can I detect an edge with Arduino LINX for example, apart from what I proposed?
-Is there a way to do it with pin 2 interrupts on Arduino?
If not someone can save me either with examples or proposals!
Thanks in advance
03-18-2022 11:48 AM
Hi Ayoubas,
is it an requirement to use LINX?
Why don't you use the ArduinoIDE to create Arduino code? Then all you need is a serial.writeln command to send measurement data to your computer…
There are (most probably) existing libraries for the Arduino to count signal edges…
03-21-2022 07:25 AM
Thank you for responding
in fact it is not an obligation to work with Linx, but it is among the libraries used as LIFA.
I made an IDE code with VISA I can read the data well, but to send a PWM signal and read the speed, I can not
with VISA there is not I believe a block for a PWM signal, that's why I opt for LINX or LIFA;
I wanted to do both at the same time acquire the speed with VISA via IDE code and send a PWM signal with LINX but it did not work as the serial port takes only one input channel at a time.
How can I acquire the speed and send a PWM signal with either LINX or LIFA?
I hope I was clear in the explanation
03-21-2022 01:42 PM
Hi Ayoubas,
@Ayoubas01 wrote:
in fact it is not an obligation to work with Linx, but it is among the libraries used as LIFA.
I made an IDE code with VISA I can read the data well, but to send a PWM signal and read the speed, I can not
with VISA there is not I believe a block for a PWM signal, that's why I opt for LINX or LIFA;
Why do you mix LINX and LIFA? They are different drivers and cannot be used mixed with each other!?
So you already know how to communicate with an Arduino using VISA functions.
Your only problem is to implement a PWM output on your Arduino? I guess there are Arduino libraries with PWM implementations readily available!
@Ayoubas01 wrote:
How can I acquire the speed and send a PWM signal with
either LINX or LIFAVISA?
First you send a command to your Arduino, including the PWM duty cycle.
The Arduino handles that command and can then send the acquired speed signal value back to your computer…
03-22-2022 03:43 AM
yes I understood, but to use VISA (write to send PWM and read the speed at the same time) I have to upload the program which is not practical.
So my question is can you help me to make a program that can measure the time between two edges?
Thanks
03-22-2022 05:49 AM
How do you expect Arduino to work without uploading a program you need?
03-22-2022 07:44 AM
the problem with visa is that to measure the speed you have to upload the program on IDE Arduino
to send the PWM signal also we upload and we lose the old program
so is there a way to run two programs at the same time writing and reading?
for me if sincerely I avoid to work with VISA! because of that
I would like to take advantage of the sub vi already made on the LINX or LIFA library to realize my project, my major problem is the detection of the rising or falling edge and to calculate the frequency as I explained in my first message ?
03-22-2022 08:33 AM - edited 03-22-2022 08:38 AM
I think you are misunderstanding some concepts here.
You write an Arduino program in which you poll the pins for their state to determine motor rpm AND a communication function which either sends rpm data or receives commands (over USB presumably).
how that would look like:
-> generate interrupt if pin is low
-> count how many interrupts happened in 1 second
-> average several seconds of data for smoother output (optional)
-> once a second check if any commands were received over comm (or generate interrupt when command comes)
-> execute commands
-> send data once a second
On the Labview side all you needs is a simple VISA procedure with read/write capability.
03-22-2022 10:19 AM
this is what i want to make
for exemple this is my speed signal and if i detect edges (2 , 3 , 4 , 5 , 6 , 7) is 3 tr /s
but I think for high speeds it will not be very effective?
here is what I could do someone can improve my program
more thanks
03-23-2022 03:03 AM
Honestly i don't have much experience with arduino or LINX, but i do have experience with atmega chips.
Opening a serial communication, executing two tasks in parallel and then closing it twice is at best gonna give you trouble and at worst won't even work.
Again, not an arduino expert, but on atmega chips there are things called external interrupts, which can be set to be triggered by different changes, a falling edge being one of them. I think you could safely go up to 100kHz motor speed and still have it trigger (it of course depends on your code, interrupt code should be kept simple).