LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

MX2125 Accelerometer to control 2 servos

Hello,

This is my first labview project so i have lots of questions.

 

I want to use a mx2125 accelerometer for a school project with an USB 6218 NI DAQ.

 

I want to read the tilt angle from the accelerometer and than control 2 servo motors to those angles.

I am having problems reading the duty cycle of the mx2125 with daq assistant and pulse measurement block. On a flat surface it should read 500m but it seems to vary from 495 to 505 is it normal?

 

Also setting up the daq assistant seems tricky I do not fully understand how to use sample rate and number of samples and if it should be continous samples or n samples ?

I am currently using a rate of 10k HZ with 1k samples is this ok?

0 Kudos
Message 1 of 10
(3,594 Views)

Hi milupus,

 

I have check the manual for MX2125 from the internet.

http://www.parallax.com/Portals/0/Downloads/docs/prod/sens/28017-Memsic2Axis-v2.0.pdf

 

 

mx2125.JPG

 

Seems like there is a range of 48.7% to 51.3% tolerance on this.

Meanwhile, the axis output should be 100Hz PWM signal, so the period will be 10ms, the duty cycle will be vary around 5ms instead, please correct me if I am wrong?

 

Regards,

KwokHow

Applications Engineer | National Instruments
Singapore (65) 6226 5886 | Malaysia (60) 3 7948 2000 | Thailand (66) 2 298 4800
Philippines (63) 2 659 1722 | Vietnam (84) 28 3911 3150 | Indonesia (62) 21 2783 2355
0 Kudos
Message 2 of 10
(3,572 Views)

This is what I get on a flat surface. Values of -3.5656 , 0 and +3,5656 but I think it is normal. What I want to do now is to program 2 servos to move to those angles, any idea how to do that and have a smooth movement? Thanks!

screen.png

 

0 Kudos
Message 3 of 10
(3,566 Views)

Any ideas on how to control servos? I think i need to output a pwm signal but i don't know how to do it, should i use a digital output or an analog output?

0 Kudos
Message 4 of 10
(3,551 Views)

PWM for servo control?  What servos are you using?  Usually you just need a DC analog voltage...

0 Kudos
Message 5 of 10
(3,548 Views)

This is my first labview project so I am not sure how to do it properly.

I am using 2 x TowerPro SG90 9G  servos but i am unable to find their datasheets.

0 Kudos
Message 6 of 10
(3,540 Views)

No datasheet?  Well that does present a challenge, doesn't it?

 

According to http://www.hobbypartz.com/topromisesg9.html , the operating voltage is 4.0-7.2 volts.  These are analog values.

 

From your description, you need to create a conditional statement that sends the appropriate servo a voltage within this range when the accelerometer indicates that your device has tilted one way or the other.  You could use a case structure to accomplish this.

 

As for what voltage to use...  You'll have to experiment.

0 Kudos
Message 7 of 10
(3,536 Views)

pwm servo.jpg

This is the output of my arduino with a working servo code. First graph is for position 0 second one is for 180 degrees.

 

I have wired the digital pin  used for signal on arduino directly to an input on my daq and got these graphs. I have used only one wire.

 

How to obtain those signals in labview and control my servo?

0 Kudos
Message 8 of 10
(3,489 Views)

I checked with an oscilloscope and I am using the same signals from my Arduino(where it works) and from my DAQ Analog output(where it doesnt). However when I connect the servo to the USB 6128 NI DAQ I hear the pwm inside the motor, changing the duty cycle also changes the buzz frequency. Could this mean the DAQ can not provide enough current to move the servo?

 

The input pwm signal is fixed at least.

0 Kudos
Message 9 of 10
(3,478 Views)

Ok, I tried with an external power source and it works. It seems like the USB 6218 is not providing enough current to the servo. How come a 10$ arduino board can do this and this National Instruments expensive board can't?

0 Kudos
Message 10 of 10
(3,470 Views)