LabVIEW Embedded

cancel
Showing results for 
Search instead for 
Did you mean: 

ARM PWM frequency as Elemental Property Node

I want programmatically change the frequency of a PWM signal on a Keil MCB2300 ARM board. I see how to change it in the property window here:

 

http://digital.ni.com/public.nsf/allkb/839DB5B54A0915A9862574D70063B64B

 

But I want to make this an actual variable I can change in my program. I have tried to put an Elemental I/O Property Node on my block diagram and selected PWM1 signal. However when I right click and try to choose a property, it says none are available. 

 

I know of people doing this on the Luminary but can't figure out how to do it on the Keil.

 

thanks,

jason

0 Kudos
Message 1 of 24
(8,806 Views)

Hello Jason,

 

I am not sure if the Keil board has this functionality built in. The ARM Porting guide here: http://zone.ni.com/devzone/cda/tut/p/id/7119

mentions Elemental I/O supports the following I/O classes:

  • Analog In
  • Analog Out
  • Digital In
  • Digital Out
  • Digital Bank In
  • Digital Bank Out
  • Pulse Width Modulation Out

You can implement some or all of the supported I/O classes for an I/O device. For the LPC3180, Digital In, Digital Out, Analog In, and Pulse Width Modulation Out are implemented. So it looks like this can be done if it is not native.

 

I would look at the section in the Porting Guide above about creating an EIO for PWM. 🙂 there is a second section as well attached at the bottom which may help.

 

I hope this helps!

Sam S
Applications Engineer
National Instruments
0 Kudos
Message 2 of 24
(8,803 Views)

Additionally I found these other 2 threads which other customers have asked similar questions:

http://forums.ni.com/t5/LabVIEW-Embedded/ARM-Module-LM3S8962-PWM-problem/m-p/1091888

http://forums.ni.com/t5/LabVIEW-Embedded/pwm-doesn-t-work-with-MCB2300-generic-elemental-I-O/m-p/908...

 

I hope this helps too! 🙂

Sam S
Applications Engineer
National Instruments
0 Kudos
Message 3 of 24
(8,795 Views)

All,

 

I am attempting to do the same thing as Jason with a LM3S8962 ARM board and LabVIEW 2010 embedded.  I was able to find the properties vi that I thought would allow me to change the frequency of PWM1 within the VI.  The attached block diagram shows my approach. 

 

I want to change the default PWM1 frequency (1000 Hz) to 2000 Hz within the program. I can MANUALLY change the default frequency of PWM1 in the node attributes and the buzzer works fine at the frequency setting.  However, when I try to change the PWM1 base frequency within the VI, the VI runs, produces a short beep and then no sound. 

 

Is it possible to do this and how?

 

Thanks,

 

Jack

0 Kudos
Message 4 of 24
(8,612 Views)

Hi Jack,

 

It looks like you may be running into the same issue that Paul had in this discussion forum thread where you need to initialize the PWM before configuring it with the property node.  You can do this by using a Flat Sequence Structure to enforce the order of execution. 

Jayme W.
Applications Engineer
National Instruments
0 Kudos
Message 5 of 24
(8,597 Views)

Thanks Jayme!!!

 

I attempted to add the flat structure as shown on the attached.  I placed it inside the loop as well.  When measuring the PWM1 output with a scope, the frequency was always 1000 Hz.  Which is  the defaulat setting of the PWM1 node.

 

Any suggestions?

 

Thanks for you time, it is appreciated.

 

Jack

0 Kudos
Message 6 of 24
(8,585 Views)

Hey Jack, 

 

The reason Jayme had suggested the case structure, was to force data flow in your VI. 

 

It sounds like the actual PWM node, which is in the while loop of the screen shot you posted, needs to be carried out before the properly node which allows you to change the frequency. 

 

Since there is nothing linking the two structures in your VI, there isn't going to be any way to determine which one is going to be executed by LabVIEW first. 

In order to force the data flow, you'll need to wire something from the sequence structure to the while loop, or attach a second frame of the sequence structure surrounding the while loop. 

 

Wiring something from the sequence structure will cause the while loop to wait on the data coming from the sequence structure in order for it to execute. 

Adding the second sequence structure will force everything in the first sequence structure to execute before moving on to the second sequence structure. 

 

Either one should force the data flow for us, so that we call the PWM node, (which it appears you're writing 50 to) at least once before trying to set the frequency of that PWM channel with the property node, and then using the while loop to keep the signal going.  

 

 

 

Applications Engineer
National Instruments
CLD Certified
0 Kudos
Message 7 of 24
(8,574 Views)

Thanks Zach,

 

What you posted seemed like it should work.   I implemented the attached VI.  No luck and no sound form the buzzer on the board.  Is that the way I should have programmed it?  Any other thoughts?

 

Your help is appreciated.

 

Jack

0 Kudos
Message 8 of 24
(8,562 Views)

Looks like you're close. 

 

As I understand it from the other post you'll still need the PWM1 Node inside the while loop at the end. 

 "1st start the PWM, 2nd set PWM properties, 3rd infinite loop"

 

So, from where you're at I think you'd need to insert another frame between your current two. 

Place the frequency property node in the second frame (without the while loop) and a copy of the PWM1 node in the while loop (still in the last/third frame)

 

It sounds like you'll need the PWM1 node inside the while loop at the end to keep the buzzer making noise. 

 

Applications Engineer
National Instruments
CLD Certified
0 Kudos
Message 9 of 24
(8,549 Views)

Thanks Zach for the reply.

 

I attempted to make the changes but I do not get any sound.  Could I have done it incorrectly?  See the attached.

 

Any other thoughts? 

 

I really appreciate your time.

 

Jack

0 Kudos
Message 10 of 24
(8,534 Views)