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

Ocsilocope and Control Panel


  • Please log in to reply
36 replies to this topic

#1 Susi

Susi
  • Members
  • 31 posts

Posted 30 August 2012 - 02:39 PM

I'm ussing the FIO4 as an output to generate a PWM signal, to control a servo, but I need to see the signal becuase it isn't working like I want, so I connect the FIO4 to FIO5 to see the signal in the ocsiloscope but I can't see anything. How can I use the osciloscope ?? Thanks

#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 30 August 2012 - 03:10 PM

Do you mean LJStreamUD? Start with these links:

http://labjack.com/s...3/users-guide/3
http://labjack.com/s...users-guide/3.2
http://labjack.com/s...ers-guide/4.3.7
http://labjack.com/s...t/ud/ljstreamud

#3 Susi

Susi
  • Members
  • 31 posts

Posted 04 September 2012 - 01:11 PM

Do you mean LJStreamUD? Start with these links:

http://labjack.com/s...3/users-guide/3
http://labjack.com/s...users-guide/3.2
http://labjack.com/s...ers-guide/4.3.7
http://labjack.com/s...t/ud/ljstreamud


the LabJackStreamUD generates and error

LabJack Error #1007:  LabJack not found occured at LJUD_OpenLabJackS.vi

I don'r know why is it, I did everything the manual tells me to do

#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 04 September 2012 - 01:26 PM

Make sure you close any other software that might be connected to the U3. Only one process can open the U3 at a time.

#5 Susi

Susi
  • Members
  • 31 posts

Posted 05 September 2012 - 12:18 PM

Make sure you close any other software that might be connected to the U3. Only one process can open the U3 at a time.


the other process using the U3 is the control panel, Can I open the LJStream and the ControlPanel at the same time??

#6 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 05 September 2012 - 12:34 PM

No. Only one process can open the U3 at a time.

#7 Susi

Susi
  • Members
  • 31 posts

Posted 10 September 2012 - 05:33 PM

No. Only one process can open the U3 at a time.


but how can I see the signal in the Stream and change it at the same time, because I need to make sure the PWM is the one I need.

#8 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 11 September 2012 - 05:31 AM

The problem with two processes is that you wind up with conflicting configurations which causes no end of problems. You will need to write a single app that does everything, use a real O-scope, or use a second data acquisition device. We provide a lot of stream examples, it should be easy to start a PWM output before starting the stream. The stream data can them be used to make a scope graph.

#9 Susi

Susi
  • Members
  • 31 posts

Posted 13 September 2012 - 03:11 PM

The problem with two processes is that you wind up with conflicting configurations which causes no end of problems. You will need to write a single app that does everything, use a real O-scope, or use a second data acquisition device.

We provide a lot of stream examples, it should be easy to start a PWM output before starting the stream. The stream data can them be used to make a scope graph.


I tried in a real scope, the signal is great, but I couldn't get the freceuncy I need (50 Hz) but my tutor insisted that I make my onw PWM signal so I make this program in simulink and is great I have my signal and I can control everithing but I'm having problems sending the signal with the labjack.

I have a vector with a secuence of 0 and 5, that indicates when the signal was low and when it was high, and I'm ussing the DAC0, so my question is should I use a flexible output or maybe I'm doing it wrong.

here is the progrma I have been ussing.

acum=0; 
To=0.0005;
aux=1;
    while aux<length(pwm)
    [DAC0] = ljud_ePut ( ljHandle, LJ_ioPUT_DAC, 0, pwm(aux), 0 );
    Error_Message(Error)
    [Error] = ljud_ePut ( ljHandle, LJ_ioPUT_DAC, 0 , 0 , 0);
    Error_Message(Error)
    aux=aux+1;
    tic
    while toc < To, 
    end
    end
  
;

where pwm is the vector with the signal

but the motor is not working.

#10 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 13 September 2012 - 04:25 PM

I think the indents on your code snippet should look like:
acum=0; 
To=0.0005;
aux=1;
while aux<length(pwm)
	[DAC0] = ljud_ePut ( ljHandle, LJ_ioPUT_DAC, 0, pwm(aux), 0 );
	Error_Message(Error)
	[Error] = ljud_ePut ( ljHandle, LJ_ioPUT_DAC, 0 , 0 , 0);
	Error_Message(Error)
	aux=aux+1;
	tic
		while toc < To, 
		end
end

So I gather you are trying to use command/response DAC updates to make a PWM output. There are a few things in your code that don't make sense to me, but the bigger problem is that you can't make a 50Hz output with a DAC:

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

You could do this with a digital output, but I don't see a reason to use software timing. Rather you should use a timer to produce the PWM output:

http://labjack.com/s...s-guide/2.9.1.1

Before you do anything in Matlab, try using the test panel in LJControlPanel to try out the timer.

#11 Susi

Susi
  • Members
  • 31 posts

Posted 13 September 2012 - 06:07 PM

I think the indents on your code snippet should look like:

acum=0; 
To=0.0005;
aux=1;
while aux<length(pwm)
	[DAC0] = ljud_ePut ( ljHandle, LJ_ioPUT_DAC, 0, pwm(aux), 0 );
	Error_Message(Error)
	[Error] = ljud_ePut ( ljHandle, LJ_ioPUT_DAC, 0 , 0 , 0);
	Error_Message(Error)
	aux=aux+1;
	tic
		while toc < To, 
		end
end

So I gather you are trying to use command/response DAC updates to make a PWM output. There are a few things in your code that don't make sense to me, but the bigger problem is that you can't make a 50Hz output with a DAC:

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

You could do this with a digital output, but I don't see a reason to use software timing. Rather you should use a timer to produce the PWM output:

http://labjack.com/s...s-guide/2.9.1.1

Before you do anything in Matlab, try using the test panel in LJControlPanel to try out the timer.


I really don't know what to do, because I need the signal with that frecuency, isn't another way to do it?.

Which is the closer frecuency to 50Hz that the U3 is able to reproduce, what about the PWM16 or PWM8 function, can I use he 1MHZ/Divisor, and if the divisor is of 20, is the frecuency 50Hz???

#12 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 14 September 2012 - 07:12 AM

The PWM16 frequency formula is given in Section 2.9.1.1 as: frequency = (TimerClockBase/2^16) / TimerClockDivisor So you can do various things to get 50Hz. I suggest you try TimerBaseClock = 48MHz w/ Div, and TimerClockDivisor = 14 or 15. Try it using the test panel in LJControlPanel.

#13 Susi

Susi
  • Members
  • 31 posts

Posted 14 September 2012 - 08:14 AM

The PWM16 frequency formula is given in Section 2.9.1.1 as:

frequency = (TimerClockBase/2^16) / TimerClockDivisor

So you can do various things to get 50Hz. I suggest you try TimerBaseClock = 48MHz w/ Div, and TimerClockDivisor = 14 or 15. Try it using the test panel in LJControlPanel.


Ok I'm gone try that,I also need to know how do I select the amplitud of the wave, because I need it to be 5V. so how can I select that??

#14 Susi

Susi
  • Members
  • 31 posts

Posted 14 September 2012 - 10:19 AM

Ok I try ussing the LJ_ioPUT_WAIT but I got an error this is the code [codebox] while aux<length(pwm) %Set FIO3 to output-high. AddRequest (ljHandle, LJ_ioPUT_DIGITAL_BIT, 4, pwm(aux), 0, 0); %Wait 0.5ms. AddRequest (ljHandle, LJ_ioPUT_WAIT, 0, 5000, 0, 0); end [/codebox] but this error message apears in the matlab window [codebox] ??? Undefined function or method 'AddRequest' for input arguments of type 'int32'. Error in ==> pwmtry at 28 AddRequest (ljHandle, LJ_ioPUT_DIGITAL_BIT, 4, pwm(aux), 0, 0); ??? Undefined function or method 'AddRequest' for input arguments of type 'int32'. Error in ==> pwmtry at 31 AddRequest (ljHandle, LJ_ioPUT_WAIT, 0, 5000, 0, 0); [/codebox] So what is the problem here?? I check all the .m files that are need it are in the same folder of the main program

#15 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 14 September 2012 - 04:14 PM

Ok I'm gone try that,I also need to know how do I select the amplitude of the wave, because I need it to be 5V. so how can I select that??

Digital outputs are 3.3V logic. You can't just select 5V.

See the comments from today in this section:

http://labjack.com/s...s-guide/2.9.1.1

Can you provide any more information about your load and perhaps we can evaluate the best way to interface to it? Perhaps 3.3V will work fine?


Ok I try ussing the LJ_ioPUT_WAIT but I got an error

We would have to see more of your matlab code to try to find your problem, but realize that the LJ_ioPUT_WAIT iotype does not seem useful to you. You can just use it to make a few pulses, not continuous PWM. The Timer is what you want to use.

#16 Susi

Susi
  • Members
  • 31 posts

Posted 14 September 2012 - 07:00 PM

ok, can I just send 5 voltage to the FIO4 output?? I'm more confuse now... I don't know how to use the timers how can I used the timer in my current code?? because I'm not going to use the PWM of the LabJack I have to use the one I made, and I have in a vector the 0 and 5 taking everyt 0.0005 seg. so I need to send one value then wait 0.0005 seg and then send the other value, etc.... Is that posible with the LJ_ioPUT_WAIT?? and if it is should I used the FIO4 or the DAC0?? If it dosen't work how can I used the timer in my on PWM signal?? Thanks for your help

#17 Susi

Susi
  • Members
  • 31 posts

Posted 14 September 2012 - 07:03 PM

Oh I forgot this the Matlab code compet [codebox] ljud_LoadDriver; % Loads LabJack UD Function Library ljud_Constants; % Loads LabJack UD constant file [Error ljHandle] = ljud_OpenLabJack(LJ_dtU3,LJ_ctUSB,'1',1); % Returns ljHandle for open LabJack Error_Message(Error) % Check for and display any Errros [Error] = ljud_ePut(ljHandle, LJ_ioPIN_CONFIGURATION_RESET, 0, 0, 0); Error_Message(Error) [Error] = ljud_ePut(ljHandle, LJ_ioPUT_ANALOG_ENABLE_PORT, 0, 12, 16); Error_Message(Error) To=0.0005; aux=1; while aux<length(pwm) %Set FIO3 to output-high. AddRequest (ljHandle, LJ_ioPUT_DIGITAL_BIT, 4, pwm(aux), 0, 0); %Wait 0.5ms. AddRequest (ljHandle, LJ_ioPUT_WAIT, 0, 500, 0, 0); end [/codebox]

#18 Susi

Susi
  • Members
  • 31 posts

Posted 15 September 2012 - 10:42 AM

I fix the problem in the code but is still not working how it was suppose to How can I use the timer of the LabJack to ensure that the value is hihg for the time I want and the low for the time I need?? Please I really need to get this working Thanks

#19 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 15 September 2012 - 04:56 PM

ok, can I just send 5 voltage to the FIO4 output??


No. Digital outputs are 3.3V logic. You can't just select 5V.

See the comments from yesterday in this section:

http://labjack.com/s...s-guide/2.9.1.1


I'm more confuse now... I don't know how to use the timers

You want to use Timer0 in PWM16 mode. First, try it using the test panel in LJControlPanel. I suggest you try TimerBaseClock = 48MHz w/ Div, and TimerClockDivisor = 14 or 15.


how can I used the timer in my current code??

To see how to enable and configure Timer0 with the UD driver, see the following:

http://labjack.com/s...ers-guide/4.3.6
http://labjack.com/s...ers-guide/4.3.9

Then to try it in Matlab, start with the example "U3_Simple_Timer_Counter.m".


because I'm not going to use the PWM of the LabJack I have to use the one I made

Are you saying you cannot use Timer0 in PWM mode for some reason? Using Timer0 is definitely the best way to do PWM.


Do you want continuous PWM, or just a couple pulses? If you just want a couple pulses, you could use the PUT_WAIT method, but you will still get a 3.3V output so it would be better to use Timer0.

#20 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 15 September 2012 - 04:58 PM

Can you provide any more information about your load and perhaps we can evaluate the best way to interface to it? Perhaps 3.3V will work fine?

#21 Susi

Susi
  • Members
  • 31 posts

Posted 16 September 2012 - 05:07 PM

Can you provide any more information about your load and perhaps we can evaluate the best way to interface to it? Perhaps 3.3V will work fine?


I was able to make the motor work with the PWM16, but I'm not sure if I calculate the frecuency correctly, I used the ecuation Frecuency=(48Mhz/2^16)/14

So 14 is the divisor because I'm ussing the timerclock 48MHz/14, that gives 52 Hz. Is that correct??

The other thing is that I'm trying to used the timer to generate a PWM signal to used the signal I had created in matlab, but I don't know how should I used it?? and how to select the timerclock??

I had posted 2 message but I don't know why the message aren't been public I hope this one does...

#22 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 17 September 2012 - 07:31 AM

So 14 is the divisor because I'm ussing the timerclock 48MHz/14, that gives 52 Hz. Is that correct??

Yes, (48M/65536)/14 gives you 52Hz.

The other thing is that I'm trying to used the timer to generate a PWM signal to used the signal I had created in matlab, but I don't know how should I used it?? and how to select the timerclock??

To see how to enable and configure Timer0 with the UD driver, see the following:

http://labjack.com/s...ers-guide/4.3.6
http://labjack.com/s...ers-guide/4.3.9

Then to try it in Matlab, start with the example "U3_Simple_Timer_Counter.m".

and what do you mean when you said you need more info in the load??

What sort of device does the PWM output connect to? A motor driver, motor controller, or solid-state relays? Please provide a link to technical details for this device.

#23 Susi

Susi
  • Members
  • 31 posts

Posted 17 September 2012 - 02:44 PM

So 14 is the divisor because I'm ussing the timerclock 48MHz/14, that gives 52 Hz. Is that correct??

Yes, (48M/65536)/14 gives you 52Hz.

The other thing is that I'm trying to used the timer to generate a PWM signal to used the signal I had created in matlab, but I don't know how should I used it?? and how to select the timerclock??

To see how to enable and configure Timer0 with the UD driver, see the following:

http://labjack.com/s...ers-guide/4.3.6
http://labjack.com/s...ers-guide/4.3.9

Then to try it in Matlab, start with the example "U3_Simple_Timer_Counter.m".

and what do you mean when you said you need more info in the load??

What sort of device does the PWM output connect to? A motor driver, motor controller, or solid-state relays? Please provide a link to technical details for this device.


I'm working on ussing the PWM16 that the U3 generates in Matlab, the signal controls an electric motor, as you should know the electric motors need a signal control and that signal is a Pulse Width Modulation. here is the link with the specification fo the Motor

http://www.servodata...vo/hitec/hs-311

I also have an pdf format with the specifications of the motor

Attached Files



#24 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 17 September 2012 - 03:10 PM

I see. You have an R/C servo motor. Here are a couple related forum topics:

https://forums.labja...p?showtopic=584

https://forums.labja...?showtopic=1198

One thing I see in those topics is that many servo motors draw too big of a surge current to power from VS. You might try an external 5V supply instead.

Have you gotten the servo to work correctly through the test panel in LJControlPanel? That is the first step.

#25 Susi

Susi
  • Members
  • 31 posts

Posted 18 September 2012 - 02:22 PM

I see. You have an R/C servo motor. Here are a couple related forum topics:

https://forums.labja...p?showtopic=584

https://forums.labja...?showtopic=1198

One thing I see in those topics is that many servo motors draw too big of a surge current to power from VS. You might try an external 5V supply instead.

Have you gotten the servo to work correctly through the test panel in LJControlPanel? That is the first step.


Yes I finally make the servo worked thank you for helping :D

I'm having another problem I'm seendin a different pwm singals to the servo and I connect a wire from FIO4 to AIN0 so I can read the value but I need to read from labjack every 0.01ms because the data I'm saving it needs to be in real time... so the question is how can I do in MAtlab to save a value every 0.01ms ??


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users