LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PWM servo control works in FPGA, not from Real Time

Hello,

 

I'm using the example Robotics/Motion Control/PWM Width Modulation.lvpropj to control a servo, using CompactRIO and LabVIEW. I've modified the example and replaced the high period ticks with slides in the FPGA front panel. It works fine moving the servos, however when I move the slides to a real time VI and try sending the data to FPGA something goes wrong. The servos don't move at all, but by using probes the data seems to come through. What can be the error?

 

I've attached screenshots of my code (note that the wires are broken since the CompactRIO isn't connected) and would be thankful if someone could take a look at it. Thank you!

Download All
0 Kudos
Message 1 of 4
(2,582 Views)

Hi fahstr,

 

If you add a Read/Write Control in your realtimeVI reading the "signal till servo 1" indicator in the FPGAVI, is the signal then correctly displayed? You could also try disabling as much code as possible in one of the FPGA loops, leaving just a boolean control connected to a DIO. Are you still getting the same behavior? If you upload your entire project in your post I can take a look at it.

 

Best regards,

Robert P-F
Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(2,519 Views)

Hi Robert,

 

I tried the following in the FPGA VI:

* Adding an indicator (named high period) before the "select operator", it shows the value which is sent from real time. This value is also sent back to realtime by the read/write control as you suggested, it updates very very slowly.

* Adding a boolean indicator (named high/low period) which shows the signal to the I/O in the FPGA,  I also send that signal back to real time by the read/write control as you suggested. They aren't synched, but I guess that might have to do something with FPGA:s frequency?

 

I am attaching a whole project, where we've started from the beginning to get everything right. I am basing the real time VI  on the example Producer Consumer VI. Our intention with the program is to make the servo rotate from 120 to 180 degrees, stepping through the angles. I translate the angle to ticks, with a couple of simple calculations, which are sent to a PWM generation in FPGA. The servos are still not moving.

 

Questions:

* In the PWM generation example, what does the integer "10 000 000"  to the far left connected to the true/false-case do?

* Can I use several FPGA references in real time?

* The high period which I am writing to in the FPGA VI, it's also a control, can it disturb someway?

 

I would be very thankful for your help!

 

0 Kudos
Message 3 of 4
(2,490 Views)

Hi fahstr,

 

To answer your questions.

 

  1. The integer is a constant to initialize the two shiftregisters in the inputside of the while loop: Resetting the Initial Value of Shift Registers
  2. You can use only one bit file reference at a time. However, you can use the Open Dynamic Bitfile Reference Function to return a dynamic bit file reference at run-time.
  3. If by 'high period I am writing to' you mean the high period indicator located inside the forloop in the FPGA VI, you are reading from it with the read/write control in realtime.vi. The reason for it updating slowely might be because the read/write node is only executed once an element is dequeued in the concumer loop. By looking on the producer look I can see that six elements are enqueued if case open is selected, but there is also a 5000ms delay in between each loop iterations which affects how often the consumer loop executes.

Hope this helps.

Regards,
Eirikur Runarsson
0 Kudos
Message 4 of 4
(2,366 Views)