U9 example adapted for U3


glrf

Recommended Posts

Hi DAQFactory, LabJack Support,

I need to get variable pulse width on a U3 output. After I learn more about how things work, an analog input-signal applied to another U3 terminal will control a loop to get a variable 1 to 2 microsecond-width pulse, and repeat every 50 microseconds. but that is later...For now I need a few basics. I'm glad I don't have to do this with punchcards.

Labjack Support wisely directed me to this portion of the forum, when I guessed about copy, and paste into DAQFactoryExpress objects when I find useful code I want to try. They suggested looking at the U9 example for counters and timers to begin to learn more (how cool is that?).

I guess DAQFactory example for timers/counters for the U9 LabJack needs to be tweaked to work for a U3, because I downloaded the example and I got the following when I tried to enter my first frequency:

C1000 Channel or function not found: Line 3 - unable to perform quick sequence action.

So I opened properties for that particular page component, went to Action tab and see:

frequency = System.EntryDialog("Enter Frequency (12-2900 Hz):")

divisor = Floor(750000/(256*frequency)) <Umm, ther's yer trouble? 750,000 is a huge number...

freq_actual = 750000/(256*divisor) <Umm, this must be the problem because it's on the third line...Right?

beginseq(Timers)

I'm guessing the U3 and the U9 have different hardware speeds or something.

Can I change some things to make the example (start to) work with a U3?

ARS

Link to comment
Share on other sites

LabJack control panel now indicates UD Driver Version 2.68...Loaded DAQFactory U3 Timer And Counter Sample (Sequence Based)...Jumpered between FIO4, FIO5, FIO6...Leaving safe mode, I see period measurement on FIO5 is 256uS...The counter on FIO6 advances about 4000 units each second...

Frequency measured on FIO4 with D-multimeter is around 3.9KHz...

What might be a good way to graph this signal to see the shape of this very fast pulse wave?

Link to comment
Share on other sites

The issue for that is the sampling rate. Say you want to acquire the waveform and display it. You decide that to properly display the waveform, you want 100 samples during 1 period so that you can draw it nicely. For a 4 kHz waveform, that would require a sample rate of 400000 samples/second, which is beyond the U3.

Link to comment
Share on other sites

Yes that is a very fast wave produced by the new U3 PWM example.

A lower frequency LabJack digital output would be better for my application anyway. To position a common RC servo shaft precisely, and hold it there, countering real-world force (force such as a tiny steel spring), requires a signal-high only every 50 milliseconds. This is only twenty cycles per second...I'm guessing this wave is more easily graphed real-time in DAQFactory from a U3.

Caution: Anyone trying this must refer to an earlier forum post by LabJack Support with respect to a proper seperate power supply for the servo! See: http://www.labjack.com/forums/index.php?showtopic=1198

I had good success cycling my Futaba S3003 from fully clockwise to fully counter-clockwise using The DAQFactory U9 Example for PWM (my test however of a U3) by resetting the duty cycle to 4%. This moves the shaft to relative zero degrees against the stop...Disable timer... Reset duty cycle to 8%...enable timer... This moves the servo shaft fully 180 degrees clockwise to the other stop...Disable timer. Smiles all around.

Now for precision positioning of the servo-shaft in small increments of rotation (my next goal), adjustment somehow of example code is nessesary. Which shiny billet of DAQFactory Example shall I take my hacksaw to (to learn more about effects of different width high-pulse-durations and reduction of total-signal-cycle frequency)?

I need to reduce the frequency, and adjust (modulate) how fat the high part of the signal is...

GLRF

Link to comment
Share on other sites

Say this is great!

Using your example, I can position my servo arm anywhere within ~60 degrees of rotation. When I change the dutycycle in DAQFactory, the arm moves to the new position, and it is held there quite strongly. However, the servo is acting like it has Parkinson's disease....

The servo growls quietly, and the servo-case warms up a little above ambient temperature. I don't know how long it will last in continuous service. These little Radio Control (R/C) servos are low-cost (for what they can do). I'll let you know how they last, if you are interested.

Tony van Roon; University of Guelph, says the following about R/C servo signals: "Modern R/C systems use a 40Hz - 60Hz frame rate, but the exact timing is not critical. If your frame rate is too slow, your servo's movement will become rough. If the rate is too fast the servo may become very confused."

I'm guessing the frequency of the signal is now a little too low, but not too bad... I am comparing the parameters you set with sequences in your earlier example for PWM to learn more. Good work, people!

Thanks!

GLRF

Link to comment
Share on other sites

In the example the frequency of the 16-bit PWM output is:

(48M/14)/(2^16) = 52.3 Hz

If you drop the divisor to 13, you get a frequency of 56.3 Hz. A divisor of 12 gives you 61 Hz.

I would check on the power you are using to supply the servo. Make sure it provides the voltage and current required for the servo. For that matter, you might tell us the connections between the servo, labjack, and power supply, so we can approve.

Link to comment
Share on other sites

For the power supply, I'm using an old cell phone battery charger. Nameplate output: 5.8VDC at 1.75W. Note: 1.75/5.8= only a third of an ampre. Voltage measurement shows 5.5 Volts most of the time with no load. Just fine for charging a BATTERY, but it may not be the best for this purpose.

For a Futaba S3003 servo:

The positive output-lead from the power-supply connects to the servo red wire.

The negative Output-lead connects to both the servo black wire, and a ten-ohm resistor. This resistor is series-connected to the U3 ground.

The servo white wire (the signal wire) is connected to U3 screw terminal: FIO0.

GLRF

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.