Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

56 views
Skip to first unread message

JOEY

unread,
Apr 17, 2012, 12:22:12 PM4/17/12
to
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

Joel Koltner

unread,
Apr 17, 2012, 1:30:48 PM4/17/12
to
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?


Tim Wescott

unread,
Apr 17, 2012, 1:33:46 PM4/17/12
to
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

JOEY

unread,
Apr 17, 2012, 5:22:42 PM4/17/12
to
Yes i mean writing couple of 0"s and 1's
in a continuous loop to create PWM

hamilton

unread,
Apr 17, 2012, 5:44:56 PM4/17/12
to
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

hamilton

unread,
Apr 17, 2012, 5:45:45 PM4/17/12
to
On 4/17/2012 3:22 PM, JOEY wrote:
By the way, which VB version are you using to do this ?

hamilton

Jamie

unread,
Apr 17, 2012, 6:42:12 PM4/17/12
to
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


Tim Wescott

unread,
Apr 17, 2012, 6:39:23 PM4/17/12
to
"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.

hamilton

unread,
Apr 17, 2012, 6:57:56 PM4/17/12
to
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.

Joel Koltner

unread,
Apr 17, 2012, 7:21:42 PM4/17/12
to
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.

Jasen Betts

unread,
Apr 19, 2012, 6:55:18 AM4/19/12
to
FTDI chips have a GPIO mode not covered by the other usb-serial chips
I've not investigated further whethere this mode includes any PWM outputs

if all you have is an multitaskinn OS and a generic programming
language the best you can do is one PWM channel with the step size
governed by the bitratte by emitting crafted bit patterns

--
⚂⚃ 100% natural

--- Posted via news://freenews.netfront.net/ - Complaints to ne...@netfront.net ---

Tauno Voipio

unread,
Apr 19, 2012, 12:59:48 PM4/19/12
to
Get a Stellaris development kit. It includes a FTDI 2232 USB adapter,
power feed from the USB and a 32 bit ARM Cortex with plenty of suitable
timers. With a piece of simple code in the processor, you'll get
a bunch of PWM ports controllable via a virtual serial port from the PC.

--

Tauno Voipio

Jasen Betts

unread,
Apr 21, 2012, 5:33:20 AM4/21/12
to
On 2012-04-19, Tauno Voipio <tauno....@notused.fi.invalid> wrote:
>>
>> FTDI chips have a GPIO mode not covered by the other usb-serial chips
>> I've not investigated further whethere this mode includes any PWM outputs
>>
>> if all you have is an multitaskinn OS and a generic programming
>> language the best you can do is one PWM channel with the step size
>> governed by the bitratte by emitting crafted bit patterns

> Get a Stellaris development kit. It includes a FTDI 2232 USB adapter,
> power feed from the USB and a 32 bit ARM Cortex with plenty of suitable
> timers. With a piece of simple code in the processor, you'll get
> a bunch of PWM ports controllable via a virtual serial port from the PC.

the smaller TI MSP430 lauchpad is a bargain, USD 4.30 with free
international shipping.

(they ask not to use the kit itself for production devices, but for
play or education it's fine. it seems like cheating to use the
programming interface for a control input, but it works...)

edvo...@gmail.com

unread,
Apr 21, 2012, 9:07:11 AM4/21/12
to
I use these USB I/O peripherals often. They come with Visual Basic drivers and example programs and are reasonably priced:

http://www.mccdaq.com/usb-data-acquisition/USB-1208-Series.aspx

The FT245R could be used to communicate with another peripheral that has PWM capability.

Don't be discouraged, mistakes contain far more information than getting it right the first time.

Best,
Ed

upsid...@downunder.com

unread,
Apr 21, 2012, 9:48:42 AM4/21/12
to
On Tue, 17 Apr 2012 09:22:12 -0700 (PDT), JOEY <joej...@gmail.com>
wrote:
Why not use a UART (PCI or USB) to generate a PWM signal ?

If the output value is known 10-50 milliseconds in advance, the values
can be precalculated and queued to the serial port and the timing only
depends of the UART crystal. At 115k200 bits/s, the pulse width is
about 10 us. Even if a single character can produce only 8 different
values (most other are duplicates), this could still be quite usable
for low frequency applications.

Of course, using 8 data bits + start bit + one stop bit, the
available range is just 10 .. 90 %, but for any AC coupled systems
(base line at 50 %), this would not be an issue.

k...@att.bizzzzzzzzzzzz

unread,
Apr 21, 2012, 10:29:24 AM4/21/12
to
You only get about 10% (~three bits) resolution, at least at the symbol rate.
Just by inspection, it seems you'd pick up another bit for each doubling of
symbols, so at 115kbps and a 10Hz signal, that's what, 16 bits
(log2(11500/10)+3)? For very low bandwidth, with a large enough filter, it
seems like an idea, though.

upsid...@downunder.com

unread,
Apr 21, 2012, 11:56:24 AM4/21/12
to
I completely agree, but if the alternative is to use bit banging
through USB to some digital output, using some _user_ mode code on
some _non_deterministic OS (such as Windows XX), executing under some
kind of interpreter,:-) :-)

I still think the UART is a viable alternative.


k...@att.bizzzzzzzzzzzz

unread,
Apr 22, 2012, 12:18:43 AM4/22/12
to
Or serial into a PIC to a PWM port. ;-)

>I still think the UART is a viable alternative.

Actually, it's kinda cute.
0 new messages