LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting a 1D array of Doubles to a double

Hi,

 

In order to ramp-up the frequency of the square wave powering my stepper motor, I am using a formula node to increment the frequency input for the signal generator vi. This is not working as it says the data types are different. The for loop is outputting a 1D array of doubles and the signal generator requires a double.

 

Any help or advice would be greatly appreciated. 

Ciaran

 

C_Mongey_0-1579860063736.png

0 Kudos
Message 1 of 7
(2,961 Views)

Hi Ciaran,

 


@C_Mongey wrote:

In order to ramp-up the frequency of the square wave powering my stepper motor, I am using a formula node to increment the frequency input for the signal generator vi. This is not working as it says the data types are different. The for loop is outputting a 1D array of doubles and the signal generator requires a double.


The generation of that array is working nicely. (Why do you  need a formula node just to add 1? There is a "+1" function!)

Why do you convert the array to CDB/complex double?

Why do you even create an array when you need just a scalar DBL value???

Best regards,
GerdW


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

Hi GerdW,

 

Thanks for the quick reply!, the CDB conversion was just left in by accident. I dont want to create the array ideally, however i think the program creates the array by default because of the for loop in the code.

 

Is there a simple conversion to output the scalar double from the for loop ?

 

Ciaran

0 Kudos
Message 3 of 7
(2,945 Views)

Hi Ciaran,

 


@C_Mongey wrote:

the CDB conversion was just left in by accident. I dont want to create the array ideally, however i think the program creates the array by default because of the for loop in the code.

Is there a simple conversion to output the scalar double from the for loop ?


Why do you need that inner FOR loop at all?

The simple conversion is named IndexArray - but again: clean up all that Rube-Goldberg before!

Best regards,
GerdW


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

Hi GerdW,

 

I am using the inner FOR loop to increment the frequency at a time controlled rate using the wait vi. This brings the motor up to speed, and the next section of the flat sequence continues to run the motor at the peak frequency set by the FOR loop.

 

I removed the formula node and tried to increment the frequency output value using the FOR loop iteration number, however this produces the same issues with data-types.

 

Regards

Ciaran

0 Kudos
Message 5 of 7
(2,932 Views)

Hi Ciaran,

 


@C_Mongey wrote:

I am using the inner FOR loop to increment the frequency at a time controlled rate using the wait vi. This brings the motor up to speed, and the next section of the flat sequence continues to run the motor at the peak frequency set by the FOR loop.


Both sentences show some lack of "THINK DATAFLOW!" knowledge!

(Please take the Training resources offered in the header of the LabVIEW board!)

 

That inner FOR loop does not increment the frequency used in the outer WHILE loop - due to DATAFLOW!

Using a sequence structure indicates you should use a statemachine instead!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 7
(2,927 Views)

If you want to use all generated values to control the frequencies then you need to send/control it as part of the loop ...

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 7
(2,870 Views)