LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW FPGA PMW modulation for L298n H-bridge

Hello to everyone,

I am new in LabVIEW FPGA programing and I have a couple questions, so I would be grateful if you could answer me. For my final work I have to control the speed and direction  of DC motor  using sb-RIO 9636 and H-bridge L298n. In attachments you can find scheme of the H- bridge and my program. I have conected In1(pin 5 of L298n) to digital pin 1 of the card, In2(pin 7 of L298n) to digital pin 2 of the card and changing the state of the pin I change the direction of the motor(I know that the one In should be Low and the other High so the motor can rotate  in one or the other direction). PWM(Enable pin of the L298n pin 6) I have conected to DIO3.

PWM signal I cretaed is  shown in picture.

My questions are:

1.Will loop timer I used, provide that period of signal is lenght I specify in the control(for example if I put 20 000  will the period be 20000 s)?

2. Can I vary the duty cycle changing the control Waiting (DIO3 is HIGH for a couple of us, then it sets LOW, and then all that repeats )?

3. Earlier I thaugt that PWM signal I should send in both IN1 and IN2, and that the Enable pin is used to stop or start the motor. I tried that and the motor was rotating different speed, and I could stop or star the motor with enable pin, sending it HIGH OR LOW, but I could not change the direction of the motor. So my other option was to conect the pins as I explained at the begining.  My question is: Should I PWM conect to the enable pin, and will thah work?

 

Thank you

Download All
0 Kudos
Message 1 of 8
(4,136 Views)

I'm not an expert in motor control, but I have some recommended resources.

 

There is a pretty large and active community of LabVIEW FPGA users who focus on power electronics (motor drives, energy conversion, power inverters).  I would recommend taking a look at some of their educational material and example code:

 

www.ni.com/powerdev

 

Regards,

Spex
National Instruments

To the pessimist, the glass is half empty; to the optimist, the glass is half full; to the engineer, the glass is twice as big as it needs to be has a 2x safety factor...
0 Kudos
Message 2 of 8
(3,918 Views)

Thank you a lot on your information. 

0 Kudos
Message 3 of 8
(3,895 Views)

I still did not get the answer, so if there is somebody else who can help me, I would be grateful. This project is very important to me.

Thak you

0 Kudos
Message 4 of 8
(3,860 Views)

I found a couple of resources that deal with PWM on the FPGA and motor control - they might be helpful to reference as you look for answers to your questions.

 

Developing a PWM Interface using LabVIEW FPGA
http://www.ni.com/white-paper/3254/en/

 

CompactRIO Motor Control Basics Tutorial

http://www.ni.com/pdf/labview/us/compactrio_motor_control_basics.pdf

 

PWM Output With LabVIEW FPGA

http://www.ni.com/example/26499/en/

0 Kudos
Message 5 of 8
(3,809 Views)

Thank you on your answer. Biut I have allready found that, and nothing of this did not help me. If you have something else, or if you know solution for my problem I would be grateful.

0 Kudos
Message 6 of 8
(3,789 Views)

The screenshot you posted is everything you need to create a PWM signal - setting a digital output to true for the period specified and then back to false with a delay before the next loop. You will need to see the configuration of the loop timer / wait VIs to get the units - but it's probably uSec.

 

As for your final question - you need to refer to the datasheet of the device to learn how to change the direction. You need to set the 'enable' pin to high to allow the output and then set one of the two 'input' pins high to set the direction.

 

 


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 7 of 8
(3,782 Views)

OK,Thank you very much.

0 Kudos
Message 8 of 8
(3,775 Views)