Dear Guys
Nice Day
I am wanted to control DC motor by using H Bridge.
I am using FIO4 to right direction and FIO4 to left direction and VCC and GND with two timers and the program work well.
for timer 1
LJUD.eGet(lngHandle, LJUD.IO.PUT_DIGITAL_BIT, 4, 1, 0)
LJUD.eGet(lngHandle, LJUD.IO.PUT_DIGITAL_BIT, 5, 0, 0)
for timer 2
LJUD.eGet(lngHandle, LJUD.IO.PUT_DIGITAL_BIT, 5, 1, 0)
LJUD.eGet(lngHandle, LJUD.IO.PUT_DIGITAL_BIT, 4, 0, 0)
But I need update program to control the speed by using BWM.
I am using VB.net 2010
Please Help

DC control with BWM and VB.net
Started by
raheem
, Jun 20 2012 08:27 AM
3 replies to this topic
#1
Posted 20 June 2012 - 08:27 AM
#2
Posted 20 June 2012 - 08:58 AM
What are "timer 1" and "timer 2"? Are these software timers in VB?
I think the pseudocode for what you want would look something like:
Right:
Disable all Timers
Set FIO5 to output-low
Enable Timer0 on FIO4 in PWM output mode
Right:
Disable all Timers
Set FIO4 to output-low
Enable Timer0 on FIO5 in PWM output mode
Read about the PWM output modes in Section 2.9 of the U3 User's Guide, and then use the test panel in LJControlPanel to try it out and see if the speed varies as desired.
I think the pseudocode for what you want would look something like:
Right:
Disable all Timers
Set FIO5 to output-low
Enable Timer0 on FIO4 in PWM output mode
Right:
Disable all Timers
Set FIO4 to output-low
Enable Timer0 on FIO5 in PWM output mode
Read about the PWM output modes in Section 2.9 of the U3 User's Guide, and then use the test panel in LJControlPanel to try it out and see if the speed varies as desired.
#3
Posted 20 June 2012 - 12:24 PM
Thank you very much for your fast reply
indeed, my background in mechanic and I am building a mechanical system, I am try to uesd this section(2.9) before writing this topic but I not get more information.
So that id possible please send me small code to cotrol the speed.
Since speed of motor is only small part of mechanical system.
Waiting your reply soon
REGARD
#4
Posted 20 June 2012 - 12:41 PM
You can use PWM to reduce how much power is going to your motor. For example, try a duty-cycle of 50% to reduce power to 50%.
PWM is at a particular frequency, and then you vary the duty-cycle. To choose a frequency, ask the manufacturer of the H-bridge for a recommended PWM frequency.
Lets use 16-bit PWM and a frequency of 732 Hz. From Table 2.9.1.1-1, and the formula given in Section 2.9.1.1, that means you want the TimerClockBase=48MHz and the TimerClockDivisor is not used. Set the TimerValue=32768 for 50% duty-cycle.
Try this in the test panel in LJControlPanel. Set FIO5 to DO with State=Low. Click Config in the Timers and Counters area, set # of Timers = 1, set the mode of Timer0 to PWM16, set the Value of Timer0 = 32768, set the TimerClockBase = 48MHz, and set the Pin Offset = 4 (to put the timer on FIO4). Click OK and you should get a 732 Hz square wave (50% duty cycle) out of FIO4. On the main test panel window in the Timers and Counters area you can now change the Timer0 value to get different duty cycles. Set Value=0 to get 100% duty cycle. Set Value = 50000 to get about 24% duty cycle.
Once you use the test panel to understand the timer settings you want, look at Sections 4.3.6 and 4.3.9 to see how to set those settings in your own code. Then look at a VB.net example that does something with timers.
http://labjack.com/s...ers-guide/4.3.6
http://labjack.com/s...ers-guide/4.3.9
http://labjack.com/support/ud/examples
PWM is at a particular frequency, and then you vary the duty-cycle. To choose a frequency, ask the manufacturer of the H-bridge for a recommended PWM frequency.
Lets use 16-bit PWM and a frequency of 732 Hz. From Table 2.9.1.1-1, and the formula given in Section 2.9.1.1, that means you want the TimerClockBase=48MHz and the TimerClockDivisor is not used. Set the TimerValue=32768 for 50% duty-cycle.
Try this in the test panel in LJControlPanel. Set FIO5 to DO with State=Low. Click Config in the Timers and Counters area, set # of Timers = 1, set the mode of Timer0 to PWM16, set the Value of Timer0 = 32768, set the TimerClockBase = 48MHz, and set the Pin Offset = 4 (to put the timer on FIO4). Click OK and you should get a 732 Hz square wave (50% duty cycle) out of FIO4. On the main test panel window in the Timers and Counters area you can now change the Timer0 value to get different duty cycles. Set Value=0 to get 100% duty cycle. Set Value = 50000 to get about 24% duty cycle.
Once you use the test panel to understand the timer settings you want, look at Sections 4.3.6 and 4.3.9 to see how to set those settings in your own code. Then look at a VB.net example that does something with timers.
http://labjack.com/s...ers-guide/4.3.6
http://labjack.com/s...ers-guide/4.3.9
http://labjack.com/support/ud/examples
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users