Forums

How Do i Control PWM with Trackbar for a Pin in Visual Basic

Started by JOEY April 17, 2012
I am using an FTDIchip which is the FT245R,
i was able to connect and write to the device.
And the aim to be able to creat PWM on any of the
Data PINs and control it with a Trackbar. I have tried
writing 1's and 0's to create that but have not control
of the PIN
JOEY wrote:
> I am using an FTDIchip which is the FT245R, > i was able to connect and write to the device.
Good.
> And the aim to be able to creat PWM on any of the > Data PINs and control it with a Trackbar.
From Visual Basic you'll going to be restricted to relatively low output frequencies and the precision of the PWM is going to be affected by whatever else is running on your system... but if you're just hooking the PWM outputs to LEDs or heaters or something, it should be OK.
> I have tried > writing 1's and 0's to create that but have not control > of the PIN
Eh? I'm not sure what you mean here?
On Tue, 17 Apr 2012 09:22:12 -0700, JOEY wrote:

> I am using an FTDIchip which is the FT245R, i was able to connect and > write to the device. And the aim to be able to creat PWM on any of the > Data PINs and control it with a Trackbar. I have tried writing 1's and > 0's to create that but have not control of the PIN
Do you mean that you can't turn the pin on and off at all, even slowly? This is probably a programming or driver issue. Getting this sort of basic functionality is often the most frustrating part of a project. -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
On Apr 17, 6:30=A0pm, Joel Koltner <zapwire-use...@yahoo.com> wrote:
> JOEY wrote: > > I am using an FTDIchip which is the FT245R, > > i was able to connect and write to the device. > > Good. > > > And the aim to be able to creat PWM on any of the > > Data PINs and control it with a Trackbar. > > =A0From Visual Basic you'll going to be restricted to relatively low > output frequencies and the precision of the PWM is going to be affected > by whatever else is running on your system... but if you're just hooking > the PWM outputs to LEDs or heaters or something, it should be OK. > > > I have tried > > writing 1's and 0's to create that but have not control > > of the PIN > > Eh? =A0I'm not sure what you mean here?
Yes i mean writing couple of 0"s and 1's in a continuous loop to create PWM
On 4/17/2012 3:22 PM, JOEY wrote:
> On Apr 17, 6:30 pm, Joel Koltner<zapwire-use...@yahoo.com> wrote: >> JOEY wrote: >>> I am using an FTDIchip which is the FT245R, >>> i was able to connect and write to the device. >> >> Good. >> >>> And the aim to be able to creat PWM on any of the >>> Data PINs and control it with a Trackbar. >> >> From Visual Basic you'll going to be restricted to relatively low >> output frequencies and the precision of the PWM is going to be affected >> by whatever else is running on your system... but if you're just hooking >> the PWM outputs to LEDs or heaters or something, it should be OK. >> >>> I have tried >>> writing 1's and 0's to create that but have not control >>> of the PIN >> >> Eh? I'm not sure what you mean here? > Yes i mean writing couple of 0"s and 1's > in a continuous loop to create PWM
Joey, I think you do not understand that USB is NOT deterministic. A USB device can not create timing of any kind. A program writes to a USB driver, when the USB driver is called by the operating system, one or more messages will get delivered. USB does not understand time, only packets of data. You can not do what you are asking to do. hamilton
On 4/17/2012 3:22 PM, JOEY wrote:
> On Apr 17, 6:30 pm, Joel Koltner<zapwire-use...@yahoo.com> wrote: >> JOEY wrote: >>> I am using an FTDIchip which is the FT245R, >>> i was able to connect and write to the device. >> >> Good. >> >>> And the aim to be able to creat PWM on any of the >>> Data PINs and control it with a Trackbar. >> >> From Visual Basic you'll going to be restricted to relatively low >> output frequencies and the precision of the PWM is going to be affected >> by whatever else is running on your system... but if you're just hooking >> the PWM outputs to LEDs or heaters or something, it should be OK. >> >>> I have tried >>> writing 1's and 0's to create that but have not control >>> of the PIN >> >> Eh? I'm not sure what you mean here? > Yes i mean writing couple of 0"s and 1's > in a continuous loop to create PWM
By the way, which VB version are you using to do this ? hamilton
On Tue, 17 Apr 2012 15:44:56 -0600, hamilton wrote:

> On 4/17/2012 3:22 PM, JOEY wrote: >> On Apr 17, 6:30 pm, Joel Koltner<zapwire-use...@yahoo.com> wrote: >>> JOEY wrote: >>>> I am using an FTDIchip which is the FT245R, i was able to connect and >>>> write to the device. >>> >>> Good. >>> >>>> And the aim to be able to creat PWM on any of the Data PINs and >>>> control it with a Trackbar. >>> >>> From Visual Basic you'll going to be restricted to relatively low >>> output frequencies and the precision of the PWM is going to be >>> affected by whatever else is running on your system... but if you're >>> just hooking the PWM outputs to LEDs or heaters or something, it >>> should be OK. >>> >>>> I have tried >>>> writing 1's and 0's to create that but have not control of the PIN >>> >>> Eh? I'm not sure what you mean here? >> Yes i mean writing couple of 0"s and 1's in a continuous loop to >> create PWM > > Joey, > > I think you do not understand that USB is NOT deterministic. > > A USB device can not create timing of any kind. > > A program writes to a USB driver, when the USB driver is called by the > operating system, one or more messages will get delivered. > > USB does not understand time, only packets of data. > > You can not do what you are asking to do.
"Can not do" may be a bit strong. "Can't run it very fast" is certainly correct, though. PWM frequencies for an oven can run down into the millihertz; you could certainly do that in a PC. An FTDI sending serial commands to a microprocessor that's generating a PWM signal -- that would work, at far far higher speeds than bit-banging PWM from a PC ever could. -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
JOEY wrote:
> I am using an FTDIchip which is the FT245R, > i was able to connect and write to the device. > And the aim to be able to creat PWM on any of the > Data PINs and control it with a Trackbar. I have tried > writing 1's and 0's to create that but have not control > of the PIN
You picked the wrong device to do that with. You need to talk to a stand alone device that will do that for you. Look into PIC from microchip.com or ATmel that carries the Avr Tiny or megas.. The USB system does not allow for real time in windows. Jamie
On 4/17/2012 4:39 PM, Tim Wescott wrote:
> On Tue, 17 Apr 2012 15:44:56 -0600, hamilton wrote: > >> On 4/17/2012 3:22 PM, JOEY wrote: >>> On Apr 17, 6:30 pm, Joel Koltner<zapwire-use...@yahoo.com> wrote: >>>> JOEY wrote: >>>>> I am using an FTDIchip which is the FT245R, i was able to connect and >>>>> write to the device. >>>> >>>> Good. >>>> >>>>> And the aim to be able to creat PWM on any of the Data PINs and >>>>> control it with a Trackbar. >>>> >>>> From Visual Basic you'll going to be restricted to relatively low >>>> output frequencies and the precision of the PWM is going to be >>>> affected by whatever else is running on your system... but if you're >>>> just hooking the PWM outputs to LEDs or heaters or something, it >>>> should be OK. >>>> >>>>> I have tried >>>>> writing 1's and 0's to create that but have not control of the PIN >>>> >>>> Eh? I'm not sure what you mean here? >>> Yes i mean writing couple of 0"s and 1's in a continuous loop to >>> create PWM >> >> Joey, >> >> I think you do not understand that USB is NOT deterministic. >> >> A USB device can not create timing of any kind. >> >> A program writes to a USB driver, when the USB driver is called by the >> operating system, one or more messages will get delivered. >> >> USB does not understand time, only packets of data. >> >> You can not do what you are asking to do. > > "Can not do" may be a bit strong.
OK, I'll admit 1 hertz PWM is still PWM, but lets get real. At 1 hertz, it the next edge is .1 second off thats not a problem. But at even 10 hertz, .1 sec is an entire cycle lost. Why even discuss this at this level, it can not be done, so go do it right. I do like the idea of a USB PWM controller.
> > "Can't run it very fast" is certainly correct, though. PWM frequencies > for an oven can run down into the millihertz; you could certainly do that > in a PC. > > An FTDI sending serial commands to a microprocessor that's generating a > PWM signal -- that would work, at far far higher speeds than bit-banging > PWM from a PC ever could. >
hamilton wrote:
> But at even 10 hertz, .1 sec is an entire cycle lost.
Even in Visual Basic, if you "own" the machine (i.e., you boost your own priority and make sure there aren't any other long-running high-priority processes that are likely to run), 10Hz is likely viable, USB non-determinism and all. I wouldn't ask for much more, though.