LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems generating PWM Signal

Hardware: USB 6002 DAQ, LabVIEW 2019, L298N H bridge board.

 

I'm trying to generate a signal for controlling the PWM pin on the H bridge board to run a DC motor following this example(example1.png). Problem is, in the example says they use digital output on the DAQ to generate the controlling signal. When running it with DAQ Assistant configured for Digital I get this error (digitalerror1.png).  Reconfiguring the DAQ Assistant to generate Analog signal results into this (analogerror.png).

 

Even tho different H bridge board was used before, I know that this code with this DAQ was used to create such PWM signal. What am I doing wrong here?

0 Kudos
Message 1 of 4
(1,366 Views)

Hi jiksan,

 


@jiksan wrote:

Hardware: USB 6002 DAQ,


Did you read the specs for your DAQ hardware? DId you understand all that is written in there?

The USB6002 does not support outputting a PWM signal on digital outputs, neither DIO nor PFI. All it supports are static DIO (aka software timed digital outputs)…

 


@jiksan wrote:

Problem is, in the example says they use digital output on the DAQ to generate the controlling signal. When running it with DAQ Assistant configured for Digital I get this error (digitalerror1.png).  Reconfiguring the DAQ Assistant to generate Analog signal results into this (analogerror.png).

 

Even tho different H bridge board was used before, I know that this code with this DAQ was used to create such PWM signal. What am I doing wrong here?


Wrong:

Relying on DAQAssistent without understanding how it works. Doing some data conversions (from scalar boolean to scalar integer numeric to boolean array) without understanding its implications!

You create an array of 16 boolean element from your scalar boolean - and now you wonder why the DAQAssistent complains about a wrong number of channels in the provided data?

 

Also wrong:

Attaching an image of code instead of attaching the real code…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(1,334 Views)

Thanks for the reply GerdW

 

To fix some of my mistakes:

Yes, I have read the specs of my DAQ and I knew it cant generate a counter or such digital output. What confused me was the "documentation" of the example I'm following. There it says "to control the speed of the motor, we create digital PWM generator" and this confused me. Now I get it, that they mean the first part of the code. Translation and understanding errors.

 

Also you are right about doing data conversions without understanding its implications.

This is what I understand: We compare the current number of iterations of the for cycle. Until our set number is higher, the NOT gate gives output true (because the Greater? is at false). After the NOT, I have Boolean to (0,1) which makes the true/false to 1 and 0s (also the reason why the digital output was saying it needed 16 channels was cuz this makes 16 bits integers). This is what I understand of it. Why after that I have Number to Boolean Array, or what data type I need to give DAQAss in order to generate the voltage, I cannot understand atm and would be grateful to any explanations.

 

The code is attached below this time.

 

0 Kudos
Message 3 of 4
(1,322 Views)

Hi jiksan,

 


@jiksan wrote:

Also you are right about doing data conversions without understanding its implications.

This is what I understand: We compare the current number of iterations of the for cycle. Until our set number is higher, the NOT gate gives output true (because the Greater? is at false). After the NOT, I have Boolean to (0,1) which makes the true/false to 1 and 0s (also the reason why the digital output was saying it needed 16 channels was cuz this makes 16 bits integers). This is what I understand of it. Why after that I have Number to Boolean Array, or what data type I need to give DAQAss in order to generate the voltage, I cannot understand atm and would be grateful to any explanations.


Your DAQAssistent is configured to drive one (1) digital output, so it expects an array with just one boolean element.

To build an array of exactly one element you should actually use the BuildArray function:

No ExpressVIs needed! (You might replace the DAQAssistent by simple DAQmx functions.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 4
(1,270 Views)