Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Photo

T7 PWM output for servo motor control


  • Please log in to reply
14 replies to this topic

#1 terryalison

terryalison
  • Members
  • 8 posts

Posted 26 January 2015 - 06:17 AM

Has anyone had any experience with trying to control a servo motor using the PWM outputs from the T7? if so could tell me how you got it working as I cannot.

 

Thanks.



#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 26 January 2015 - 01:30 PM

What are you using for software?

 

What DIO-EF settings have you tried writing?

 

Do you have a scope or similar you can use to look at the output to see if it is what you expect?

 

I suggest using the latest version of everything, including the latest beta T7 firmware.  See the "Updates" section on the T7 Support Homepage:

 

http://labjack.com/support/t7



#3 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 26 January 2015 - 01:37 PM

Found another almost duplicate post that mentioned LabVIEW, so that answers the first question.  Will continue on this post and delete that other one.



#4 terryalison

terryalison
  • Members
  • 8 posts

Posted 26 January 2015 - 01:47 PM

Hi I am using LabVIEW and I have been going off of the examples, to be specific I have been looking at the "DIO EF Config 1 PWM Output" example initially and I have got a bit confused. All the config values that are here don't really make much sense to me, I have read the information on your site and it isn't much clearer, could you possibly explain what these mean? and then maybe I can move forward.

 

Thanks for any help you can give.



#5 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 26 January 2015 - 01:55 PM

I would start with the example from Section 13.1.2:

 

http://labjack.com/s...eatures/pwm-out

 

Confirm that you get a 10 kHz output with 25% duty-cycle.  Then consider what frequency and duty-cycle you want and try that.



#6 terryalison

terryalison
  • Members
  • 8 posts

Posted 26 January 2015 - 02:17 PM

I have seen that page before, I have read it more thoroughly and I think I can try a few more things. I have been looking at some more of the DIO EF PWM examples and I see no where about the amplitude of the square wave, as I require approx 5V I am wondering what the amplitude of is.

 

Thanks.



#7 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 26 January 2015 - 02:24 PM

PWM will drive the digital line between output-low (0V) and output-high (3.3V).  See "Electrical Overview" and "Increase logic level to 5V" here:

 

http://labjack.com/s...s/t7/digital-io

 

In addition, there is a new tick we are making that is a 3.3V to 5V level-shifter, but not sure if we have any available.  Inquire with [email protected] if interested.

 

Another possibility is to control a DAC output, but you would have to use a different technique to get your desired waveform.  I'd say Stream Output or Scripting will work if your frequency and resolution requirements are not too high, but those techniques are not as simple as DIO-EF.

 

http://labjack.com/s...form-generation



#8 terryalison

terryalison
  • Members
  • 8 posts

Posted 26 January 2015 - 02:57 PM

To achieve the 5V could I not just add two signals together say from the DAC0 using a square wave generator and a duty cycle at 100% along with the DIO EF? of would this not be plausible?  



#9 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 26 January 2015 - 03:09 PM

You can only add voltages like that when they are floating compared to each other.  That is, they do not share a common reference.  For example, 2 AA batteries that have no other connections that create a common reference, can be put in series and their voltages then add.

 

On the T7 all the signals are referred to the same ground, which is GND.



#10 terryalison

terryalison
  • Members
  • 8 posts

Posted 28 January 2015 - 04:01 AM

We only actually need 3-5V square wave so the T7 PWM output would be fine. However I have read lots of information that I don't understand. Is it even possible to control a servo motor with the T7's PWM output? as I need specific pulse times (1-2ms pulses) and a specific off time (time at 0V) for the servo to work. I have no idea how to do this with the resources available.

 

If you could help at all more specifically with my problem that would be great.

 

Thanks.



#11 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 28 January 2015 - 10:06 AM

I gather you are talking about an R/C style servo motor.  These typically specify a range for the allowable period/frequency of the signal, and then specify a range for the positive pulse that corresponds to position.  For example, a typical R/C servo allows a pulse frequency of 40 to 70 Hz, where a high time of 1-2ms corresponds to 0-90 degrees.  The formulas at the top of 13.1.2 guide you on configuring for the desired frequency and duty-cycle (duty-cycle determines high time).

 

So say you want a PWM frequency of 50 Hz.  Go ahead and write the following registers:

 

DIO_EF_CLOCK0_ENABLE = 0
DIO_EF_CLOCK0_DIVISOR = 1
DIO_EF_CLOCK0_ROLL_VALUE = 1600000
DIO_EF_CLOCK0_ENABLE = 1

 

With 50 Hz, the period is 20 ms, so a 1-2 ms high pulse is 5-10% duty-cycle, so you want to set DIO#_EF_CONFIG_A to values from 80000 to 160000.  You can initialize the output on FIO0 at 1.5 ms:

 

DIO0_EF_ENABLE = 0
DIO0_EF_INDEX = 0
DIO0_EF_CONFIG_A = 120000
DIO0_EF_ENABLE = 1

 

And then whenever you want to change the pulse from 1-2 ms write:

 

DIO0_EF_CONFIG_A = 80000 to 160000

 

 

Also, you might be able to use the 5 volt supply from the LabJack (VS) to power the servo, but in general I would not recommend it. We have found the servos draw a big surge current when they move, which can cause the supply voltage to droop and might cause the LabJack to reboot.  So the signal from the LabJack is certainly fine, and you will need to connect GND to ground on the servo, but the power supply for the servo might need to connect to an external source.



#12 terryalison

terryalison
  • Members
  • 8 posts

Posted 31 January 2015 - 04:27 AM

I have now got the servo working, I can change the angle by changing the constants that determine the duty cycle, what I cant do is to change the duty cycle via say a numeric control of some form in labview whilst in a loop.

 

I want to be able to control the servo constantly. I know the LabJack PWM requires a 0 (off) enable value before any configuration changes occur and then requires a 1 (on) before the changes happen. I have tried writing vi's that do what I have just said but I also don't want it to be continuously turning on and off.

 

Is there a simple way using the LabJack PWM output to change the duty cycle while in a loop?

 

Thanks for any help.



#13 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 02 February 2015 - 10:57 AM

You should be able to just write to DIO0_EF_CONFIG_A in a loop.  See "Update" in 13.1.2:

 

http://labjack.com/s...eatures/pwm-out



#14 terryalison

terryalison
  • Members
  • 8 posts

Posted 02 February 2015 - 11:26 AM

To do this I will have set DIO0_EF_ENABLE to zero before I change DIO0_EF_CONFIG_A and then change DIO0_EF_ENABLE back to 1. This is possible and I have done this but the servo will be constantly turning off and on again, which isn't ideal. What I wanted to know is if there is a standard way that this is done?

 

Thanks.



#15 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 02 February 2015 - 12:26 PM

You should not have to disable the EF to update Config-A.  Are you getting an error if you try to update Config-A while the EF is enabled?  I just tried it and it works fine for me.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users